/* ==========================================================================
   Scyle — design tokens
   Dark: near-black void + sapphire/violet accent + restrained emerald signal
   for encrypted rooms. Chrome (sidebar/header/composer/modals) carries the
   glass material; message content sits on a slightly more opaque surface
   so legibility never depends on what's behind it.
   ========================================================================== */
:root {
  --bg-void: #08090d;
  --bg-deep: #0d0f16;
  --bg-elevated: #14161f;

  --glass-fill: rgba(255, 255, 255, 0.055);
  --glass-fill-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-highlight: rgba(255, 255, 255, 0.16);
  --glass-blur: 24px;

  --ink: #eef0f5;
  --ink-dim: #9297a8;
  --ink-faint: #676c7d;

  --accent: #5b7fff;
  --accent-2: #8a5cf6;
  --accent-ink: #ffffff;
  --accent-glow: rgba(91, 127, 255, 0.35);

  --secret: #29d19b;
  --secret-glow: rgba(41, 209, 155, 0.16);

  --danger: #ff5470;
  --warn: #ffb648;
  --online: #29d19b;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --radius-pill: 999px;

  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-deep: 0 24px 70px rgba(0, 0, 0, 0.55);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.8, 0.28, 1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-void: #eef0f5;
  --bg-deep: #e6e9f0;
  --bg-elevated: #ffffff;

  --glass-fill: rgba(255, 255, 255, 0.62);
  --glass-fill-strong: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(20, 20, 40, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.9);

  --ink: #14151c;
  --ink-dim: #62677a;
  --ink-faint: #9096a8;

  --accent-glow: rgba(91, 127, 255, 0.22);
  --shadow-soft: 0 10px 30px rgba(30, 34, 60, 0.1);
  --shadow-deep: 0 24px 60px rgba(30, 34, 60, 0.16);
  color-scheme: light;
}

/* ========================================================================== base */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg-void);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--ink-dim); }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.inline-icon { width: 15px; height: 15px; vertical-align: -3px; margin-right: 4px; }

body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60vw 60vw at 15% 0%, rgba(91, 127, 255, 0.10), transparent 60%),
    radial-gradient(50vw 50vw at 100% 100%, rgba(138, 92, 246, 0.08), transparent 60%);
  pointer-events: none;
}

/* ========================================================================== glass */
.glass {
  background: var(--glass-fill);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-soft);
}
.glass-inset {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--glass-border);
}
[data-theme="light"] .glass-inset { background: rgba(20, 24, 40, 0.045); }

@media (prefers-reduced-transparency: reduce) {
  .glass { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg-elevated); }
}

/* ========================================================================== buttons / forms */
.btn {
  border: none; border-radius: var(--radius-pill); padding: 11px 18px;
  font-size: 14.5px; font-weight: 600; background: var(--glass-fill-strong);
  color: var(--ink); border: 1px solid var(--glass-border);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; box-shadow: 0 10px 26px var(--accent-glow);
  position: relative; overflow: hidden;
}
.btn.primary::after {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 45%, transparent 60%);
  transform: translateX(-60%); transition: opacity .2s;
}
.btn.primary:hover::after { opacity: 1; animation: sheen 1.1s var(--ease); }
@keyframes sheen { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
.btn.ghost { background: transparent; border: 1px solid var(--glass-border); }
.btn.danger { background: rgba(255, 84, 112, 0.14); color: var(--danger); border: 1px solid rgba(255, 84, 112, 0.25); }
@media (prefers-reduced-motion: reduce) { .btn, .btn.primary::after { transition: none; animation: none !important; } }

.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: transparent; border: none; color: var(--ink-dim);
  transition: background .15s, color .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--glass-fill-strong); color: var(--ink); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn.primary-round {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 8px 22px var(--accent-glow);
}
.icon-btn.primary-round:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--ink-dim); }
.field input, .field textarea, .field select {
  font-size: 15px; padding: 11px 13px; border-radius: var(--radius-s); border: 1px solid var(--glass-border);
  background: var(--glass-fill-strong); color: var(--ink); outline: none; resize: none;
  transition: border-color .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field-hint { font-size: 11.5px; color: var(--ink-faint); }
.checkbox-field { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 14px; cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.input-with-action { position: relative; }
.input-with-action input { width: 100%; padding-right: 42px; }
.ghost-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--ink-faint); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ghost-toggle svg { width: 18px; height: 18px; }
.prefix-input { display: flex; align-items: center; gap: 8px; }
.prefix-input span { font-size: 13px; color: var(--ink-faint); }
.prefix-input input { flex: 1; }
.form-error { color: var(--danger); font-size: 13px; margin: -6px 0 12px; }
.form-hint { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
.strength-meter { height: 4px; border-radius: 2px; background: var(--glass-fill-strong); overflow: hidden; margin-top: 6px; }
.strength-meter span { display: block; height: 100%; width: 0%; background: var(--danger); transition: width .2s, background .2s; }

/* focus visibility, kept even inside glass */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ========================================================================== avatars */
.avatar {
  width: 42px; height: 42px; border-radius: var(--radius-m); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; background-size: cover; background-position: center;
  position: relative;
}
.avatar.xl { width: 76px; height: 76px; border-radius: 22px; font-size: 26px; }
.avatar-btn { background: none; border: none; padding: 0; border-radius: var(--radius-m); }
.status-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-faint); border: 2.5px solid var(--bg-deep); }
.status-dot.online { background: var(--online); }

