/* ============================================================
   Trading Tutor — design tokens & base
   Warm "cognitive instrument" aesthetic. Light default + dark.
   ============================================================ */

:root {
  /* Foundation — warm neutral, low glare (Claude-grade warmth) */
  --background:        #F4F2EC;
  --surface:           #FBFAF6;
  --surface-2:         #F7F5EF;   /* nested surface */
  --surface-sunken:    #ECE9E1;   /* journal / locked zones */
  --foreground:        #29261F;   /* warm graphite, not black */
  --foreground-muted:  #6B6459;
  --foreground-subtle: #978F80;
  --border:            #E6E2D8;
  --border-strong:     #D2CCBE;

  /* DQ — calm cognitive teal (thinking, not reward) */
  --dq:        #3E6E73;
  --dq-strong: #2F565A;
  --dq-soft:   #DBE5E2;

  /* P&L — deliberately neutral. Sign is a tiny accent, never a fill. */
  --pnl-fg:  #29261F;
  --pnl-pos: #5E7C5E;   /* muted sage */
  --pnl-neg: #9E6B5C;   /* muted clay — NOT red */

  /* Behaviour / wellbeing — calm sand-amber (informs, never alarms) */
  --cooldown:    #A8824E;
  --cooldown-bg: #F1E7D1;
  --tilt:        #9C6E44;
  --tilt-bg:     #EFE1CD;

  /* System health */
  --ok:   #5E7C5E;
  --down: #9E6B5C;

  /* Safety — the ONLY weighty color. Sober brick. No glow, no gradient. */
  --danger:    #A63D3D;
  --danger-strong: #8F3232;
  --danger-fg: #FFFFFF;
  --danger-soft: #F4E2DE;

  /* Edge verdicts */
  --verdict-confirmed:    var(--dq);
  --verdict-notconfirmed: var(--foreground-muted);
  --verdict-insufficient: var(--cooldown);

  --accent:     var(--dq);
  --focus-ring: var(--dq);

  /* Type */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "IBM Plex Serif", ui-serif, Georgia, serif;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-lg:   1.125rem;
  --text-xl:   1.4rem;
  --text-2xl:  1.85rem;
  --text-hero: 3.5rem;

  /* Spacing */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px;

  --radius:    10px;
  --radius-lg: 14px;
  --radius-sm: 7px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(41,38,31,0.04);
  --shadow-md: 0 2px 10px rgba(41,38,31,0.06), 0 1px 2px rgba(41,38,31,0.04);
  --shadow-lg: 0 12px 40px rgba(41,38,31,0.14), 0 2px 8px rgba(41,38,31,0.08);

  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 360ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-w: 248px;
}

.dark {
  --background:        #17171A;
  --surface:           #1F1F23;
  --surface-2:         #25252A;
  --surface-sunken:    #161619;
  --foreground:        #E8E6E1;
  --foreground-muted:  #A29C90;
  --foreground-subtle: #6F6A60;
  --border:            #2D2D33;
  --border-strong:     #3B3B43;

  --dq:        #6FA3A6;
  --dq-strong: #88BABC;
  --dq-soft:   #283739;

  --pnl-fg:  #E8E6E1;
  --pnl-pos: #82A382;
  --pnl-neg: #C18876;

  --cooldown:    #CCA470;
  --cooldown-bg: #2C2517;
  --tilt:        #C2935F;
  --tilt-bg:     #2C2316;

  --ok:   #82A382;
  --down: #C18876;

  --danger:    #C75555;
  --danger-strong: #D86767;
  --danger-fg: #17171A;
  --danger-soft: #2E1D1D;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1;
}

h1, h2, h3, h4 { font-weight: 500; margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.serif { font-family: var(--serif); }
.num { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }

::selection { background: color-mix(in oklab, var(--dq) 24%, transparent); }

/* Focus */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--foreground-subtle); background-clip: padding-box; border: 3px solid transparent; }

