
    /* ===================== DESIGN TOKENS ===================== */
    :root {
      --bg:          #f0f2f5;
      --bg-2:        #e8eaed;
      --fg:          #111b21;
      --fg-2:        #3b4a54;
      --muted:       #8696a0;
      --card:        #ffffff;
      --card-2:      #f7f8fa;
      --border:      #e2e5e9;
      --border-2:    #d1d5db;
      --soft:        #f0f2f5;
      --soft-2:      #e8eaed;
      --brand:       #0a7cff;
      --brand-dark:  #0062cc;
      --brand-soft:  rgba(10,124,255,.12);
      --brand-glow:  rgba(10,124,255,.28);
      --success:     #25d366;
      --danger:      #ff3b30;
      --danger-soft: rgba(255,59,48,.12);
      --warn:        #ff9f0a;
      --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
      --shadow-md:   0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
      --shadow-lg:   0 16px 48px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
      --shadow-xl:   0 32px 80px rgba(0,0,0,.16), 0 8px 24px rgba(0,0,0,.08);
      --radius-sm:   8px;
      --radius-md:   12px;
      --radius-lg:   18px;
      --radius-xl:   24px;
      --radius-full: 9999px;
      --sidebar-w:   72px;
      --transition:  all .18s cubic-bezier(.4,0,.2,1);
    }

    html.dark {
      --bg:          #111b21;
      --bg-2:        #0d1418;
      --fg:          #e9edef;
      --fg-2:        #aebac1;
      --muted:       #667781;
      --card:        #1f2c34;
      --card-2:      #182229;
      --border:      #2a3942;
      --border-2:    #374248;
      --soft:        #182229;
      --soft-2:      #212e35;
      --brand:       #3b9eff;
      --brand-dark:  #0a7cff;
      --brand-soft:  rgba(59,158,255,.15);
      --brand-glow:  rgba(59,158,255,.30);
      --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
      --shadow-md:   0 4px 16px rgba(0,0,0,.4);
      --shadow-lg:   0 16px 48px rgba(0,0,0,.5);
      --shadow-xl:   0 32px 80px rgba(0,0,0,.6);
    }

    /* ===================== RESET ===================== */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html, body {
      height: 100%;
      min-height: 100%;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      background: var(--bg);
      color: var(--fg);
      overflow: hidden;
    }
    body.mobile-menu-open { overflow: hidden; }
    a { color: var(--brand); text-decoration: none; }
    button { font-family: inherit; cursor: pointer; border: none; background: none; }
    input, textarea { font-family: inherit; }
    * { -webkit-tap-highlight-color: transparent; }

    /* ===================== SCROLLBAR ===================== */
    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

    /* ===================== APP SHELL ===================== */
    .app-shell {
      display: flex;
      height: 100vh;
      height: var(--app-height, 100dvh);
      overflow: hidden;
      position: relative;
    }

    /* ===================== SIDEBAR ===================== */
    .sidebar {
      width: var(--sidebar-w);
      background: var(--card);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 16px 0;
      gap: 4px;
      flex-shrink: 0;
      z-index: 100;
    }

    .sidebar-logo {
      width: 44px;
      height: 44px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, var(--brand) 0%, #5856d6 100%);
      box-shadow: 0 4px 12px var(--brand-glow);
      margin-bottom: 8px;
      flex-shrink: 0;
    }
    .sidebar-logo img { width: 26px; height: 26px; object-fit: contain; }
    .sidebar-logo-text {
      font-size: 18px; font-weight: 800;
      background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,.8) 100%);
      -webkit-background-clip: text; background-clip: text; color: transparent;
      letter-spacing: -.5px;
    }

    .sidebar-nav {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      width: 100%;
      padding: 0 10px;
    }

    .nav-item {
      width: 52px;
      height: 52px;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: var(--transition);
      color: var(--muted);
      position: relative;
      gap: 3px;
    }
    .nav-item:hover { background: var(--soft); color: var(--fg-2); }
    .nav-item.active {
      background: var(--brand-soft);
      color: var(--brand);
    }
    .nav-item.active svg { stroke: var(--brand); }
    .nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; transition: var(--transition); flex-shrink: 0; }
    .nav-label { font-size: 9px; font-weight: 600; letter-spacing: .02em; line-height: 1; }

    .sidebar-footer {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      padding: 0 10px;
      width: 100%;
    }

    .avatar-btn {
      width: 40px; height: 40px;
      border-radius: 50%;
      border: 2px solid var(--border);
      background: var(--soft) center/cover no-repeat;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='1.8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
      cursor: pointer;
      transition: var(--transition);
      flex-shrink: 0;
    }
    .avatar-btn:hover { border-color: var(--brand); transform: scale(1.04); }

    .theme-btn {
      width: 40px; height: 40px;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      color: var(--muted);
      transition: var(--transition);
    }
    .theme-btn:hover { background: var(--soft); color: var(--fg-2); }
    .theme-btn svg { width: 18px; height: 18px; }

    /* ===================== MAIN CONTENT ===================== */
    .main-content {
      flex: 1;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: var(--bg);
    }

    /* ===================== PANEL ===================== */
    .panel { display: none; flex: 1; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; }
    .panel.active { display: flex; }

    /* ===================== PANEL HEADER ===================== */
    .panel-header {
      background: var(--card);
      border-bottom: 1px solid var(--border);
      padding: 0 24px;
      height: 64px;
      display: flex;
      align-items: center;
      gap: 14px;
      flex-shrink: 0;
    }
    .panel-header h1 {
      font-size: 18px;
      font-weight: 700;
      letter-spacing: -.3px;
      color: var(--fg);
    }
    .panel-header .sub {
      font-size: 12px;
      color: var(--muted);
      font-weight: 400;
    }
    .header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

    /* ===================== STATUS PILL ===================== */
    .status-pill {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      padding: 5px 12px;
      border-radius: var(--radius-full);
      font-size: 12px;
      font-weight: 600;
      background: var(--soft);
      color: var(--fg-2);
      border: 1px solid var(--border);
      letter-spacing: .01em;
    }
    .status-pill .dot {
      width: 7px; height: 7px;
      border-radius: 50%;
      background: var(--success);
      flex-shrink: 0;
    }
    .status-pill.connecting .dot { background: var(--warn); animation: pulse-dot 1.5s infinite; }
    .status-pill.error .dot { background: var(--danger); }
    @keyframes pulse-dot {
      0%,100% { opacity: 1; } 50% { opacity: .4; }
    }

    /* ===================== PANEL BODY ===================== */
    .panel-body {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: 24px;
      display: flex;
      flex-direction: column;
      gap: 20px;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
    }

    /* ===================== CARDS ===================== */
    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-sm);
      overflow: hidden;
    }
    .card-body { padding: 20px 24px; }
    .card-header {
      padding: 16px 24px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .card-title { font-size: 15px; font-weight: 700; color: var(--fg); }
    .card-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

    /* ===================== GRID ===================== */
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    @media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

    /* ===================== CODE DISPLAY ===================== */
    .code-box {
      background: var(--soft);
      border: 1.5px dashed var(--border-2);
      border-radius: var(--radius-md);
      padding: 18px 20px;
      text-align: center;
      cursor: pointer;
      transition: var(--transition);
      user-select: all;
    }
    .code-box:hover { border-color: var(--brand); background: var(--brand-soft); }
    .code-value {
      font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
      font-size: 28px;
      font-weight: 800;
      letter-spacing: 8px;
      color: var(--fg);
    }
    .code-box.empty .code-value { color: var(--border-2); letter-spacing: 10px; }
    .code-hint { font-size: 11px; color: var(--muted); margin-top: 6px; }
    .code-box:focus-visible,
    .otp-wrap input:focus-visible,
    .composer-icon:focus-visible,
    .composer-send:focus-visible,
    .btn:focus-visible,
    .btn-icon:focus-visible {
      outline: 3px solid var(--brand-glow);
      outline-offset: 2px;
    }

    /* ===================== OTP INPUT ===================== */
    .otp-wrap {
      display: flex;
      justify-content: center;
      gap: 8px;
      margin: 12px 0 16px;
    }
    .otp-wrap input {
      width: 44px; height: 52px;
      text-align: center;
      font-size: 20px;
      font-weight: 700;
      border: 1.5px solid var(--border);
      background: var(--card);
      color: var(--fg);
      border-radius: var(--radius-md);
      outline: none;
      transition: var(--transition);
      caret-color: var(--brand);
    }
    .otp-wrap input:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 3px var(--brand-soft);
      background: var(--brand-soft);
    }

    /* ===================== BUTTONS ===================== */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 13px 20px;
      border-radius: var(--radius-md);
      font-size: 14px;
      font-weight: 600;
      letter-spacing: .01em;
      cursor: pointer;
      border: none;
      transition: var(--transition);
      white-space: nowrap;
      width: 100%;
    }
    .btn-primary {
      background: var(--brand);
      color: #fff;
      box-shadow: 0 2px 8px var(--brand-glow);
    }
    .btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 16px var(--brand-glow); transform: translateY(-1px); }
    .btn-primary:active { transform: translateY(0); }
    .btn-ghost {
      background: var(--soft);
      color: var(--fg-2);
      border: 1px solid var(--border);
    }
    .btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
    .btn-danger {
      background: var(--danger);
      color: #fff;
    }
    .btn-danger:hover { opacity: .9; }
    .btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--radius-sm); width: auto; }
    .btn-icon {
      width: 36px; height: 36px;
      padding: 0;
      border-radius: 50%;
      background: var(--soft);
      color: var(--muted);
      border: 1px solid var(--border);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition);
      cursor: pointer;
      flex-shrink: 0;
    }
    .btn-icon:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
    .btn-icon svg { width: 16px; height: 16px; }

    /* ===================== CALL BUTTON (circle) ===================== */
    .cbtn {
      width: 56px; height: 56px;
      border-radius: 50%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: none;
      cursor: pointer;
      transition: var(--transition);
      flex-shrink: 0;
    }
    .cbtn:hover { transform: scale(1.06); }
    .cbtn:active { transform: scale(.96); }
    .cbtn:disabled { opacity: .3; cursor: not-allowed; transform: none; }
    .cbtn svg { width: 22px; height: 22px; }
    .cbtn.brand { background: var(--brand); color: #fff; box-shadow: 0 4px 16px var(--brand-glow); }
    .cbtn.neutral { background: var(--soft); color: var(--fg); border: 1px solid var(--border); }
    .cbtn.dark-neutral { background: rgba(255,255,255,.12); color: #fff; backdrop-filter: blur(10px); }
    .cbtn.end { background: var(--danger); color: #fff; box-shadow: 0 4px 16px rgba(255,59,48,.35); }
    .cbtn.big { width: 80px; height: 80px; }
    .cbtn.big svg { width: 30px; height: 30px; }

    .act { display: flex; flex-direction: column; align-items: center; gap: 7px; }
    .act-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
    .actions { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; padding: 8px 0; }

    /* ===================== MESSAGES PANEL ===================== */
    #panel-messages .panel-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
    .message-setup { flex-shrink: 0; }
    .message-setup-grid { min-width: 0; }
    #panel-messages .top-section { padding: 20px 24px 0; display: flex; flex-direction: column; gap: 14px; }
    #panel-messages .grid-2 { padding: 0 24px; }

    /* ===================== CHAT WRAP ===================== */
    .chat-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-height: 0;
      min-width: 0;
    }
    .file-drop-zone { position: relative; }
    .drop-overlay {
      position: absolute;
      inset: 0;
      z-index: 20;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: rgba(10,124,255,.14);
      border: 2px dashed var(--brand);
      border-radius: inherit;
      pointer-events: none;
    }
    .file-drop-zone.drag-over .drop-overlay { display: flex; }
    .drop-overlay-card {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      padding: 18px 22px;
      border-radius: var(--radius-lg);
      background: color-mix(in srgb, var(--card) 94%, transparent);
      color: var(--brand);
      box-shadow: var(--shadow-lg);
      text-align: center;
      font-size: 14px;
      font-weight: 700;
    }
    .drop-overlay-card span {
      color: var(--fg-2);
      font-size: 12px;
      font-weight: 500;
    }
    .file-attachment {
      display: flex;
      align-items: center;
      gap: 8px;
      max-width: 260px;
      margin-top: 6px;
      padding: 9px 10px;
      border-radius: 10px;
      background: rgba(0,0,0,.08);
    }
    .msg.me .file-attachment { background: rgba(255,255,255,.16); }
    .file-attachment a {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: inherit;
      text-decoration: underline;
    }

    .chat-header {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 20px;
      background: var(--card);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      min-width: 0;
    }
    .chat-peer-info { flex: 1; min-width: 0; }
    .chat-peer-name { font-size: 15px; font-weight: 700; }
    .chat-peer-status { font-size: 12px; color: var(--muted); }

    .chat-body {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 2px;
      background: var(--bg);
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
    }
    /* WhatsApp-style chat background pattern */
    html:not(.dark) .chat-body {
      background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d0d4d9' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    }

    /* ===================== MESSAGE BUBBLES ===================== */
    .msg-wrap { display: flex; gap: 8px; align-items: flex-end; padding: 2px 0; }
    .msg-wrap.me { flex-direction: row-reverse; }

    .msg {
      max-width: 72%;
      padding: 8px 12px;
      border-radius: 16px;
      font-size: 14px;
      line-height: 1.45;
      word-wrap: break-word;
      position: relative;
    }
    .msg.me {
      background: var(--brand);
      color: #fff;
      border-bottom-right-radius: 4px;
      box-shadow: 0 1px 4px rgba(10,124,255,.25);
    }
    .msg.them {
      background: var(--card);
      color: var(--fg);
      border-bottom-left-radius: 4px;
      border: 1px solid var(--border);
      box-shadow: var(--shadow-sm);
    }
    .msg.sys {
      align-self: center;
      background: rgba(134,150,160,.15);
      color: var(--muted);
      font-size: 12px;
      border-radius: var(--radius-full);
      padding: 5px 14px;
      border: none;
      box-shadow: none;
      max-width: 90%;
      text-align: center;
    }
    .msg .who { font-size: 11px; font-weight: 700; margin-bottom: 3px; display: block; opacity: .75; }
    .msg.me .who { color: rgba(255,255,255,.85); }
    .msg.them .who { color: var(--brand); }

    .avatar-sm {
      width: 28px; height: 28px;
      border-radius: 50%;
      background: var(--soft) center/cover no-repeat;
      flex-shrink: 0;
    }
    .avatar-lg {
      width: 64px; height: 64px;
      border-radius: 50%;
      background: var(--soft) center/cover no-repeat;
      margin: 0 auto 10px;
      box-shadow: 0 4px 16px rgba(0,0,0,.12);
    }

    /* ===================== TYPING INDICATOR ===================== */
    .typing-row { display: none; padding: 4px 0; }
    .typing-row.active { display: flex; }
    .typing-indicator {
      display: flex;
      gap: 4px;
      align-items: center;
      padding: 10px 14px;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 16px;
      border-bottom-left-radius: 4px;
    }
    .typing-indicator span {
      width: 6px; height: 6px;
      border-radius: 50%;
      background: var(--muted);
      animation: typing-bounce 1.4s infinite ease-in-out both;
    }
    .typing-indicator span.typing-text {
      width: auto; height: auto;
      border-radius: 0;
      background: none;
      animation: none;
      margin-left: 8px;
      font-size: 13px;
      color: var(--muted);
    }
    .typing-indicator span:nth-child(1) { animation-delay: -.32s; }
    .typing-indicator span:nth-child(2) { animation-delay: -.16s; }
    @keyframes typing-bounce {
      0%,80%,100% { transform: scale(0); opacity: .4; }
      40% { transform: scale(1); opacity: 1; }
    }

    /* ===================== VOICE NOTES ===================== */
    .voice-note-player {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 6px 10px;
      min-width: 240px;
      max-width: 300px;
      background: var(--soft);
      border-radius: 18px;
      border: 1px solid var(--border);
    }
    .vn-play-btn {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: var(--brand);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      box-shadow: 0 2px 5px rgba(0,0,0,.15);
      transition: transform 0.2s, background 0.2s;
    }
    .vn-play-btn:hover {
      transform: scale(1.05);
      background: var(--brand-dark);
    }
    .vn-play-btn svg {
      width: 14px;
      height: 14px;
    }
    .vn-play-btn .vn-pause-icon.hidden,
    .vn-play-btn .vn-play-icon.hidden {
      display: none;
    }
    .vn-waveform {
      display: flex;
      align-items: center;
      gap: 2px;
      flex: 1;
      height: 24px;
      cursor: pointer;
    }
    .vn-bar {
      flex: 1;
      height: 100%;
      background: var(--border-2);
      border-radius: 1px;
      transition: background 0.1s;
    }
    .vn-bar.played {
      background: var(--brand);
    }
    .vn-meta {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 2px;
      font-size: 11px;
      color: var(--muted);
      flex-shrink: 0;
    }
    .vn-speed-btn {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 1px 4px;
      font-size: 9px;
      font-weight: 600;
      color: var(--fg);
      cursor: pointer;
    }

    /* ===================== COMPOSER ===================== */
    .composer {
      display: flex;
      gap: 8px;
      align-items: flex-end;
      padding: 10px 16px max(12px, env(safe-area-inset-bottom, 0px));
      background: var(--card);
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      min-width: 0;
    }

    .mention-wrap { position: relative; flex: 1; display: flex; }
    .mention-wrap > textarea {
      width: 100%;
      background: transparent !important;
      position: relative;
      z-index: 2;
    }
    .mention-wrap > .mention-bg {
      position: absolute; inset: 0;
      padding: 11px 16px;
      font-size: 14px;
      font-family: inherit;
      line-height: 1.45;
      white-space: pre-wrap;
      word-wrap: break-word;
      overflow: hidden;
      color: transparent;
      pointer-events: none;
      z-index: 1;
      border: 1.5px solid transparent;
      border-radius: var(--radius-md);
    }
    .mention-wrap > .mention-bg mark {
      background: var(--brand-soft);
      color: transparent;
      border-radius: 4px;
      padding: 1px 2px;
    }

    .composer textarea, .composer input[type="text"] {
      flex: 1;
      min-width: 0;
      min-height: 44px;
      border: 1.5px solid var(--border);
      background: var(--soft);
      color: var(--fg);
      padding: 11px 16px;
      border-radius: var(--radius-md);
      font-size: 14px;
      outline: none;
      resize: none;
      line-height: 1.45;
      max-height: 120px;
      overflow-y: auto;
      transition: var(--transition);
    }
    .composer textarea:focus, .composer input[type="text"]:focus {
      border-color: var(--brand);
      background: var(--card);
      box-shadow: 0 0 0 3px var(--brand-soft);
    }
    .composer textarea::placeholder { color: var(--muted); }

    .composer-send {
      width: 44px; height: 44px;
      border-radius: 50%;
      background: var(--brand);
      color: #fff;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      transition: var(--transition);
      box-shadow: 0 2px 8px var(--brand-glow);
    }
    .composer-send:hover { background: var(--brand-dark); transform: scale(1.06); }
    .composer-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
    .composer-send svg { width: 18px; height: 18px; }

    .composer-icon {
      width: 40px; height: 40px;
      border-radius: 50%;
      background: var(--soft);
      color: var(--muted);
      border: 1.5px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      transition: var(--transition);
    }
    .composer-icon:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
    .composer-icon:disabled { opacity: .4; cursor: not-allowed; }
    .composer-icon.recording { border-color: var(--danger); color: var(--danger); animation: recording-pulse 1.5s infinite; }
    .composer-icon svg { width: 17px; height: 17px; }
    @keyframes recording-pulse {
      0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.4); }
      50% { box-shadow: 0 0 0 8px rgba(255,59,48,0); }
    }

    /* ===================== MEDIA IN BUBBLES ===================== */
    .msg img, .msg video { max-width: 100%; border-radius: 10px; margin-top: 6px; display: block; }
    .msg audio { width: 100%; max-width: 240px; margin-top: 6px; outline: none; }
    .media-wrap { position: relative; display: inline-block; margin: 4px 0; }
    .media-dl {
      position: absolute; bottom: 7px; right: 7px;
      background: rgba(0,0,0,.55); color: #fff; border: none;
      border-radius: 7px; padding: 4px 7px; cursor: pointer;
      display: flex; align-items: center; gap: 3px; font-size: 11px;
      text-decoration: none;
    }
    .media-dl:hover { background: rgba(0,0,0,.8); }
    .media-dl-row {
      display: inline-flex; align-items: center; gap: 5px;
      font-size: 11px; opacity: .75; margin-top: 4px;
      color: inherit; text-decoration: none; cursor: pointer;
    }
    .media-dl-row:hover { opacity: 1; }

    /* ===================== AUDIO CALL PANEL ===================== */
    #panel-audio .panel-body {
      align-items: center;
      justify-content: center;
      padding: 32px 24px;
    }

    .call-card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius-xl);
      box-shadow: var(--shadow-lg);
      width: 100%;
      max-width: 440px;
      overflow: visible;
    }
    .call-hero {
      background: linear-gradient(160deg, #0a7cff 0%, #5856d6 100%);
      padding: 40px 30px 36px;
      text-align: center;
      color: #fff;
      position: relative;
      overflow: hidden;
      border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    .call-hero::before {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.15) 0%, transparent 70%);
    }
    .call-avatar-ring {
      width: 110px; height: 110px;
      border-radius: 50%;
      background: rgba(255,255,255,.15);
      border: 2px solid rgba(255,255,255,.25);
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto 20px;
      backdrop-filter: blur(10px);
      position: relative;
    }
    .call-avatar-ring::before {
      content: '';
      position: absolute;
      inset: -8px;
      border-radius: 50%;
      border: 1px solid rgba(255,255,255,.12);
      animation: ring-pulse 2s ease-in-out infinite;
    }
    @keyframes ring-pulse {
      0%,100% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.08); opacity: .5; }
    }
    .call-hero h2 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin: 0 0 6px; }
    .call-hero p { font-size: 13px; opacity: .8; margin: 0; }
    .call-hero-status { margin-top: 10px; font-size: 13px; font-weight: 600; opacity: .9; }

    .audio-join-shortcut { display: none; }
    .call-body { padding: 24px 28px 28px; }
    .audio-panel-body {
      align-items: stretch;
      justify-content: flex-start;
      gap: 20px;
      overflow-y: auto;
      max-width: 960px;
      width: 100%;
      margin: 0 auto;
      display: grid;
      grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
      align-content: start;
    }
    .audio-panel-body > .call-card,
    .audio-panel-body > .card {
      width: 100% !important;
      max-width: none !important;
      align-self: start;
      flex-shrink: 0;
    }
    .audio-code-label {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }
    .audio-code-label span:first-child {
      font-size: 11px;
      font-weight: 700;
      color: var(--muted);
      letter-spacing: .06em;
      text-transform: uppercase;
    }
    .audio-code-label span:last-child {
      font-size: 11px;
      color: var(--muted);
    }
    .audio-join-card .card-body { padding-top: 20px; }
    .audio-join-card .otp-wrap { margin-top: 4px; }
    .audio-join-card .btn { width: 100%; }
    .participant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px,1fr)); gap: 12px; margin: 4px 0 16px; }
    .participant-item { text-align: center; }
    .participant-name { font-size: 11px; color: var(--muted); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

    /* ===================== VIDEO PANEL ===================== */
    #panel-video .panel-body {
      padding: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    .video-stage {
      position: relative;
      background: #000;
      flex: 1;
      overflow: hidden;
      min-height: 0;
    }
    .video-stage video.remote {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .video-stage video.local {
      position: absolute;
      top: 16px; right: 16px;
      width: 110px; height: 148px;
      object-fit: cover;
      border-radius: var(--radius-md);
      border: 2px solid rgba(255,255,255,.2);
      background: #111;
      box-shadow: 0 8px 24px rgba(0,0,0,.4);
      cursor: pointer;
      transition: var(--transition);
    }
    .video-stage video.local:hover { transform: scale(1.04); }

    .video-overlay {
      position: absolute;
      top: 16px; left: 16px;
      color: #fff;
      z-index: 2;
    }
    .video-overlay h3 {
      font-size: 18px;
      font-weight: 800;
      letter-spacing: -.3px;
      text-shadow: 0 2px 8px rgba(0,0,0,.4);
    }
    .video-overlay p {
      font-size: 13px;
      opacity: .8;
      margin-top: 2px;
      font-weight: 500;
    }

    .video-controls {
      position: absolute;
      bottom: 0; left: 0; right: 0;
      display: flex;
      justify-content: center;
      gap: 12px;
      padding: 20px 16px 28px;
      background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 100%);
    }
    .video-stage:fullscreen, .video-stage:-webkit-full-screen { max-height: 100vh; }

    .video-bottom-bar {
      background: var(--card);
      border-top: 1px solid var(--border);
      padding: 16px 24px;
      display: flex;
      align-items: center;
      gap: 16px;
      flex-shrink: 0;
    }
    .video-code-area { flex: 1; }
    .video-code-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; letter-spacing: .06em; text-transform: uppercase; }
    .video-code-val {
      font-family: "SF Mono", Menlo, Consolas, monospace;
      font-size: 22px;
      font-weight: 800;
      letter-spacing: 6px;
      color: var(--fg);
      cursor: pointer;
    }
    .video-code-val.empty { color: var(--border-2); }
    .video-start-btn { flex-shrink: 0; }

    /* ===================== GROUP CHAT PANEL ===================== */
    #panel-group { overflow: hidden; }
    #panel-group .panel-body { padding: 0; overflow: hidden; }
    #panel-group .panel-body > * { height: 100%; }

    .group-container {
      display: flex;
      height: 100%;
      min-height: 0;
      min-width: 0;
      overflow: hidden;
    }
    .group-sidebar {
      width: 300px;
      display: flex;
      flex-direction: column;
      border-right: 1px solid var(--border);
      background: var(--card);
      flex-shrink: 0;
    }
    .group-sidebar-header {
      height: 64px;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0 16px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .group-sidebar-header h3 { font-size: 17px; font-weight: 800; flex: 1; letter-spacing: -.3px; }
    .group-list { flex: 1; overflow-y: auto; }
    .group-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
      cursor: pointer;
      transition: var(--transition);
      border-bottom: 1px solid var(--border);
      position: relative;
    }
    .group-item:hover { background: var(--soft); }
    .group-item.active { background: var(--brand-soft); }
    .group-item.active::before {
      content: '';
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 3px;
      background: var(--brand);
      border-radius: 0 3px 3px 0;
    }
    .group-item-info { flex: 1; min-width: 0; }
    .group-item-name { font-size: 14px; font-weight: 700; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .group-item-last { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
    .group-avatar {
      width: 46px; height: 46px;
      border-radius: 50%;
      background: var(--soft-2) center/cover no-repeat;
      flex-shrink: 0;
    }

    .group-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
    .group-chat-header {
      height: 64px;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 0 16px;
      background: var(--card);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      min-width: 0;
    }
    .group-empty-state {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      padding: 40px;
      color: var(--muted);
      text-align: center;
    }
    .group-empty-icon {
      width: 72px; height: 72px;
      border-radius: 50%;
      background: var(--soft);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--border-2);
    }
    .group-empty-icon svg { width: 34px; height: 34px; }
    .group-empty-state h3 { font-size: 18px; font-weight: 800; color: var(--fg-2); letter-spacing: -.3px; }
    .group-empty-state p { font-size: 14px; max-width: 260px; line-height: 1.5; }

    .group-back-btn { display: none; }

    /* ===================== PUBLIC CHAT PANEL ===================== */
    #panel-public .panel-body { padding: 0; overflow: hidden; }
    #panel-public .chat-container { display: flex; flex-direction: column; height: 100%; min-height: 0; }

    /* ===================== MODAL ===================== */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.5);
      backdrop-filter: blur(4px);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      opacity: 0;
      pointer-events: none;
      transition: opacity .2s ease;
    }
    .modal-overlay.active { opacity: 1; pointer-events: auto; }
    .modal {
      background: var(--card);
      border-radius: var(--radius-xl);
      width: 100%;
      max-width: 400px;
      padding: 28px;
      box-shadow: var(--shadow-xl);
      border: 1px solid var(--border);
      transform: translateY(8px) scale(.98);
      transition: transform .2s cubic-bezier(.34,1.56,.64,1);
    }
    .modal-overlay.active .modal { transform: none; }
    .modal-title { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 20px; color: var(--fg); }
    .modal-field { margin-bottom: 16px; }
    .modal-field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; letter-spacing: .06em; text-transform: uppercase; }
    .modal-field input {
      width: 100%;
      padding: 12px 14px;
      border-radius: var(--radius-md);
      border: 1.5px solid var(--border);
      background: var(--soft);
      color: var(--fg);
      outline: none;
      font-size: 14px;
      transition: var(--transition);
    }
    .modal-field input:focus { border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 3px var(--brand-soft); }
    .modal-actions { display: flex; gap: 10px; margin-top: 24px; }
    .modal-actions .btn { flex: 1; }

    /* ===================== TOASTS ===================== */
    #toasts {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 8px;
      align-items: center;
      pointer-events: none;
    }
    .toast {
      background: var(--fg);
      color: var(--bg);
      padding: 10px 18px;
      border-radius: var(--radius-full);
      font-size: 13px;
      font-weight: 500;
      box-shadow: var(--shadow-lg);
      animation: toast-in .25s cubic-bezier(.34,1.56,.64,1);
      pointer-events: auto;
      white-space: nowrap;
    }
    @keyframes toast-in {
      from { opacity: 0; transform: translateY(12px) scale(.92); }
      to { opacity: 1; transform: none; }
    }

    /* ===================== MISC UTILS ===================== */
    .hidden { display: none !important; }
    .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .muted { color: var(--muted); font-size: 13px; }
    .row { display: flex; align-items: center; gap: 10px; }
    .between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
    .center { text-align: center; }
    .grow { flex: 1; }
    .css-fullscreen { position: fixed !important; inset: 0 !important; width: 100% !important; height: 100% !important; max-height: none !important; z-index: 99999 !important; border-radius: 0 !important; margin: 0 !important; }
    .text-sm { font-size: 13px; }
    .font-mono {
      font-family: "SF Mono", Menlo, Consolas, monospace;
      letter-spacing: .04em;
    }
    .pill-brand {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--brand-soft);
      color: var(--brand);
      font-size: 12px;
      font-weight: 700;
      padding: 5px 12px;
      border-radius: var(--radius-full);
      cursor: pointer;
    }

    /* ===================== BOTTOM NAV (mobile) ===================== */
    .bottom-nav {
      display: none;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      height: 64px;
      background: var(--card);
      border-top: 1px solid var(--border);
      z-index: 200;
      padding: 0 8px;
      align-items: stretch;
      justify-content: space-around;
    }
    .bottom-nav .nav-item {
      flex: 1;
      width: auto;
      height: auto;
      border-radius: var(--radius-md);
      padding: 8px 4px;
      gap: 4px;
    }
    .bottom-nav .nav-item svg { width: 22px; height: 22px; }
    .bottom-nav .nav-label { font-size: 10px; }

    .mobile-menu-toggle,
    .mobile-menu-backdrop { display: none; }

    /* ===================== NAME FIELD ===================== */
    .name-field {
      display: flex;
      align-items: center;
      gap: 8px;
      background: var(--soft);
      border: 1.5px solid var(--border);
      border-radius: var(--radius-md);
      padding: 7px 12px;
      transition: var(--transition);
    }
    .name-field:focus-within { border-color: var(--brand); background: var(--card); }
    .name-field label { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
    .name-field input {
      border: none; outline: none; background: transparent;
      color: var(--fg); font-size: 14px; width: 140px; font-weight: 500;
    }

    /* ===================== PUBLIC WALL ===================== */
    .pub-info-bar {
      padding: 12px 20px;
      background: var(--card);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
    }
    .pub-name-input {
      padding: 8px 12px;
      border: 1.5px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--soft);
      color: var(--fg);
      font-size: 13px;
      font-weight: 500;
      outline: none;
      width: 130px;
      transition: var(--transition);
    }
    .pub-name-input:focus { border-color: var(--brand); background: var(--card); }

    /* ===================== VLEN BUBBLE ===================== */
    .vlen-bubble {
      position: relative;
      background: linear-gradient(135deg, rgba(10,124,255,.1) 0%, rgba(88,86,214,.1) 100%) !important;
      border: 1px solid rgba(10,124,255,.3) !important;
      box-shadow: 0 4px 14px rgba(10,124,255,.1) !important;
    }
    html.dark .vlen-bubble {
      background: linear-gradient(135deg, rgba(56,72,200,.28) 0%, rgba(99,102,241,.2) 100%) !important;
      border: 1px solid rgba(129,140,248,.4) !important;
      box-shadow: 0 4px 18px rgba(56,72,200,.3) !important;
    }
    .vlen-bubble::before {
      content: "✦ Vlen AI";
      display: block;
      font-size: 10px;
      font-weight: 800;
      letter-spacing: .06em;
      background: linear-gradient(90deg,var(--brand),#5856d6);
      -webkit-background-clip: text; background-clip: text; color: transparent;
      margin-bottom: 4px;
    }
    .vlen-typing {
      display: none; align-items: center; gap: 8px;
      padding: 8px 14px; margin: 4px 0;
      font-size: 12px; color: var(--muted);
      background: linear-gradient(135deg, rgba(10,124,255,.08), rgba(88,86,214,.08));
      border: 1px dashed rgba(10,124,255,.35);
      border-radius: var(--radius-md);
      width: max-content; max-width: 85%;
    }
    .vlen-typing.active { display: inline-flex; }
    .vlen-typing .dots { display: inline-flex; gap: 3px; }
    .vlen-typing .dots i {
      width: 5px; height: 5px; border-radius: 50%;
      background: var(--brand); display: inline-block;
      animation: vlenBlink 1.2s infinite ease-in-out;
    }
    .vlen-typing .dots i:nth-child(2) { animation-delay: .15s; }
    .vlen-typing .dots i:nth-child(3) { animation-delay: .3s; }
    @keyframes vlenBlink {
      0%,80%,100% { opacity: .25; transform: translateY(0); }
      40% { opacity: 1; transform: translateY(-2px); }
    }

    /* ===================== MENTION POPUP ===================== */
    .mention-pop {
      position: absolute; z-index: 9999;
      background: var(--card); border: 1px solid var(--border);
      border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
      padding: 6px; min-width: 210px; font-size: 13px; display: none;
    }
    .mention-pop.active { display: block; }
    .mention-pop .item {
      display: flex; align-items: center; gap: 10px;
      padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--fg);
    }
    .mention-pop .item:hover, .mention-pop .item.sel { background: var(--brand-soft); }
    .mention-pop .item .badge {
      width: 26px; height: 26px; border-radius: 50%;
      background: linear-gradient(135deg, var(--brand), #5856d6);
      color: #fff; display: flex; align-items: center; justify-content: center;
      font-size: 12px; font-weight: 800; flex-shrink: 0;
    }
    .mention-pop .item .hint { margin-left: auto; font-size: 11px; color: var(--muted); }
    .mention-pop .item .nm { font-weight: 700; }
    .mention-pop .item .sub { font-size: 11px; color: var(--muted); }

    /* ===================== LIGHTBOX ===================== */
    #vexaLightbox {
      display: none; position: fixed; inset: 0; z-index: 99999;
      background: rgba(0,0,0,.92); backdrop-filter: blur(20px);
      align-items: center; justify-content: center; cursor: zoom-out;
    }
    #vexaLightbox.open { display: flex; }
    #vexaLightbox img {
      max-width: 94vw; max-height: 92vh; border-radius: var(--radius-md);
      box-shadow: 0 8px 60px rgba(0,0,0,.8); cursor: default;
    }
    #vexaLightboxClose {
      position: fixed; top: 16px; right: 20px; color: #fff; font-size: 28px;
      cursor: pointer; background: rgba(255,255,255,.1); border: none;
      border-radius: 50%; width: 40px; height: 40px;
      display: flex; align-items: center; justify-content: center;
      line-height: 1; backdrop-filter: blur(10px);
      transition: background .15s;
    }
    #vexaLightboxClose:hover { background: rgba(255,255,255,.2); }

    /* ===================== RESPONSIVE ===================== */
    @media (max-width: 768px) {
      .app-shell {
        height: 100vh;
        height: var(--app-height, 100dvh);
      }
      .sidebar {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, 84vw);
        height: 100dvh;
        align-items: stretch;
        padding-top: max(16px, env(safe-area-inset-top, 0px));
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
        transform: translateX(-105%);
        transition: transform .24s cubic-bezier(.4,0,.2,1);
        box-shadow: 12px 0 36px rgba(0,0,0,.18);
        z-index: 320;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
      }
      .sidebar-logo {
        margin-left: 16px;
        margin-right: auto;
      }
      .sidebar-nav {
        align-items: stretch;
        padding: 0 14px;
        gap: 6px;
      }
      .sidebar-nav .nav-item {
        width: 100%;
        height: 52px;
        flex-direction: row;
        justify-content: flex-start;
        padding: 0 16px;
        gap: 14px;
        border-radius: 14px;
      }
      .sidebar-nav .nav-label {
        font-size: 14px;
        font-weight: 600;
      }
      .sidebar-footer {
        flex-direction: row;
        justify-content: flex-start;
        padding: 0 18px;
        gap: 14px;
      }
      .sidebar.mobile-open { transform: translateX(0); }
      .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        display: block;
        background: rgba(15,23,42,.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        z-index: 310;
      }
      .mobile-menu-backdrop.active {
        opacity: 1;
        pointer-events: auto;
      }
      .mobile-menu-toggle {
        position: fixed;
        top: max(10px, env(safe-area-inset-top, 0px));
        left: 12px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: color-mix(in srgb, var(--card) 92%, transparent);
        color: var(--fg-2);
        box-shadow: var(--shadow-sm);
        z-index: 220;
        backdrop-filter: blur(12px);
      }
      .mobile-menu-toggle:hover,
      .mobile-menu-toggle:focus-visible {
        color: var(--brand);
        border-color: var(--brand);
        background: var(--brand-soft);
      }
      .mobile-menu-toggle svg { width: 20px; height: 20px; }
      .bottom-nav { display: none; }
      .main-content {
        width: 100%;
        height: 100%;
        min-height: 0;
        padding-bottom: 0;
      }
      .panel { min-width: 0; min-height: 0; }
      .panel-header { height: 56px; padding: 0 16px 0 64px; }
      .panel-header h1 { font-size: 17px; }
      .panel-header > div:first-child { min-width: 0; }
      .panel-header .header-actions { min-width: 0; max-width: 58%; }
      .panel-body { padding: 16px; }
      .chat-body { padding: 12px 14px; }
      .composer { padding: 8px 10px max(10px, env(safe-area-inset-bottom, 0px)); }
      .composer { gap: 6px; }
      .composer textarea {
        min-width: 0;
        min-height: 42px;
        padding: 10px 12px;
        font-size: 16px;
      }
      .composer-icon { width: 40px; height: 40px; }
      .composer-send { width: 44px; height: 44px; }
      .msg { max-width: 85%; }
      .grid-2 { grid-template-columns: 1fr; }
      #panel-messages .panel-body { overflow: hidden; }
      .message-setup {
        padding: 8px 12px 10px !important;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }
      .message-setup::-webkit-scrollbar { display: none; }
      .message-setup-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
        width: max-content;
      }
      .message-setup-grid > .card {
        flex: 0 0 min(84vw, 340px);
      }
      .message-setup-grid .card-header { padding: 12px 14px; }
      .message-setup-grid .card-body { padding: 14px; }
      .message-setup-grid .card-subtitle { display: none; }
      .message-setup-grid .code-box { padding: 14px 12px; }
      #panel-messages .chat-container {
        margin: 0 10px 10px !important;
        border-radius: 16px;
        flex: 1 1 auto;
        min-height: 160px;
      }
      #panel-messages .chat-header { padding: 8px 10px; }
      #panel-messages .chat-header > div:first-child { width: 32px !important; height: 32px !important; }
      #panel-messages .chat-header .btn-ghost { padding: 8px 10px; }
      .group-sidebar { width: 100%; }
      .group-container.chat-active .group-sidebar { display: none; }
      .group-container:not(.chat-active) .group-main { display: none; }
      .group-back-btn { display: flex !important; }
      .group-sidebar { border-right: none; }
      #panel-group .panel-body { min-height: 0; }
      .group-container { min-height: 0; }
      #grpChatActive { min-height: 0; }
      #grpBody { min-height: 0; }
      .call-card { max-width: 100%; }
      #panel-audio .panel-body { align-items: stretch; justify-content: flex-start; }
      .audio-panel-body { display: flex; flex-direction: column; max-width: none; padding: 14px; overflow-y: auto; flex: 1 1 0; min-height: 0; }
      .call-hero { padding: 18px 22px 16px; }
      .call-avatar-ring { width: 72px; height: 72px; margin-bottom: 10px; }
      .call-hero h2 { margin: 0 0 4px; }
      .call-body { padding: 16px 18px 18px; }
      .participant-grid { margin: 2px 0 10px; }
      .audio-code-label { align-items: flex-start; flex-direction: column; gap: 3px; }
      #panel-audio .audio-panel-body { gap: 12px; }
      .audio-join-shortcut {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 5;
        width: 100%;
        padding: 10px 14px;
        border-radius: 999px;
        border: 1px solid var(--border);
        background: var(--brand-soft, var(--soft));
        color: var(--brand);
        font-size: 13px;
        font-weight: 700;
        box-shadow: var(--shadow-sm);
      }
      .audio-join-shortcut svg:last-child { animation: join-hint-bounce 1.4s ease-in-out infinite; }
      @keyframes join-hint-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
      .video-bottom-bar { flex-direction: column; gap: 12px; align-items: stretch; }
      .modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-width: 100%; }
      .modal-overlay { align-items: flex-end; padding: 0; }
      .modal-actions { flex-direction: column-reverse; }
      .modal-actions .btn { width: 100%; }
      .otp-wrap input { width: 38px; height: 46px; font-size: 18px; }
      .group-chat-header { padding-left: 12px; padding-right: 12px; }
      .group-chat-header > div:last-child { gap: 2px !important; }
      .group-chat-header .btn-icon { width: 36px; height: 36px; }
      .pub-info-bar { flex-wrap: wrap; padding: 8px 12px; }
      .pub-info-bar > span { width: 100%; padding-left: 22px; }
      #panel-public .panel-body { min-height: 0; }
      #pubWrap { min-height: 0; }
    }

    @media (max-width: 480px) {
      .code-value { font-size: 22px; letter-spacing: 6px; }
      .otp-wrap { gap: 6px; }
      .otp-wrap { width: 100%; }
      .otp-wrap input { width: auto; flex: 1; min-width: 0; height: 44px; font-size: 16px; gap: 4px; }
      .panel-header .header-actions .status-pill { max-width: 132px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
      .panel-header .header-actions { min-width: 0; }
      .name-field { max-width: 110px; }
      .name-field input { min-width: 0; width: 100%; }
      .audio-panel-body { padding: 10px; }
      .call-avatar-ring { width: 88px; height: 88px; margin-bottom: 16px; }
      .call-hero h2 { font-size: 20px; }
      .actions { gap: 12px; }
      .act-label { font-size: 10px; }
      .chat-header { padding-left: 12px; padding-right: 12px; }
      .chat-header .btn-icon { width: 34px; height: 34px; }
      .msg { max-width: 90%; }
      .panel-header .sub { display: none; }
      .panel-header .header-actions { max-width: 52%; }
      .panel-header .header-actions .name-field { display: none; }
      .panel-header .header-actions .status-pill { max-width: 118px; }
      .message-setup-grid > .card { flex-basis: min(86vw, 330px); }
      #panel-messages .chat-container { margin-left: 8px !important; margin-right: 8px !important; }
      .chat-peer-name { font-size: 14px; }
      .chat-peer-status { font-size: 11px; }
      .composer-icon { width: 40px; height: 40px; }
      .composer-send { width: 44px; height: 44px; }
      .group-chat-header { gap: 8px; }
      .group-chat-header > div:last-child { min-width: 0; }
      #grpActiveCode { max-width: 58px; overflow: hidden; text-overflow: ellipsis; }
      #grpFs { display: none; }
    }
  


    /* ===================== VEXA FEATURE PACK (polls, vault, themes, games, voice FX) ===================== */
    .vx-hide { display: none !important; }

    /* --- popover menu / sheet --- */
    .vx-scrim {
      position: fixed; inset: 0; background: rgba(0,0,0,.45);
      backdrop-filter: blur(2px); z-index: 480;
      opacity: 0; pointer-events: none; transition: opacity .18s ease;
    }
    .vx-scrim.open { opacity: 1; pointer-events: auto; }

    .vx-sheet {
      position: fixed; z-index: 500;
      left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.97);
      width: min(430px, calc(100vw - 28px));
      max-height: min(78vh, 640px);
      background: var(--card); color: var(--fg);
      border: 1px solid var(--border); border-radius: var(--radius-xl);
      box-shadow: var(--shadow-xl);
      display: flex; flex-direction: column; overflow: hidden;
      opacity: 0; pointer-events: none;
      transition: opacity .18s ease, transform .18s cubic-bezier(.4,0,.2,1);
    }
    .vx-sheet.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
    .vx-sheet-head {
      display: flex; align-items: center; gap: 10px;
      padding: 15px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    }
    .vx-sheet-title { font-size: 15px; font-weight: 700; flex: 1; }
    .vx-sheet-body { padding: 14px 16px 18px; overflow: auto; }
    .vx-x {
      width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
      background: var(--soft); color: var(--muted); cursor: pointer;
      display: flex; align-items: center; justify-content: center; font-size: 17px; line-height: 1;
      transition: var(--transition);
    }
    .vx-x:hover { color: var(--danger); border-color: var(--danger); }

    .vx-menu-list { display: flex; flex-direction: column; gap: 6px; }
    .vx-menu-item {
      display: flex; align-items: center; gap: 12px; width: 100%;
      padding: 12px 13px; border-radius: var(--radius-md);
      background: var(--soft); border: 1.5px solid transparent;
      color: var(--fg); font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
      transition: var(--transition);
    }
    .vx-menu-item:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
    .vx-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
    .vx-menu-item small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
    .vx-menu-item:hover small { color: inherit; opacity: .8; }

    .vx-field { margin-bottom: 12px; }
    .vx-field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
    .vx-input, .vx-textarea, .vx-select {
      width: 100%; background: var(--soft); border: 1.5px solid var(--border);
      color: var(--fg); border-radius: var(--radius-md); padding: 10px 12px;
      font-size: 14px; outline: none; font-family: inherit; transition: var(--transition);
    }
    .vx-textarea { resize: vertical; min-height: 108px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; }
    .vx-input:focus, .vx-textarea:focus, .vx-select:focus { border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 3px var(--brand-soft); }
    .vx-row { display: flex; gap: 8px; align-items: center; }
    .vx-row > * { min-width: 0; }
    .vx-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

    .vx-btn {
      border: 1.5px solid var(--border); background: var(--soft); color: var(--fg);
      border-radius: var(--radius-md); padding: 9px 15px; font-size: 13px; font-weight: 650;
      cursor: pointer; transition: var(--transition); font-family: inherit;
      display: inline-flex; align-items: center; gap: 7px;
    }
    .vx-btn:hover { border-color: var(--brand); color: var(--brand); }
    .vx-btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 10px var(--brand-glow); }
    .vx-btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
    .vx-btn-danger { color: var(--danger); }
    .vx-btn-danger:hover { border-color: var(--danger); color: var(--danger); }
    .vx-btn svg { width: 15px; height: 15px; }
    .vx-btn:disabled { opacity: .45; cursor: not-allowed; }

    /* --- in-chat feature cards --- */
    .vx-card {
      align-self: center; width: min(430px, 92%);
      background: var(--card); border: 1.5px solid var(--border);
      border-radius: var(--radius-lg); padding: 14px 15px; margin: 10px auto;
      box-shadow: var(--shadow-sm); animation: vx-pop .22s cubic-bezier(.4,0,.2,1);
    }
    @keyframes vx-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
    .vx-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
    .vx-chip {
      font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
      color: var(--brand); background: var(--brand-soft); padding: 3px 8px; border-radius: var(--radius-full);
    }
    .vx-card-by { font-size: 11.5px; color: var(--muted); margin-left: auto; }
    .vx-card-q { font-size: 15px; font-weight: 700; line-height: 1.35; margin-bottom: 12px; }

    .vx-poll-opt {
      position: relative; overflow: hidden; width: 100%; text-align: left;
      border: 1.5px solid var(--border); background: var(--soft); color: var(--fg);
      border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 7px;
      font-size: 13.5px; font-weight: 600; cursor: pointer; transition: var(--transition);
      font-family: inherit;
    }
    .vx-poll-opt:hover { border-color: var(--brand); }
    .vx-poll-opt.voted { border-color: var(--brand); }
    .vx-poll-fill {
      position: absolute; inset: 0 auto 0 0; width: 0%;
      background: var(--brand-soft); transition: width .45s cubic-bezier(.4,0,.2,1); z-index: 0;
    }
    .vx-poll-opt.voted .vx-poll-fill { background: var(--brand-glow); }
    .vx-poll-line { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; }
    .vx-poll-pct { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--brand); }
    .vx-poll-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }

    /* --- games --- */
    .vx-game-status { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
    .vx-ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 250px; margin: 0 auto; }
    .vx-ttt button {
      aspect-ratio: 1; border: 1.5px solid var(--border); background: var(--soft);
      border-radius: var(--radius-md); font-size: 30px; font-weight: 800; cursor: pointer;
      color: var(--brand); transition: var(--transition); font-family: inherit; line-height: 1;
    }
    .vx-ttt button:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
    .vx-ttt button:disabled { cursor: default; }
    .vx-ttt button.o { color: var(--warn); }
    .vx-ttt button.win { background: var(--brand-soft); border-color: var(--brand); }

    .vx-c4 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 300px; margin: 0 auto; }
    .vx-c4 button {
      aspect-ratio: 1; border: 1.5px solid var(--border); background: var(--soft);
      border-radius: 50%; cursor: pointer; padding: 0; transition: var(--transition);
    }
    .vx-c4 button:hover:not(:disabled) { border-color: var(--brand); }
    .vx-c4 button.p1 { background: var(--brand); border-color: var(--brand); }
    .vx-c4 button.p2 { background: var(--warn); border-color: var(--warn); }
    .vx-c4 button.win { box-shadow: 0 0 0 3px var(--brand-glow); }

    /* --- vault drawer --- */
    .vx-vault {
      position: fixed; top: 0; right: 0; bottom: 0; z-index: 490;
      width: min(420px, 100vw); background: var(--card);
      border-left: 1px solid var(--border); box-shadow: var(--shadow-xl);
      display: flex; flex-direction: column;
      transform: translateX(104%); transition: transform .24s cubic-bezier(.4,0,.2,1);
      padding-top: env(safe-area-inset-top, 0px);
    }
    .vx-vault.open { transform: none; }
    .vx-vault-head { display: flex; align-items: center; gap: 10px; padding: 15px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .vx-vault-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }
    .vx-vault-body { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
    .vx-vault-foot { padding: 12px 16px max(14px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }
    .vx-drop {
      border: 1.6px dashed var(--border-2); border-radius: var(--radius-lg);
      padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px;
      cursor: pointer; transition: var(--transition);
    }
    .vx-drop:hover, .vx-drop.hot { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
    .vx-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; line-height: 1.6; }

    .vx-item { border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--card-2); overflow: hidden; }
    .vx-item-head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--border); }
    .vx-item-name { font-size: 12.8px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .vx-item-meta { font-size: 10.5px; color: var(--muted); margin-left: auto; white-space: nowrap; }
    .vx-item-acts { display: flex; gap: 6px; padding: 8px 11px; border-top: 1px solid var(--border); flex-wrap: wrap; }
    .vx-mini {
      font-size: 11.5px; font-weight: 650; padding: 5px 10px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: var(--soft); color: var(--fg-2);
      cursor: pointer; transition: var(--transition); font-family: inherit; text-decoration: none;
      display: inline-flex; align-items: center; gap: 5px;
    }
    .vx-mini:hover { border-color: var(--brand); color: var(--brand); }
    .vx-code {
      margin: 0; padding: 11px 12px; max-height: 230px; overflow: auto;
      font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55;
      background: var(--card-2); color: var(--fg); white-space: pre; tab-size: 2;
    }
    .vx-code.wrap { white-space: pre-wrap; word-break: break-word; }
    .vx-t-key { color: #c678dd; } .vx-t-str { color: #98c379; } .vx-t-num { color: #d19a66; }
    .vx-t-com { color: var(--muted); font-style: italic; } .vx-t-fn { color: #61afef; } .vx-t-tag { color: #e06c75; }
    html:not(.dark) .vx-t-key { color: #a626a4; } html:not(.dark) .vx-t-str { color: #12864a; }
    html:not(.dark) .vx-t-num { color: #b76b01; } html:not(.dark) .vx-t-fn { color: #2f6fd0; }
    html:not(.dark) .vx-t-tag { color: #c0392b; }

    /* --- theme picker --- */
    .vx-theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
    .vx-theme-swatch {
      height: 62px; border-radius: var(--radius-md); border: 2px solid transparent;
      cursor: pointer; position: relative; overflow: hidden; padding: 0;
      box-shadow: var(--shadow-sm); transition: var(--transition);
    }
    .vx-theme-swatch:hover { transform: translateY(-2px); }
    .vx-theme-swatch.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
    .vx-theme-swatch span {
      position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px;
      font-size: 10px; font-weight: 700; color: #fff; background: rgba(0,0,0,.42);
      text-align: left; letter-spacing: .02em;
    }
    .vx-accents { display: flex; flex-wrap: wrap; gap: 8px; }
    .vx-accent {
      width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent;
      cursor: pointer; padding: 0; transition: var(--transition);
    }
    .vx-accent.sel { border-color: var(--fg); transform: scale(1.08); }

    /* --- voice FX --- */
    .vx-fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
    .vx-fx {
      padding: 12px 8px; border-radius: var(--radius-md); border: 1.5px solid var(--border);
      background: var(--soft); color: var(--fg); cursor: pointer; font-family: inherit;
      font-size: 12.5px; font-weight: 650; transition: var(--transition); text-align: center;
    }
    .vx-fx:hover { border-color: var(--brand); color: var(--brand); }
    .vx-fx.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
    .vx-fx b { display: block; font-size: 19px; margin-bottom: 4px; }
    .cbtn.vx-fx-on, .composer-icon.vx-fx-on { border-color: var(--brand) !important; color: var(--brand) !important; }

    /* --- themed room surface --- */
    .vx-themed .chat-body { background-image: var(--vx-wall, none) !important; background-size: cover; background-attachment: local; }

    @media (max-width: 768px) {
      .vx-sheet {
        left: 0; right: 0; bottom: 0; top: auto; width: 100%;
        transform: translateY(100%); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 86vh; padding-bottom: env(safe-area-inset-bottom, 0px);
      }
      .vx-sheet.open { transform: none; }
      .vx-vault { width: 100vw; border-left: 0; }
      .vx-card { width: 96%; }
      .vx-actions .vx-btn { flex: 1; justify-content: center; }
    }
  


    /* ================= MOBILE TEXTING UX (final layer) ================= */
    @media (max-width: 768px) {
      /* --- give the conversation the whole screen --- */
      #panel-messages .chat-container,
      #panel-messages .chat-container.card {
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
      }

      /* Setup cards: compact, and out of the way once a chat is live */
      .message-setup { padding: 6px 10px 8px !important; }
      .message-setup-grid { gap: 8px; }
      .message-setup-grid > .card { flex: 0 0 min(88vw, 320px); }
      .message-setup-grid .card-header { padding: 10px 12px; }
      .message-setup-grid .card-body { padding: 10px 12px 12px; }
      .message-setup-grid .code-box { padding: 10px; }
      body.dm-connected .message-setup { display: none !important; }

      /* --- chat scroll surface --- */
      .chat-body {
        padding: 10px 10px 6px;
        gap: 1px;
        scroll-behavior: smooth;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
      }

      /* --- bubbles: wider, tighter, always wrap --- */
      .msg {
        max-width: 84%;
        font-size: 15px;
        line-height: 1.4;
        padding: 7px 11px;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      .msg.sys { font-size: 12px; max-width: 92%; }
      .msg-wrap { gap: 6px; padding: 1px 0; }

      /* --- composer: pill input, roomy text, thumb-friendly --- */
      .composer {
        gap: 4px;
        align-items: flex-end;
        padding: 6px 8px max(8px, env(safe-area-inset-bottom, 0px));
        -webkit-tap-highlight-color: transparent;
      }
      .composer-icon {
        width: 40px; height: 40px;
        border: none;
        background: transparent;
        color: var(--muted);
        transition: width .18s ease, opacity .16s ease, transform .12s ease;
      }
      .composer-icon:active { transform: scale(.9); background: var(--brand-soft); color: var(--brand); }
      .composer-icon svg { width: 20px; height: 20px; }
      .composer textarea,
      .composer input[type="text"] {
        min-height: 42px;
        max-height: 108px;
        padding: 10px 15px;
        border-radius: 21px;
        font-size: 16px;
        line-height: 1.35;
      }
      .mention-wrap > .mention-bg { padding: 10px 15px; font-size: 16px; line-height: 1.35; }
      .composer-send {
        width: 42px; height: 42px;
        transition: transform .12s ease, background .15s ease;
      }
      .composer-send:hover { transform: none; }
      .composer-send:active { transform: scale(.92); }

      /* while typing, the mic collapses away so the text field grows */
      .composer.is-typing .composer-icon.mic-collapse {
        width: 0; opacity: 0; pointer-events: none; overflow: hidden;
      }

      /* keep headers slim so more of the thread is visible */
      .chat-header, #panel-messages .chat-header { padding: 6px 10px; }
      .typing-row { padding: 2px 12px; }
    }

    @media (max-width: 480px) {
      .msg { max-width: 88%; }
      .composer-icon { width: 38px; height: 38px; }
    }
  