#at-chat-wrapper * {
    box-sizing: border-box;
    margin: 0;
  }

  /* Targeted Bootstrap/website CSS reset — only the elements Bootstrap breaks */
  #at-msg-input,
  #at-msg-input:focus,
  #at-msg-input:active {
    flex: 1 !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 22px !important;
    min-height: 22px !important;
    max-height: 80px !important;
    padding: 0 0 0 10px !important;
    font-size: 13px !important;
    font-family: 'Segoe UI', Arial, sans-serif !important;
    line-height: 1.5 !important;
    color: #1a1a2e !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    transition: none !important;
    resize: none !important;
    display: block !important;
    overflow-y: hidden !important;
  }

  #at-send-btn,
  #at-send-btn:focus,
  #at-send-btn:active,
  #at-send-btn:hover {
    padding: 0 !important;
    box-shadow: none !important;
    line-height: 1 !important;
  }

  .at-hdr-close,
  .at-hdr-close:focus,
  .at-hdr-close:active,
  .at-hdr-close:hover {
    padding: 0 !important;
    box-shadow: none !important;
    line-height: 1 !important;
  }

  #at-chat-wrapper .at-bubble-time {
    margin-top: 3px !important;
  }

  #at-chat-wrapper .at-sender-name {
    margin-bottom: 3px !important;
  }

  #at-chat-wrapper {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999999;
    font-family: 'Segoe UI', Arial, sans-serif;
  }

  /* BUBBLE */
  #at-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1565C0;
    box-shadow: 0 4px 20px rgba(21, 101, 192, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: fixed;
    bottom: 20px;
    right: 20px;
    border: none;
    outline: none;
    z-index: 1000001;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  #at-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(21, 101, 192, 0.55);
  }

  .at-icon-chat,
  .at-icon-close {
    position: absolute;
    transition: opacity 0.2s, transform 0.22s;
    font-size: 22px;
    color: #fff;
    line-height: 1;
  }

  .at-icon-chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  .at-icon-close {
    opacity: 0;
    transform: scale(0.4) rotate(-90deg);
  }

  #at-chat-bubble.is-open .at-icon-chat {
    opacity: 0;
    transform: scale(0.4) rotate(90deg);
  }

  #at-chat-bubble.is-open .at-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  #at-online-dot {
    width: 13px;
    height: 13px;
    background: #43A047;
    border: 2.5px solid #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    right: 3px;
  }

  #at-online-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(67, 160, 71, 0.28);
    animation: at-pulse 2s infinite;
  }

  @keyframes at-pulse {
    0%, 100% { transform: scale(1); opacity: .6; }
    50% { transform: scale(1.6); opacity: 0; }
  }

  #at-unread-badge {
    position: absolute;
    top: -3px;
    left: -3px;
    background: #E53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    width: 19px;
    height: 19px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
  }

  /* PREVIEW STRIP */
  #at-preview-strip {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: #fff;
    border: 1px solid #BBDEFB;
    border-radius: 14px 14px 4px 14px;
    padding: 10px 13px;
    max-width: 230px;
    min-width: 170px;
    box-shadow: 0 4px 16px rgba(21, 101, 192, 0.13);
    cursor: pointer;
    display: none;
    z-index: 1000000;
    transition: transform 0.15s;
  }

  #at-preview-strip:hover {
    transform: translateY(-2px);
  }

  #at-preview-strip .ps-agent {
    font-size: 11px;
    font-weight: 700;
    color: #1565C0;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
  }

  #at-preview-strip .ps-agent::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #43A047;
    border-radius: 50%;
  }

  #at-preview-strip .ps-msg {
    font-size: 12.5px;
    color: #333;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }

  #at-preview-strip .ps-time {
    font-size: 10px;
    color: #bbb;
    margin-top: 4px;
    text-align: right;
  }

  /* CHAT WINDOW */
  #at-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(21, 101, 192, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000000;
    transform-origin: bottom right;
    transform: scale(0.82) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(.34, 1.56, .64, 1), opacity 0.22s ease;
  }

  #at-chat-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  /* Header */
  #at-chat-header {
    background: linear-gradient(135deg, #f9811e 0%, #f9811e 100%);
    padding: 13px 14px 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  .at-hdr-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
  }

  .at-hdr-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .at-hdr-info { flex: 1; }

  .at-hdr-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
  }

  .at-hdr-status {
    font-size: 11px;
    color: rgb(255, 255, 255);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
  }

  .at-hdr-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #3fef9a;
    border-radius: 50%;
  }

  .at-hdr-brand {
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: 1px;
  }

  .at-hdr-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
    font-size: 13px;
    color: #fff;
  }

  .at-hdr-close:hover {
    background: rgba(255, 255, 255, 0.28);
  }

  /* Messages */
  #at-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;   /* stop scroll-chaining to host page at top/bottom */
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px;
    background: #F8FAFF;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
  }

  #at-messages::-webkit-scrollbar { width: 4px; }
  #at-messages::-webkit-scrollbar-thumb { background: #BBDEFB; border-radius: 4px; }

  .at-date-sep {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
  }

  .at-date-sep::before,
  .at-date-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: #E3F2FD;
  }

  .at-date-sep::before { left: 0; }
  .at-date-sep::after { right: 0; }

  .at-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 7px;
  }

  .at-msg-row.user { flex-direction: row-reverse; }

  .at-msg-avatar {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #02a054;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
  }

  .at-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .at-msg-avatar.user-av { background: #E3F2FD; color: #1565C0; }

  .at-msg-col {
    display: flex;
    flex-direction: column;
    max-width: 76%;
  }

  .at-msg-row.user .at-msg-col { align-items: flex-end; }

  .at-sender-name {
    font-size: 10px;
    color: #02a054;
    font-weight: 700;
    margin-bottom: 3px;
    padding-left: 2px;
  }

  .at-bubble {
    max-width: 100%;
    padding: 9px 12px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
  }

  .at-bubble.agent {
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #E3F2FD;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(21, 101, 192, 0.07);
  }

  .at-bubble.user {
    background: #1565C0;
    color: #fff;
    border-bottom-right-radius: 4px;
  }

  .at-bubble-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 3px;
    text-align: right;
  }

  .at-bubble.agent .at-bubble-time { color: #bbb; text-align: left; }

  /* Typing */
  #at-typing {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px;
  }

  .at-typing-bubble {
    background: #fff;
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .at-typing-bubble span {
    width: 6px;
    height: 6px;
    background: #90CAF9;
    border-radius: 50%;
    animation: at-bounce 1.2s infinite;
  }

  .at-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
  .at-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

  @keyframes at-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
  }

  /* Input */
  #at-input-area {
    border-top: 1px solid #E3F2FD;
    padding: 9px 11px 6px;
    background: #fff;
    flex-shrink: 0;
  }

  .at-input-row {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #ffffff;
    border: 1.5px solid #02a054;
    border-radius: 22px;
    padding: 5px 7px 5px 13px;
    transition: border-color 0.2s;
  }

  .at-input-row:focus-within { border-color: #02a054; }

  #at-msg-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: #1a1a2e;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 22px;
    line-height: 1.5;
    font-family: inherit;
    overflow-y: auto;
    padding: 0 0 0 10px;
  }

  #at-msg-input::placeholder { color: #9ab; }

  #at-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #02a054;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    font-size: 14px;
    color: #fff;
  }

  #at-send-btn:hover { background: #02a054; transform: scale(1.07); }
  #at-send-btn:active { transform: scale(0.94); }

  .at-footer {
    text-align: center;
    font-size: 9.5px;
    color: #ccc;
    padding: 4px 0 5px;
  }

  .at-footer a { color: #90CAF9; text-decoration: none; }

  /* MOBILE */
  @media (max-width: 600px) {
    #at-chat-bubble { width: 44px; height: 44px; bottom: 14px; right: 14px; box-shadow: 0 3px 12px rgba(21, 101, 192, 0.38); }
    #at-online-dot { width: 10px; height: 10px; top: 1px; right: 1px; border-width: 2px; }
    #at-unread-badge { width: 16px; height: 16px; font-size: 9px; top: -2px; left: -2px; }
    #at-preview-strip { max-width: 190px; min-width: 140px; bottom: 68px; right: 14px; padding: 8px 11px; }
    #at-preview-strip .ps-msg { max-width: 160px; font-size: 11.5px; }
    #at-chat-window {
      position: fixed;
      bottom: 0;
      right: 0;
      width: 70%;
      height: 65vh;
      border-radius: 20px 20px 0 0;
      transform-origin: bottom right;
      transform: translateY(100%);
      opacity: 1;
      transition: transform 0.3s cubic-bezier(.34, 1.3, .64, 1);
      box-shadow: 0 -4px 32px rgba(21, 101, 192, 0.18);
    }
    #at-chat-window.is-open { transform: translateY(0); opacity: 1; }
    #at-chat-bubble.is-open { display: none; }
    #at-send-btn { position: relative; z-index: 1000002; }
    .at-bubble { padding: 9px 12px !important; }
  }