    /* ── Reset & Base ──────────────────────────────────────────────────────── */
    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

    :root {
      --bg:          #09090d;
      --surface:     #0f0f14;
      --surface2:    #141419;
      --border:      #1c1c24;
      --border2:     #24242f;
      --text:        #c8c8d8;
      --muted:       #4a4a60;
      --muted2:      #2e2e3e;
      --accent:      #8b7ef5;
      --accent-glow: rgba(139,126,245,0.2);
      --danger:      #ff4d6a;
      --success:     #4dffa0;
      --system-fg:   #3a3a52;
      --radius:      6px;
      --font:        'JetBrains Mono', 'Courier New', monospace;
    }

    html, body { height: 100%; overflow: hidden; }

    body {
      font-family: var(--font);
      background: var(--bg);
      color: var(--text);
      font-size: 13px;
      line-height: 1.6;
      -webkit-font-smoothing: antialiased;
    }

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

    /* ── Utilities ─────────────────────────────────────────────────────────── */
    .hidden { display: none !important; }

    /* ── Auth Screen ───────────────────────────────────────────────────────── */
    #auth-screen {
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(139,126,245,0.06) 0%, transparent 70%),
        var(--bg);
    }

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

    .auth-logo {
      text-align: center;
      margin-bottom: 28px;
    }

    .auth-logo .star {
      display: inline-block;
      font-size: 36px;
      font-weight: 700;
      color: var(--accent);
      text-shadow: 0 0 24px var(--accent-glow), 0 0 48px rgba(139,126,245,0.1);
      line-height: 1;
      margin-bottom: 8px;
    }

    .auth-logo .wordmark {
      display: block;
      font-size: 16px;
      font-weight: 500;
      letter-spacing: 0.18em;
      color: var(--text);
    }

    .auth-tabs {
      display: flex;
      border-bottom: 1px solid var(--border);
      margin-bottom: 24px;
    }

    .auth-tab {
      flex: 1;
      padding: 8px;
      text-align: center;
      font-family: var(--font);
      font-size: 12px;
      letter-spacing: 0.06em;
      color: var(--muted);
      background: none;
      border: none;
      cursor: pointer;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
      transition: color 0.15s, border-color 0.15s;
    }

    .auth-tab.active {
      color: var(--text);
      border-bottom-color: var(--accent);
    }

    .auth-form { display: flex; flex-direction: column; gap: 12px; }

    .field label {
      display: block;
      font-size: 11px;
      letter-spacing: 0.08em;
      color: var(--muted);
      margin-bottom: 5px;
    }

    .field input {
      width: 100%;
      padding: 9px 12px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      font-family: var(--font);
      font-size: 13px;
      outline: none;
      transition: border-color 0.15s;
    }

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

    .auth-error {
      font-size: 12px;
      color: var(--danger);
      min-height: 16px;
      text-align: center;
    }

    .btn-primary {
      width: 100%;
      padding: 10px;
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: var(--radius);
      font-family: var(--font);
      font-size: 13px;
      font-weight: 500;
      letter-spacing: 0.04em;
      cursor: pointer;
      transition: opacity 0.15s, transform 0.1s;
      margin-top: 4px;
    }

    .btn-primary:hover:not(:disabled)  { opacity: 0.88; }
    .btn-primary:active:not(:disabled) { transform: scale(0.98); }
    .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

    /* ── Chat Screen ───────────────────────────────────────────────────────── */
    #chat-screen {
      height: 100%;
      display: flex;
      flex-direction: column;
    }

    /* Header */
    #chat-header {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 0 16px;
      height: 46px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .header-logo {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .header-star {
      font-size: 18px;
      font-weight: 700;
      color: var(--accent);
      line-height: 1;
    }

    .header-name {
      font-size: 13px;
      font-weight: 500;
      letter-spacing: 0.12em;
      color: var(--text);
    }

    .header-sep {
      width: 1px;
      height: 18px;
      background: var(--border);
    }

    #conn-status {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 11px;
      color: var(--muted);
    }

    .status-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--muted);
      transition: background 0.3s;
      flex-shrink: 0;
    }

    .status-dot.connected    { background: var(--success); box-shadow: 0 0 6px rgba(77,255,160,0.4); }
    .status-dot.connecting   { background: #f5c842; animation: pulse 1s ease-in-out infinite; }
    .status-dot.disconnected { background: var(--danger); }

    @keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

    .header-spacer { flex: 1; }

    #header-user {
      font-size: 12px;
      color: var(--muted);
      display: flex;
      align-items: center;
      gap: 10px;
    }

    #header-username { font-weight: 500; }

    #logout-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--muted);
      font-family: var(--font);
      font-size: 11px;
      padding: 3px 8px;
      border-radius: var(--radius);
      cursor: pointer;
      letter-spacing: 0.04em;
      transition: color 0.15s, border-color 0.15s;
    }
    #logout-btn:hover { color: var(--text); border-color: var(--border2); }

    /* ── Channel bar (shows DM context) ───────────────────────────────────── */
    #channel-bar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 0 16px;
      height: 32px;
      background: var(--surface2);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      font-size: 11px;
      color: var(--muted);
    }

    #channel-label { letter-spacing: 0.06em; }

    #back-btn {
      background: none;
      border: none;
      color: var(--muted);
      font-family: var(--font);
      font-size: 11px;
      cursor: pointer;
      padding: 0;
      letter-spacing: 0.04em;
      transition: color 0.15s;
    }
    #back-btn:hover { color: var(--text); }

    /* Main layout */
    #chat-body {
      flex: 1;
      display: flex;
      overflow: hidden;
    }

    /* Messages area */
    #messages-panel {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    #messages {
      flex: 1;
      overflow-y: auto;
      padding: 12px 0 4px;
      scroll-behavior: smooth;
    }

    /* Message rows */
    .msg {
      display: flex;
      align-items: baseline;
      gap: 10px;
      padding: 3px 16px;
      transition: background 0.1s;
    }
    .msg:hover { background: rgba(255,255,255,0.02); }

    .msg-ts {
      font-size: 10px;
      color: var(--muted);
      flex-shrink: 0;
      width: 42px;
      text-align: right;
      padding-top: 1px;
      user-select: none;
    }

    .msg-user {
      font-size: 12px;
      font-weight: 500;
      flex-shrink: 0;
      user-select: none;
    }

    .msg-sep {
      color: var(--muted);
      flex-shrink: 0;
      user-select: none;
    }

    .msg-text {
      flex: 1;
      word-break: break-word;
      white-space: pre-wrap;
      color: var(--text);
    }

    /* DM sent by self — subtle dimming */
    .msg-dm-out .msg-text { opacity: 0.7; }

    /* System messages */
    .msg-system {
      padding: 4px 16px;
      font-size: 11px;
      color: var(--system-fg);
      font-style: italic;
      text-align: center;
      user-select: none;
    }

    /* Input area */
    #input-area {
      flex-shrink: 0;
      border-top: 1px solid var(--border);
      background: var(--surface);
    }

    #typing-bar {
      height: 20px;
      display: flex;
      align-items: center;
      padding: 0 16px;
      font-size: 11px;
      color: var(--muted);
      font-style: italic;
      user-select: none;
      transition: opacity 0.2s;
    }

    #typing-dots::after {
      content: '';
      animation: dot-anim 1.2s steps(4, end) infinite;
    }
    @keyframes dot-anim {
      0%  { content: '.'; }
      25% { content: '..'; }
      50% { content: '...'; }
      75% { content: ''; }
    }

    #input-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 14px 12px;
    }

    #msg-input {
      flex: 1;
      padding: 9px 13px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      font-family: var(--font);
      font-size: 13px;
      outline: none;
      resize: none;
      transition: border-color 0.15s;
      height: 38px;
      max-height: 140px;
      overflow-y: auto;
    }

    #msg-input:focus { border-color: var(--border2); }
    #msg-input::placeholder { color: var(--muted); }

    #send-btn {
      flex-shrink: 0;
      width: 38px;
      height: 38px;
      background: var(--accent);
      border: none;
      border-radius: var(--radius);
      color: #fff;
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: opacity 0.15s;
    }
    #send-btn:hover:not(:disabled) { opacity: 0.85; }
    #send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

    /* ── Right panel (ONLINE + FRIENDS tabs) ───────────────────────────────── */
    #right-panel {
      width: 190px;
      flex-shrink: 0;
      border-left: 1px solid var(--border);
      background: var(--surface);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    #right-tabs {
      display: flex;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .right-tab {
      flex: 1;
      padding: 9px 4px;
      font-family: var(--font);
      font-size: 10px;
      letter-spacing: 0.1em;
      color: var(--muted);
      background: none;
      border: none;
      cursor: pointer;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
      transition: color 0.15s, border-color 0.15s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
    }

    .right-tab.active {
      color: var(--text);
      border-bottom-color: var(--accent);
    }

    .notif-badge {
      background: var(--accent);
      color: #fff;
      font-size: 9px;
      padding: 1px 5px;
      border-radius: 8px;
      font-weight: 700;
      line-height: 1.4;
      font-style: normal;
    }

    /* ── Online tab ─────────────────────────────────────────────────────────── */
    #online-tab {
      flex: 1;
      overflow-y: auto;
      padding: 8px 0;
    }

    .user-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 4px 14px;
    }

    .user-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .user-name {
      font-size: 12px;
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .user-name.is-you {
      font-style: italic;
      color: var(--muted);
    }

    /* ── Friends tab ────────────────────────────────────────────────────────── */
    #friends-tab {
      flex: 1;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
    }

    #add-friend-area {
      padding: 10px 10px 0;
      flex-shrink: 0;
    }

    #add-friend-row {
      display: flex;
      gap: 6px;
    }

    #friend-input {
      flex: 1;
      padding: 6px 8px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      font-family: var(--font);
      font-size: 11px;
      outline: none;
      transition: border-color 0.15s;
      min-width: 0;
    }
    #friend-input:focus { border-color: var(--accent); }
    #friend-input::placeholder { color: var(--muted); }

    #add-friend-btn {
      flex-shrink: 0;
      width: 28px;
      height: 28px;
      background: var(--accent);
      border: none;
      border-radius: var(--radius);
      color: #fff;
      font-size: 18px;
      font-family: var(--font);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: opacity 0.15s;
      line-height: 1;
      padding-bottom: 2px;
    }
    #add-friend-btn:hover { opacity: 0.85; }

    #add-friend-msg {
      font-size: 10px;
      min-height: 18px;
      padding: 4px 2px 2px;
    }
    #add-friend-msg.err  { color: var(--danger); }
    #add-friend-msg.ok   { color: var(--success); }

    .friends-section {
      flex-shrink: 0;
    }

    .friends-section-label {
      padding: 8px 12px 4px;
      font-size: 9px;
      letter-spacing: 0.14em;
      color: var(--muted);
      text-transform: uppercase;
    }

    .discover-toggle {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding-right: 12px;
    }

    /* Incoming request card */
    .request-item {
      padding: 6px 10px 8px;
      border-bottom: 1px solid var(--border);
    }

    .request-from {
      font-size: 11px;
      font-weight: 500;
      margin-bottom: 5px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .request-actions { display: flex; gap: 5px; }

    .btn-accept, .btn-reject {
      flex: 1;
      padding: 3px 0;
      font-family: var(--font);
      font-size: 10px;
      border-radius: var(--radius);
      cursor: pointer;
      border: 1px solid;
      transition: opacity 0.15s;
      letter-spacing: 0.04em;
    }
    .btn-accept { background: rgba(77,255,160,0.08); border-color: rgba(77,255,160,0.25); color: var(--success); }
    .btn-reject { background: rgba(255,77,106,0.07); border-color: rgba(255,77,106,0.22); color: var(--danger); }
    .btn-accept:hover, .btn-reject:hover { opacity: 0.75; }

    /* Outgoing request row */
    .outgoing-item {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 3px 12px 3px 12px;
    }

    .outgoing-name {
      font-size: 11px;
      color: var(--muted);
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-style: italic;
    }

    .btn-cancel-sm {
      background: none;
      border: none;
      color: var(--muted);
      font-size: 14px;
      cursor: pointer;
      line-height: 1;
      padding: 0 2px;
      transition: color 0.15s;
      flex-shrink: 0;
    }
    .btn-cancel-sm:hover { color: var(--danger); }

    /* Accepted friend row */
    .friend-item {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 4px 10px 4px 12px;
      cursor: default;
      transition: background 0.1s;
      position: relative;
    }
    .friend-item:hover { background: rgba(255,255,255,0.025); }
    .friend-item:hover .friend-actions { opacity: 1; }

    .friend-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .friend-name {
      font-size: 12px;
      color: var(--text);
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .friend-actions {
      display: flex;
      gap: 2px;
      opacity: 0;
      transition: opacity 0.15s;
      flex-shrink: 0;
    }

    .friend-dm-btn {
      background: none;
      border: none;
      font-family: var(--font);
      font-size: 10px;
      cursor: pointer;
      padding: 2px 5px;
      border-radius: 3px;
      color: var(--accent);
      transition: background 0.1s;
      letter-spacing: 0.03em;
    }
    .friend-dm-btn:hover { background: var(--accent-glow); }

    .friend-remove-btn {
      background: none;
      border: none;
      font-family: var(--font);
      font-size: 13px;
      cursor: pointer;
      padding: 0 3px;
      border-radius: 3px;
      color: var(--muted);
      transition: color 0.1s;
      line-height: 1.4;
    }
    .friend-remove-btn:hover { color: var(--danger); }

    /* Empty state */
    .friends-empty {
      padding: 14px 12px;
      font-size: 11px;
      color: var(--muted);
      font-style: italic;
    }

    /* ── Responsive ────────────────────────────────────────────────────────── */
    /* ── Mobile Layout ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-card { width: 100%; margin: 16px; padding: 32px 20px 24px; }

  /* Hide right panel — replaced by bottom nav */
  #right-panel { display: none; }

  /* Header tweaks */
  #chat-header { padding: 0 10px; gap: 8px; }
  #rate-limit  { display: none; }
  .header-sep:last-of-type { display: none; }

  /* Channel bar */
  #channel-bar { padding: 0 10px; }

  /* Push input area above bottom nav */
  #chat-screen { padding-bottom: 48px; }

  /* Bottom navigation bar */
  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 48px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 9px;
    letter-spacing: 0.08em;
    cursor: pointer;
    position: relative;
    transition: color 0.15s;
  }
  .mobile-nav-btn.active { color: var(--accent); }
  .mobile-nav-btn .nav-icon { font-size: 16px; line-height: 1; }

  .mobile-nav-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 8px;
    font-weight: 700;
    line-height: 1.4;
  }

  /* Mobile panels (online + friends) overlay the messages area */
  #mobile-online-panel,
  #mobile-friends-panel {
    display: none;
    position: absolute;
    top: 78px; /* header + channel bar */
    bottom: 48px; /* above nav */
    left: 0; right: 0;
    background: var(--bg);
    overflow-y: auto;
    z-index: 50;
    padding: 8px 0;
  }

  #mobile-friends-panel { padding: 0; }

  #mobile-online-panel.visible,
  #mobile-friends-panel.visible { display: block; }

  /* Make chat body position:relative so panels overlay it */
  #chat-body { position: relative; }

  /* Touch-friendly sizing */
  .msg      { padding: 4px 12px; }
  .msg-ts   { display: none; } /* hide timestamps on mobile to save space */
  #input-row { padding: 8px 10px 10px; }
  #msg-input { font-size: 16px; } /* prevents iOS zoom */
  #send-btn  { width: 42px; height: 42px; font-size: 18px; }

  .friend-actions { opacity: 1; } /* always show on mobile (no hover) */
  .user-item { padding: 6px 16px; }
  .friend-item { padding: 6px 12px; }
  .request-item { padding: 8px 14px 10px; }
}

