
  :root {
    --chatw-accent: #25D366;
    --chatw-accent-dark: #1ead52;
    --chatw-surface: #161b22;
    --chatw-surface2: #1c2128;
    --chatw-surface3: #0d1117;
    --chatw-border: #30363d;
    --chatw-text: #e6edf3;
    --chatw-muted: #8b949e;
    --chatw-danger: #ff4757;
    --chatw-radius: 14px;
    --chatw-widget-w: 340px;
    --chatw-widget-h: 480px;
  }

  /* Reset SCOPED sirf widget ke apne elements tak — universal `*` selector
     poori site ke har element ka margin/padding 0 kar deta, jo existing
     layout tod deta. Ab sirf .chat-bubble aur .chat-widget ke andar wale
     elements affect hote hain. */
  .chat-bubble, .chat-bubble *, .chat-bubble *::before, .chat-bubble *::after,
  .chat-widget, .chat-widget *, .chat-widget *::before, .chat-widget *::after {
    box-sizing: border-box; margin: 0; padding: 0;
  }

  .chat-bubble {
    position: fixed; bottom: 24px; right: 24px;
    width: 58px; height: 58px;
    background: var(--chatw-accent); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 9999;
    box-shadow: 0 8px 24px rgba(37,211,102,.35);
    transition: transform .2s, box-shadow .2s;
  }
  .chat-bubble:hover { transform: scale(1.07); box-shadow: 0 12px 30px rgba(37,211,102,.45); }
  .chat-bubble svg { width: 26px; height: 26px; fill: #fff; }

  .bubble-badge {
    position: absolute; top: -2px; right: -2px;
    background: var(--chatw-danger); color: #fff;
    font-size: 11px; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    border: 2px solid var(--chatw-surface3);
  }
  .bubble-badge.visible { display: flex; }

  .chat-widget {
    position: fixed; bottom: 94px; right: 24px;
    width: var(--chatw-widget-w); height: var(--chatw-widget-h);
    background: var(--chatw-surface3); border-radius: var(--chatw-radius);
    border: 1px solid var(--chatw-border);
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    z-index: 9998;
    transform: translateY(20px) scale(.95);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  }
  .chat-widget.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

  .chat-header {
    background: var(--chatw-surface);
    padding: 12px 14px;
    border-bottom: 1px solid var(--chatw-border);
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
  }
  .header-avatar { position: relative; flex-shrink: 0; }
  .header-avatar img {
    width: 42px; height: 42px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--chatw-accent); display: block;
  }
  .avatar-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--chatw-muted); border: 2px solid var(--chatw-surface);
    transition: background .4s;
  }
  .avatar-dot.online { background: var(--chatw-accent); }

  .header-info { flex: 1; min-width: 0; }
  .header-name { color: var(--chatw-text); font-weight: 700; font-size: 14px; }
  .header-status { font-size: 11px; color: var(--chatw-muted); margin-top: 2px; }
  .header-status.online { color: var(--chatw-accent); }
  .header-schedule { font-size: 10px; color: var(--chatw-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .header-close {
    color: var(--chatw-muted); cursor: pointer; font-size: 18px; line-height: 1;
    padding: 4px; border-radius: 4px; transition: color .15s; flex-shrink: 0;
  }
  .header-close:hover { color: var(--chatw-text); }

  .chat-messages {
    flex: 1; overflow-y: auto; padding: 12px 10px;
    display: flex; flex-direction: column; gap: 6px;
    background: var(--chatw-surface3); scroll-behavior: smooth;
  }
  .chat-messages::-webkit-scrollbar { width: 4px; }
  .chat-messages::-webkit-scrollbar-track { background: transparent; }
  .chat-messages::-webkit-scrollbar-thumb { background: var(--chatw-border); border-radius: 4px; }

  .msg-row { display: flex; flex-direction: column; }
  .msg-row.from-user { align-items: flex-end; }
  .msg-row.from-admin { align-items: flex-start; }

  .msg-bubble {
    max-width: 78%; padding: 8px 12px;
    border-radius: 14px; font-size: 13px; line-height: 1.45; word-break: break-word;
  }
  .from-user .msg-bubble { background: var(--chatw-accent); color: #000; border-bottom-right-radius: 4px; }
  .from-admin .msg-bubble { background: var(--chatw-surface2); color: var(--chatw-text); border-bottom-left-radius: 4px; }

  .msg-meta {
    font-size: 10px; color: var(--chatw-muted);
    margin-top: 3px; padding: 0 2px;
    display: flex; align-items: center; gap: 4px;
  }
  .msg-tick { font-size: 12px; }
  .msg-tick.read { color: var(--chatw-accent); }
  .msg-tick.delivered { color: var(--chatw-muted); }
  .msg-tick.pending { color: var(--chatw-danger); }

  .typing-row { display: flex; align-items: flex-start; }
  .typing-bubble {
    background: var(--chatw-surface2); padding: 10px 14px; border-radius: 14px;
    border-bottom-left-radius: 4px; display: flex; gap: 4px; align-items: center;
  }
  .typing-bubble span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--chatw-muted); display: block; animation: bounce 1.2s infinite;
  }
  .typing-bubble span:nth-child(2) { animation-delay: .2s; }
  .typing-bubble span:nth-child(3) { animation-delay: .4s; }
  @keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

  .offline-banner {
    background: #2a1a1a; border-left: 3px solid var(--chatw-danger);
    padding: 10px 12px; margin: 8px 10px;
    border-radius: 6px; font-size: 12px; color: #ffb3b3;
    display: none; flex-shrink: 0;
  }
  .offline-banner.visible { display: block; }

  .sys-msg { text-align: center; font-size: 11px; color: var(--chatw-muted); padding: 2px 0; }

.chat-input-wrap {
    border-top: 1px solid var(--chatw-border); background: var(--chatw-surface);
    padding: 10px; display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
  }
  .textarea-wrap { 
    flex: 1; position: relative;  display: flex;  
   }
  .chat-input-wrap textarea {
    width: 100%; background: var(--chatw-surface2); border: 1px solid var(--chatw-border);
    border-radius: 8px; padding: 8px 6px 8px 10px; color: var(--chatw-text);
    font-size: 13px; font-family: inherit; resize: none; outline: none;
     min-height: 36px; 
    max-height: 80px; line-height: 1.4; transition: border-color .15s;
    overflow-y: auto; box-sizing: border-box;
    scrollbar-width: thin; scrollbar-color: var(--chatw-border) transparent;
  }
  .chat-input-wrap textarea:focus { border-color: var(--chatw-accent); }
  .chat-input-wrap textarea::placeholder { color: var(--chatw-muted); }
  .chat-input-wrap textarea::-webkit-scrollbar { width: 4px; }
  .chat-input-wrap textarea::-webkit-scrollbar-track { background: transparent; }
  .chat-input-wrap textarea::-webkit-scrollbar-thumb { background: var(--chatw-border); border-radius: 4px; }
  .chat-input-wrap textarea::-webkit-scrollbar-thumb:hover { background: var(--chatw-muted); }
  .chat-input-wrap textarea::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  .char-counter {
    position: absolute; bottom: 5px; right: 12px;
    font-size: 10px; line-height: 1; color: var(--chatw-muted);
    opacity: 0; transition: opacity .15s, color .15s;
    pointer-events: none; user-select: none;
  
  }
  .char-counter.visible { opacity: 1; }
  .char-counter.danger  { color: var(--chatw-danger); }

  .send-btn {
    background: var(--chatw-accent); border: none; width: 36px; height: 36px;  min-height: 36px; 
    border-radius: 8px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; transition: background .15s, transform .1s;
     align-self: flex-end;
  }
  .send-btn:hover { background: var(--chatw-accent-dark); }
  .send-btn:active { transform: scale(.93); }
  .send-btn svg { width: 16px; height: 16px; fill: #fff; }
  .send-btn:disabled { opacity: .4; cursor: not-allowed; }

  .skeleton {
    height: 36px; border-radius: 10px;
    background: linear-gradient(90deg, var(--chatw-surface2) 25%, var(--chatw-surface) 50%, var(--chatw-surface2) 75%);
    background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: 8px;
  }
  @keyframes shimmer { to { background-position: -200% 0; } }

  /* Pagination: purani messages load hote waqt ya history ka end batane ke liye */
  .load-older {
    display: none; text-align: center; font-size: 11px; color: var(--chatw-muted);
    padding: 4px 0 8px; flex-shrink: 0;
  }

  @media (max-width: 400px) { .chat-widget { width: calc(100vw - 20px); right: 10px; } }
