/* The case browser. Same palette and type as the checker page, so the two
   read as one tool. A case page is one reading column: the message, what the
   system is given, the simulated person, then the reference answer. Tier
   colours follow the bands: severe, moderate, mild. */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #18202b;
  --muted: #586474;
  --line: #d8dee7;
  --accent: #1f3864;
  --accent-ink: #ffffff;
  --accent-soft: #e3ebf7;
  --err: #a8261d;
  --err-bg: #fbe9e6;
  --warn: #7d5200;
  --warn-bg: #fff3d1;
  --note: #45556a;
  --note-bg: #e9edf3;
  --ok: #1b6537;
  --ok-bg: #e2f2e7;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-code: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.3125rem;
  --step-3: 1.75rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10151c;
    --surface: #171e27;
    --ink: #e6ebf2;
    --muted: #9ba8b7;
    --line: #2b3542;
    --accent: #a9c1ec;
    --accent-ink: #10151c;
    --accent-soft: #1d293b;
    --err: #ff9d92;
    --err-bg: #3a1b19;
    --warn: #f1c768;
    --warn-bg: #382c0f;
    --note: #aab8c9;
    --note-bg: #1f2833;
    --ok: #82d49d;
    --ok-bg: #14301f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-text); font-size: var(--step-0); line-height: 1.5; }
h1, h2, h3, p, ul, ol, dl, dd, table, figure, blockquote { margin: 0; }
h1 { font-size: var(--step-3); line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: var(--step-2); line-height: 1.25; text-wrap: balance; }
h3 { font-size: var(--step-0); }
a { color: var(--accent); }
.code { font-family: var(--font-code); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.spread { justify-content: space-between; }

/* top bar */
.bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-inner { max-width: 76rem; margin: 0 auto; padding: 0.6rem max(16px, env(safe-area-inset-right, 0px)) 0.6rem max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.5rem; }
.brand { font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0.15rem; flex: 1 1 auto; }
.nav a { text-decoration: none; color: var(--muted); padding: 0.3rem 0.65rem; border-radius: 4px; font-weight: 500; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a:hover { color: var(--ink); }
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: var(--step--1); color: var(--muted); }
.page { max-width: 76rem; margin: 0 auto; padding-block: 1.5rem 4rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 1.25rem; }
.page.narrow { max-width: 58rem; }
.page.tiny { max-width: 26rem; padding-top: 4rem; }

/* controls */
.button { display: inline-flex; align-items: center; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 4px; padding: 0.45rem 0.9rem; cursor: pointer; text-decoration: none; }
.button.quiet { background: transparent; color: var(--accent); border-color: var(--line); font-weight: 500; }
.button.small { padding: 0.25rem 0.6rem; font-size: var(--step--1); }
.button.danger { background: transparent; color: var(--err); border-color: var(--err); }
.button:disabled { opacity: 0.5; cursor: default; }
.button:not(:disabled):hover { filter: brightness(1.08); }
.button.quiet:not(:disabled):hover { border-color: var(--accent); filter: none; }
label.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--step--1); color: var(--muted); font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.45rem 0.6rem; min-width: 0; }
textarea { width: 100%; min-height: 5rem; resize: vertical; line-height: 1.45; }
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.filters .field { flex: 0 1 11rem; }
.filters .field.grow { flex: 1 1 14rem; }
.filters select, .filters input { width: 100%; }
.check { display: flex; align-items: center; gap: 0.4rem; font-size: var(--step--1); color: var(--muted); padding-bottom: 0.5rem; flex: 0 0 auto; white-space: nowrap; }
.banner { border-left: 5px solid var(--warn); }
.message { border-radius: 6px; padding: 0.7rem 0.9rem; }
.message.error { background: var(--err-bg); color: var(--err); font-weight: 500; }
.message.ok { background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.message.info { background: var(--note-bg); color: var(--note); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.card.pad { padding: 1rem 1.15rem; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.45rem 0.75rem; vertical-align: top; }
thead th { font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--bg); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; white-space: nowrap; }
tbody tr + tr td { border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--accent-soft); }
tr.link a { text-decoration: none; font-family: var(--font-code); font-weight: 600; }
td.opening { min-width: 18rem; max-width: 34rem; color: var(--ink); }

