/* ============================================================================
   SAI web chat surface (the logged-in product plane), reskinned to SAI's real
   app look. Built entirely on SAI's design tokens (sai-tokens.css): the emissive
   object on a dark viewport, Fraunces titles, Instrument Sans body, real chat
   bubbles (her right, his left), and the SAME robust composer as the sign-in door.
   The bubble, viewport and glass rules are ported from SAI's own app
   (E:\SAI\ui\styles\main.css); the composer block is ported from the door
   (assets/css/sai-entry.css) so the two stay identical. Tokens only.
   Universal Network Development LLC · UND Industries   [UND-MARKER: SAI-WEB v1]
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Instrument+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body.sai-chat-page {
  margin: 0;
  background: var(--sai-bg);
  color: var(--sai-text);
  font: var(--sai-text-md)/var(--sai-leading) var(--sai-font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;   /* the chat shell owns the viewport */
  display: flow-root; /* its own formatting context: the shell's 56px top margin stays INSIDE body instead of collapsing
                         out to <html> (that made the document 56px taller than the window, so the page scrolled + jumped) */
}
::placeholder { color: var(--sai-muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--sai-text); outline-offset: 2px; box-shadow: var(--sai-focus); }

/* ----------------------------------------------------------------------------
   The object's viewport: always dark, in both themes (A73). SAI's calm object
   stage sits behind the glass chat frame. No frantic motion, just a soft bloom.
   ---------------------------------------------------------------------------- */
.viewport { position: fixed; inset: 0; z-index: var(--sai-z-viewport, 0); background: linear-gradient(180deg, var(--sai-viewport-top), var(--sai-viewport) 55%, var(--sai-viewport-bottom)); }
.viewport::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(46% 38% at 50% 30%, color-mix(in srgb, var(--sai-emb-blue) 22%, transparent), transparent 70%),
    radial-gradient(40% 34% at 82% 88%, color-mix(in srgb, var(--sai-emb-purple) 20%, transparent), transparent 72%);
  opacity: 0.7;
}
.viewport::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(75% 65% at 50% 48%, transparent 45%, color-mix(in srgb, var(--sai-viewport-bottom) 70%, transparent) 100%); }

/* ----------------------------------------------------------------------------
   The chat shell: a full-height glass frame floating over the object (A75 glass).
   ---------------------------------------------------------------------------- */
.sai-chat-shell {
  position: relative; z-index: var(--sai-z-content, 1);
  width: min(880px, 100%);
  height: calc(100dvh - 72px);
  margin: 56px auto 0;
  display: flex; flex-direction: column;
  border-radius: var(--sai-radius-lg) var(--sai-radius-lg) 0 0;
  overflow: hidden;
  border: 1px solid var(--sai-glass-line);
  border-bottom: none;
  background: linear-gradient(160deg, var(--sai-glass-hi) 0%, var(--sai-glass-over-viewport) 42%, var(--sai-glass-over-viewport) 100%);
  backdrop-filter: blur(var(--sai-glass-blur)) saturate(var(--sai-glass-sat)) brightness(1.04);
  -webkit-backdrop-filter: blur(var(--sai-glass-blur)) saturate(var(--sai-glass-sat)) brightness(1.04);
  box-shadow: inset 0 1px 0 var(--sai-glass-edge), var(--sai-glass-shadow);
}

/* header: a small SAI orb + name + live status, matching the app presence */
.sai-chat-head {
  display: flex; align-items: center; gap: var(--sai-space-3);
  padding: 14px 18px;
  border-bottom: 1px solid var(--sai-glass-line);
  flex: none;
}
/* the header's logo is the shared .sai-logo component (sai-logo.css); its listening/thinking pace is set there */
.sai-head-meta { display: flex; flex-direction: column; gap: 1px; }
.sai-head-name { font: 600 var(--sai-text-lg)/1 var(--sai-font-display); letter-spacing: -0.01em; }
.sai-head-status { font: 500 var(--sai-text-xs)/1 var(--sai-font-mono); color: var(--sai-muted); letter-spacing: 0.04em; }
.sai-head-spacer { flex: 1; }
.sai-head-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--sai-radius-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--sai-muted); cursor: pointer; text-decoration: none;
  transition: background var(--sai-motion-fast) var(--sai-ease), color var(--sai-motion-fast) var(--sai-ease);
}
.sai-head-btn:hover { background: var(--sai-raised); color: var(--sai-text); }
.sai-head-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* thread: the conversation. Her bubbles right, his left (A55 palette). */
.sai-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; gap: var(--sai-space-3); align-content: start;
  padding: var(--sai-space-5) var(--sai-space-5) var(--sai-space-3);
  scrollbar-width: thin; scrollbar-color: var(--sai-line) transparent;
}
.sai-thread::-webkit-scrollbar { width: 8px; }
.sai-thread::-webkit-scrollbar-thumb { background: var(--sai-line); border-radius: 8px; }