#emoji-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
}
#emoji-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}



/* Desktop: hide mobile-only elements */
@media (min-width: 601px) {
  #mobile-nav { display: none; }
  #mobile-online-panel,
  #mobile-friends-panel { display: none !important; }
}

#channel-tabs { display: flex; gap: 4px; }
.ch-tab {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.04em;
}
.ch-tab:hover { color: var(--text); }
.ch-tab.active { color: var(--accent); background: var(--accent-glow); }

@media (max-width: 600px) {
  #channel-tabs { gap: 2px; }
  .ch-tab { font-size: 10px; padding: 2px 4px; }
}

#attachment-preview {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 0;
  font-size: 11px;
  color: var(--muted);
}

#attachment-preview.visible { display: flex; }

#attachment-name {
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

#attachment-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
#attachment-remove:hover { color: var(--danger); }

  /* ── Settings Modal ─────────────────────────────────────────────────────────── */
#settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
#settings-overlay.hidden { display: none !important; }

#settings-modal {
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.s-head {
  display: flex; align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.s-title {
  flex: 1;
  font-size: 12px; font-weight: 500; letter-spacing: 0.12em; color: var(--text);
}
.s-close {
  background: none; border: none; color: var(--muted); font-family: var(--font);
  font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; transition: color 0.15s;
}
.s-close:hover { color: var(--danger); }

.s-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.s-tab {
  flex: 1; padding: 8px 4px;
  font-family: var(--font); font-size: 10px; letter-spacing: 0.1em; color: var(--muted);
  background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.s-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.s-body {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 18px;
}
.s-section-label {
  font-size: 9px; letter-spacing: 0.16em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 12px;
}
.s-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.s-row:last-child { margin-bottom: 0; }
.s-row-info { flex: 1; }
.s-row-label { font-size: 12px; color: var(--text); }
.s-row-sub   { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Toggle */
.s-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.s-toggle input { display: none; }
.s-toggle-track {
  display: block; width: 36px; height: 20px;
  background: var(--muted2); border-radius: 10px; cursor: pointer;
  transition: background 0.2s;
}
.s-toggle input:checked + .s-toggle-track { background: var(--accent); }
.s-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; background: #fff; border-radius: 50%;
  pointer-events: none; transition: transform 0.2s;
}
.s-toggle input:checked ~ .s-toggle-thumb { transform: translateX(16px); }

/* Accent swatches */
.s-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.s-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.s-swatch:hover { transform: scale(1.18); }
.s-swatch.selected { border-color: var(--text); }

/* Segmented controls (font size, density) */
.s-seg { display: flex; gap: 4px; }
.s-seg-btn {
  padding: 3px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font-family: var(--font); font-size: 11px; cursor: pointer;
  letter-spacing: 0.04em; transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.s-seg-btn.active {
  color: var(--accent); border-color: var(--accent); background: var(--accent-glow);
}

/* Settings gear button (header) */
#settings-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: var(--font); font-size: 14px; padding: 3px 8px;
  border-radius: var(--radius); cursor: pointer; letter-spacing: 0.04em;
  transition: color 0.15s, border-color 0.15s; line-height: 1.6;
}

/* ── Nodes ──────────────────────────────────────────────────────────────────── */
#nodes-tab { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

#nodes-create-area { padding: 10px 10px 0; flex-shrink: 0; }
#nodes-create-row, #nodes-invite-row { display: flex; gap: 6px; margin-bottom: 6px; }
#nodes-create-row input, #nodes-invite-row input {
  flex: 1; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font);
  font-size: 11px; outline: none; transition: border-color 0.15s; min-width: 0;
}
#nodes-create-row input:focus, #nodes-invite-row input:focus { border-color: var(--accent); }
#nodes-create-row input::placeholder, #nodes-invite-row input::placeholder { color: var(--muted); }

