/* ───────────────────────── Theme tokens ───────────────────────── */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --bg-tint: #F6F7FB;
  --sidebar: #F4F5F9;
  --raised: #FFFFFF;
  --sunken: #F1F3F8;
  --hover: rgba(15, 23, 42, .05);
  --active: rgba(15, 23, 42, .08);
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --text: #0F1729;
  --muted: #5A6377;
  --faint: #8B93A5;
  --accent: #3D6BFF;
  --accent-soft: rgba(61, 107, 255, .10);
  --accent-text: #0B8F7C;
  --bubble: #EEF1F7;
  --code-bg: #F5F7FB;
  --solid: #0F1729;          /* send button / primary on light */
  --solid-text: #FFFFFF;
  --danger: #DC3B52;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -8px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 64px -16px rgba(15, 23, 42, .25);
  --glow-a: rgba(124, 92, 255, .07);
  --glow-b: rgba(59, 240, 207, .07);
  --scrim: rgba(15, 23, 42, .35);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0D14;
  --bg-tint: #0A0D14;
  --sidebar: #0E121B;
  --raised: #141925;
  --sunken: #0D1119;
  --hover: rgba(255, 255, 255, .05);
  --active: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);
  --text: #ECEFF5;
  --muted: #9CA4B6;
  --faint: #667085;
  --accent: #6E95FF;
  --accent-soft: rgba(110, 149, 255, .14);
  --accent-text: #3BF0CF;
  --bubble: #1A2030;
  --code-bg: #0D1119;
  --solid: #ECEFF5;
  --solid-text: #0A0D14;
  --danger: #FF6B7D;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8);
  --glow-a: rgba(124, 92, 255, .10);
  --glow-b: rgba(59, 240, 207, .05);
  --scrim: rgba(3, 6, 12, .6);
}

:root {
  --grad: linear-gradient(135deg, #3BF0CF, #4FA8FF 50%, #7C5CFF);
  --radius: 14px;
  --sidebar-w: 272px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* smooth cross-fade only while switching themes */
.theme-anim, .theme-anim * { transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), fill .25s var(--ease) !important; }

:root[data-theme="dark"] .show-light, :root[data-theme="light"] .show-dark { display: none; }

/* ───────────────────────── Base ───────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--font); letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code, kbd { font-family: var(--mono); font-size: .86em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 10px; border: 0; background: none; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.wordmark { font-weight: 600; font-size: 19px; letter-spacing: -.03em; }
.wordmark b { font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ───────────────────────── Layout ───────────────────────── */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh;
  transition: grid-template-columns .28s var(--ease);
}
.app.nav-collapsed { grid-template-columns: 0 1fr; }

/* Sidebar */
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 10px 10px; min-height: 0; min-width: 0; overflow: hidden;
}
.app.nav-collapsed .sidebar { border-right-color: transparent; }
.sidebar > * { min-width: calc(var(--sidebar-w) - 20px); }
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 4px 14px 6px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.collapse-btn { margin-left: auto; }

.btn-new {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--raised); box-shadow: var(--shadow-sm);
  font-weight: 500; font-size: 14px; color: var(--text); transition: border-color .15s, background .15s;
}
.btn-new:hover { border-color: var(--line-strong); }
.btn-new svg { width: 17px; height: 17px; }
.btn-new kbd { margin-left: auto; font-size: 11px; color: var(--faint); background: none; }