/* ============================================================ LAYOUT */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100%;
}
.app__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app__scroll {
  flex: 1;
  overflow-y: auto;
}
.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-16);
  width: 100%;
}
.page__head {
  margin-bottom: var(--space-6);
}
.page__title { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.page__sub { color: var(--foreground-muted); font-size: var(--text-sm); margin-top: 6px; max-width: 64ch; }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .page { padding: var(--space-5) var(--space-4) 120px; }
  .page__title { font-size: 1.55rem; }
  .dash-grid, .edge-grid, .risk-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================ SIDEBAR */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-5) var(--space-5) var(--space-4);
}
.brand__mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--dq); color: #fff;
  display: grid; place-items: center; flex: none;
  box-shadow: var(--shadow-sm);
}
.brand__name { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; }
.brand__sub { font-size: 11px; color: var(--foreground-subtle); font-family: var(--mono); }

.nav { padding: var(--space-2) var(--space-3); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--foreground-muted); font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; border: none; background: none; text-align: left; width: 100%;
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.nav__item:hover { background: var(--surface-sunken); color: var(--foreground); }
.nav__item.is-active { background: color-mix(in oklab, var(--dq) 12%, transparent); color: var(--dq-strong); }
.nav__item.is-active::before {
  content: ""; position: absolute; left: -3px; top: 8px; bottom: 8px; width: 3px;
  background: var(--dq); border-radius: 99px;
}
.nav__item svg { flex: none; }

.sidebar__foot { padding: var(--space-3) var(--space-3) var(--space-4); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--space-3); }

/* ============================================================ TOPBAR (kill + heartbeat always reachable) */
.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar__spacer { flex: 1; }
.topbar__title { display: none; }
@media (max-width: 880px) {
  .topbar { padding: 9px var(--space-4); }
  .topbar__title { display: block; font-weight: 600; font-size: 0.95rem; }
}

/* ============================================================ HEARTBEAT */
.heartbeat {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--foreground-muted);
  font-family: var(--mono); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  padding: 6px 10px; border-radius: var(--radius-pill);
  transition: border-color var(--dur-fast);
}
.heartbeat:hover { border-color: var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.dot--ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent); }
.dot--down { background: var(--down); box-shadow: 0 0 0 3px color-mix(in oklab, var(--down) 22%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .dot--ok { animation: pulse-soft 3.2s var(--ease-inout) infinite; }
}
@keyframes pulse-soft { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ============================================================ KILL SWITCH */
.kill {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--danger); color: var(--danger-fg);
  border: none; cursor: pointer; font-weight: 600; font-size: var(--text-sm);
  padding: 10px 16px; border-radius: var(--radius);
  min-height: 44px; box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast), transform var(--dur-fast);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.kill:hover { background: var(--danger-strong); }
.kill:active { transform: translateY(1px); }
.kill--block { width: 100%; }
.kill--lg { padding: 16px 22px; font-size: var(--text-base); min-height: 56px; }
.kill[data-stopped="true"] { background: var(--surface-sunken); color: var(--foreground-muted); cursor: default; }

/* ============================================================ CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: var(--space-6); }
.card--sunken { background: var(--surface-sunken); box-shadow: none; }
.card__label {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--foreground-subtle); font-weight: 600; margin-bottom: var(--space-2);
}

.grid { display: grid; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); } .gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2);} .mt-3{margin-top:var(--space-3);} .mt-4{margin-top:var(--space-4);} .mt-6{margin-top:var(--space-6);}
.muted { color: var(--foreground-muted); }
.subtle { color: var(--foreground-subtle); }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================ BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 500; font-size: var(--text-sm);
  padding: 9px 15px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--foreground); cursor: pointer; min-height: 40px;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-sunken); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--dq); color: #fff; border-color: var(--dq); }
.btn--primary:hover { background: var(--dq-strong); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-sunken); }
.btn--danger { background: var(--danger); color: var(--danger-fg); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-strong); }
.btn--sm { min-height: 32px; padding: 5px 11px; font-size: var(--text-xs); }
.btn--quiet { color: var(--foreground-muted); border-color: var(--border); font-weight: 500; }

/* ============================================================ PILL / BADGE */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid var(--border-strong); color: var(--foreground-muted);
  background: var(--surface);
}
.pill--neutral { background: var(--surface-sunken); border-color: var(--border); }
.pill--dq { color: var(--dq-strong); border-color: color-mix(in oklab, var(--dq) 35%, var(--border)); background: color-mix(in oklab, var(--dq) 9%, var(--surface)); }
.pill--cooldown { color: var(--cooldown); border-color: color-mix(in oklab, var(--cooldown) 40%, var(--border)); background: var(--cooldown-bg); }
.pill--danger { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.pill--ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, var(--border)); }
.pill svg { flex: none; }

