/* Calm, readable, printable. Colour is never the only carrier of meaning. */
:root {
  --fg: #1d1d1f;
  --muted: #5c5c66;
  --bg: #fbfaf7;
  --panel: #ffffff;
  --line: #d9d6cf;
  --accent: #1f4e79;
  --ok: #1b6e3a;
  --bad: #a1271b;
  --warn: #8a5a00;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  line-height: 1.55;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--sans);
  font-size: 0.9rem;
}
header.site .brand { font-weight: 600; color: var(--fg); text-decoration: none; }
header.site nav { display: flex; gap: 1rem; flex-wrap: wrap; }
header.site .who { margin-left: auto; color: var(--muted); }
header.site form { display: inline; }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h1, h2, h3 { font-family: var(--sans); line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
p.lead { color: var(--muted); max-width: 48rem; }

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--sans); font-weight: 600; font-size: 0.8rem; color: var(--muted); }
td code, .mono { font-family: var(--mono); font-size: 0.85em; }

button, .button, input, select {
  font: inherit;
  font-family: var(--sans);
  font-size: 0.9rem;
}
button, .button {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="email"], input[type="text"], input[type="number"], select, textarea {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.25rem; }
.notice { border-left: 4px solid var(--warn); padding: 0.75rem 1rem; background: #fff8e6; }
.error { border-left: 4px solid var(--bad); padding: 0.75rem 1rem; background: #fdecea; }

/* Status labels always carry a word, not only a colour */
.status { font-family: var(--sans); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.status.ok::before { content: "✓ "; }
.status.bad::before { content: "✗ "; }
.status.warn::before { content: "! "; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.warn { color: var(--warn); }

.check { font-size: 0.85rem; }
.check dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.75rem; margin: 0.4rem 0; }
.check dt { color: var(--muted); font-family: var(--sans); }
.check dd { margin: 0; }
details summary { cursor: pointer; font-family: var(--sans); font-size: 0.85rem; color: var(--accent); }
pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 0.8rem; background: #f4f2ed; padding: 0.5rem; max-height: 24rem; overflow: auto; }

.htmx-request .spinner { display: inline; }
.spinner { display: none; color: var(--muted); font-family: var(--sans); font-size: 0.85rem; }

@media (max-width: 40rem) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  td { border: none; padding: 0.2rem 0; }
  tr { border-bottom: 1px solid var(--line); padding: 0.5rem 0; }
}

@media print {
  header.site, button, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  details > *:not(summary) { display: block; }
}

/* Cases */
nav.tabs { display: flex; gap: 1.25rem; margin: 1.5rem 0 0.75rem; font-family: var(--sans); font-size: 0.9rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.split h3 { font-size: 0.95rem; }
pre.doc { font-family: var(--serif); font-size: 0.9rem; line-height: 1.5; max-height: 70vh; background: var(--panel); border: 1px solid var(--line); padding: 0.75rem 1rem; }
@media (max-width: 60rem) { .split { grid-template-columns: 1fr; } }
@media print { pre.doc { max-height: none; overflow: visible; } }

/* Prompts and orders */
textarea { font-family: var(--mono); font-size: 0.85rem; line-height: 1.45; }
input[type="number"] { width: 6rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1rem; padding: 0.5rem 1rem 0.75rem; background: var(--panel); }
legend { font-family: var(--sans); font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }
label.choice { display: block; font-size: 0.92rem; }
.case-choices { max-height: 24rem; overflow: auto; }
a.button { display: inline-block; text-decoration: none; font-family: var(--sans); }

/* Dashboard (stage 6b): reference palette of the dataviz method, light surface. */
.viz-root { --surface: #fcfcfb; --ink2: #52514e; --grid: #e1e0d9; }
.viz-root .figure { margin-bottom: 2.5rem; }
.viz-root .scroll { overflow-x: auto; }
.viz-root table { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.viz-root .r { text-align: right; }
.viz-root .c { text-align: center; }
.viz-root .nowrap { white-space: nowrap; }
.viz-root .ci { color: var(--ink2); font-family: var(--mono); font-size: 0.85em; }
.viz-root .flag { font-size: 0.7rem; font-weight: 600; color: var(--warn); border: 1px solid var(--warn); border-radius: 3px; padding: 0 0.2rem; }
.viz-root .leader svg { vertical-align: middle; margin-right: 0.4rem; }
.viz-root .tabs { display: flex; gap: 1rem; flex-wrap: wrap; font-family: var(--sans); margin-bottom: 1.5rem; }
.viz-root .tabs a[aria-current] { font-weight: 700; text-decoration: none; border-bottom: 2px solid var(--accent); }
.viz-root table.heat { border-collapse: separate; border-spacing: 2px; background: transparent; }
.viz-root table.heat td { border: 0; border-radius: 4px; padding: 0.6rem 0.4rem; min-width: 4rem; }
.viz-root table.heat td.diag { outline: 2px solid var(--fg); outline-offset: -2px; }
.viz-root table.grid { border-collapse: separate; border-spacing: 2px; background: transparent; width: auto; }
.viz-root table.grid th, .viz-root table.grid td { border: 0; padding: 0.2rem; }
.viz-root td.cell { width: 1.8rem; height: 1.8rem; text-align: center; border-radius: 4px; font-weight: 700; }
.viz-root .legend { font-family: var(--sans); font-size: 0.85rem; display: flex; gap: 0.4rem 1rem; flex-wrap: wrap; align-items: center; }
.viz-root .swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 3px; vertical-align: middle; margin-right: 0.25rem; }
.viz-root .swatch.line { height: 0.2rem; width: 1.2rem; }
.viz-root .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(26rem, 1fr)); gap: 1rem; }
.viz-root .card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.25rem; }
.viz-root .card h3 { margin-top: 0; }
.viz-root .card svg { width: 100%; height: auto; }
.viz-root svg .tick { font: 11px var(--mono); fill: #898781; }
.viz-root svg .label { font: 12px var(--sans); fill: var(--fg); }
.viz-root table.bars td, .viz-root table.bars th { padding: 0.2rem 0.4rem; border-bottom: 0; }

/* Printable case comparison */
.comparison section.answer { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 0.5rem; }
@media print {
  .comparison section.answer { break-before: page; border-top: none; }
  .comparison .split { grid-template-columns: 1fr 1fr; }
  .comparison pre.doc { white-space: pre-wrap; }
}
@media (max-width: 700px) { .comparison .split { grid-template-columns: 1fr; } }
