
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg:       #0f1015;
    --bg2:      #16171d;
    --bg3:      #1e1f28;
    --bg4:      #252631;
    --border:   #2a2b38;
    --text:     #e2e3ef;
    --muted:    #6b6d82;
    --accent:   #003153;
    --accent2:  #00223d;
    --green:    #2ec27e;
    --bubble-in:  #1e1f28;
    --bubble-out: #1a2f6e;
    --font: 'DM Sans', system-ui, sans-serif;
    --mono: 'DM Mono', monospace;
  }

  html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }

  /* ── AUTH SCREEN ─────────────────────────────────────── */
  #auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
  }

  .auth-box {
    width: 360px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
  }

  .auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
  }

  .auth-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .auth-logo-icon svg { width: 20px; height: 20px; }
  .auth-logo-name { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }

  .auth-tabs {
    display: flex;
    background: var(--bg3);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 24px;
    gap: 3px;
  }

  .auth-tab {
    flex: 1;
    padding: 7px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    transition: all .15s;
    user-select: none;
  }

  .auth-tab.active { background: var(--bg4); color: var(--text); font-weight: 500; }

  .auth-field { margin-bottom: 14px; }

  .auth-field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
  }

  .auth-field input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
  }

  .auth-field input:focus { border-color: var(--accent); }

  .auth-btn {
    width: 100%;
    margin-top: 8px;
    padding: 11px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
  }

  .auth-btn:hover { background: var(--accent2); }
  .auth-btn:active { transform: scale(0.98); }

  .auth-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: #2d1a1a;
    border: 1px solid #5a2020;
    border-radius: 8px;
    color: #f07070;
    font-size: 13px;
    display: none;
  }

  /* ── CHAT SCREEN ─────────────────────────────────────── */
  #chat-screen {
    display: none;
    height: 100vh;
    flex-direction: row;
  }

  /* Sidebar */
  .sidebar {
    width: 260px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  .sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .sidebar-logo {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .sidebar-logo svg { width: 16px; height: 16px; }
  .sidebar-appname { font-size: 15px; font-weight: 600; flex: 1; }

  .sidebar-me {
    font-size: 12px;
    color: var(--muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .me-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

  .new-chat-wrap { padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; }

  .new-chat-input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
  }

  .new-chat-input:focus { border-color: var(--accent); }

  .new-chat-btn {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    width: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
  }

  .new-chat-btn:hover { background: var(--accent2); }
  .new-chat-btn svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }

  .contacts-list { flex: 1; overflow-y: auto; }

  .contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid #1a1b22;
  }

  .contact-item:hover { background: var(--bg3); }
  .contact-item.active { background: var(--bg4); }

  .contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .contact-info { flex: 1; min-width: 0; }
  .contact-name { font-size: 13px; font-weight: 500; color: var(--text); }
  .contact-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
  .contact-online-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
  .contact-online-dot.online { background: var(--green); }

  .sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
  }

  .logout-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .15s;
  }

  .logout-btn:hover { border-color: #c04040; color: #f07070; }
  .logout-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

  /* Chat area */
  .chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    min-width: 0;
  }

  .chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg2);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .chat-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .chat-header-info { flex: 1; }
  .chat-header-name { font-size: 14px; font-weight: 600; }
  .chat-header-status { font-size: 11px; color: var(--green); margin-top: 1px; }

  .e2e-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--green);
    background: #0d2e1c;
    border: 1px solid #1a5c38;
    border-radius: 20px;
    padding: 3px 10px;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
  }
  .e2e-badge:hover { background: #143d26; }
  .e2e-badge svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.5; }

  /* E2E popup */
  .e2e-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .e2e-popup-overlay.visible { display: flex; }
  .e2e-popup {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 400px;
    width: 100%;
  }
  .e2e-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
  }
  .e2e-popup-icon {
    width: 36px; height: 36px;
    background: #0d2e1c;
    border: 1px solid #1a5c38;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .e2e-popup-icon svg { width: 18px; height: 18px; stroke: var(--green); fill: none; stroke-width: 2; }
  .e2e-popup-title { font-size: 16px; font-weight: 600; color: var(--text); }
  .e2e-popup-subtitle { font-size: 12px; color: var(--green); margin-top: 2px; }
  .e2e-layer {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
  }
  .e2e-layer-title {
    font-size: 13px; font-weight: 600; color: var(--text);
    margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
  }
  .e2e-layer-title .lbadge {
    font-size: 10px; border-radius: 4px;
    padding: 1px 6px; font-weight: 500; color: #fff;
  }
  .e2e-layer-title .lbadge.blue { background: var(--accent); }
  .e2e-layer-title .lbadge.green { background: #0f6e56; }
  .e2e-layer-title .lbadge.teal { background: #0a5a6e; }
  .e2e-layer-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
  .e2e-popup-close {
    width: 100%; margin-top: 16px; padding: 10px;
    background: var(--bg4); border: 1px solid var(--border);
    border-radius: 8px; color: var(--muted);
    font-family: var(--font); font-size: 13px;
    cursor: pointer; transition: background .15s;
  }
  .e2e-popup-close:hover { background: var(--bg3); color: var(--text); }

  /* Empty state */
  .chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
  }

  .chat-empty svg { width: 48px; height: 48px; stroke: var(--border); fill: none; stroke-width: 1.5; }
  .chat-empty-title { font-size: 16px; font-weight: 500; color: var(--muted); }
  .chat-empty-sub { font-size: 13px; color: #3a3b4a; }

  /* Messages */
  .messages-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .msg-day {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    margin: 10px 0 6px;
  }

  .msg-row { display: flex; }
  .msg-row.out { justify-content: flex-end; }
  .msg-row.in { justify-content: flex-start; }

  .msg-bubble {
    max-width: 62%;
    padding: 8px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
  }

  .msg-row.in .msg-bubble {
    background: var(--bubble-in);
    color: var(--text);
    border-bottom-left-radius: 3px;
  }

  .msg-row.out .msg-bubble {
    background: var(--bubble-out);
    color: #c8d8f5;
    border-bottom-right-radius: 3px;
  }

  .msg-time {
    font-size: 10px;
    color: var(--muted);
    margin-top: 3px;
    display: block;
    text-align: right;
  }

  .msg-row.in .msg-time { text-align: left; }

  .msg-status { font-size: 10px; color: var(--muted); margin-left: 4px; }
  .msg-status.sent { color: var(--muted); }
  .msg-status.delivered { color: var(--green); }
  .msg-status.read { color: #3b9eff; }
  .msg-status.failed { color: #e5534b; }

  /* Input */
  .input-area {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bg2);
    position: sticky;
    bottom: 0;
    z-index: 10;
  }

  .msg-input-wrap { flex: 1; position: relative; }

  .msg-textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color .15s;
    line-height: 1.4;
  }

  .msg-textarea:focus { border-color: var(--accent); }
  .msg-textarea::placeholder { color: var(--muted); }

  .send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
  }

  .send-btn:hover { background: var(--accent2); }
  .send-btn:active { transform: scale(0.95); }
  .send-btn svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }

  .attach-btn {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg3); border: 1px solid var(--border);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s;
  }
  .attach-btn:hover { background: var(--bg4); }
  .attach-btn svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; }

  /* ── Call UI ──────────────────────────────────────────── */
  /* ── Call UI — Discord style ──────────────────────────── */
  .call-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.82);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
  }
  .call-overlay.visible { display: flex; }
  .call-box {
    background: #1e1f2e;
    border: 1px solid #2a2c40;
    border-radius: 24px;
    padding: 40px 48px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 300px;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
  }

  /* Avatar with pulse ring */
  .call-avatar-wrap {
    position: relative;
    margin-bottom: 20px;
  }
  .call-avatar {
    width: 88px; height: 88px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 34px; font-weight: 700; color: #fff;
    position: relative;
    z-index: 2;
  }
  .call-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    display: none;
  }
  .call-pulse.ring1 { animation: callPulse 2s ease-out infinite; }
  .call-pulse.ring2 { animation: callPulse 2s ease-out .6s infinite; }
  .call-pulse.ring3 { animation: callPulse 2s ease-out 1.2s infinite; }
  @keyframes callPulse {
    0% { transform: scale(1); opacity: .5; }
    100% { transform: scale(1.5); opacity: 0; }
  }
  .call-avatar-wrap.pulsing .call-pulse { display: block; }

  .call-name {
    font-size: 22px; font-weight: 700;
    color: #e8e9f0;
    margin-bottom: 6px;
    letter-spacing: -.3px;
  }
  .call-status {
    font-size: 13px; color: #6b6d82;
    margin-bottom: 4px;
    min-height: 20px;
  }
  .call-timer {
    font-size: 16px; color: #2ecc71;
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
    display: none;
  }

  /* Volume slider */
  .call-volume {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 16px 0 8px;
    width: 100%;
  }
  .call-volume.visible { display: flex; }
  .call-volume svg { width: 16px; height: 16px; stroke: #6b6d82; fill: none; stroke-width: 2; flex-shrink: 0; }
  .call-volume input[type=range] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: #2a2c40;
    border-radius: 2px;
    outline: none;
  }
  .call-volume input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #003153;
    cursor: pointer;
  }

  /* Buttons */
  .call-btns {
    display: flex;
    gap: 16px;
    margin-top: 28px;
    align-items: flex-end;
  }
  .call-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .call-btn-label {
    font-size: 11px;
    color: #6b6d82;
    font-weight: 500;
  }
  .call-btn {
    width: 60px; height: 60px; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s, opacity .15s;
  }
  .call-btn:hover { transform: scale(1.08); }
  .call-btn:active { transform: scale(.95); }
  .call-btn svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }
  .call-btn.end { background: #e03c3c; width: 68px; height: 68px; }
  .call-btn.end svg { width: 26px; height: 26px; }
  .call-btn.accept { background: #1a9c5b; width: 68px; height: 68px; }
  .call-btn.accept svg { width: 26px; height: 26px; }
  .call-btn.mute { background: #2a2c40; }
  .call-btn.mute.active { background: #e03c3c; }
  .call-btn.vol { background: #2a2c40; }

  /* ── Call bar — minimized indicator ─────────────────── */
  .call-bar {
    display: none;
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    height: 32px;
    background: #1a4a2e;
    border: 1px solid #2a6a3e;
    border-radius: 20px;
    z-index: 150;
    align-items: center;
    gap: 10px;
    padding: 0 6px 0 12px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    white-space: nowrap;
  }
  .call-bar.visible { display: flex; }
  .call-bar-left { display: flex; align-items: center; gap: 6px; }
  .call-bar-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #2ecc71;
    animation: callBarPulse 1.5s ease-in-out infinite;
  }
  @keyframes callBarPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
  }
  .call-bar-name { font-size: 13px; font-weight: 600; color: #2ecc71; }
  .call-bar-timer { font-size: 12px; color: #2ecc71; font-variant-numeric: tabular-nums; }
  .call-bar-end {
    background: #e03c3c;
    border: none; border-radius: 14px;
    padding: 4px 10px;
    color: #fff; font-size: 11px; font-weight: 600;
    cursor: pointer;
  }
  .call-bar-end:hover { background: #c0392b; }

  .upload-progress {
    display: none;
    padding: 6px 16px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
  }
  .upload-progress.visible { display: block; }
  .upload-progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
  }
  .upload-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .1s;
    width: 0%;
  }
  .upload-progress-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
  }

  .msg-image { max-width: 240px; max-height: 240px; border-radius: 8px; cursor: pointer; display: block; margin-bottom: 4px; }
  .msg-file { display: flex; align-items: center; gap: 8px; padding: 6px 0; color: inherit; text-decoration: none; }
  .msg-file svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }

  .delete-btn {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    color: var(--muted); font-size: 11px; opacity: 0; transition: opacity .15s;
    position: absolute; top: 2px; right: 2px;
  }
  .msg-bubble { position: relative; cursor: context-menu; }
  .msg-bubble:hover .delete-btn { opacity: 1; }
  .msg-deleted { font-style: italic; color: var(--muted); font-size: 12px; }
  .ctx-menu { position: fixed; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; z-index: 300; min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,.4); display: none; }
  .ctx-menu.visible { display: block; }
  .ctx-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); transition: background .1s; }
  .ctx-item:hover { background: var(--bg3); }
  .ctx-item.danger { color: #e05c5c; }
  .ctx-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
  .reactions-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
  .reaction-chip { background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; padding: 2px 8px; font-size: 13px; cursor: pointer; transition: background .1s; display: inline-flex; align-items: center; gap: 4px; }
  .reaction-chip:hover { background: var(--bg4); }
  .reaction-chip.mine { border-color: var(--accent); }
  .reaction-chip .rcount { font-size: 11px; color: var(--muted); }
  .emoji-picker { position: fixed; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 8px; z-index: 310; display: none; gap: 4px; flex-wrap: wrap; width: 192px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
  .emoji-picker.visible { display: flex; }
  .emoji-btn { font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; transition: background .1s; background: none; border: none; }
  .emoji-btn:hover { background: var(--bg3); }
  .reply-bar { display: none; padding: 8px 16px; background: var(--bg2); border-top: 1px solid var(--border); align-items: center; gap: 10px; }
  .reply-bar.visible { display: flex; }
  .reply-bar-text { flex: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .reply-bar-text strong { color: var(--accent); }
  .reply-bar-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
  .msg-reply-quote { background: rgba(255,255,255,.06); border-left: 3px solid var(--accent); border-radius: 4px; padding: 4px 8px; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
  .msg-reply-quote strong { color: var(--accent); display: block; margin-bottom: 2px; font-size: 11px; }
  .fwd-badge { font-size: 11px; color: var(--muted); margin-bottom: 2px; display: block; }

  .typing-indicator {
    display: none;
    padding: 6px 20px 2px;
    font-size: 12px;
    color: var(--muted);
    height: 22px;
  }
  .typing-indicator.visible { display: flex; align-items: center; gap: 6px; }
  .typing-dots span {
    display: inline-block;
    width: 5px; height: 5px;
    background: var(--muted);
    border-radius: 50%;
    animation: typingDot 1.2s infinite;
  }
  .typing-dots span:nth-child(2) { animation-delay: .2s; }
  .typing-dots span:nth-child(3) { animation-delay: .4s; }
  @keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  /* Avatar colors */
  .av-0 { background:#1a2f6e; color:#6b9aff; }
  .av-1 { background:#0d3d2e; color:#2db887; }
  .av-2 { background:#2d2060; color:#9b8de8; }
  .av-3 { background:#3d1f10; color:#d4825a; }
  .av-4 { background:#2d1040; color:#c47ae0; }

  .no-chat { display: none; }

  /* ── MOBILE ──────────────────────────────────────── */
  .back-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px 4px 0;
    color: var(--text);
    align-items: center;
  }
  .back-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

  @media (max-width: 600px) {
    .sidebar {
      width: 100%;
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      z-index: 10;
    }
    .chat-area {
      width: 100%;
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      z-index: 5;
    }
    #chat-screen {
      position: relative;
    }
    .sidebar.hidden { display: none !important; }
    .chat-area.hidden { display: none !important; }
    .back-btn { display: flex; }
    .msg-bubble { max-width: 80%; }
    .e2e-badge { font-size: 0; min-width: 30px; width: 30px; height: 30px; padding: 0; display: flex; justify-content: center; align-items: center; border-radius: 50%; flex-shrink: 0; margin-left: auto; gap: 0; }
    .e2e-badge svg { width: 14px; height: 14px; margin: 0; display: block; }
    .chat-header-status { display: none; }
  }