.tag { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--border); color: var(--foreground-muted); }
.tag--warn { background: var(--cooldown-bg); border-color: color-mix(in oklab, var(--cooldown) 30%, var(--border)); color: var(--cooldown); }

/* ============================================================ BEHAVIORAL BANNER */
.banner {
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--cooldown-bg);
  border: 1px solid color-mix(in oklab, var(--cooldown) 32%, var(--border));
}
.banner__icon { color: var(--cooldown); flex: none; margin-top: 2px; }
.banner__body { flex: 1; min-width: 0; }
.banner__title { font-weight: 600; font-size: var(--text-base); color: color-mix(in oklab, var(--cooldown) 70%, var(--foreground)); }
.banner__text { font-size: var(--text-sm); color: var(--foreground-muted); margin-top: 3px; }
.banner__timer { font-family: var(--mono); font-size: var(--text-sm); color: var(--cooldown); font-weight: 500; white-space: nowrap; }

/* ============================================================ DQ GAUGE */
.gauge { position: relative; display: grid; place-items: center; }
.gauge__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge__value { font-family: var(--mono); font-size: var(--text-hero); font-weight: 500; line-height: 1; color: var(--dq-strong); letter-spacing: -0.03em; }
.gauge__max { font-family: var(--mono); font-size: var(--text-lg); color: var(--foreground-subtle); }
.gauge__cap { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--foreground-subtle); font-weight: 600; margin-top: 6px; }

/* breakdown bars */
.bk { display: grid; gap: 12px; }
.bk__row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.bk__label { font-size: var(--text-sm); color: var(--foreground-muted); }
.bk__val { font-family: var(--mono); font-size: var(--text-sm); color: var(--foreground); }
.bk__track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--dq-soft); overflow: hidden; }
.bk__fill { height: 100%; background: var(--dq); border-radius: 99px; transition: width var(--dur-slow) var(--ease-out); }

/* ============================================================ P&L */
.pnl__value { font-family: var(--mono); font-size: 1.9rem; font-weight: 500; letter-spacing: -0.02em; color: var(--pnl-fg); }
.pnl__sign { font-size: 0.7em; vertical-align: 0.06em; margin-right: 1px; }
.sign-pos { color: var(--pnl-pos); }
.sign-neg { color: var(--pnl-neg); }
.pnl__note { font-size: var(--text-xs); color: var(--foreground-subtle); margin-top: 8px; max-width: 38ch; line-height: 1.45; }

/* sparkline */
.spark { width: 100%; height: 48px; display: block; }

/* progress */
.progress { height: 8px; border-radius: 99px; background: var(--surface-sunken); overflow: hidden; }
.progress__fill { height: 100%; background: var(--dq); border-radius: 99px; }
.progress--cool .progress__fill { background: var(--cooldown); }

/* ============================================================ TABLES */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--foreground-subtle); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--foreground); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td .num { color: var(--foreground); }