#node-create-btn, #node-invite-btn {
  flex-shrink: 0; width: 28px; height: 28px; background: var(--accent); border: none;
  border-radius: var(--radius); color: #fff; font-size: 16px; font-family: var(--font);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s; line-height: 1;
}
#node-create-btn:hover, #node-invite-btn:hover { opacity: 0.85; }

#nodes-msg { font-size: 10px; min-height: 18px; padding: 2px 2px 6px; }
#nodes-msg.err { color: var(--danger); } #nodes-msg.ok { color: var(--success); }

#nodes-my-list { flex-shrink: 0; }
#nodes-discover-section { flex-shrink: 0; }
#nodes-discover-list { padding-bottom: 8px; }

.discover-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 12px;
}

.active-node { background: rgba(139,126,245,0.07) !important; }

#node-members-section {
  flex-shrink: 0; border-top: 1px solid var(--border); padding-top: 4px; margin-top: 4px;
}

.node-del-btn {
  background: none; border: none; color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 0 3px; opacity: 0; transition: opacity 0.15s, color 0.15s;
  line-height: 1.4; margin-left: auto; flex-shrink: 0;
}
.msg:hover .node-del-btn { opacity: 1; }
.node-del-btn:hover { color: var(--danger); }

/* ── GIF button ───────────────────────────────────────────────── */
#gif-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#gif-btn:hover { background: var(--accent); color: #fff; }
#gif-btn.active { background: var(--accent); color: #fff; }