/* ========================================================================== auth */
.auth-screen { position: relative; height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.auth-glow { position: fixed; inset: 0; z-index: -1; background: radial-gradient(50vw 50vw at 50% 15%, rgba(91,127,255,0.16), transparent 65%); }
.auth-card { width: 380px; max-width: 100%; border-radius: 28px; padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 22px var(--accent-glow); }
.brand-mark svg { width: 22px; height: 22px; color: #fff; }
.brand-mark.large { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; }
.brand-mark.large svg { width: 32px; height: 32px; }
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.auth-tabs { display: flex; gap: 4px; background: var(--glass-inset); background: rgba(0,0,0,.18); border-radius: var(--radius-pill); padding: 4px; margin-bottom: 22px; }
[data-theme="light"] .auth-tabs { background: rgba(20,24,40,.05); }
.auth-tab { flex: 1; border: none; background: none; padding: 9px; border-radius: var(--radius-pill); font-size: 13.5px; font-weight: 600; color: var(--ink-dim); }
.auth-tab.active { background: var(--glass-fill-strong); color: var(--ink); }
.auth-form.hidden { display: none; }

/* ========================================================================== app shell */
.app { display: flex; height: 100dvh; }
.sidebar { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; padding: 16px 14px; border-right: 1px solid var(--glass-border); background: var(--bg-deep); }
.sidebar-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sidebar-search { flex: 1; display: flex; align-items: center; gap: 8px; border-radius: var(--radius-pill); padding: 9px 14px; }
.sidebar-search input { flex: 1; background: none; border: none; outline: none; color: var(--ink); font-size: 14.5px; }
.search-icon { width: 17px; height: 17px; color: var(--ink-faint); flex-shrink: 0; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 4px -6px; padding: 0 6px; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--glass-border); margin-top: 8px; }
.link-btn { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: var(--radius-s); background: none; border: none; color: var(--ink-dim); font-size: 14px; text-align: left; }
.link-btn:hover { background: var(--glass-fill); color: var(--ink); }
.link-btn svg { width: 19px; height: 19px; }
.pill { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-m); cursor: pointer; transition: background .15s; position: relative; }
.chat-item:hover { background: var(--glass-fill); }
.chat-item.active { background: var(--glass-fill-strong); }
.chat-item-meta { flex: 1; min-width: 0; }
.chat-item-row1 { display: flex; align-items: center; gap: 6px; }
.chat-item-title { font-weight: 600; font-size: 14.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-item-time { font-size: 11.5px; color: var(--ink-faint); flex-shrink: 0; }
.chat-item-row2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chat-item-preview { font-size: 13px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-item-badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 5px; flex-shrink: 0; }
.chat-item-badge.muted-badge { background: var(--ink-faint); }
.chat-item svg.type-icon { width: 13px; height: 13px; color: var(--ink-faint); flex-shrink: 0; }
.chat-item svg.pin-icon { width: 13px; height: 13px; color: var(--ink-faint); flex-shrink: 0; }
.search-results { position: absolute; left: 14px; right: 14px; top: 68px; z-index: 30; border-radius: var(--radius-m); max-height: 70vh; overflow-y: auto; padding: 8px; }
.search-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); padding: 8px 10px 4px; }