.msg { max-width: 82%; display: grid; gap: 4px; }
.msg.me { justify-self: end; }
.msg.sai { justify-self: start; }
.msg-head { display: flex; align-items: center; gap: 6px; }
.msg-head .wm-dot { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--sai-emb-blue), var(--sai-emb-purple)); box-shadow: 0 0 6px var(--sai-emb-purple); }
.msg-head .wm-name { font: 600 var(--sai-text-xs)/1 var(--sai-font-body); letter-spacing: var(--sai-tracking-caps); text-transform: uppercase; color: var(--sai-muted); }
.msg-body { padding: 10px 14px; border-radius: var(--sai-radius-md); line-height: var(--sai-leading); white-space: pre-wrap; word-break: break-word; font-size: var(--sai-text-md); }
.msg.me .msg-body { background: var(--sai-blue-soft); color: var(--sai-ink-on-soft); border-bottom-right-radius: 6px; }
.msg.sai .msg-body { background: var(--sai-surface); border: 1px solid var(--sai-line); border-bottom-left-radius: 6px; }

/* typing indicator (his three dots while thinking) */
.sai-typing { display: inline-flex; gap: 5px; align-items: center; padding: 3px 2px; }
.sai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--sai-muted); opacity: 0.5; animation: sai-typing 1.2s infinite; }
.sai-typing span:nth-child(2) { animation-delay: 0.2s; }
.sai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sai-typing { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* usage meter: shows the truth the server reports (never faked client-side) */
.sai-usage { flex: none; padding: 4px 18px 0; text-align: center; font: 500 var(--sai-text-xs) var(--sai-font-mono); letter-spacing: 0.04em; color: var(--sai-muted); }
.sai-usage:empty { display: none; }
.sai-usage b { color: var(--sai-text); font-weight: 600; }

/* composer wrapper: the robust box pinned at the bottom, full width of the shell */
.sai-composer-wrap { flex: none; padding: 12px 16px 18px; border-top: 1px solid var(--sai-glass-line); }
.sai-composer-wrap .sai-box { width: 100%; }

/* ============================================================================
   THE ROBUST COMPOSER (.sai-box): ported verbatim from the sign-in door
   (assets/css/sai-entry.css) so the door and the app share ONE composer. Modes
   dropdown, coming-soon pills that shake-deny, model selector, mic, and voice.
   ============================================================================ */
.sai-box { width: min(680px, 100%); display: grid; gap: 0; padding: 8px 8px 6px; border-radius: var(--sai-radius-lg);
  background: var(--sai-surface); border: 1px solid var(--sai-line); box-shadow: var(--sai-shadow-card);
  transition: border-color var(--sai-motion-fast) var(--sai-ease), box-shadow var(--sai-motion-fast) var(--sai-ease); }
.sai-box:focus-within { border-color: color-mix(in srgb, var(--sai-blue) 60%, var(--sai-line)); box-shadow: var(--sai-shadow-card); }
.sai-box-input { resize: none; border: 0; outline: none; background: transparent; color: var(--sai-text);
  font: var(--sai-text-lg)/1.45 var(--sai-font-body); padding: 12px 12px 10px; min-height: 30px; max-height: 168px; }
.sai-box-input::placeholder { color: var(--sai-muted); }
.sai-box-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px; }
.sai-box-left, .sai-box-right { display: flex; align-items: center; gap: 6px; }

.box-icon { position: relative; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--sai-radius-sm); border: 0; background: transparent; color: var(--sai-muted); cursor: pointer;
  transition: background var(--sai-motion-fast) var(--sai-ease), color var(--sai-motion-fast) var(--sai-ease); }
.box-icon:hover { background: var(--sai-raised); color: var(--sai-text); }
.box-icon svg { width: 18px; height: 18px; }
.box-icon.voice { color: var(--sai-ink-on-soft); background: linear-gradient(135deg, var(--sai-blue-soft), var(--sai-purple-soft)); }
.box-icon.voice:hover { filter: brightness(1.04); }