.search { position: relative; margin: 10px 0 6px; }
.search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--faint); width: 15px; height: 15px; }
.search input {
  width: 100%; height: 36px; border-radius: 10px; border: 1px solid transparent;
  background: var(--hover); padding: 0 10px 0 33px; font-size: 13.5px; outline: none; transition: border-color .15s, background .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { background: var(--raised); border-color: var(--line-strong); }

.chat-list { flex: 1; overflow-y: auto; margin: 2px -4px; padding: 0 4px; min-height: 0; }
.chat-group { font-size: 11.5px; font-weight: 500; color: var(--faint); padding: 14px 10px 4px; }
.chat-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 6px 7px 10px; border-radius: 9px; border: 0; background: none;
  text-align: left; color: var(--muted); font-size: 14px; cursor: pointer; transition: background .12s, color .12s;
}
.chat-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item:hover { background: var(--hover); color: var(--text); }
.chat-item.active { background: var(--active); color: var(--text); font-weight: 500; }
.chat-item .del { opacity: 0; padding: 4px; border-radius: 6px; border: 0; background: none; color: var(--faint); display: grid; transition: opacity .12s; }
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-item .del:hover { color: var(--danger); }
.chat-item .del svg { width: 15px; height: 15px; }

.sidebar-foot { display: flex; align-items: center; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.user-chip {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; border: 0; background: none; text-align: left; transition: background .12s;
}
.user-chip:hover { background: var(--hover); }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); min-width: 0; }
.status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.status.ok .dot { background: #22C3A6; box-shadow: 0 0 0 3px rgba(34, 195, 166, .18); }
.status.err .dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.avatar-initials {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--grad); color: #0A0D14; font-weight: 700; font-size: 12.5px; letter-spacing: .01em;
}
.avatar-initials.lg { width: 44px; height: 44px; font-size: 16px; }

/* Main */
.main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
  background:
    radial-gradient(1000px 520px at 80% -15%, var(--glow-a), transparent 60%),
    radial-gradient(800px 460px at 0% 115%, var(--glow-b), transparent 60%),
    var(--bg);
}
.topbar { display: flex; align-items: center; gap: 4px; padding: 10px 14px; min-height: 56px; }
#toggleSidebar, .when-collapsed { display: none; }
.app.nav-collapsed #toggleSidebar, .app.nav-collapsed .when-collapsed { display: inline-grid; }
.chat-title {
  flex: 1; min-width: 0; padding: 0 8px; font-size: 14px; font-weight: 500; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.pill-toggle {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--raised); color: var(--muted);
  font-size: 13px; font-weight: 500; transition: color .15s, border-color .15s, background .15s;
}
.pill-toggle svg { width: 16px; height: 16px; }
.pill-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.pill-toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill-toggle.listening { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }

/* Thread */
.thread { flex: 1; overflow-y: auto; min-height: 0; }
.messages { max-width: 760px; margin: 0 auto; padding: 4px 24px 32px; }

/* Empty state: greeting + composer centred together */
.app:not(.has-messages) .thread { flex: 0 0 auto; overflow: visible; margin-top: auto; }
.app:not(.has-messages) .composer-wrap { margin-bottom: auto; }
.app.has-messages .empty, .app.has-messages .chips { display: none; }
.empty { max-width: 720px; margin: 0 auto; padding: 0 24px 26px; text-align: center; animation: rise .5s var(--ease) both; }
.empty-mark { width: 56px; height: 56px; margin: 0 auto 18px; position: relative; }
.empty-mark img { width: 100%; height: 100%; border-radius: 16px; position: relative; box-shadow: var(--shadow-md); }
.empty-mark::before { content: ""; position: absolute; inset: -14px; border-radius: 30px; background: var(--grad); filter: blur(28px); opacity: .25; }
.empty h1 { font-weight: 600; font-size: clamp(28px, 4.4vw, 38px); letter-spacing: -.04em; margin: 0 0 4px; line-height: 1.15; }
.empty p { color: var(--muted); margin: 0; font-size: 16px; }