/* ============================================================ JOURNAL */
.jentry { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; transition: border-color var(--dur-fast); }
.jentry:hover { border-color: var(--border-strong); }
.jentry__head { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: var(--space-4); align-items: center; padding: 14px 18px; cursor: pointer; width: 100%; background: none; border: none; text-align: left; font-family: inherit; }
.jentry__date { font-family: var(--mono); font-size: var(--text-xs); color: var(--foreground-muted); min-width: 96px; }
.jentry__inst { font-weight: 600; font-size: var(--text-sm); }
.jentry__dir { font-size: var(--text-xs); color: var(--foreground-muted); }
.jentry__dq { font-family: var(--mono); font-weight: 500; color: var(--dq-strong); font-size: var(--text-base); }
.jentry__r { font-family: var(--mono); font-size: var(--text-sm); }
.jentry__body { padding: 0 18px 18px; border-top: 1px solid var(--border); display: grid; gap: var(--space-5); }
.thesis { background: var(--surface-sunken); border-radius: var(--radius); padding: 14px 16px; position: relative; }
.thesis__lock { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--foreground-subtle); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 8px; }
.thesis__text { font-size: var(--text-sm); line-height: 1.55; color: var(--foreground); }
.tutor-note { border-left: 2px solid var(--dq); padding-left: 14px; }
.tutor-note__text { font-family: var(--serif); font-size: var(--text-base); line-height: 1.6; color: var(--foreground); font-style: italic; }

.avatar { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; flex: none; background: var(--surface-sunken); border: 1px solid var(--border); color: var(--foreground-muted); }

/* ============================================================ DIALOG / SHEET */
.overlay { position: fixed; inset: 0; background: rgba(20,18,14,0.42); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: var(--space-4); }
.dark .overlay { background: rgba(0,0,0,0.6); }
.dialog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: var(--space-6); }
.dialog__title { font-size: var(--text-lg); font-weight: 600; }
.dialog__text { color: var(--foreground-muted); font-size: var(--text-sm); margin-top: 10px; line-height: 1.55; }
.dialog__actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-6); }
@media (prefers-reduced-motion: no-preference) {
  .overlay { animation: fade-in var(--dur-base) var(--ease-out); }
  .dialog { animation: dialog-in var(--dur-base) var(--ease-out); }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* mobile sheet */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet__panel { position: absolute; left: 0; top: 0; bottom: 0; width: 270px; max-width: 84vw; background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
@media (prefers-reduced-motion: no-preference) {
  .sheet__panel { animation: slide-in var(--dur-base) var(--ease-out); }
}
@keyframes slide-in { from { transform: translateX(-100%); } }

/* ============================================================ MOBILE BOTTOM NAV */
.mobnav { display: none; }
@media (max-width: 880px) {
  .mobnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .mobnav__item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: none; background: none; color: var(--foreground-subtle); font-size: 10px; font-weight: 500; cursor: pointer; min-height: 48px; border-radius: 8px; }
  .mobnav__item.is-active { color: var(--dq-strong); }
  .mobnav__kill { color: var(--danger) !important; }
}

/* ============================================================ TUTOR CHAT */
.chat { display: flex; flex-direction: column; gap: var(--space-5); }
.msg { display: flex; gap: var(--space-3); max-width: 760px; }
.msg--op { align-self: flex-end; flex-direction: row-reverse; }
.msg__avatar { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; }
.msg__avatar--tutor { background: color-mix(in oklab, var(--dq) 16%, var(--surface)); color: var(--dq-strong); border: 1px solid color-mix(in oklab, var(--dq) 30%, var(--border)); }
.msg__avatar--op { background: var(--surface-sunken); color: var(--foreground-muted); border: 1px solid var(--border); }
.msg__bubble { padding: 12px 16px; border-radius: 14px; }
.msg--tutor .msg__bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg--tutor .msg__bubble p { font-family: var(--serif); font-size: var(--text-base); line-height: 1.6; }
.msg--op .msg__bubble { background: color-mix(in oklab, var(--dq) 10%, var(--surface)); border: 1px solid color-mix(in oklab, var(--dq) 22%, var(--border)); border-top-right-radius: 4px; }
.composer { display: flex; gap: var(--space-3); align-items: flex-end; border-top: 1px solid var(--border); padding-top: var(--space-4); }
.composer.is-unaided { opacity: 0.55; pointer-events: none; }
textarea, input[type=text], input[type=number] {
  font-family: var(--sans); font-size: var(--text-sm); color: var(--foreground);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 11px 13px; width: 100%; resize: none; line-height: 1.5;
  transition: border-color var(--dur-fast);
}
textarea:focus, input:focus { outline: none; border-color: var(--dq); }
textarea::placeholder, input::placeholder { color: var(--foreground-subtle); }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 16px; }
.typing span { width: 6px; height: 6px; border-radius: 99px; background: var(--foreground-subtle); }
@media (prefers-reduced-motion: no-preference) {
  .typing span { animation: typing 1.2s infinite; }
  .typing span:nth-child(2){ animation-delay: 0.18s; } .typing span:nth-child(3){ animation-delay: 0.36s; }
}
@keyframes typing { 0%,60%,100% { opacity: 0.3; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-3px);} }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-sunken); border-radius: var(--radius); padding: 3px; gap: 2px; border: 1px solid var(--border); }
.seg__btn { border: none; background: none; padding: 7px 14px; border-radius: 7px; font-size: var(--text-sm); font-weight: 500; color: var(--foreground-muted); cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast); }
.seg__btn.is-active { background: var(--surface); color: var(--foreground); box-shadow: var(--shadow-sm); }