/* ── GIF picker panel ─────────────────────────────────────────── */
#gif-picker {
  position: absolute;
  bottom: calc(100% + 6px); /* sits above the input area */
  left: 0; right: 0;
  height: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

#gif-picker-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#gif-search {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}
#gif-search:focus { border-color: var(--accent); }

#gif-tabs { display: flex; gap: 4px; }
.gif-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.gif-tab.active, .gif-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#gif-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
}
.gif-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  background: var(--surface2);
}
.gif-thumb:hover { opacity: 0.85; transform: scale(1.02); }
.gif-fave-star {
  position: absolute;
  top: 3px; right: 4px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.gif-item { position: relative; }
.gif-item:hover .gif-fave-star { opacity: 1; }
.gif-fave-star.faved { opacity: 1; color: gold; }

#gif-attribution {
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* empty / loading states */
.gif-empty {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 32px 0;
}
#settings-btn:hover { color: var(--text); border-color: var(--border2); }

@media (max-width: 600px) {
  #settings-modal { max-height: calc(100vh - 96px); }
}

/* ── Node channels bar ──────────────────────────────────────────────────────── */
#node-channels-bar {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  height: 30px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;          /* Firefox */
}
#node-channels-bar::-webkit-scrollbar { display: none; }
#node-channels-bar.visible { display: flex; }