.box-pill { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--sai-radius-pill); border: 1px solid var(--sai-line); background: var(--sai-raised); color: var(--sai-text);
  cursor: pointer; font: 500 var(--sai-text-sm) var(--sai-font-body); white-space: nowrap;
  transition: border-color var(--sai-motion-fast) var(--sai-ease), background var(--sai-motion-fast) var(--sai-ease); }
.box-pill:hover { background: color-mix(in srgb, var(--sai-text) 7%, var(--sai-raised)); border-color: color-mix(in srgb, var(--sai-text) 14%, var(--sai-line)); }
.box-pill svg { width: 15px; height: 15px; }
.box-pill > svg:first-child { opacity: 0.8; }
.box-pill .chev { width: 13px; height: 13px; opacity: 0.55; }
.box-pill.on { border-color: color-mix(in srgb, var(--sai-blue) 45%, var(--sai-line)); background: color-mix(in srgb, var(--sai-blue) 10%, transparent); }
.box-pill.locked { color: var(--sai-muted); }
.box-pill .lock { width: 12px; height: 12px; opacity: 0.7; }
/* phone: the composer row fits (it ran 26px past a 390px screen): Tasks becomes its icon + lock, chevrons go, pills tighten */
@media (max-width: 480px) {
  .box-pill { padding: 0 9px; }
  .box-pill .chev, .box-pill .pill-label { display: none; }
}

/* coming-soon shake-deny */
@keyframes box-shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-4px)} 40%,60%{transform:translateX(4px)} 100%{transform:none} }
.shake { animation: box-shake 0.42s var(--sai-ease); }
.soon-tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 5px 10px; border-radius: var(--sai-radius-sm); background: var(--sai-text); color: var(--sai-bg);
  font-size: var(--sai-text-xs); font-weight: 600; pointer-events: none; opacity: 0; transition: opacity var(--sai-motion-fast); z-index: 6; }
.soon-tip.show { opacity: 1; }

/* modes / model dropdown menu */
.box-mode { position: relative; }
.box-menu { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 20; min-width: 230px; display: grid; gap: 2px;
  padding: 6px; border-radius: var(--sai-radius-md); background: var(--sai-surface); border: 1px solid var(--sai-line); box-shadow: var(--sai-glass-shadow); }
.box-menu[hidden] { display: none; }
.box-menu.right { left: auto; right: 0; }
.mode-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0;
  background: transparent; color: var(--sai-text); border-radius: var(--sai-radius-sm); cursor: pointer; font: 500 var(--sai-text-sm) var(--sai-font-body); }
.mode-item:hover { background: var(--sai-raised); }
.mode-item .mi-ic { width: 16px; height: 16px; color: var(--sai-muted); flex: none; }
.mode-item .mi-txt { flex: 1; display: grid; gap: 1px; }
.mode-item .mi-txt small { color: var(--sai-muted); font-size: 11px; font-weight: 400; }
.mode-item .mi-check { width: 15px; height: 15px; color: var(--sai-blue); flex: none; }
.mode-item.locked .mi-txt b { color: var(--sai-muted); }
.mode-item .mi-soon { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px;
  background: var(--sai-orange-soft); color: var(--sai-ink-on-soft); flex: none; }

/* the mic while it is recording: a soft pulse on the mic icon button */
.box-icon.is-recording { color: var(--sai-bad); background: color-mix(in srgb, var(--sai-bad) 16%, transparent); animation: sai-rec-pulse 1.4s var(--sai-ease) infinite; }
@keyframes sai-rec-pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sai-bad) 40%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }

/* ----------------------------------------------------------------------------
   Overlays: the access gate and the audio/device settings sheet. Glass card on
   a dimmed, blurred backdrop. Tokens only.
   ---------------------------------------------------------------------------- */