/* switch */
.switch { position: relative; width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); border: none; cursor: pointer; transition: background var(--dur-base); flex: none; }
.switch.is-on { background: var(--dq); }
.switch__knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 99px; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease-out); }
.switch.is-on .switch__knob { transform: translateX(18px); }

/* metric row */
.metric { display: grid; grid-template-columns: 1fr auto auto; gap: var(--space-4); align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.metric:last-child { border-bottom: none; }
.metric__name { font-weight: 500; font-size: var(--text-sm); }
.metric__def { font-size: var(--text-xs); color: var(--foreground-subtle); margin-top: 2px; }
.metric__val { font-family: var(--mono); font-size: var(--text-base); text-align: right; }
.metric__thr { font-family: var(--mono); font-size: var(--text-xs); color: var(--foreground-subtle); }

/* skeleton */
.skel { background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-2) 50%, var(--surface-sunken) 75%); background-size: 200% 100%; border-radius: var(--radius); }
@media (prefers-reduced-motion: no-preference) { .skel { animation: shimmer 1.4s infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* tooltip */
.tip { position: relative; display: inline-flex; }
.tip__pop { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--foreground); color: var(--background); font-size: var(--text-xs); padding: 7px 10px; border-radius: 7px; width: max-content; max-width: 240px; line-height: 1.4; z-index: 60; box-shadow: var(--shadow-md); pointer-events: none; }
.tip__pop::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--foreground); }

/* toast */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
@media (max-width: 880px){ .toasts { bottom: 84px; left: 12px; right: 12px; max-width: none; } }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-left: 3px solid var(--down); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-lg); display: flex; gap: 11px; align-items: flex-start; }
.toast--danger { border-left-color: var(--danger); }
.toast--ok { border-left-color: var(--ok); }
.toast__title { font-weight: 600; font-size: var(--text-sm); }
.toast__text { font-size: var(--text-xs); color: var(--foreground-muted); margin-top: 2px; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in var(--dur-base) var(--ease-out); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

/* helpers */
.divider { height: 1px; background: var(--border); border: none; margin: var(--space-5) 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.hide-mobile { } 
@media (max-width: 880px){ .hide-mobile { display: none !important; } }
.only-mobile { display: none; }
@media (max-width: 880px){ .only-mobile { display: revert; } }

.section-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-4); letter-spacing: -0.01em; }

.empty { text-align: center; padding: var(--space-12) var(--space-4); color: var(--foreground-muted); }
.empty__icon { color: var(--foreground-subtle); margin-bottom: var(--space-4); display: inline-flex; }
.empty__title { font-size: var(--text-lg); font-weight: 500; color: var(--foreground); }
.empty__text { font-size: var(--text-sm); margin-top: 8px; max-width: 42ch; margin-inline: auto; line-height: 1.55; }