/* pills and chips */
.pill { display: inline-block; font-size: 0.75rem; border-radius: 999px; padding: 0.1rem 0.55rem; background: var(--note-bg); color: var(--note); font-weight: 600; white-space: nowrap; }
.pill.submitted { background: var(--accent-soft); color: var(--accent); }
.pill.confirmed { background: var(--ok-bg); color: var(--ok); }
.pill.returned { background: var(--warn-bg); color: var(--warn); }
.pill.rejected { background: var(--err-bg); color: var(--err); }
.chip { display: inline-block; font-size: var(--step--1); border: 1px solid var(--line); border-radius: 4px; padding: 0.05rem 0.45rem; background: var(--surface); white-space: nowrap; }
.chip.flag { font-family: var(--font-code); border-color: var(--err); color: var(--err); background: var(--err-bg); }
.tier { display: inline-block; font-family: var(--font-code); font-weight: 700; font-size: var(--step--1); border-radius: 4px; padding: 0.05rem 0.4rem; }
.tier.S { background: var(--err-bg); color: var(--err); }
.tier.M { background: var(--warn-bg); color: var(--warn); }
.tier.L { background: var(--ok-bg); color: var(--ok); }

/* case page */
.case-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; }
.case-head h1 { font-family: var(--font-code); }
.section { display: flex; flex-direction: column; gap: 0.75rem; }
.section > header { display: flex; flex-direction: column; gap: 0.1rem; }
.section > header p { color: var(--muted); font-size: var(--step--1); }
.spoken { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 6px; padding: 0.9rem 1.1rem; font-size: var(--step-1); line-height: 1.55; max-width: 44rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts-grid { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0; }
.facts-grid dt { color: var(--muted); font-size: var(--step--1); padding: 0.5rem 0.9rem; border-top: 1px solid var(--line); }
.facts-grid dd { padding: 0.5rem 0.9rem 0.5rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
.facts-grid dt:first-of-type, .facts-grid dd:first-of-type { border-top: 0; }
@media (max-width: 34rem) {
  .facts-grid { grid-template-columns: minmax(0, 1fr); }
  .facts-grid dd { padding: 0 0.9rem 0.5rem; border-top: 0; }
}
.as-said { color: var(--muted); font-style: italic; display: block; padding-top: 0.2rem; }
.decisive { color: var(--err); font-weight: 700; }
.ladder { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; max-width: 34rem; }
.rung { text-align: center; font-family: var(--font-code); font-size: var(--step--1); font-weight: 600; padding: 0.4rem 0; border-radius: 3px; background: var(--note-bg); color: var(--muted); border: 2px solid transparent; }
.rung.in-range.S { background: var(--err-bg); color: var(--err); }
.rung.in-range.M { background: var(--warn-bg); color: var(--warn); }
.rung.in-range.L { background: var(--ok-bg); color: var(--ok); }
.rung.expected { border-color: currentColor; font-weight: 800; }
.keys { display: flex; flex-direction: column; gap: 0.75rem; }
.keys h3 { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; color: var(--muted); }
.keys ul { list-style: none; padding: 0; display: flex; flex-direction: column; }
.keys li { padding: 0.5rem 0.9rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.15rem; }
.keys li:first-child { border-top: 0; }
.source { color: var(--muted); font-size: var(--step--1); }
.timeline { list-style: none; padding: 0; display: flex; flex-direction: column; }
.timeline li { padding: 0.6rem 0.9rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.15rem; }
.timeline li:first-child { border-top: 0; }
.timeline .when { color: var(--muted); font-size: var(--step--1); }
.timeline .said { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.6rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.9rem; display: flex; flex-direction: column; }
.tile strong { font-size: var(--step-2); font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: var(--step--1); }
.findings li { border-left: 4px solid var(--note); }
.findings.error li { border-left-color: var(--err); }
.findings.warning li { border-left-color: var(--warn); }
.linkbox { font-family: var(--font-code); font-size: var(--step--1); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0.5rem 0.6rem; overflow-wrap: anywhere; user-select: all; }
form.stack { gap: 0.8rem; }