.node-ch-tab {
  flex-shrink: 0;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius);
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.node-ch-tab:hover  { color: var(--text); }
.node-ch-tab.active { color: var(--accent); background: var(--accent-glow); }

/* delete × on tab — only visible to owner on hover */
.node-ch-tab-inner {
  display: flex;
  align-items: center;
  gap: 4px;
}
.node-ch-del {
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.node-ch-tab:hover .node-ch-del { opacity: 1; }
.node-ch-del:hover { color: var(--danger); }

/* + button (owner only) */
#node-add-ch-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 2px;
  transition: color 0.15s;
}
#node-add-ch-btn:hover { color: var(--accent); }

#input-row {
  position: relative;
}

#emoji-picker {
  position: absolute;
  bottom: 48px;
  right: 0;
  z-index: 999;
}
#emoji-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 1000;
  max-width: 280px;
  overflow: hidden;
}

.emoji-ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.emoji-ac-item:hover, .emoji-ac-item.selected {
  background: var(--surface2);
}

.emoji-ac-native {
  font-size: 18px;
}

.emoji-ac-name {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 600px) {
  #node-channels-bar { padding: 0 8px; height: 32px; }
  .node-ch-tab { font-size: 11px; padding: 3px 8px; }
  .node-ch-del { opacity: 1; } /* always visible on mobile */
}