.sai-sheet {
  position: fixed; inset: 0; z-index: var(--sai-z-dialog, 4);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in srgb, var(--sai-viewport-bottom) 72%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.sai-sheet[hidden] { display: none; }
.sai-sheet-card {
  width: 100%; max-width: 440px; border-radius: var(--sai-radius-lg); padding: 28px 26px;
  background: var(--sai-surface); border: 1px solid var(--sai-line);
  box-shadow: var(--sai-glass-shadow);
}
.sai-gate .sai-sheet-card { text-align: center; position: relative; }
/* Every screen has a way out (a sign-in gate with no exit trapped people on it: Alex 2026-09-30). The gate's X, like
   Escape, goes back to the page the person came from (the join page when buying), else home (sai-chat.js BACK). */
.sai-sheet-x { position: absolute; top: 12px; right: 12px; }
/* the sign-in box's logo is the shared .sai-logo component (sai-logo.css): one hovering S, its own still shadow */
.sai-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sai-space-3); margin-bottom: 18px; }
.sai-sheet-title { font: 600 var(--sai-text-xl)/1.15 var(--sai-font-display); }
.sai-gate .sai-sheet-title { display: block; margin-bottom: 8px; }
.sai-gate #stepSignin > .sai-sheet-title { margin-bottom: 22px; }   /* room between the title and the first sign-in button */
.sai-sheet-sub { font-size: var(--sai-text-sm); color: var(--sai-muted); line-height: 1.55; margin-bottom: 22px; }
.sai-field-label { display: block; font: 600 var(--sai-text-sm)/1 var(--sai-font-body); color: var(--sai-text); margin-bottom: 8px; }
.sai-field {
  width: 100%; padding: 11px 13px; border-radius: var(--sai-radius-sm);
  background: var(--sai-raised); border: 1px solid var(--sai-line); color: var(--sai-text);
  font: var(--sai-text-md) var(--sai-font-body); outline: none;
}
.sai-field:focus { border-color: var(--sai-blue); }
.sai-gate-input { text-align: center; font-family: var(--sai-font-mono); letter-spacing: 0.1em; text-transform: uppercase; }
.sai-select { cursor: pointer; margin-bottom: 18px; }
.sai-gate-msg { min-height: 18px; font-size: var(--sai-text-sm); color: var(--sai-bad); margin: 12px 0; }
.sai-check { display: flex; align-items: center; gap: 10px; color: var(--sai-muted); font-size: var(--sai-text-md); cursor: pointer; }
.sai-check input { width: 16px; height: 16px; accent-color: var(--sai-blue); cursor: pointer; }
.sai-btn-primary {
  width: 100%; padding: 11px 16px; border-radius: var(--sai-radius-pill); border: 1px solid transparent; cursor: pointer;
  font: 600 var(--sai-text-md) var(--sai-font-body); color: var(--sai-ink-on-soft);
  background: linear-gradient(135deg, var(--sai-blue-soft), var(--sai-purple-soft));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform var(--sai-motion-fast) var(--sai-ease);
}
.sai-btn-primary:hover { transform: translateY(-1px); }
.sai-btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }
/* the early-access notice at sign-in: the plain words a person agrees to before the first message */
.sai-gate-note { margin: 14px 0 0; font-size: var(--sai-text-xs); line-height: 1.5; color: var(--sai-muted); text-align: left; }
.sai-gate-note a { color: var(--sai-blue); text-decoration: none; font-weight: 600; }
.sai-gate-note a:hover { text-decoration: underline; }
.sai-sheet-foot { margin-top: 18px; font-size: var(--sai-text-sm); color: var(--sai-muted); text-align: center; }
.sai-sheet-foot a { color: var(--sai-blue); text-decoration: none; font-weight: 600; }
.sai-sheet-foot a:hover { text-decoration: underline; }

/* ---- the sign-in gate: Google / Apple / email code, then "Access denied" -> join or redeem (MEMBERSHIP.md) ---- */
.gate-step[hidden], .gate-form[hidden], .gate-providers > [hidden] { display: none; }
.gate-providers { display: grid; gap: 10px; }
.gate-google { display: flex; justify-content: center; min-height: 44px; }
.btn-provider { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 16px; box-sizing: border-box;
  border-radius: var(--sai-radius-pill); border: 1px solid var(--sai-line); background: var(--sai-text); color: var(--sai-bg);
  font: 600 var(--sai-text-md) var(--sai-font-body); cursor: pointer; transition: transform var(--sai-motion-fast) var(--sai-ease); }
.btn-provider:hover { transform: translateY(-1px); }
.btn-provider svg { width: 18px; height: 18px; flex: none; }
.btn-provider:disabled { cursor: not-allowed; transform: none; opacity: 0.5; }   /* not switched on yet: must not look live */
/* consent: both boxes before any sign-in method works (the server enforces it too: worker.js hasConsent) */
.gate-consent { border: 0; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; text-align: left; }   /* under the methods */
.gate-botcheck { display: flex; justify-content: center; margin-top: 12px; }   /* Cloudflare's check: empty unless it needs a click */
.gate-botcheck:empty { display: none; }
.gate-check { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; cursor: pointer;
  font-size: var(--sai-text-sm); line-height: 1.45; color: var(--sai-text); }