/* ========================================================================== chat area */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--ink-dim); padding: 20px; }
.chat-empty h2 { color: var(--ink); font-weight: 650; font-size: 20px; margin: 0 0 6px; }
.chat-empty p { margin: 0; font-size: 14px; }
.chat-live { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-header { display: flex; align-items: center; gap: 6px; padding: 10px 16px; z-index: 5; }
.chat-identity { flex: 1; display: flex; align-items: center; gap: 12px; background: none; border: none; text-align: left; padding: 4px; border-radius: var(--radius-m); min-width: 0; }
.chat-identity:hover { background: var(--glass-fill); }
.chat-identity-text { display: flex; flex-direction: column; min-width: 0; }
.chat-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-subtitle { font-size: 12.5px; }
.chat-actions { display: flex; gap: 2px; }
.mobile-only { display: none; }

.chat-live.is-secret .chat-header { background: var(--secret-glow); border-color: rgba(41,209,155,0.22); }
.chat-live.is-secret .messages { background: linear-gradient(180deg, rgba(41,209,155,0.05), transparent 30%); }
.chat-live.is-secret .composer { border-color: rgba(41,209,155,0.22); }
.secret-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--secret); font-size: 11.5px; font-weight: 600; }
.secret-badge svg { width: 12px; height: 12px; }