/* Messages */
.msg { display: flex; gap: 14px; padding: 14px 0; animation: rise .3s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg .avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; margin-top: 1px; }
.msg.user { justify-content: flex-end; }
.msg.user > div { max-width: 80%; display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  background: var(--bubble); padding: 10px 16px; border-radius: 20px 20px 6px 20px;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg.assistant .body { flex: 1; min-width: 0; }
.msg .name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.content { overflow-wrap: anywhere; line-height: 1.7; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p { margin: 0 0 .85em; }
.content h1, .content h2, .content h3 { letter-spacing: -.025em; line-height: 1.3; margin: 1.3em 0 .5em; font-weight: 600; }
.content h1 { font-size: 1.35em; } .content h2 { font-size: 1.2em; } .content h3 { font-size: 1.05em; }
.content ul, .content ol { padding-left: 1.4em; margin: 0 0 .85em; }
.content li { margin: .25em 0; }
.content li::marker { color: var(--faint); }
.content a { color: var(--accent); text-underline-offset: 3px; }
.content strong { font-weight: 600; }
.content blockquote { margin: 0 0 .85em; padding: 2px 14px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.content :not(pre) > code { background: var(--sunken); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.content pre {
  position: relative; background: var(--code-bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 .9em;
}
.content pre code { font-size: 13px; line-height: 1.6; }
.content table { border-collapse: separate; border-spacing: 0; margin: 0 0 .9em; display: block; overflow-x: auto; font-size: 14px; border: 1px solid var(--line); border-radius: 12px; }
.content th, .content td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.content tr:last-child td { border-bottom: 0; }
.content th { background: var(--sunken); font-weight: 600; }
.copy-code {
  position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 9px; border-radius: 7px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted); opacity: 0; transition: opacity .15s;
}
.content pre:hover .copy-code { opacity: 1; }
.msg-actions { display: flex; gap: 0; margin: 6px 0 0 -8px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:last-child .msg-actions { opacity: 1; }
.msg-actions .icon-btn { width: 30px; height: 30px; color: var(--faint); }
.msg-actions .icon-btn:hover { color: var(--text); }
.msg-actions svg { width: 15px; height: 15px; }
.err-text { color: var(--danger); }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Composer */
.composer-wrap { padding: 0 24px 12px; max-width: 808px; width: 100%; margin: 0 auto; }
.composer {
  display: flex; flex-direction: column; border-radius: 24px;
  background: var(--raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); box-shadow: var(--shadow-md), 0 0 0 4px var(--accent-soft); }
.composer textarea {
  resize: none; border: 0; outline: none; background: none; width: 100%;
  padding: 16px 18px 6px; max-height: 240px; min-height: 52px; line-height: 1.55; font-size: 15.5px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px 8px 10px; }
.composer label.icon-btn { cursor: pointer; }
.composer-bar .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.mic.on { color: #fff !important; background: #E5484D !important; animation: pulse 1.4s infinite; }
.model-pick { margin-left: auto; margin-right: 6px; }
.model-pick select {
  appearance: none; height: 32px; padding: 0 28px 0 12px; border-radius: 999px; border: 1px solid transparent;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B93A5' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  font-size: 13px; font-weight: 500; color: var(--muted); max-width: 38vw; outline: none; cursor: pointer; transition: background-color .15s, color .15s;
}
.model-pick select:hover { background-color: var(--hover); color: var(--text); }
.model-pick select option { background: var(--raised); color: var(--text); }
.send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none;
  background: var(--solid); color: var(--solid-text); transition: opacity .15s, transform .1s;
}
.send svg { stroke-width: 2.3; width: 18px; height: 18px; }
.send:disabled { opacity: .25; cursor: default; }
.send:not(:disabled):active { transform: scale(.92); }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.app.busy .send .i-send { display: none; }
.app.busy .send .i-stop { display: block; }

.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 0; }
.attachments:empty { display: none; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  padding: 5px 6px 5px 10px; border-radius: 10px; background: var(--sunken); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { border: 0; background: none; color: var(--faint); padding: 2px; display: grid; }
.file-chip button:hover { color: var(--danger); }
.file-chip svg { width: 14px; height: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; animation: rise .5s .08s var(--ease) both; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--raised); color: var(--muted); font-size: 13.5px; font-weight: 500;
  transition: border-color .15s, color .15s, background .15s;
}
.chip svg { width: 16px; height: 16px; color: var(--faint); }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip:hover svg { color: var(--accent); }
.fineprint { text-align: center; font-size: 12px; color: var(--faint); margin: 10px 0 0; }
.app:not(.has-messages) .fineprint { visibility: hidden; }

/* ───────────────────────── Settings ───────────────────────── */
.settings {
  width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); padding: 0;
  border-radius: 20px; border: 1px solid var(--line); background: var(--raised); color: var(--text); box-shadow: var(--shadow-lg);
}
.settings[open] { animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.settings::backdrop { background: var(--scrim); backdrop-filter: blur(6px); }
.settings form { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.settings header, .settings footer { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 22px; }
.settings header { border-bottom: 1px solid var(--line); }
.settings footer { border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; padding: 12px 16px; }
.settings h2 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.02em; }
.settings-body { overflow-y: auto; padding: 4px 22px 18px; }
fieldset { border: 0; padding: 18px 0; margin: 0; display: grid; gap: 12px; }
fieldset + fieldset { border-top: 1px solid var(--line); }
legend { float: left; width: 100%; font-size: 13px; color: var(--text); margin-bottom: 2px; font-weight: 600; padding: 0; }
legend + * { clear: both; }
.settings label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.settings input:not([type="radio"]), .settings textarea, .settings select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--bg); outline: none; color: var(--text); font-size: 14px; font-weight: 400; transition: border-color .15s, box-shadow .15s;
}
.settings textarea { resize: vertical; line-height: 1.5; }
.settings input:focus, .settings textarea:focus, .settings select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.settings small { color: var(--faint); font-size: 12px; font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--sunken); border: 1px solid var(--line); }
.seg label {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; border-radius: 9px;
  font-size: 13.5px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.seg label:hover { color: var(--text); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.seg svg { width: 16px; height: 16px; }

.btn-primary, .btn-ghost { height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: opacity .15s, background .15s, border-color .15s; }
.btn-primary { border: 0; background: var(--solid); color: var(--solid-text); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { border: 1px solid var(--line-strong); background: none; color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.account-row { display: flex; align-items: center; gap: 12px; }
.account-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 14px; }
.account-meta span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.role-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.role-badge.admin { color: var(--accent-text); background: color-mix(in srgb, #3BF0CF 14%, transparent); }
.settings details summary { cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
.settings details summary::-webkit-details-marker { display: none; }
.settings details summary:hover { color: var(--text); }
.settings details summary svg { width: 15px; height: 15px; }
.pw-grid, .add-grid { display: grid; gap: 8px; margin-top: 10px; }
.add-grid { grid-template-columns: 1fr 1fr; }
.add-grid .btn-primary { grid-column: 1 / -1; }
.user-table { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-row .avatar-initials { width: 30px; height: 30px; font-size: 11px; }
.user-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.user-row .who b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .who span { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row.off { opacity: .55; }
.user-row .acts { display: flex; gap: 0; }
.user-row .acts .icon-btn { width: 30px; height: 30px; }
.user-row .acts svg { width: 15px; height: 15px; }
.user-row .acts .danger:hover { color: var(--danger); }

/* ───────────────────────── Auth ───────────────────────── */
body.booting .app, body.booting .auth { visibility: hidden; }
body:not(.authed) .app { display: none; }
body.authed .auth { display: none; }
body:not(.authed) { overflow: auto; }
.auth {
  position: relative; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(700px 420px at 50% -10%, var(--glow-a), transparent 65%),
    radial-gradient(600px 400px at 50% 110%, var(--glow-b), transparent 60%),
    var(--bg-tint);
}
.auth-theme { position: absolute; top: 14px; right: 14px; }
.auth { isolation: isolate; overflow: hidden; }
.auth::before {
  content: "";
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("/adinkra-pattern.svg?v=gye-sankofa-1") 0 0 / 560px 480px repeat;
  opacity: .65;
  animation: adinkra-drift 80s linear infinite;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,.25) 12%, #000 78%);
}
[data-theme="light"] .auth::before { opacity: .45; }
@media (max-width: 600px) {
  .auth::before { background-size: 380px 326px; opacity: .48; }
}
.auth-card {
  width: 100%; max-width: 400px; padding: 32px 28px 24px; border-radius: 22px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: rise .45s var(--ease) both;
}
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }
.auth-brand img { width: 40px; height: 40px; border-radius: 11px; box-shadow: var(--shadow-md); }
.auth-brand .wordmark { font-size: 23px; }
.auth h1 { font-size: 23px; font-weight: 600; letter-spacing: -.035em; text-align: center; margin: 0 0 6px; }
.auth-sub { color: var(--muted); text-align: center; margin: 0 0 24px; font-size: 14px; }
#authForm { display: grid; gap: 14px; }
#authForm label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
#authForm label[hidden] { display: none; }
#authForm input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--bg); outline: none; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
#authForm input::placeholder { color: var(--faint); }
#authForm input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pw { position: relative; }
.pw input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: 0; background: none; color: var(--faint); border-radius: 8px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--text); }
.auth-error { margin: 0; font-size: 13.5px; color: var(--danger); }
.auth-error:empty { display: none; }
.auth-submit { height: 46px; font-size: 15px; margin-top: 4px; border-radius: 12px; }
.auth-submit:disabled { opacity: .6; cursor: progress; }
.auth-switch { text-align: center; font-size: 14px; color: var(--muted); margin: 20px 0 0; }
.auth-switch:empty { display: none; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.auth-switch a:hover { text-decoration: underline; }
.auth-foot { color: var(--faint); font-size: 12px; margin: 20px 0 0; }

/* sign-up control */
.auth-notice { margin: -8px 0 18px; padding: 10px 12px; border-radius: 11px; font-size: 13.5px; line-height: 1.45; background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.auth-notice.ok { background: color-mix(in srgb, #22C3A6 12%, transparent); border-color: color-mix(in srgb, #22C3A6 35%, transparent); }
.auth-notice.warn { background: color-mix(in srgb, #F5A524 12%, transparent); border-color: color-mix(in srgb, #F5A524 40%, transparent); }
#authForm input[readonly] { background: var(--sunken); color: var(--muted); }
.turnstile:empty { display: none; }
.turnstile { display: flex; justify-content: center; min-height: 65px; }
.invite-form { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; }
.invite-form select { width: auto; }
.invite-result { display: flex; gap: 8px; }
.invite-result[hidden] { display: none; }
.invite-result input { font-family: var(--mono); font-size: 12.5px !important; }
.invite-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.invite-list:empty { display: none; }
.invite-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px 9px 12px; font-size: 13px; background: var(--bg); }
.invite-row + .invite-row { border-top: 1px solid var(--line); }
.invite-row .what { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.invite-row .what b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-row .what span { color: var(--faint); font-size: 12px; }
.invite-row.done { opacity: .6; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); flex: none; }
.pill.wait { background: color-mix(in srgb, #F5A524 16%, transparent); color: #B7791F; }
:root[data-theme="dark"] .pill.wait { color: #F5C26B; }
.user-row.pending { background: color-mix(in srgb, #F5A524 6%, var(--bg)); }
.user-row .approve:hover { color: #22C3A6; }

/* ───────────────────────── Misc ───────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; translate: -50% 20px; opacity: 0; pointer-events: none;
  background: var(--solid); color: var(--solid-text); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: opacity .2s, translate .25s var(--ease); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; translate: -50% 0; }
.scrim { display: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───────────────────────── Mobile ───────────────────────── */
@media (max-width: 820px) {
  .app, .app.nav-collapsed { grid-template-columns: 1fr; }
  #toggleSidebar, .when-collapsed { display: inline-grid; }
  .collapse-btn { display: none; }
  .btn-new kbd { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw); z-index: 30;
    transform: translateX(-100%); transition: transform .26s var(--ease); box-shadow: var(--shadow-lg);
  }
  .sidebar > * { min-width: 0; }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
  .topbar { padding: 8px 10px; min-height: 52px; }
  .pill-toggle span { display: none; }
  .pill-toggle { padding: 0 9px; }
  .messages, .composer-wrap { padding-left: 14px; padding-right: 14px; }
  .msg.user > div { max-width: 88%; }
  .msg { gap: 10px; }
  .composer-wrap { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .two, .add-grid, .invite-form { grid-template-columns: 1fr; }
  .invite-form select { width: 100%; }
  .chip { height: 36px; padding: 0 13px; font-size: 13px; }
}

.local-options {display:flex;gap:20px;align-items:center;padding:8px 16px;flex-wrap:wrap;font-size:13px}.local-options label {display:flex;align-items:center;gap:8px}.local-options select {padding:5px;border-radius:8px;background:var(--bg);color:inherit;}

[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.assistant-picker { flex-shrink: 0; }
.assistant-picker select { border: 1px solid var(--line); border-radius: 10px; background: var(--raised); color: var(--text); padding: 7px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.jarvis-console { display: flex; align-items: center; gap: 22px; flex-shrink: 0; margin: 10px 24px 0; padding: 22px 26px; border: 1px solid #36cddd55; border-radius: 20px; background: radial-gradient(ellipse at 8% 50%, #24c4dd1a, transparent 65%), var(--raised); }
.jarvis-core { position: relative; display: grid; place-items: center; width: 92px; height: 92px; flex-shrink: 0; border: 1px solid #41cddc55; border-radius: 50%; box-shadow: 0 0 30px #32bcd918, inset 0 0 24px #32bcd91c; }
.jarvis-core::before, .jarvis-core::after { content: ""; position: absolute; inset: 6px; border: 2px solid transparent; border-top-color: #60dbef; border-bottom-color: #60dbef; border-radius: 50%; animation: jarvis-orbit 18s linear infinite; }
.jarvis-core::after { inset: 16px; border-top-color: #54c7d977; border-bottom-color: #54c7d977; animation-direction: reverse; animation-duration: 26s; }
.jarvis-core span { font-size: 27px; font-weight: 300; color: #60cee1; }
.jarvis-intro { flex: 1; min-width: 0; }
.jarvis-eyebrow { color: var(--muted); font-size: 9px; letter-spacing: .15em; font-weight: 600; }
.jarvis-intro h2 { margin: 6px 0; color: var(--text); font-size: 25px; letter-spacing: .12em; font-weight: 500; }
.jarvis-intro p { margin: 0; color: var(--text); font-size: 13px; }
.jarvis-intro small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.jarvis-controls { display: flex; flex-direction: column; gap: 8px; }
.jarvis-controls button { border: 1px solid #45b6ca55; border-radius: 9px; background: #31bfdc12; color: var(--text); padding: 9px 13px; font-size: 12px; cursor: pointer; }
.jarvis-controls button:hover { background: #31bfdc28; }
.app[data-assistant="jarvis"] .composer { border-color: #38bbcd66; }
.app[data-assistant="jarvis"].busy .jarvis-core { box-shadow: 0 0 35px #32bcd945, inset 0 0 24px #32bcd92c; }
@keyframes jarvis-orbit { to { transform: rotate(360deg); } }
@media (max-width: 650px) {
  .jarvis-console { margin: 8px 12px 0; padding: 15px; gap: 12px; flex-wrap: wrap; }
  .jarvis-core { width: 64px; height: 64px; }
  .jarvis-intro h2 { font-size: 21px; }
  .jarvis-controls { flex-direction: row; width: 100%; }
  .jarvis-controls button { flex: 1; }
  .assistant-picker select { max-width: 100px; padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .jarvis-core::before, .jarvis-core::after { animation: none; }
}

@keyframes adinkra-drift {
  from { background-position: 0 0; }
  to { background-position: 560px -480px; }
}
@keyframes adinkra-drift-mobile {
  from { background-position: 0 0; }
  to { background-position: 380px -326px; }
}
@media (max-width: 600px) {
  .auth::before { animation-name: adinkra-drift-mobile; animation-duration: 65s; }
}
@media (prefers-reduced-motion: reduce) {
  .auth::before { animation: none; transform: none; }
}