.gate-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--sai-blue); cursor: pointer; }
.gate-check input:focus-visible { outline: none; box-shadow: var(--sai-focus); }
.gate-check a { color: var(--sai-blue); font-weight: 600; text-decoration: none; }
.gate-check a:hover { text-decoration: underline; }
.gate-consent.is-missing .gate-check input:not(:checked) { outline: 2px solid var(--sai-bad); outline-offset: 2px; border-radius: 3px; }
/* Locked until both boxes are ticked, but NOT washed out (Alex 2026-10-03: the whole box looked broken). Only the Google
   and Apple buttons are covered while locked, so a click there says "tick both boxes below"; the email field can be typed
   in at once and its submit checks the boxes (sai-chat.js). The server refuses sign-in without consent either way. */
.gate-methods { position: relative; }
.gate-providers { position: relative; }
.gate-methods.is-locked .gate-providers > * { pointer-events: none; }
.gate-methods.is-locked .gate-providers::after { content: ""; position: absolute; inset: 0; cursor: pointer; }
.gate-soon { margin: 2px 0 0; font-size: var(--sai-text-xs); color: var(--sai-muted); text-align: center; }
.gate-soon[hidden] { display: none; }
.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; }
.gate-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--sai-muted); font-size: var(--sai-text-sm); }
.gate-or[hidden] { display: none; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--sai-line); }
.gate-form { display: grid; gap: 12px; text-align: left; }
.gate-form .sai-field { box-sizing: border-box; }
.gate-otp { font-size: 24px; letter-spacing: 0.45em; padding: 12px 12px 12px 22px; }
.gate-links { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.gate-link { background: none; border: 0; padding: 4px 2px; cursor: pointer; color: var(--sai-blue); font: 600 var(--sai-text-sm) var(--sai-font-body); }
.gate-link:hover { text-decoration: underline; }
.gate-link:focus-visible, .btn-provider:focus-visible { outline: none; box-shadow: var(--sai-focus); border-radius: var(--sai-radius-sm); }
.gate-eyebrow { display: block; margin-bottom: 10px; font: 600 var(--sai-text-xs)/1 var(--sai-font-body); letter-spacing: var(--sai-tracking-caps);
  text-transform: uppercase; color: var(--sai-bad); }
.gate-join { display: block; box-sizing: border-box; text-align: center; text-decoration: none; }
.gate-none { color: var(--sai-muted); font-size: var(--sai-text-sm); margin: 0; }
.gate-none[hidden] { display: none; }

/* the gate card scrolls inside itself on a short screen (the profile step is taller than a phone), never the page */
.sai-gate .sai-sheet-card { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* the X answers at once: the gate fades out on the click itself while the home page loads (Alex 2026-10-03: "flaky") */
/* The app is never drawn for someone who is not in (Alex 2026-10-03: closing the box "glitched them into the app's UI"):
   chat.html starts with body.app-locked; only a member's openChat() lifts it. */
body.app-locked .dock, body.app-locked .sai-chat-shell { visibility: hidden; }
.sai-sheet-x { z-index: 2; width: 40px; height: 40px; }   /* above the logo's layer, and a bigger target for a thumb */

/* ---- Log in | Sign up: a real two-way switch (Alex 2026-10-03), the thumb slides under the chosen side ---- */
.gate-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: min(260px, 100%); margin: 0 auto 20px; padding: 4px;
  border-radius: var(--sai-radius-pill); background: var(--sai-raised); border: 1px solid var(--sai-line); }
.gate-switch-opt { position: relative; z-index: 1; padding: 8px 12px; border: 0; background: none; cursor: pointer; border-radius: var(--sai-radius-pill);
  font: 600 var(--sai-text-sm) var(--sai-font-body); color: var(--sai-muted); transition: color var(--sai-motion-fast) var(--sai-ease); }
.gate-switch-opt[aria-pressed="true"] { color: var(--sai-ink-on-soft); }
.gate-switch-opt:focus-visible { outline: none; box-shadow: var(--sai-focus); }
.gate-switch-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: var(--sai-radius-pill);
  background: linear-gradient(135deg, var(--sai-blue-soft), var(--sai-purple-soft)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 3px rgba(0,0,0,0.12);
  transition: transform 220ms var(--sai-ease); }
.gate-switch[data-mode="signup"] .gate-switch-thumb { transform: translateX(100%); }
@media (prefers-reduced-motion: reduce) { .gate-switch-thumb { transition: none; } }
.gate-consent[hidden] { display: none; }

/* ---- the profile step: a WIDE two-column card on a desktop (Alex 2026-10-03: the narrow sign-in box made it look like a
   cramped phone screen). About you on the left, your data on the right; one column only on a phone. ---- */
.sai-gate.is-wide .sai-sheet-card { max-width: 920px; padding: 32px 40px 30px; }
.sai-gate.is-wide .sai-sheet-logo { margin-bottom: 6px; }
.sai-gate.is-wide .sai-sheet-logo .sai-logo { --logo: 44px; }
.sai-gate.is-wide #stepProfile > .sai-sheet-sub { margin-bottom: 24px; }
.gate-profile { gap: 0; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 36px; text-align: left; }
.profile-col { display: grid; gap: 18px; align-content: start; min-width: 0; }
.profile-col + .profile-col { padding-left: 36px; border-left: 1px solid var(--sai-line); }
.profile-col-title { margin: 0; font: 600 var(--sai-text-xs)/1 var(--sai-font-body); letter-spacing: var(--sai-tracking-caps); text-transform: uppercase; color: var(--sai-muted); }
.profile-actions { display: flex; justify-content: flex-end; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--sai-line); }
.profile-actions .sai-btn-primary { width: auto; min-width: 220px; }
@media (max-width: 760px) {
  .sai-gate.is-wide .sai-sheet-card { padding: 26px 20px 22px; }
  .profile-grid { grid-template-columns: 1fr; gap: 22px; }
  .profile-col + .profile-col { padding-left: 0; border-left: 0; padding-top: 22px; border-top: 1px solid var(--sai-line); }
  .profile-actions { justify-content: stretch; }
  .profile-actions .sai-btn-primary { width: 100%; }
}
.gate-field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.gate-field .sai-field-label { margin-bottom: 2px; }
.gate-help { font-size: var(--sai-text-xs); color: var(--sai-muted); line-height: 1.4; }
.gate-optional { margin-left: 6px; font: 500 var(--sai-text-xs) var(--sai-font-body); color: var(--sai-muted); text-transform: none; letter-spacing: 0; }
.gate-at { display: flex; align-items: center; border-radius: var(--sai-radius-sm); background: var(--sai-raised); border: 1px solid var(--sai-line); }
.gate-at:focus-within { border-color: var(--sai-blue); }
.gate-at > span { padding-left: 13px; color: var(--sai-muted); font: 600 var(--sai-text-md) var(--sai-font-body); }
.gate-at .sai-field { border: 0; background: transparent; padding-left: 4px; }
.gate-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.gate-chips legend { width: 100%; padding: 0; margin-bottom: 8px; }
.gate-chip { position: relative; cursor: pointer; }
.gate-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gate-chip span { display: inline-block; padding: 7px 13px; border-radius: var(--sai-radius-pill); border: 1px solid var(--sai-line); background: var(--sai-raised);
  font: 500 var(--sai-text-sm) var(--sai-font-body); color: var(--sai-text); transition: background var(--sai-motion-fast) var(--sai-ease), border-color var(--sai-motion-fast) var(--sai-ease); }