.pinned-bar, .in-chat-search, .reply-bar { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13.5px; border-radius: 0; border-left: none; border-right: none; }
.pinned-bar svg, .reply-bar svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.pinned-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.in-chat-search input { flex: 1; background: none; border: none; outline: none; color: var(--ink); font-size: 14px; }
.reply-bar-text { flex: 1; min-width: 0; }
.reply-bar-author { display: block; font-weight: 600; color: var(--accent); font-size: 12.5px; }
.reply-bar-snippet { display: block; color: var(--ink-dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages { flex: 1; overflow-y: auto; padding: 18px 5% 10px; display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth; }
.day-divider { align-self: center; font-size: 11.5px; color: var(--ink-faint); background: var(--glass-fill); padding: 5px 12px; border-radius: 999px; margin: 14px 0 10px; }

.msg-row { display: flex; gap: 9px; max-width: 72%; align-items: flex-end; margin-top: 8px; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar { width: 28px; height: 28px; border-radius: 9px; font-size: 12px; margin-bottom: 2px; }
.msg-row.grouped .avatar { visibility: hidden; }
.msg-row.grouped { margin-top: 2px; }
.bubble { position: relative; padding: 9px 13px 8px; border-radius: 19px; background: var(--glass-fill-strong); min-width: 60px; }
.msg-row.mine .bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 6px; }
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 6px; }
.bubble-author { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; color: var(--accent); }
.msg-row.mine .bubble-author { display: none; }
.bubble-reply { display: block; border-left: 2.5px solid rgba(255,255,255,0.4); padding: 3px 0 3px 9px; margin-bottom: 5px; font-size: 12.5px; opacity: .85; border-radius: 3px; cursor: pointer; }
.msg-row:not(.mine) .bubble-reply { border-left-color: var(--accent); background: var(--glass-fill); }
.bubble-forward { font-size: 11.5px; font-weight: 600; opacity: .75; margin-bottom: 3px; }
.bubble-text { font-size: 14.8px; line-height: 1.42; white-space: pre-wrap; word-break: break-word; }
.bubble-text code { font-family: var(--font-mono); background: rgba(0,0,0,0.25); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.bubble-text a { color: inherit; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.5); }
.msg-row:not(.mine) .bubble-text a { color: var(--accent); }
.bubble-text .mention { font-weight: 700; color: inherit; background: rgba(91,127,255,0.18); padding: 0 3px; border-radius: 4px; }
.bubble-meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 4px; font-size: 10.5px; opacity: .68; }
.bubble-meta svg { width: 14px; height: 14px; }
.self-destruct-badge { font-variant-numeric: tabular-nums; opacity: .85; }
.bubble-meta .check-read { color: #7fd8ff; opacity: 1; }
.bubble-deleted { font-style: italic; opacity: .6; font-size: 13.5px; }
.bubble-img { display: block; max-width: 100%; max-height: 340px; border-radius: 14px; margin-top: 2px; cursor: pointer; object-fit: cover; }
.bubble-file { display: flex; align-items: center; gap: 10px; padding: 4px 2px; text-decoration: none; color: inherit; }
.bubble-file-icon { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,0.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bubble-file-icon svg { width: 19px; height: 19px; }
.bubble-file-name { font-size: 13.5px; font-weight: 600; word-break: break-all; }
.bubble-file-size { font-size: 11.5px; opacity: .7; }
.bubble-voice { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.voice-play { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: none; color: inherit; }
.voice-play svg { width: 16px; height: 16px; }
.voice-track { flex: 1; height: 26px; display: flex; align-items: center; gap: 1.5px; }
.voice-bar { width: 2.5px; background: currentColor; opacity: .4; border-radius: 2px; }
.voice-time { font-size: 11px; opacity: .75; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.reactions-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.reaction-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--glass-fill-strong); font-size: 12.5px; border: 1px solid transparent; }
.reaction-pill.mine { border-color: var(--accent); background: var(--accent-glow); }
.reaction-pill .count { font-weight: 700; }

.msg-toolbar { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .12s; background: var(--glass-fill-strong); border-radius: var(--radius-pill); padding: 2px; align-self: center; }
.msg-row:hover .msg-toolbar { opacity: 1; }

.poll-block { min-width: 240px; }
.poll-question { font-weight: 650; font-size: 14.5px; margin-bottom: 8px; }
.poll-option { position: relative; border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; background: rgba(255,255,255,0.1); overflow: hidden; cursor: pointer; }
.poll-option-fill { position: absolute; inset: 0; background: rgba(255,255,255,0.14); width: 0%; transition: width .3s var(--ease); }
.poll-option.voted-mine { outline: 1.5px solid rgba(255,255,255,0.5); }
.poll-option-row { position: relative; display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.poll-meta { font-size: 11.5px; opacity: .7; margin-top: 4px; }

.typing-indicator { padding: 2px 5% 8px; font-size: 12.5px; color: var(--ink-dim); font-style: italic; min-height: 18px; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 14px; }
.composer-input { flex: 1; display: flex; align-items: flex-end; border-radius: 22px; padding: 6px 6px 6px 16px; }
.composer-input textarea { flex: 1; background: none; border: none; outline: none; resize: none; color: var(--ink); font-size: 15px; line-height: 1.4; max-height: 160px; padding: 6px 0; font-family: inherit; }
.recording-indicator { display: flex; align-items: center; gap: 8px; flex: 1; padding: 0 8px; color: var(--danger); font-size: 14px; font-weight: 600; }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .recording-dot { animation: none; } }

/* ========================================================================== modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2,3,8,0.55); backdrop-filter: blur(6px); z-index: 100; }
.modal { position: fixed; inset: 0; z-index: 101; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content { width: 420px; max-width: 100%; max-height: 86vh; overflow-y: auto; border-radius: 26px; padding: 6px; }
.modal-content.wide { width: 480px; }
.modal-content.narrow { width: 340px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 12px 20px 22px; }
.modal-body h3 { margin: 0 0 6px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-row-actions { display: flex; flex-direction: column; gap: 2px; margin: 16px 0; }

.segmented { display: flex; gap: 3px; background: rgba(0,0,0,0.2); border-radius: var(--radius-pill); padding: 3px; margin-bottom: 18px; }
[data-theme="light"] .segmented { background: rgba(20,24,40,.05); }
.seg { flex: 1; border: none; background: none; padding: 8px 4px; border-radius: var(--radius-pill); font-size: 12.8px; font-weight: 600; color: var(--ink-dim); }
.seg.active { background: var(--glass-fill-strong); color: var(--ink); }

.entity-header { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.entity-name { font-size: 18px; font-weight: 700; }
.entity-meta { font-size: 13px; margin-top: 2px; }
.entity-bio { font-size: 13.5px; color: var(--ink-dim); margin: 6px 0 4px; line-height: 1.5; }
.entity-extra { font-size: 13px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }

.row-action { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 10px; border-radius: var(--radius-s); background: none; border: none; text-align: left; font-size: 14.5px; color: var(--ink); }
.row-action:hover { background: var(--glass-fill); }
.row-action svg { width: 19px; height: 19px; color: var(--ink-dim); flex-shrink: 0; }
.row-action.danger-text { color: var(--danger); }
.row-action.danger-text svg { color: var(--danger); }
.row-action .row-value { margin-left: auto; color: var(--ink-faint); font-size: 12.5px; }

.section-label { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 6px 6px; margin-top: 6px; }

.members-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: var(--radius-s); }
.member-row:hover { background: var(--glass-fill); }
.member-row .avatar { width: 36px; height: 36px; font-size: 13px; border-radius: 11px; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.member-sub { font-size: 12px; color: var(--ink-faint); }
.role-chip { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); background: var(--accent-glow); padding: 2px 7px; border-radius: 999px; }
.members-list.selectable .member-row { cursor: pointer; }
.members-list.selectable .member-row.selected { background: var(--accent-glow); }

.qr-image { display: block; width: 200px; height: 200px; margin: 6px auto 14px; border-radius: 16px; background: #fff; padding: 10px; }
.secret-code { display: block; text-align: center; font-family: var(--font-mono); font-size: 15px; letter-spacing: .1em; background: var(--glass-fill-strong); border-radius: var(--radius-s); padding: 10px; margin-bottom: 16px; user-select: all; }

.poll-options-edit { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.poll-option-edit-row { display: flex; gap: 8px; align-items: center; }
.poll-option-edit-row input { flex: 1; }

/* ========================================================================== popovers */
.popover { position: fixed; z-index: 200; border-radius: var(--radius-m); }
.reaction-popover { display: flex; gap: 3px; padding: 6px; border-radius: 999px; }
.reaction-popover button { width: 36px; height: 36px; border-radius: 50%; border: none; background: none; font-size: 20px; }
.reaction-popover button:hover { background: var(--glass-fill-strong); transform: scale(1.15); }
.emoji-popover { width: 300px; max-height: 320px; overflow-y: auto; padding: 10px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-grid button { border: none; background: none; font-size: 20px; padding: 6px 0; border-radius: 8px; }
.emoji-grid button:hover { background: var(--glass-fill-strong); }
.emoji-cat-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; padding: 6px 2px 3px; }

.context-menu { list-style: none; margin: 0; padding: 6px; min-width: 190px; }
.context-menu li { padding: 10px 12px; border-radius: 10px; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.context-menu li:hover { background: var(--glass-fill-strong); }
.context-menu li.danger { color: var(--danger); }
.context-menu li svg { width: 17px; height: 17px; color: var(--ink-dim); }
.context-menu li.danger svg { color: var(--danger); }

.mention-popover { max-height: 200px; overflow-y: auto; padding: 6px; min-width: 220px; }
.mention-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.mention-row:hover, .mention-row.active { background: var(--glass-fill-strong); }
.mention-row .avatar { width: 26px; height: 26px; font-size: 11px; border-radius: 8px; }

/* ========================================================================== lightbox */
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 18px; right: 18px; background: rgba(255,255,255,0.1); color: #fff; }

/* ========================================================================== toasts */
.toast-container { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-deep); animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ========================================================================== responsive */
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0; width: 100%; z-index: 10; transition: transform .28s var(--ease); }
  .sidebar.mobile-hide { transform: translateX(-100%); }
  .chat-area { position: fixed; inset: 0; z-index: 8; transform: translateX(100%); transition: transform .28s var(--ease); background: var(--bg-void); }
  .chat-area.mobile-show { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .msg-row { max-width: 86%; }
  .modal-content.wide { width: 100%; }
  @media (prefers-reduced-motion: reduce) { .sidebar, .chat-area { transition: none; } }
}
@media (min-width: 861px) { #mobileBackBtn { display: none; } }
