:root {
  --bg: #fbfbfc;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #666b75;
  --line: #e3e5ea;
  --line-soft: #eff0f3;
  --accent: #15603a;
  --accent-soft: #e8f3ec;
  --up: #116b3c;
  --down: #a3252b;
  --warn: #8a5a00;
  --warn-soft: #fdf5e3;
  --chip: #f1f2f5;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --panel: #1b1e24;
    --ink: #e8eaee;
    --muted: #9aa1ad;
    --line: #2b3039;
    --line-soft: #23272e;
    --accent: #5fd196;
    --accent-soft: #1d2b23;
    --up: #5fd196;
    --down: #f2888d;
    --warn: #e5b85c;
    --warn-soft: #2a2415;
    --chip: #23272e;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --panel: #1b1e24; --ink: #e8eaee; --muted: #9aa1ad;
  --line: #2b3039; --line-soft: #23272e; --accent: #5fd196;
  --accent-soft: #1d2b23; --up: #5fd196; --down: #f2888d;
  --warn: #e5b85c; --warn-soft: #2a2415; --chip: #23272e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

/* ---------- chrome ---------- */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 650; letter-spacing: -0.01em; text-decoration: none; font-size: 17px; }
.top nav { display: flex; gap: 2px; margin-right: auto; }
.top nav a {
  padding: 5px 11px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-weight: 500;
}
.top nav a:hover { background: var(--chip); color: var(--ink); }
.top nav a.on { background: var(--accent-soft); color: var(--accent); }
.session { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.session i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.session.open i { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.session.pre_open i { background: var(--warn); }

.banner {
  background: var(--warn-soft); color: var(--warn); text-align: center;
  padding: 9px 16px; font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
footer {
  max-width: 1180px; margin: 0 auto; padding: 0 16px 36px;
  color: var(--muted); font-size: 13px;
}
footer p { margin: 4px 0; }
.muted { color: var(--muted); }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 28px 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600;
     text-transform: uppercase; letter-spacing: 0.04em; }
.sub { color: var(--muted); margin: 0 0 18px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px;
}
.notice { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.advice { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line);
          padding-left: 10px; margin: 0 0 18px; }

/* ---------- stat strip ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; min-width: 112px; flex: 1 1 112px;
}
.stat b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.stat.good b { color: var(--up); }
.stat.bad b { color: var(--down); }

/* ---------- controls ---------- */
.controls { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.control label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.control label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.control input[type=range] { width: 100%; accent-color: var(--accent); }
.toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px;
           padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.toggles label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented a {
  padding: 6px 14px; text-decoration: none; font-size: 14px; color: var(--muted);
  background: var(--panel);
}
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a.on { background: var(--accent); color: #fff; font-weight: 550; }
@media (prefers-color-scheme: dark) { .segmented a.on { color: #0f1a14; } }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; white-space: nowrap;
  position: sticky; top: 0; background: var(--panel); z-index: 1;
}
tbody tr:hover { background: var(--chip); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { font-weight: 500; }
td.name a { text-decoration: none; }
td.name a:hover { text-decoration: underline; }
.tick { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.dim { color: var(--muted); }
.empty { padding: 28px 4px; color: var(--muted); text-align: center; }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 99px; background: var(--chip);
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.chip.thin { background: var(--warn-soft); color: var(--warn); }
.chip.notrade { background: var(--chip); color: var(--muted); font-style: italic; }
.group-head { margin: 22px 0 6px; display: flex; align-items: baseline; gap: 10px; }
.group-head h2 { margin: 0; }
.group-head .count { font-size: 13px; color: var(--muted); }

/* ---------- scorecard ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .big { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; display: block; }
.card .lab { font-size: 12px; color: var(--muted); }
.card .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: 10px 0 2px; }
.bars div { flex: 1; background: var(--accent-soft); border-radius: 2px 2px 0 0; min-height: 2px; }
.bars div.hit { background: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---------- forms ---------- */
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
input[type=text], input[type=search], input[type=number], select {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel); color: var(--ink); min-width: 0;
}
button, .btn {
  font: inherit; font-weight: 550; padding: 7px 14px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #0f1a14; } }
button:hover, .btn:hover { border-color: var(--muted); }
details.fix summary { cursor: pointer; font-size: 13px; color: var(--accent); }
details.fix[open] summary { margin-bottom: 8px; }

@media (max-width: 640px) {
  main { padding: 14px 12px 40px; }
  .top { padding: 9px 12px; gap: 10px; }
  .top nav a { padding: 5px 9px; }
  .session { width: 100%; order: 3; }
  h1 { font-size: 21px; }
  th, td { padding: 7px 8px; }
  .stat b { font-size: 19px; }
  .card .big { font-size: 25px; }
  .hide-sm { display: none; }
}

/* ---------- why it is up, and the case either way ---------- */
.why-row td { padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
/* The panel lives in a cell of a table that scrolls sideways on a phone, so
   without this the prose scrolls away with the columns and is clipped at both
   edges. Sticky pins it to the left of the scrolling area and the max-width
   holds it to the screen. On a wide screen the table does not scroll, nothing
   is pinned, and the max-width never bites. */
.why-row td > details, .why-row td > .why-static {
  position: sticky; left: 0;
  max-width: calc(100vw - 2.5rem);
  box-sizing: border-box;
}
details.why summary {
  cursor: pointer; font-size: 12px; color: var(--accent); padding: 4px 0;
  list-style: none;
}
details.why summary::-webkit-details-marker { display: none; }
details.why summary::before { content: "+ "; font-weight: 600; }
details.why[open] summary::before { content: "- "; }
details.why[open] summary { margin-bottom: 6px; }
.why-summary {
  font-size: 13px; margin: 0 0 10px; max-width: 76ch; line-height: 1.55;
}
.why-cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.why-col {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px;
}
.why-col.for { border-left: 3px solid var(--up); }
.why-col.against { border-left: 3px solid var(--warn); }
.why-col h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 0 0 6px; font-weight: 600;
}
.why-col ul, .why-news { margin: 0; padding-left: 16px; }
.why-col li, .why-news li { font-size: 13px; margin-bottom: 5px; line-height: 1.5; }
.why-col li:last-child, .why-news li:last-child { margin-bottom: 0; }
details.why h4 { margin-top: 12px; }
.why-news li span { display: block; font-size: 11px; }
@media (max-width: 640px) {
  .why-summary, .why-col li, .why-news li { font-size: 12px; }
}

/* ---------- the live record, above the list ---------- */
.record {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px;
}
.record-head { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; }
.record-head h2 { margin: 0; font-size: 16px; }
.record-head .btn { margin-left: auto; font-size: 13px; padding: 5px 11px; }
.notice-inline {
  background: var(--warn-soft); color: var(--warn); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin: 10px 0 0;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ---------- sortable headings ---------- */
th.sortable { padding: 0; }
th.sortable a {
  display: block; padding: 8px 10px; text-decoration: none; color: inherit;
  white-space: nowrap;
}
th.sortable a:hover { background: var(--chip); color: var(--ink); }
th.sortable.on a { color: var(--accent); }
th.sortable .arrow { font-size: 9px; margin-left: 3px; }
.listhead {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 22px 0 4px;
}

/* ---------- The Skeptic ---------- */
.finding {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 14px;
}
.finding.fails { border-left-color: var(--down); }
.finding.survives { border-left-color: var(--up); }
.finding.mixed { border-left-color: var(--warn); }
.finding.context { border-left-color: var(--muted); }
.finding-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.finding-head h2 { margin: 0; font-size: 17px; }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.badge.fails { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.badge.survives { background: var(--accent-soft); color: var(--up); }
.badge.mixed { background: var(--warn-soft); color: var(--warn); }
.badge.context { background: var(--chip); color: var(--muted); }
.finding-headline { font-size: 15px; margin: 8px 0 6px; max-width: 76ch; }
table.numbers { font-size: 13px; max-width: 460px; }
table.numbers td { padding: 4px 10px; border-bottom: 1px solid var(--line-soft); }
table.numbers td:first-child { color: var(--muted); }

/* ---------- the plain language explainer ---------- */
details.howto {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin: 0 0 18px;
}
details.howto summary {
  cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px;
}
details.howto[open] summary { margin-bottom: 8px; }
details.howto p, details.howto li { font-size: 14px; max-width: 76ch; line-height: 1.6; }
details.howto ul { padding-left: 18px; }
details.howto li { margin-bottom: 7px; }
.howto-q {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 12px;
  font-weight: 600; color: var(--ink); margin: 10px 0;
}
