/* ==========================================================================
   Nyaya
   Ink navy on cool paper, with brass for anything the user acts on.
   Verification state is the one place semantic colour is spent, so a green
   or amber mark in the interface always means the same thing: whether a
   citation was checked against the passage it points at.
   ========================================================================== */

:root {
  /* surfaces, cool biased toward the ink rather than a flat grey */
  --ground:        #EBEFF5;
  --surface:       #FFFFFF;
  --surface-2:     #F4F6FA;
  --surface-sunk:  #E3E8F1;

  /* text */
  --ink:        #131C29;
  --ink-mid:    #414F66;
  --ink-soft:   #64728B;
  --ink-faint:  #8A96AB;

  /* structure */
  --line:        #D3DBE7;
  --line-strong: #B9C4D6;

  /* brass, the single accent */
  --accent:        #8A6115;
  --accent-strong: #6E4C0F;
  --accent-wash:   #F6EEDC;
  --accent-line:   #E0CBA0;

  /* verification semantics, deliberately not the accent */
  --good:       #1B6E45;
  --good-wash:  #E4F1EA;
  --good-line:  #B6D8C6;
  --warn:       #94510F;
  --warn-wash:  #FBEDDF;
  --warn-line:  #EBC8A3;
  --bad:        #A3231C;
  --bad-wash:   #F9E7E5;

  --focus: #2B6CB0;

  --shadow-sm: 0 1px 2px rgba(19, 28, 41, .06);
  --shadow-md: 0 6px 20px -8px rgba(19, 28, 41, .22);
  --shadow-lg: 0 24px 60px -20px rgba(19, 28, 41, .34);

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", "IBM Plex Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "IBM Plex Serif", "IBM Plex Sans Devanagari", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --rail-w: 17.5rem;
  --measure: 40rem;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:       #0B111C;
    --surface:      #131C2A;
    --surface-2:    #18222F;
    --surface-sunk: #0F1723;

    --ink:       #E7EDF6;
    --ink-mid:   #B3C0D4;
    --ink-soft:  #8B99B0;
    --ink-faint: #6A778D;

    --line:        #263349;
    --line-strong: #35455F;

    --accent:        #DFAA4C;
    --accent-strong: #F0C877;
    --accent-wash:   #23200F;
    --accent-line:   #4A3E1E;

    --good:      #57C08B;
    --good-wash: #10241A;
    --good-line: #275F42;
    --warn:      #E0A263;
    --warn-wash: #251A0F;
    --warn-line: #5B4325;
    --bad:       #EE8279;
    --bad-wash:  #2A1512;

    --focus: #7FB2E8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .75);
  }
}

