:root {
  color-scheme: light dark;
  --canvas: #f5f6f8;
  --surface: #fff;
  --sidebar: #f7f8fb;
  --ink: #172338;
  --muted: #57647a;
  --line: #d9e0eb;
  --brand: #2848c4;
  --brand-text: #fff;
  --selected: #e9eeff;
  --alert: #a12d36;
  --green: #207b55;
  --amber: #935200;
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root { --canvas: #121821; --surface: #1b2433; --sidebar: #202b3b; --ink: #f2f5fb; --muted: #b1bdd1; --line: #394960;
    --brand: #9bb0ff; --brand-text: #0a153f; --selected: #313f66; --alert: #ffb2b9; --green: #82d8b2; --amber: #ffca84; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
h1, h2, p { margin: 0; }
.topbar { min-height: 68px; padding: 12px clamp(16px, 4vw, 64px); display: flex; align-items: center; gap: 20px;
  background: #17233b; color: #f6f8ff; }
.topbar :focus-visible { outline-color: #b9c6ff; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.08rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #c9d4ff; color: #172865; font-size: 18px; }
.service, .account { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
.service { margin-left: auto; color: #cbd5ec; }
.service-dot { display: block; width: 8px; height: 8px; border-radius: 99px; background: #a7b7d5; flex: none; }
.service[data-status=ready] .service-dot { background: #77d0a9; }
.service[data-status=demo] .service-dot { background: #ffc980; }
.service[data-status=offline] .service-dot { background: #f9a2af; }
.account { border-left: 1px solid #4e5b78; padding-left: 14px; }
#account-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .quiet { color: #f6f8ff; }
.primary, .quiet, .side-action, .voice-panel button { border-radius: 9px; padding: 9px 14px; border: 1px solid transparent; font-weight: 640; }
.primary { background: var(--brand); color: var(--brand-text); }
.primary:hover:not(:disabled) { filter: brightness(1.1); }
.quiet { background: transparent; color: var(--muted); }
.quiet:hover:not(:disabled), .side-action:hover:not(:disabled) { background: var(--selected); color: var(--ink); }
.account .quiet:hover { color: #17233b; background: #e5ecff; }
.danger { color: var(--alert); }
input:not([type=checkbox]), select, textarea { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 10px 12px; min-width: 0; }
label { font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .91rem; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.login-wrap { min-height: calc(100dvh - 68px); display: grid; place-items: center; padding: 28px 16px 48px; }
.login-card { width: min(100%, 430px); padding: clamp(23px, 5vw, 40px); background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.login-card h1 { font-size: clamp(1.4rem, 5vw, 1.8rem); line-height: 1.2; margin-bottom: 24px; }
.login-card form, .invites-form { display: grid; gap: 12px; }
.login-card .primary { margin-top: 6px; }
.notice { color: var(--alert); font-size: .9rem; overflow-wrap: anywhere; }
.workspace { display: grid; grid-template-columns: minmax(214px, 258px) minmax(0, 1fr); margin: 24px auto; width: min(1240px, calc(100% - 48px));
  border: 1px solid var(--line); border-radius: 16px; min-height: min(740px, calc(100dvh - 118px)); overflow: hidden; background: var(--surface); }
.sidebar { display: flex; flex-direction: column; gap: 10px; background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 14px; }
.new-chat, .side-action { text-align: left; }
.new-chat span { margin-right: 5px; }
.side-action { background: transparent; color: var(--ink); }
.history-header { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 0; }
.history-header h2 { font-size: .94rem; padding-left: 8px; }
.history-header .quiet { font-size: .79rem; padding: 4px 7px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 3px; max-height: min(54dvh, 560px); overflow-y: auto; }
.history-item { border: 0; border-radius: 8px; padding: 10px 9px; width: 100%; display: flex; align-items: baseline; gap: 8px; background: transparent; text-align: left; }
.history-item:hover, .history-item[aria-current=true] { background: var(--selected); }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item time { margin-left: auto; white-space: nowrap; color: var(--muted); font-size: .71rem; }
.history-empty { padding: 7px 9px; font-size: .87rem; color: var(--muted); }
.content { min-width: 0; display: grid; grid-template-rows: auto minmax(220px, 1fr) auto; }
.content-header { padding: 20px clamp(16px, 3.2vw, 36px); display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.content-header h1 { font-size: clamp(1.25rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
.section-label { color: var(--muted); font-size: .8rem; }
.chat-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-actions select { padding: 7px 9px; max-width: 100%; font-size: .86rem; }
.chat-actions .quiet { padding: 6px 9px; font-size: .83rem; }
.thread { padding: 22px clamp(16px, 3.2vw, 36px); overflow-y: auto; max-height: min(61dvh, 650px); }
.empty { max-width: 440px; padding: clamp(34px, 9vh, 85px) 0; }
.empty h2 { font-size: 1.45rem; }
.empty p, .invite-result p { color: var(--muted); margin-top: 6px; }
.messages { display: grid; gap: 16px; }
.bubble { max-width: min(92%, 75ch); overflow-wrap: anywhere; padding: 12px 15px; border-radius: 14px; background: var(--sidebar); border: 1px solid var(--line); justify-self: start; }
.bubble.user { background: var(--selected); justify-self: end; }
.bubble strong { display: block; font-size: .82rem; margin-bottom: 4px; }
.bubble p { white-space: pre-wrap; }
.bubble small { display: block; margin-top: 4px; color: var(--muted); }
.composer { display: grid; gap: 8px; padding: 16px clamp(16px, 3.2vw, 36px) 20px; border-top: 1px solid var(--line); }
.composer select { justify-self: start; }
.composer textarea { width: 100%; resize: vertical; min-height: 85px; max-height: 36dvh; }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.composer-actions p { margin-right: auto; }
.auxiliary { grid-template-rows: auto 1fr; }
.aux-body { padding: 22px clamp(16px, 3.2vw, 36px); }
.invites-form { max-width: 440px; }
.invites-form .primary { justify-self: start; }
.invite-result { margin-top: 22px; padding: 14px; background: var(--sidebar); border: 1px solid var(--line); border-radius: 10px; }
.invite-result h2 { font-size: 1rem; }
.invite-result code { display: block; margin: 8px 0; overflow-wrap: anywhere; user-select: all; }
.voice-panel, .voice-editor { display: grid; gap: 12px; }
.voice-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.voice-panel button { background: var(--surface); border-color: var(--line); }
.voice-panel button:hover:not(:disabled) { background: var(--selected); }
.voice-panel textarea { width: 100%; min-height: 135px; resize: vertical; }
.voice-status { color: var(--muted); }
.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; }
@media (max-width: 670px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .service { font-size: .76rem; }
  .account { border-left: 0; padding-left: 0; margin-left: auto; }
  .workspace { width: calc(100% - 20px); margin: 10px auto; grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; gap: 6px; }
  .history { max-height: 130px; }
  .history-header { margin-top: 4px; }
  .content-header { align-items: flex-start; }
  .chat-actions { justify-content: flex-end; }
  .bubble { max-width: 96%; }
  .thread { min-height: 180px; }
}
