:root {
  --paper: #edf0f2;
  --ink: #1a2238;
  --muted: #5b6477;
  --line: #c9d0d8;
  --cobalt: #2546d8;
  --amber: #e8a317;
  --danger: #b3261e;
  --surface: #ffffff;
  --surface-sunk: #f4f6f8;
  /* Text on a filled accent button. The dark steps of --cobalt/--danger are
     light, so white on them fails contrast; dark ink is what clears it. */
  --on-accent: #ffffff;

  /* Chart fill. Kept separate from --cobalt so the dark step can sit in the
     dark-surface lightness band without changing the UI blue. */
  --viz: #2546d8;
  --viz-wash: rgba(37, 70, 216, 0.1);
  --grid: #e4e8ec;

  /* Annotation lines. Ordered cool-first so one or two predictions never land
     on a warm hue, which is the pair that blurs against --correct for red-green
     colour blindness. Validated for contrast and CVD separation in both modes. */
  --correct: #008300;
  --series-1: #4a3aa7;
  --series-2: #b0326a;
  --series-3: #eb6834;

  --shadow: 0 1px 2px rgba(26, 34, 56, 0.06), 0 4px 16px rgba(26, 34, 56, 0.06);
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121827;
    --ink: #e6e9f0;
    --muted: #98a1b3;
    --line: #2c3548;
    --cobalt: #7b93ff;
    --amber: #f2bd4b;
    --danger: #ff8a80;
    --surface: #1a2133;
    --surface-sunk: #151b2a;
    --on-accent: #121827;

    --viz: #6182f5;
    --viz-wash: rgba(97, 130, 245, 0.14);
    --grid: #283148;

    --correct: #2ea043;
    --series-1: #9085e9;
    --series-2: #c95f9e;
    --series-3: #d95926;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cobalt); text-underline-offset: 0.18em; }

:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 6rem) 1.5rem 4rem;
}

/* tabular figures for columns that must align (axis ticks, table rows).
   Large standalone numbers use the font's proportional figures instead. */
.num { font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 0.8rem 1.4rem;
  background: var(--cobalt);
  color: var(--on-accent);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.quiet {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
button.quiet:hover:not(:disabled) { background: var(--surface-sunk); filter: none; }

.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* --- histogram (shared by the admin dashboard and the display) ----------- */

.plot { position: relative; }
.plot svg { display: block; width: 100%; }

.bar { fill: var(--viz); }
.grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axis-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.hit { fill: transparent; }
.hit:focus-visible { outline: none; }
.hit:focus-visible + .bar, .col:hover .bar { fill: color-mix(in srgb, var(--viz) 78%, var(--ink)); }
.col:hover .hit, .hit:focus-visible { fill: var(--viz-wash); }

/* The correct answer is thick and solid, predictions thin and dashed: the
   difference in form is what tells them apart, not the hue alone. */
.annot-line { pointer-events: none; }
.annot-correct { stroke: var(--correct); stroke-width: 3; }
.annot-prediction { stroke-width: 2; stroke-dasharray: 7 5; }
/* Drawn under each line in the surface colour, so it reads where it crosses a
   bar. Keeps the dash pattern, so a dashed line stays visibly dashed. */
.annot-halo { stroke: var(--surface) !important; }
.annot-correct.annot-halo { stroke-width: 7; }
.annot-prediction.annot-halo { stroke-width: 6; }
.annot-key { stroke-width: 3; stroke-linecap: round; }
.annot-prediction.annot-key { stroke-dasharray: 5 3; }
.series-1 { stroke: var(--series-1); }
.series-2 { stroke: var(--series-2); }
.series-3 { stroke: var(--series-3); }
/* Labels wear ink, never the line colour — the coloured key beside them carries
   the identity, and a light hue is illegible as text. */
.annot-label text { fill: var(--ink); font-size: 12px; font-weight: 600; }

.hist-tip {
  position: absolute; pointer-events: none; opacity: 0;
  transform: translate(-50%, -115%);
  background: var(--ink); color: var(--paper);
  font-size: 0.85rem; font-weight: 600; line-height: 1.3;
  padding: 0.4rem 0.6rem; border-radius: 8px; white-space: nowrap;
  transition: opacity 0.12s ease;
}
.hist-tip[data-show="true"] { opacity: 1; }
.hist-tip small { display: block; font-weight: 400; opacity: 0.75; }

.hist-empty {
  height: 300px; display: grid; place-items: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