:root[data-theme="dark"] {
  --ground:       #0B111C;
  --surface:      #131C2A;
  --surface-2:    #18222F;
  --surface-sunk: #0F1723;

  --ink:       #E7EDF6;
  --ink-mid:   #B3C0D4;
  --ink-soft:  #8B99B0;
  --ink-faint: #6A778D;

  --line:        #263349;
  --line-strong: #35455F;

  --accent:        #DFAA4C;
  --accent-strong: #F0C877;
  --accent-wash:   #23200F;
  --accent-line:   #4A3E1E;

  --good:      #57C08B;
  --good-wash: #10241A;
  --good-line: #275F42;
  --warn:      #E0A263;
  --warn-wash: #251A0F;
  --warn-line: #5B4325;
  --bad:       #EE8279;
  --bad-wash:  #2A1512;

  --focus: #7FB2E8;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .75);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  top: .5rem; left: .5rem;
  z-index: 200;
  padding: .55rem .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

::selection { background: var(--accent-wash); color: var(--ink); }

/* ----------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: 100dvh;
}

/* ------------------------------------------------------------------ rail */

.rail {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  min-height: 0;
  padding: 1.1rem 1rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rail-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.wordmark {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
}
.seal { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--accent); }
.seal svg { width: 100%; height: 100%; }
.wordmark-text { display: flex; flex-direction: column; line-height: 1.05; }
.wordmark-text strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -.015em;
}
.wordmark-text em {
  font-style: normal;
  font-size: .78rem;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.rail-tagline {
  margin-top: -.55rem;
  color: var(--ink-soft);
  font-size: .82rem;
  line-height: 1.45;
}

.rail-close { display: none; }

/* modes */
.modes { display: flex; flex-direction: column; gap: .3rem; }
.mode {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .55rem .65rem;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.mode:hover { background: var(--surface-2); }
.mode.is-active {
  background: var(--accent-wash);
  border-color: var(--accent-line);
}
.mode-name { font-weight: 600; font-size: .92rem; }
.mode.is-active .mode-name { color: var(--accent-strong); }
.mode-note { color: var(--ink-soft); font-size: .74rem; line-height: 1.35; }

/* blocks */
.rail-block { display: flex; flex-direction: column; gap: .5rem; }
.rail-title {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.rail-hint { color: var(--ink-soft); font-size: .74rem; line-height: 1.45; }

/* corpus figures */
.corpus { display: flex; flex-direction: column; gap: .5rem; }
.corpus-loading { color: var(--ink-faint); font-size: .8rem; }
.corpus-total {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}
.corpus-total b {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.corpus-total span { color: var(--ink-soft); font-size: .78rem; }

.corpus-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-sunk);
}
.corpus-bar i { display: block; height: 100%; }
.corpus-bar i[data-t="case"]         { background: var(--accent); }
.corpus-bar i[data-t="statute"]      { background: var(--ink-mid); }
.corpus-bar i[data-t="constitution"] { background: var(--good); }

.corpus-legend { display: flex; flex-direction: column; gap: .18rem; }
.corpus-legend li {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .76rem;
  color: var(--ink-soft);
  list-style: none;
}
.corpus-legend i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.corpus-legend b {
  margin-left: auto;
  color: var(--ink-mid);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* upload */
.upload-drop {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .75rem;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-drop:hover, .upload-drop.is-over {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.upload-drop svg { width: 1.15rem; height: 1.15rem; color: var(--accent); flex: none; }
.upload-drop span { display: flex; flex-direction: column; line-height: 1.25; }
.upload-drop strong { font-size: .82rem; font-weight: 600; }
.upload-drop small { color: var(--ink-faint); font-size: .7rem; }

.doc-list { display: flex; flex-direction: column; gap: .35rem; }
.doc-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  list-style: none;
}
.doc-item.is-busy { opacity: .6; }
.doc-item .doc-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.doc-item .doc-name {
  font-size: .78rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item .doc-sub { color: var(--ink-faint); font-size: .68rem; }
.doc-item button {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 1.35rem; height: 1.35rem;
  flex: none;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--ink-faint);
  cursor: pointer;
}
.doc-item button:hover { background: var(--bad-wash); color: var(--bad); }
.doc-item button svg { width: .8rem; height: .8rem; }

/* filter chips */
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  padding: .28rem .6rem;
  font-size: .76rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--line-strong); }
.chip.is-on {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 500;
}

/* rail foot */
.rail-foot {
  margin-top: auto;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.ghost-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .42rem .55rem;
  font-size: .82rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--ink-mid);
  cursor: pointer;
  text-align: left;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--ink); }
.ghost-btn svg { width: 1rem; height: 1rem; flex: none; }

#themeBtn .ico-moon { display: none; }
:root[data-theme="dark"] #themeBtn .ico-sun { display: none; }
:root[data-theme="dark"] #themeBtn .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .ico-sun { display: none; }
  :root:not([data-theme="light"]) #themeBtn .ico-moon { display: block; }
}

.provider-pill {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .2rem;
  padding: .4rem .55rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: .74rem;
  color: var(--ink-soft);
}
.provider-pill .dot {
  width: 7px; height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-faint);
}
.provider-pill.is-live .dot { background: var(--good); }
.provider-pill.is-idle .dot { background: var(--warn); }
.provider-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .8rem 1.5rem;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; }
.topbar-title h1 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.topbar-title p {
  color: var(--ink-soft);
  font-size: .78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  flex: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--ink-mid);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.rail-open { display: none; }