.gate-chip input:checked + span { background: color-mix(in srgb, var(--sai-blue) 16%, var(--sai-raised)); border-color: color-mix(in srgb, var(--sai-blue) 55%, var(--sai-line)); color: var(--sai-text); }
.gate-chip input:checked + span::before { content: "\2713\00a0"; color: var(--sai-blue); font-weight: 700; }
.gate-chip input:focus-visible + span { box-shadow: var(--sai-focus); }
.gate-data { display: grid; gap: 10px; border: 1px solid var(--sai-line); border-radius: var(--sai-radius-md); padding: 16px 18px 14px; margin: 0; text-align: left; background: color-mix(in srgb, var(--sai-raised) 55%, transparent); }
.gate-choices legend { float: left; width: 100%; padding: 0; margin-bottom: 4px; }   /* float keeps the legend inside the box */
.gate-choices legend + * { clear: both; }
.gate-choices .gate-toggle { padding: 10px 0; }
.gate-choices .gate-toggle + .gate-toggle { border-top: 1px solid var(--sai-line); }
.gate-data-title { font: 700 var(--sai-text-sm)/1.2 var(--sai-font-body); color: var(--sai-text); margin: 0; padding: 0; }
.gate-data-why { margin: 0; font-size: var(--sai-text-xs); line-height: 1.5; color: var(--sai-muted); }
.gate-data-why a { color: var(--sai-blue); font-weight: 600; text-decoration: none; }
.gate-data-why a:hover { text-decoration: underline; }
.gate-data-list { margin: 2px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.gate-data-list li { position: relative; padding-left: 24px; font-size: var(--sai-text-sm); line-height: 1.45; color: var(--sai-text); }
.gate-data-list li::before { content: ""; position: absolute; left: 2px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--sai-ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 9px no-repeat; }
.gate-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; cursor: pointer; font-size: var(--sai-text-sm); line-height: 1.4; color: var(--sai-text); }
.gate-toggle input { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--sai-line); transition: background var(--sai-motion-fast) var(--sai-ease); }
.gate-toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 180ms var(--sai-ease); }
.gate-toggle input:checked { background: var(--sai-blue); }
.gate-toggle input:checked::after { transform: translateX(16px); }
.gate-toggle input:focus-visible { outline: none; box-shadow: var(--sai-focus); }
@media (prefers-reduced-motion: reduce) { .gate-toggle input, .gate-toggle input::after { transition: none; } }
.sai-btn-secondary { width: 100%; margin-bottom: 10px; padding: 10px 16px; border-radius: var(--sai-radius-pill); cursor: pointer;
  font: 600 var(--sai-text-md) var(--sai-font-body); color: var(--sai-text); background: var(--sai-raised); border: 1px solid var(--sai-line); }
