:root {
  --bg: #0E1024;
  --surface: #151833;
  --surface-2: #1C2044;
  --line: #2A2F57;
  --text: #ECEAF6;
  --muted: #9AA0B8;
  --accent: #FFB45E;
  --accent-dim: #8A6436;
  --pass: #74D7A6;
  --fail: #FF8F85;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Figtree", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 16px 64px; }
a { color: var(--accent); }
a:hover { color: var(--text); }
code { font-family: var(--mono); font-size: 0.9em; }
h1, h2, h3 { font-family: "Bricolage Grotesque", "Figtree", sans-serif; line-height: 1.2; }
h1 { font-size: clamp(40px, 8vw, 64px); margin: 24px 0 8px; letter-spacing: -0.02em; font-weight: 700; }
h2 { font-size: 28px; margin: 32px 0 8px; font-weight: 700; }
h3 { font-size: 20px; margin: 32px 0 12px; font-weight: 500; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.topbar a { text-decoration: none; }
.lede { font-size: 20px; max-width: 720px; margin: 0 0 12px; }
.recorded {
  display: inline-block; margin: 0; padding: 4px 12px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; color: var(--muted);
}
.recorded b { color: var(--accent); font-weight: 600; }

.tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 32px 0 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  font: inherit; font-size: 15px; color: var(--muted); background: none; border: 0;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.tabs button:hover { color: var(--text); background: var(--surface); }
.tabs button[aria-selected="true"] { color: var(--bg); background: var(--accent); font-weight: 600; }
.tabs button:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .btnrow button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* bar chart */
.barchart { margin: 16px 0 8px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 112px; gap: 12px; align-items: center; padding: 8px 0; }
.bar-label b { font-family: "Bricolage Grotesque", sans-serif; font-size: 18px; }
.bar-label span { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.bar-track { position: relative; height: 24px; background: var(--surface); border-radius: 4px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-fill.det { background: none; border-right: 2px dashed var(--muted); border-radius: 0; }
.bar-val { font-variant-numeric: tabular-nums; font-size: 15px; }
.bar-val small { color: var(--muted); display: block; font-size: 12px; line-height: 1.3; }
.chart-note { font-size: 13px; color: var(--muted); }
.chart-note i { display: inline-block; width: 16px; height: 0; border-top: 2px dashed var(--muted); vertical-align: middle; margin-right: 4px; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; font-size: 15px; }
.grid th, .grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { font-weight: 600; color: var(--muted); font-size: 13px; }
.grid td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid td .sub { display: block; color: var(--muted); font-size: 13px; }
.minibar { display: block; height: 4px; margin-top: 4px; background: var(--surface-2); border-radius: 2px; width: 96px; }
.minibar i { display: block; height: 4px; background: var(--accent); border-radius: 2px; }
.grid tr.total td { border-top: 2px solid var(--line); font-weight: 600; }

.prose { max-width: 760px; }
.prose li { margin-bottom: 8px; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 12px 0; }
.controls label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; min-width: 0; }
.controls label.grow { flex: 1 1 280px; }
select, textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; max-width: 100%;
}
textarea { width: 100%; font-family: var(--mono); font-size: 14px; line-height: 1.5; resize: vertical; }
.btnrow { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.btnrow button {
  font: inherit; font-size: 14px; color: var(--accent); background: none; border: 1px solid var(--accent-dim);
  border-radius: 8px; padding: 4px 12px; cursor: pointer;
}
.btnrow button:hover { background: var(--surface); color: var(--text); }

.summary { font-size: 17px; }
.summary b { color: var(--accent); }

/* outputs */
details.item { border-top: 1px solid var(--line); padding: 8px 0; }
details.item > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
details.item > summary::-webkit-details-marker { display: none; }
details.item > summary::before { content: "+"; color: var(--accent); font-family: var(--mono); width: 12px; }
details.item[open] > summary::before { content: "-"; }
.cid { font-family: var(--mono); font-size: 14px; color: var(--accent); }
.q { flex: 1 1 320px; }
.why { font-size: 13px; color: var(--muted); width: 100%; padding-left: 24px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.out { background: var(--surface); border-radius: 8px; padding: 12px 16px; min-width: 0; }
.out h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.out pre, .passage {
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; margin: 0; font-family: "Figtree", sans-serif;
  font-size: 15px; line-height: 1.6;
}
.out pre.json { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.cite { color: var(--accent); font-weight: 600; }
.cite.bad { color: var(--fail); text-decoration: underline wavy; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 13px; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.chip.pass::before { content: "\2713"; color: var(--pass); font-weight: 700; }
.chip.fail::before { content: "\2717"; color: var(--fail); font-weight: 700; }
.chip.info { opacity: 0.8; }
.chip.unchecked::before { content: "?"; color: var(--accent); font-weight: 700; }
.verdict { margin-top: 12px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.verdict .score { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; }
.tag-pass { color: var(--pass); font-weight: 600; }
.tag-fail { color: var(--fail); font-weight: 600; }
.overall { font-size: 13px; }

.casehead { background: var(--surface); border-radius: 8px; padding: 16px; margin: 12px 0; }
.casehead .q { font-size: 19px; font-family: "Bricolage Grotesque", sans-serif; margin: 0 0 8px; }
.casehead p { margin: 4px 0; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.tags span { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
details.passage-box { border-top: 1px solid var(--line); padding: 8px 0; }
details.passage-box summary { cursor: pointer; font-size: 14px; color: var(--muted); }
details.passage-box .passage { font-size: 14px; color: var(--text); margin-top: 8px; }
details.passage-box .licence { font-size: 13px; color: var(--muted); margin: 8px 0 0; overflow-wrap: anywhere; }
.xtag { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 12px; margin-left: 4px; white-space: nowrap; }
.licence-note { font-size: 13px; margin-top: 12px; }
.stack > .out { margin-bottom: 12px; }

/* judge check */
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 16px 0; }
.stat .big { font-family: "Bricolage Grotesque", sans-serif; font-size: 44px; font-weight: 700; line-height: 1.1; color: var(--accent); }
.stat .lab { font-size: 14px; color: var(--muted); max-width: 220px; }
.split { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 32px; }
table.confusion td.num { font-size: 22px; font-family: "Bricolage Grotesque", sans-serif; }
table.confusion td.hit { color: var(--accent); }
.dis { border-top: 1px solid var(--line); padding: 12px 0; font-size: 15px; }
.dis p { margin: 4px 0; }

/* graders playground */
#tryResults { margin-top: 16px; }
.gres { display: grid; grid-template-columns: 200px 1fr; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.gres .d { color: var(--muted); font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

pre.prompt {
  background: var(--surface); border-radius: 8px; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: 13px; line-height: 1.55; margin: 8px 0 24px;
}

footer { margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

@media (max-width: 720px) {
  .bar-row { grid-template-columns: 1fr 88px; }
  .bar-label { grid-column: 1 / -1; }
  .cols { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .gres { grid-template-columns: 1fr; }
  .grid th, .grid td { padding: 8px 6px; font-size: 14px; }
  .grid td.num { white-space: normal; }
  .grid td.num .muted { display: block; font-size: 12px; }
  .minibar { width: 100%; }
  #graderTable td:first-child { max-width: 132px; }
  h2 { font-size: 24px; }
  .lede { font-size: 18px; }
}