/* fade-in on screen mount — kept as a stable no-op to guarantee visibility */
.fade-up { opacity: 1; }

/* ============================================================ VOICE SESSION */
.vs { display: flex; flex-direction: column; min-height: 0; }
.vs__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.vs__timer { font-family: var(--mono); font-size: var(--text-sm); color: var(--foreground-muted); }
.vs__stage { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-8) var(--space-4) var(--space-4); }
.vs__avatar { position: relative; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in oklab, var(--dq) 14%, var(--surface)); border: 1px solid color-mix(in oklab, var(--dq) 30%, var(--border)); color: var(--dq-strong); }
.vs__ring { position: absolute; inset: -2px; border-radius: 50%; border: 1.5px solid var(--dq); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .vs__avatar.is-speaking .vs__ring { animation: vs-ring 2.6s var(--ease-out) infinite; }
  .vs__avatar.is-speaking .vs__ring:nth-child(2) { animation-delay: 1.3s; }
}
@keyframes vs-ring { 0% { transform: scale(1); opacity: 0.45; } 100% { transform: scale(1.85); opacity: 0; } }
.vs__name { font-weight: 600; font-size: var(--text-lg); margin-top: 16px; }
.vs__state { margin-top: 4px; font-size: var(--text-sm); color: var(--foreground-muted); }

.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 40px; margin-top: 16px; }
.wave span { width: 3px; height: 16%; background: var(--dq); border-radius: 99px; opacity: 0.4; }
@media (prefers-reduced-motion: no-preference) {
  .wave.is-active span { animation: wave 1s ease-in-out infinite; opacity: 1; }
}
@keyframes wave { 0%, 100% { height: 14%; } 50% { height: 86%; } }

.vs__controls { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; padding: var(--space-5) 0 var(--space-6); }
.cbtn-wrap { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.cbtn { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--surface); color: var(--foreground); cursor: pointer; transition: background var(--dur-fast), transform var(--dur-fast), color var(--dur-fast); }
.cbtn:hover { background: var(--surface-sunken); }
.cbtn:active { transform: scale(0.95); }
.cbtn.is-on { background: var(--dq); color: #fff; border-color: var(--dq); }
.cbtn.is-off { background: var(--surface-sunken); color: var(--foreground-subtle); }
.cbtn--end { background: var(--danger); color: var(--danger-fg); border-color: var(--danger); }
.cbtn--end:hover { background: var(--danger-strong); }
.cbtn--talk { width: 76px; height: 76px; }
.cbtn--talk.is-talking { background: var(--dq); color: #fff; border-color: var(--dq); box-shadow: 0 0 0 4px color-mix(in oklab, var(--dq) 16%, transparent); }
.cbtn--talk:disabled { opacity: 0.45; cursor: not-allowed; }
.cbtn__lbl { font-size: 11px; color: var(--foreground-muted); }

.coview { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-sunken); transition: box-shadow var(--dur-base), border-color var(--dur-base); }
.coview.is-live { border-color: color-mix(in oklab, var(--dq) 45%, var(--border)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--dq) 13%, transparent); }
.coview__bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.coview__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.coview__title { font-size: var(--text-xs); color: var(--foreground-muted); margin-left: 6px; font-family: var(--mono); }
.coview__body { padding: var(--space-5); position: relative; display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.annot { position: absolute; border: 2px solid var(--dq); border-radius: 12px; pointer-events: none; }
.annot__tag { position: absolute; top: -10px; left: 12px; background: var(--dq); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }

.vs__transcript { display: flex; flex-direction: column; gap: 14px; padding: var(--space-2) 0; }
.vs__privacy { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: var(--text-xs); color: var(--foreground-subtle); padding: 10px; }
@media (max-width: 880px) { .cbtn--talk { width: 68px; height: 68px; } .vs__controls { gap: 16px; } }