.sai-btn-secondary:hover { border-color: color-mix(in srgb, var(--sai-text) 22%, var(--sai-line)); }

/* ---- phone ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .sai-chat-shell { width: 100%; height: calc(100dvh - 48px); margin-top: 32px; border-radius: var(--sai-radius-md) var(--sai-radius-md) 0 0; }
  .sai-thread { padding: var(--sai-space-4) var(--sai-space-4) var(--sai-space-3); }
  .msg { max-width: 90%; }
  .sai-composer-wrap { padding: 10px 12px 14px; }
}

/* reduced motion: still the orb, typing dots, and record pulse (the app honors this too) */
@media (prefers-reduced-motion: reduce) {
  .sai-typing span, .box-icon.is-recording { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
:root[data-motion="off"] .sai-typing span, :root[data-motion="off"] .box-icon.is-recording { animation: none; }

/* the sign-in logo: the shared .sai-logo component, centred (2026-10-03) */
.sai-sheet-logo { display: flex; justify-content: center; margin: 2px 0 12px; }

/* ---- the Settings hub (Alex 2026-10-03): tabs on the left, each its own page on the right ---- */
.sai-hub .hub-card { max-width: 860px; padding: 0; display: grid; grid-template-columns: 210px 1fr; min-height: min(560px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px); overflow: hidden; text-align: left; }
.hub-tabs { display: flex; flex-direction: column; gap: 2px; padding: 22px 12px; border-right: 1px solid var(--sai-line); background: color-mix(in srgb, var(--sai-raised) 45%, transparent); }
.hub-title { padding: 0 10px 14px; font: 600 var(--sai-text-lg)/1.2 var(--sai-font-display); }
.hub-tab { padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--sai-muted); text-align: left; cursor: pointer;
  font: 500 var(--sai-text-sm) var(--sai-font-body); transition: background var(--sai-motion-fast) var(--sai-ease), color var(--sai-motion-fast) var(--sai-ease); }
.hub-tab:hover { background: var(--sai-raised); color: var(--sai-text); }
.hub-tab[aria-current="page"] { background: color-mix(in srgb, var(--sai-blue) 16%, var(--sai-raised)); color: var(--sai-text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); }
.hub-tab:focus-visible { outline: none; box-shadow: var(--sai-focus); }
.hub-body { position: relative; padding: 26px 30px 28px; overflow-y: auto; overscroll-behavior: contain; }
.hub-x { position: absolute; top: 14px; right: 14px; }
.hub-panel[hidden] { display: none; }
.hub-h2 { margin: 0 0 6px; font: 600 var(--sai-text-xl)/1.2 var(--sai-font-display); }
.hub-h3 { margin: 20px 0 8px; font: 600 var(--sai-text-sm)/1.2 var(--sai-font-body); color: var(--sai-text); }
.hub-sub { margin: 0 0 16px; font-size: var(--sai-text-sm); color: var(--sai-muted); line-height: 1.55; }
.hub-sub a, .hub-fine a { color: var(--sai-blue); font-weight: 600; text-decoration: none; }
.hub-fine { margin: 18px 0 0; font-size: var(--sai-text-xs); color: var(--sai-muted); line-height: 1.55; }
.hub-big { margin: 6px 0 8px; font: 700 var(--sai-text-2xl)/1.1 var(--sai-font-display); }
.hub-btn { width: auto; min-width: 200px; margin-top: 4px; }
.hub-link-btn { display: inline-block; text-align: center; text-decoration: none; }
.hub-out { color: var(--sai-bad); margin-top: 18px; }
.hub-toggle { max-width: 420px; margin-top: 6px; }
.hub-facts { display: grid; gap: 10px; margin: 8px 0 16px; }
.hub-facts div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: var(--sai-text-sm); }
.hub-facts dt { color: var(--sai-muted); } .hub-facts dd { margin: 0; font-weight: 600; }
.sai-hub .sai-select { max-width: 420px; }
@media (max-width: 700px) {
  .sai-hub .hub-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .hub-tabs { flex-direction: row; overflow-x: auto; padding: 14px 12px 10px; border-right: 0; border-bottom: 1px solid var(--sai-line); }
  .hub-title { display: none; }
  .hub-tab { white-space: nowrap; }
  .hub-body { padding: 22px 18px; }
}