/* deep switch */
.switch { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  width: 2.1rem; height: 1.15rem;
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: background .18s, border-color .18s;
}
.switch-thumb {
  position: absolute;
  top: 1px; left: 1px;
  width: .95rem; height: .95rem;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform .18s;
}
.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch-track .switch-thumb { transform: translateX(.92rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-text { font-size: .8rem; color: var(--ink-mid); }

/* ---------------------------------------------------------------- stream */

.stream {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2rem 1.5rem 1rem;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  .stream { scroll-behavior: auto; }
}

.intro, #turns { max-width: var(--measure); margin: 0 auto; }

.intro { padding-bottom: 1.5rem; }
.eyebrow {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.intro h2 {
  margin: .45rem 0 .7rem;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.022em;
}
.lede { color: var(--ink-mid); font-size: .95rem; line-height: 1.65; }

.starters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: .5rem;
  margin-top: 1.4rem;
}
.starters button {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .7rem .8rem;
  text-align: left;
  font-size: .85rem;
  line-height: 1.4;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.starters button:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
  .starters button:hover { transform: none; }
}
.starter-kind {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* task picker */
.task-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .5rem;
  margin-top: 1.3rem;
}
.task {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .7rem .8rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.task strong { font-size: .88rem; }
.task span { color: var(--ink-soft); font-size: .76rem; line-height: 1.35; }
.task.is-active { border-color: var(--accent); background: var(--accent-wash); }
.task.is-active strong { color: var(--accent-strong); }

/* ----------------------------------------------------------------- turns */

.turn { padding: 1.6rem 0; border-top: 1px solid var(--line); }
.turn:first-child { border-top: 0; padding-top: .5rem; }

.ask {
  display: flex;
  gap: .7rem;
  margin-bottom: 1.1rem;
}
.ask-mark {
  flex: none;
  width: 1.6rem; height: 1.6rem;
  display: grid;
  place-items: center;
  margin-top: .1rem;
  background: var(--ink);
  color: var(--surface);
  border-radius: 50%;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.ask-text {
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.5;
  color: var(--ink);
}

/* thinking */
.thinking { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); font-size: .86rem; }
.thinking-dots { display: inline-flex; gap: .22rem; }
.thinking-dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.25s ease-in-out infinite;
}
.thinking-dots i:nth-child(2) { animation-delay: .16s; }
.thinking-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes pulse {
  0%, 100% { opacity: .25; transform: translateY(0); }
  50%      { opacity: 1;   transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-dots i { animation: none; opacity: .7; }
}

/* verification banner, the product's whole point stated up front */
.verdict {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  margin-bottom: 1rem;
  border: 1px solid;
  border-radius: var(--r-md);
  font-size: .82rem;
}
.verdict svg { width: 1rem; height: 1rem; flex: none; }
.verdict b { font-weight: 600; }
.verdict.is-good { background: var(--good-wash); border-color: var(--good-line); color: var(--good); }
.verdict.is-warn { background: var(--warn-wash); border-color: var(--warn-line); color: var(--warn); }
.verdict.is-flat { background: var(--surface-2); border-color: var(--line); color: var(--ink-soft); }
.verdict .verdict-note { color: inherit; opacity: .85; }

/* answer prose */
.answer {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.72;
  color: var(--ink);
}
.answer > * + * { margin-top: .9rem; }
.answer h3, .answer h4 {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 1.4rem;
}
.answer strong { font-weight: 500; color: var(--ink); background: var(--accent-wash); padding: 0 .15em; border-radius: 2px; }
.answer em { font-style: italic; }
.answer ul, .answer ol { padding-left: 1.15rem; display: flex; flex-direction: column; gap: .35rem; }
.answer li { list-style: disc; }
.answer ol li { list-style: decimal; }
.answer code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--surface-sunk);
  padding: .1em .35em;
  border-radius: 4px;
}
.answer blockquote {
  margin: 0;
  padding-left: .9rem;
  border-left: 2px solid var(--accent-line);
  color: var(--ink-mid);
  font-style: italic;
}

/* live citation chips */
.cite {
  display: inline-block;
  min-width: 1.55rem;
  padding: .04em .3em;
  margin: 0 .06em;
  font-family: var(--mono);
  font-size: .68em;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  vertical-align: .12em;
  border: 1px solid var(--good-line);
  background: var(--good-wash);
  color: var(--good);
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.cite:hover { transform: translateY(-1px); background: var(--good); color: var(--surface); }
.cite.is-unverified {
  border-color: var(--warn-line);
  background: var(--warn-wash);
  color: var(--warn);
}
.cite.is-unverified:hover { background: var(--warn); color: var(--surface); }
@media (prefers-reduced-motion: reduce) { .cite:hover { transform: none; } }

/* key points */
.points {
  margin-top: 1.2rem;
  padding: .85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
}
.points h4 {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .45rem;
}
.points ul { display: flex; flex-direction: column; gap: .3rem; }
.points li {
  list-style: none;
  position: relative;
  padding-left: .95rem;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--ink-mid);
}
.points li::before {
  content: "";
  position: absolute;
  left: 0; top: .6em;
  width: .3rem; height: .3rem;
  border-radius: 50%;
  background: var(--accent);
}

/* caveats */
.caveats { margin-top: 1rem; }
.caveats h4 {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .35rem;
}
.caveats li {
  list-style: none;
  position: relative;
  padding-left: .95rem;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.caveats li::before {
  content: "";
  position: absolute;
  left: .1rem; top: .55em;
  width: .35rem; height: .35rem;
  border: 1px solid var(--warn);
  border-radius: 1px;
  transform: rotate(45deg);
}

/* notice */
.notice {
  margin-bottom: 1rem;
  padding: .7rem .85rem;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  font-size: .84rem;
  line-height: 1.5;
  color: var(--ink-mid);
}
.notice b { color: var(--accent-strong); }

/* ---------------------------------------------------------------- sources */

.sources { margin-top: 1.4rem; }

.sources-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .5rem 0;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.sources-head:hover { color: var(--ink); }
.sources-head .caret { transition: transform .18s; }
.sources-head[aria-expanded="true"] .caret { transform: rotate(90deg); }
.sources-head svg { width: .7rem; height: .7rem; }
.sources-head .count {
  margin-left: auto;
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-faint);
}

.source-list { display: flex; flex-direction: column; gap: .5rem; padding-top: .5rem; }

.source {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  scroll-margin-top: 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.source.is-cited { border-left: 3px solid var(--good); }
.source.is-upload { border-left: 3px solid var(--accent); }
.source.is-flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.source-top {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .6rem .75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.source-tag {
  flex: none;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  padding: .12rem .35rem;
  background: var(--surface-sunk);
  border-radius: 4px;
  color: var(--ink-mid);
}
.source.is-cited .source-tag { background: var(--good-wash); color: var(--good); }
.source-id { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.source-title {
  font-size: .84rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.source-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .55rem;
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--ink-faint);
}
.source-sub .kind {
  font-family: var(--sans);
  font-size: .62rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: .05rem .3rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.source-sub a { color: var(--accent); }

.source-body {
  padding: .7rem .8rem;
  font-family: var(--serif);
  font-size: .87rem;
  line-height: 1.6;
  color: var(--ink-mid);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 12rem;
  overflow-y: auto;
}
.source-body mark {
  background: var(--accent-wash);
  color: var(--ink);
  box-shadow: inset 0 -1px 0 var(--accent);
  border-radius: 2px;
}

.source-foot {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .8rem;
  border-top: 1px dashed var(--line);
  font-size: .72rem;
  color: var(--ink-faint);
}
.source-foot .quote {
  font-family: var(--serif);
  font-style: italic;
  color: var(--good);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-foot.is-unverified .quote { color: var(--warn); }

/* meta line */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .8rem;
  margin-top: 1rem;
  padding-top: .6rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-faint);
}
.meta b { font-weight: 500; color: var(--ink-soft); }
.meta .sep { color: var(--line-strong); }

/* ---------------------------------------------------------------- outcome */

.outcome-stat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .3rem 1.1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  margin-bottom: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.outcome-figure {
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.outcome-figure sup { font-size: .42em; vertical-align: .85em; margin-left: .05em; color: var(--ink-soft); }
.outcome-caption { color: var(--ink-soft); font-size: .8rem; line-height: 1.4; }

.split {
  grid-column: 1 / -1;
  margin-top: .6rem;
}
.split-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-sunk);
}
.split-bar i { display: block; height: 100%; }
.split-bar .fav { background: var(--good); }
.split-bar .unf { background: var(--bad); }
.split-key {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1rem;
  margin-top: .45rem;
  font-size: .76rem;
  color: var(--ink-soft);
}
.split-key span { display: inline-flex; align-items: center; gap: .35rem; }
.split-key i { width: 7px; height: 7px; border-radius: 2px; }
.split-key b { color: var(--ink-mid); font-variant-numeric: tabular-nums; }

.factors { margin-top: 1.2rem; }
.factors h4 {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .5rem;
}
.factors ol { display: flex; flex-direction: column; gap: .4rem; counter-reset: f; }
.factors li {
  list-style: none;
  counter-increment: f;
  display: flex;
  gap: .6rem;
  font-size: .89rem;
  line-height: 1.55;
  color: var(--ink-mid);
}
.factors li::before {
  content: counter(f, decimal-leading-zero);
  flex: none;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--accent);
  padding-top: .15em;
}

.case-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.case-top {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.case-title { font-size: .84rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verdict-tag {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .12rem .45rem;
  border-radius: 999px;
  border: 1px solid;
  font-size: .68rem;
  font-weight: 600;
  white-space: nowrap;
}
.verdict-tag.fav { background: var(--good-wash); border-color: var(--good-line); color: var(--good); }
.verdict-tag.unf { background: var(--bad-wash); border-color: var(--bad); color: var(--bad); }
.verdict-tag.unk { background: var(--surface-sunk); border-color: var(--line-strong); color: var(--ink-faint); }
.case-body {
  padding: .65rem .8rem;
  font-family: var(--serif);
  font-size: .84rem;
  line-height: 1.6;
  color: var(--ink-mid);
  max-height: 9rem;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- composer */

.composer-wrap {
  padding: .75rem 1.5rem 1rem;
  background: linear-gradient(to top, var(--ground) 65%, transparent);
}
.composer {
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); }

.composer-context {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .55rem .75rem 0;
}
.ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .45rem;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  font-size: .7rem;
  color: var(--accent-strong);
}
.ctx-chip svg { width: .7rem; height: .7rem; }

.composer-row { display: flex; align-items: flex-end; gap: .5rem; padding: .6rem .6rem .6rem .9rem; }
#input {
  flex: 1;
  min-width: 0;
  max-height: 11rem;
  padding: .25rem 0;
  background: transparent;
  border: 0;
  resize: none;
  font-size: .95rem;
  line-height: 1.55;
}
#input:focus { outline: none; }
#input::placeholder { color: var(--ink-faint); }

.send {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
:root[data-theme="dark"] .send { color: #17120A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .send { color: #17120A; }
}
.send:hover:not(:disabled) { background: var(--accent-strong); }
.send:disabled { opacity: .4; cursor: not-allowed; }
.send svg { width: 1.05rem; height: 1.05rem; }

.composer-foot {
  padding: 0 .9rem .55rem;
  font-size: .7rem;
  color: var(--ink-faint);
}
.disclaimer {
  max-width: var(--measure);
  margin: .6rem auto 0;
  font-size: .7rem;
  line-height: 1.45;
  color: var(--ink-faint);
  text-align: center;
}

/* --------------------------------------------------------------- drawer */

.drawer-scrim, .rail-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 14, 22, .45);
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: 0; right: 0;
  z-index: 70;
  width: min(25rem, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
}
.drawer.is-open { transform: none; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: 1.6rem; }
.drawer-section { display: flex; flex-direction: column; gap: .55rem; }
.drawer-section h3 {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.drawer-note { font-size: .8rem; line-height: 1.5; color: var(--ink-soft); }

.provider-list { display: flex; flex-direction: column; gap: .35rem; }
.provider-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  list-style: none;
}
.provider-row .pv-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.provider-row .pv-name { font-size: .85rem; font-weight: 600; }
.provider-row .pv-model {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pv-state {
  margin-left: auto;
  flex: none;
  padding: .1rem .45rem;
  border-radius: 999px;
  border: 1px solid;
  font-size: .66rem;
  font-weight: 600;
}
.pv-state.on { background: var(--good-wash); border-color: var(--good-line); color: var(--good); }
.pv-state.off { background: var(--surface-sunk); border-color: var(--line-strong); color: var(--ink-faint); }

.key-field { display: flex; gap: .4rem; }
.key-field input {
  flex: 1;
  min-width: 0;
  padding: .5rem .6rem;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: .8rem;
}
.solid-btn {
  padding: .5rem .85rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
}
:root[data-theme="dark"] .solid-btn { color: #17120A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .solid-btn { color: #17120A; }
}
.solid-btn:hover { background: var(--accent-strong); }
.key-status { font-size: .76rem; color: var(--ink-soft); min-height: 1em; }
.key-status.is-good { color: var(--good); }
.link-btn {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-size: .78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.range-field { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; color: var(--ink-mid); }
.range-field span { display: flex; justify-content: space-between; }
.range-field output { font-family: var(--mono); color: var(--accent); }
.range-field input[type="range"] { accent-color: var(--accent); }

.check-field { display: flex; gap: .55rem; align-items: flex-start; cursor: pointer; }
.check-field input { margin-top: .25rem; accent-color: var(--accent); }
.check-field span { display: flex; flex-direction: column; gap: .1rem; }
.check-field strong { font-size: .84rem; font-weight: 600; }
.check-field small { font-size: .74rem; line-height: 1.45; color: var(--ink-soft); }

.how-list { display: flex; flex-direction: column; gap: .5rem; padding-left: 1.1rem; }
.how-list li { font-size: .82rem; line-height: 1.5; color: var(--ink-soft); }
.how-list strong { color: var(--ink-mid); }

/* --------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  bottom: 1rem; left: 50%;
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  pointer-events: none;
}
.toast {
  padding: .6rem .9rem;
  background: var(--ink);
  color: var(--ground);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: .82rem;
  max-width: 24rem;
  animation: rise .22s ease-out;
}
.toast.is-bad { background: var(--bad); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ------------------------------------------------------------ responsive */

@media (max-width: 60rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed;
    top: 0; left: 0;
    z-index: 65;
    width: min(19rem, 86vw);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    box-shadow: var(--shadow-lg);
  }
  .rail.is-open { transform: none; }
  .rail-close, .rail-open { display: grid; }
  .topbar { padding-inline: 1rem; }
  .stream { padding-inline: 1rem; }
  .composer-wrap { padding-inline: 1rem; }
  .theme-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
}

@media (max-width: 34rem) {
  .topbar-title p { display: none; }
  .switch-text { display: none; }
  .starters { grid-template-columns: 1fr; }
  .outcome-stat { grid-template-columns: 1fr; }
}

@media print {
  .rail, .topbar, .composer-wrap, .drawer, .toasts, .sources-head { display: none !important; }
  .stream { overflow: visible; padding: 0; }
  body { background: #fff; }
}