/* ---- the usage ring next to the composer's model menu (Alex 2026-10-03) ---- */
.usage-wrap { display: flex; align-items: center; }
.usage-ring { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; display: grid; place-items: center; }
.usage-ring:hover { background: var(--sai-raised); }
.usage-ring:focus-visible { outline: none; box-shadow: var(--sai-focus); }
.usage-ring svg { width: 22px; height: 22px; transform: rotate(-90deg); }
.usage-ring .ur-track { fill: none; stroke: var(--sai-line); stroke-width: 4; }
.usage-ring .ur-fill { fill: none; stroke: #8fb2ff; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 87.96; stroke-dashoffset: 87.96; transition: stroke-dashoffset 300ms var(--sai-ease), stroke 300ms var(--sai-ease); }
.usage-ring.is-warn .ur-fill { stroke: #ffb35c; }
.usage-ring.is-full .ur-fill { stroke: #ff6b6b; }
.usage-pop { min-width: 300px; padding: 14px 16px 12px; gap: 7px; }
.usage-pop .up-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: var(--sai-text-sm); }
.usage-pop .up-meta { display: inline-flex; gap: 10px; align-items: baseline; color: var(--sai-muted); font-size: var(--sai-text-xs); }
.usage-pop .up-meta b, .usage-pop .up-row b { color: var(--sai-text); font-size: var(--sai-text-sm); }
.usage-pop .up-head { margin-top: 2px; font-size: var(--sai-text-xs); color: var(--sai-muted); }
.usage-pop .up-note { font-size: 11px; color: var(--sai-muted); line-height: 1.4; }
.usage-pop .up-sep { height: 1px; margin: 6px 0 4px; background: var(--sai-line); }
.usage-pop .up-more { margin-top: 6px; justify-self: start; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--sai-line); background: var(--sai-raised);
  color: var(--sai-text); font: 600 var(--sai-text-xs) var(--sai-font-body); cursor: pointer; }
.usage-pop .up-more:hover { border-color: color-mix(in srgb, var(--sai-text) 22%, var(--sai-line)); }

/* ---- quiet notes in the conversation (not SAI speaking): the "getting long" warning, a compression, the session recap,
   a limit reached (Alex 2026-10-03: warning signs, automatic compression, the session wrap-up) ---- */
.msg.note { justify-self: center; max-width: min(560px, 92%); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 0; background: none; border: 0; box-shadow: none; }
.msg.note .msg-body { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--sai-line); background: color-mix(in srgb, var(--sai-raised) 70%, transparent);
  color: var(--sai-muted); font-size: var(--sai-text-sm); line-height: 1.45; text-align: center; }
.msg.note .msg-body a { color: var(--sai-blue); font-weight: 600; text-decoration: none; }
.msg.note .msg-body a:hover { text-decoration: underline; }
.note-btn { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--sai-line); background: var(--sai-raised); color: var(--sai-text);
  font: 600 var(--sai-text-xs) var(--sai-font-body); cursor: pointer; }
.note-btn:hover { border-color: color-mix(in srgb, var(--sai-text) 22%, var(--sai-line)); }
.note-btn:focus-visible { outline: none; box-shadow: var(--sai-focus); }
.usage-row .ur-meta { display: inline-flex; gap: 12px; align-items: baseline; color: var(--sai-muted); font-size: var(--sai-text-xs); }
.usage-row .ur-meta b { color: var(--sai-text); }
.hub-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.hub-actions .hub-btn { margin-top: 0; }
