/* Ishaare dashboards: design system.
   Neutral paper, hairline borders instead of shadows, one accent (blue), semantic good / warn / bad that always travel
   with a word or glyph. Data colour follows the dataviz reference palette: categorical slots 1-3 for X/Y/Z and for the
   four sleep stages (orange, violet, aqua, blue: validated adjacent in both modes), one-hue sequential blue for the
   heatmap (light end recedes into the surface in light mode, into the dark surface in dark mode).
   Scale: 4 / 8 spacing, radius 6 / 8 / 12, type 12 / 13 / 14 / 16 / 20 / 28. System fonts only (CSP: self). */

:root {
  color-scheme: light;
  /* neutral */
  --page: #f8f8f6; --surface: #ffffff; --surface-2: #f3f3f0; --surface-3: #e9e9e4;
  --ink: #141413; --ink-2: #4b4a46; --ink-3: #6b6a64;
  --grid: #e6e5df; --axis: #c9c8bf;
  --border: rgba(20, 20, 19, 0.09); --border-strong: rgba(20, 20, 19, 0.17); --shade: rgba(20, 20, 19, 0.18);
  /* accent and semantic (text tints validated >= 4.5:1 on their own fill) */
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-soft: #e8f0fb;
  --good: #0ca30c; --good-ink: #005f00; --good-soft: #e7f3e7;
  --warning: #fab219; --warn-ink: #7a5200; --warn-soft: #fcf2d6;
  --critical: #d03b3b; --crit-ink: #a12a2a; --crit-soft: #fbe9e9;
  --mask: #d03b3b;
  /* categorical (data series) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  /* sleep stages: lane order W R L D passes the adjacent CVD and normal-vision gates */
  --stage-w: #eb6834; --stage-r: #6250d6; --stage-l: #1baf7a; --stage-d: #2a78d6;
  /* sequential blue, 6 bins above zero (palette steps 100 200 300 500 600 700); text flips at bin 4 */
  --heat-0: #f3f3f0; --heat-1: #cde2fb; --heat-2: #9ec5f4; --heat-3: #6da7ec; --heat-4: #256abf; --heat-5: #184f95; --heat-6: #0d366b;
  --heat-text-lo: #141413; --heat-text-hi: #ffffff;
  /* ramp ends for canvas drawing */
  --heat-lo: #f3f3f0; --heat-hi: #0d366b;
  /* spacing, radius, type */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --radius: 12px; --radius-md: 8px; --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 1280px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e0e0d; --surface: #181817; --surface-2: #222220; --surface-3: #2e2e2b;
    --ink: #f2f1ec; --ink-2: #c6c5bb; --ink-3: #a09e96;
    --grid: #2a2a28; --axis: #3a3a37;
    --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.18); --shade: rgba(255, 255, 255, 0.16);
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #14253b;
    --good: #0ca30c; --good-ink: #7fd67f; --good-soft: #14281a;
    --warn-ink: #f6c453; --warn-soft: #2d2410;
    --crit-ink: #f29a9a; --crit-soft: #331a1a; --mask: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c;
    --stage-w: #d95926; --stage-r: #9085e9; --stage-l: #199e70; --stage-d: #3987e5;
    --heat-0: #222220; --heat-1: #104281; --heat-2: #1c5cab; --heat-3: #256abf; --heat-4: #6da7ec; --heat-5: #9ec5f4; --heat-6: #cde2fb;
    --heat-text-lo: #ffffff; --heat-text-hi: #0b0b0b;
    --heat-lo: #222220; --heat-hi: #cde2fb;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e0e0d; --surface: #181817; --surface-2: #222220; --surface-3: #2e2e2b;
  --ink: #f2f1ec; --ink-2: #c6c5bb; --ink-3: #a09e96;
  --grid: #2a2a28; --axis: #3a3a37;
  --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.18); --shade: rgba(255, 255, 255, 0.16);
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #14253b;
  --good: #0ca30c; --good-ink: #7fd67f; --good-soft: #14281a;
  --warn-ink: #f6c453; --warn-soft: #2d2410;
  --crit-ink: #f29a9a; --crit-soft: #331a1a; --mask: #e66767;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c;
  --stage-w: #d95926; --stage-r: #9085e9; --stage-l: #199e70; --stage-d: #3987e5;
  --heat-0: #222220; --heat-1: #104281; --heat-2: #1c5cab; --heat-3: #256abf; --heat-4: #6da7ec; --heat-5: #9ec5f4; --heat-6: #cde2fb;
  --heat-text-lo: #ffffff; --heat-text-hi: #0b0b0b;
  --heat-lo: #222220; --heat-hi: #cde2fb;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); min-height: 100dvh; overflow-x: hidden;
  -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, dl { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.022em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 13px; line-height: 1.35; font-weight: 600; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 40; }
.skip:focus { top: 8px; text-decoration: none; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.num, table, .stat__value, .badge, .chip, .seg, .readout { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.small { font-size: 12px; }

/* ------------------------------------------------------------------ top bar: brand, five sections, controls; section menu below */
.topbar { background: var(--page); border-bottom: 1px solid var(--border); }
@media (min-width: 768px) { .topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 94%, transparent); backdrop-filter: blur(8px); } }
/* the sticky top bar (two rows) must not cover a heading that a jump link scrolls to */
@media (min-width: 768px) { html { scroll-padding-top: 112px; } }
.topbar__row { max-width: var(--measure); margin: 0 auto; padding: 0 var(--sp-6); min-height: 56px; display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark { width: 22px; height: 22px; display: block; }
.brand__name { font-weight: 700; letter-spacing: 0.08em; }
.brand__sub { color: var(--ink-3); font-size: 13px; padding-left: 10px; border-left: 1px solid var(--border-strong); }
.tabs { display: flex; gap: var(--sp-1); align-self: stretch; }
.tabs__link { display: inline-flex; align-items: center; padding: 0 var(--sp-3); color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs__link:hover { color: var(--ink); text-decoration: none; }
.tabs__link[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.controls { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
#whoami:empty { display: none; }
/* section menu (js/nav.js): the current section's pages, one quiet row under the top bar; scrolls inside itself on a phone */
.section-nav { border-top: 1px solid var(--border); }
.section-nav:empty { display: none; }
.section-nav__row { max-width: var(--measure); margin: 0 auto; padding: 0 var(--sp-6); }
.section-nav__list { list-style: none; margin: 0; padding: 6px 0; display: flex; align-items: center; gap: var(--sp-1); overflow-x: auto;
  scrollbar-width: none; min-height: 44px; }
.section-nav__list::-webkit-scrollbar { display: none; }
.section-nav__list > li { flex: none; }
.section-nav__link { display: inline-flex; align-items: center; min-height: 30px; padding: 2px var(--sp-3); border-radius: 999px; color: var(--ink-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.section-nav__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.section-nav__link.is-parent { color: var(--ink); border-color: var(--border-strong); }
.section-nav__link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn--primary:hover { background: var(--ink-2); }
.btn--small { min-height: 26px; padding: 2px 8px; font-size: 12px; border-radius: var(--radius-sm); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ------------------------------------------------------------------ layout: title, one-line subtitle, content */
.main { --main-gap: var(--sp-5); max-width: var(--measure); margin: 0 auto; padding: var(--sp-5) var(--sp-6) var(--sp-7); display: flex; flex-direction: column;
  gap: var(--main-gap); }
.main:focus { outline: none; }
@media (max-width: 700px) {
  .topbar__row { padding: var(--sp-2) var(--sp-4); gap: var(--sp-2) var(--sp-4); }
  /* phone: the five sections wrap onto two short rows, so every section stays visible (no hidden scroll) */
  .tabs { order: 3; width: calc(100% + var(--sp-4) * 2); margin: 0 calc(var(--sp-4) * -1); padding: 0 var(--sp-2); flex-wrap: wrap; column-gap: 0;
    border-top: 1px solid var(--border); }
  .tabs__link { flex: none; white-space: nowrap; min-height: 40px; padding: 0 var(--sp-2); margin-bottom: 0; }
  .section-nav__row { padding: 0 var(--sp-4); }
  .main { --main-gap: var(--sp-4); padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .brand__sub { display: none; }
  h1 { font-size: 22px; }
}
/* page head: the title and one short line; breadcrumbs sit tight above it, "On this page" tight below it */
.page-head { display: flex; flex-direction: column; gap: var(--sp-1); }
.page-head h1 { font-size: 26px; }
@media (max-width: 700px) { .page-head h1 { font-size: 22px; } }
.page-head__title { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.page-head__sub { color: var(--ink-2); font-size: 14px; max-width: 72ch; }
.crumbs { font-size: 13px; color: var(--ink-3); min-width: 0; }
.crumbs__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.crumbs__item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.crumbs__item + .crumbs__item::before { content: "\203A"; content: "\203A" / ""; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); }
.crumbs [aria-current="page"] { color: var(--ink-3); }
.crumbs + .page-head { margin-top: calc(var(--sp-2) - var(--main-gap, var(--sp-5))); }
.on-this-page { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); font-size: 13px; }
.page-head + .on-this-page { margin-top: calc(var(--sp-2) - var(--main-gap, var(--sp-5))); }
.on-this-page__label { color: var(--ink-3); font-weight: 500; }
.on-this-page__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); }
.on-this-page__link { background: none; border: 0; padding: 2px 0; color: var(--accent-ink); cursor: pointer; font: inherit; text-align: left; }
.on-this-page__link:hover { text-decoration: underline; text-underline-offset: 2px; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.panel__title { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.panel__sub { color: var(--ink-3); font-size: 13px; margin-top: calc(var(--sp-3) * -1); }
.panel--flat { background: transparent; border-color: transparent; padding: 0; }
@media (max-width: 700px) { .panel { padding: var(--sp-4); border-radius: var(--radius-md); } }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); align-items: start; }
.note { font-size: 13px; color: var(--ink-2); max-width: 90ch; }
.notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--sp-5); font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 0; } .kv dd { margin-bottom: var(--sp-2); } }
ul, ol { padding-left: 18px; }

/* ------------------------------------------------------------------ notices, states, i-notes, how to read this */
.callout, .notice { display: flex; min-width: 0; overflow-wrap: anywhere; gap: var(--sp-2); align-items: baseline; padding: 8px 12px; border-radius: var(--radius-md); font-size: 13px; color: var(--ink);
  background: var(--warn-soft); border: 1px solid transparent; }
.callout > ul { margin: 0; }
.callout--info, .notice--info { background: var(--accent-soft); }
.callout--crit, .notice--bad { background: var(--crit-soft); }
.notice__mark { flex: none; font-weight: 700; color: var(--warn-ink); }
.notice--info .notice__mark { color: var(--accent-ink); }
.notice--bad .notice__mark { color: var(--crit-ink); }
.state { padding: var(--sp-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.state--error { background: var(--crit-soft); color: var(--ink); }
.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-strong);
  color: var(--ink-3); font: 600 10px/1 var(--font); cursor: help; vertical-align: middle; background: transparent; padding: 0; }
.info:hover { color: var(--ink); border-color: var(--ink-3); }
details { font-size: 13px; }
details > summary { cursor: pointer; color: var(--ink-2); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--ink); }
details[open] > summary { margin-bottom: var(--sp-3); }
.howto { border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.howto > summary { color: var(--ink); font-weight: 600; font-size: 14px; }
.howto__body { display: flex; flex-direction: column; gap: var(--sp-2); color: var(--ink-2); max-width: 90ch; }

/* ------------------------------------------------------------------ badges (tinted pills; warn and bad carry a glyph) */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; padding: 3px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; border: 1px solid transparent; }
.badge--info { background: var(--accent-soft); color: var(--accent-ink); }
.badge--good { background: var(--good-soft); color: var(--good-ink); }
.badge--warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge--bad { background: var(--crit-soft); color: var(--crit-ink); }
.badge--provisional { background: transparent; border: 1px dashed var(--warning); color: var(--warn-ink); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
.badge--warn::before, .badge--provisional::before { content: "!"; font-weight: 800; }
.badge--bad::before { content: "\00d7"; font-weight: 800; }
.badge--good::before { content: "\2713"; font-weight: 800; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ------------------------------------------------------------------ controls: fields, segmented switch, chips */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4); align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); min-width: 0; font-weight: 500; }
.field select, .field input { min-height: 34px; padding: 4px 28px 4px 10px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-size: 13px; max-width: 100%; }
.field select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.field select:hover { border-color: var(--ink-3); }
.field--grow { flex: 1 1 260px; }
@media (max-width: 700px) { .filters .field { flex: 1 1 140px; } .filters .field--grow { flex-basis: 100%; } }
.seg { display: inline-flex; padding: 2px; background: var(--surface-2); border-radius: var(--radius-md); border: 1px solid var(--border); gap: 2px; }
.seg__btn { min-height: 28px; padding: 2px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2);
  cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: var(--border-strong); font-weight: 600; }
.seg-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scope { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; }
.controls-bar { display: flex; flex-direction: column; gap: var(--sp-3); }
.controls-bar__row { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); align-items: flex-end; }
.more > summary { color: var(--ink-3); }
.more[open] > summary { margin-bottom: var(--sp-3); }

/* ------------------------------------------------------------------ headline stats */
.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: var(--sp-5) var(--sp-4); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat__label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat__value { font-size: 30px; font-weight: 650; line-height: 1.1; letter-spacing: -0.02em; }
.stat__ci { font-size: 12px; color: var(--ink-3); }
.refline { font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px var(--sp-5); border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.refline b { font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data thead th { background: var(--surface-2); font-weight: 500; font-size: 12px; color: var(--ink-3); white-space: nowrap; position: sticky; top: 0; }
table.data tbody th { font-weight: 600; text-align: left; }
table.data td.r, table.data th.r { text-align: right; }
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data caption { text-align: left; padding: 8px 12px; color: var(--ink-3); font-size: 12px; caption-side: bottom; border-top: 1px solid var(--border); }
table.data tr.row--link { cursor: pointer; }
table.data tr.row--head > * { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.ci { color: var(--ink-3); font-size: 11px; display: block; font-weight: 400; }
.conf-list { display: flex; flex-direction: column; gap: 1px; font-size: 12px; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-right: 8px; min-width: 2px; }
.rank { color: var(--ink-3); font-weight: 600; width: 36px; }

/* ------------------------------------------------------------------ charts */
.chart { position: relative; width: 100%; min-width: 0; }
.chart canvas { display: block; touch-action: pan-y; }
.chart:focus-visible { outline-offset: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: 12px; color: var(--ink-2); align-items: center; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend__swatch--line { height: 3px; border-radius: 2px; }
.readout { font-size: 13px; min-height: 1.5em; color: var(--ink-2); }
.track-label { font-size: 12px; color: var(--ink-2); font-weight: 500; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.tracks { display: flex; flex-direction: column; gap: var(--sp-3); }
.twobytwo { border-collapse: separate; border-spacing: 3px; max-width: 460px; width: 100%; table-layout: fixed; }
.twobytwo td, .twobytwo th { padding: 10px 12px; font-size: 12px; text-align: left; vertical-align: middle; }
.twobytwo td.corner { background: none; padding: 0; }
.twobytwo td { background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; color: var(--ink-2); }
.twobytwo th { color: var(--ink-3); font-weight: 500; }
.twobytwo td strong { display: block; font-size: 22px; color: var(--ink); font-weight: 650; letter-spacing: -0.01em; }
.twobytwo td.hit { background: var(--accent-soft); }
.twobytwo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); }
.twobytwo-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.twobytwo--small td, .twobytwo--small th { padding: 6px 8px; font-size: 11px; }
.twobytwo--small td.corner { padding: 0; }
.twobytwo--small td { min-width: 0; }
.twobytwo--small td strong { font-size: 16px; }
.u-legend { font-size: 12px; color: var(--ink-2); }
.u-idle .u-value, .u-idle .u-series:first-child { display: none; }
.u-idle .u-label::after, .u-idle .u-legend th::after { content: none; }   /* vendor rule .u-inline.u-live th::after adds the colon */
.kv + .tracks { margin-top: var(--sp-4); }
.uplot { font-family: var(--font); }

/* ------------------------------------------------------------------ identified-as matrix (HTML table: sticky headers, keyboard) */
.matrix-scroll { overflow: auto; max-width: 100%; max-height: min(86vh, 960px); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table.matrix { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; min-width: calc(var(--k, 22) * 36px + 218px);
  font-size: 12px; line-height: 1; }
table.matrix th, table.matrix td { padding: 0; text-align: center; }
table.matrix col.c-fam { width: 26px; }
table.matrix col.c-row { width: 134px; }
table.matrix col.c-tot { width: 58px; }
table.matrix td.cell { height: 32px; position: relative; cursor: default; color: var(--heat-text-lo); background: var(--heat-0);
  border-right: 1px solid var(--surface); border-bottom: 1px solid var(--surface); }
table.matrix td.cell.interactive { cursor: pointer; }
table.matrix td.cell[data-h="1"] { background: var(--heat-1); } table.matrix td.cell[data-h="2"] { background: var(--heat-2); }
table.matrix td.cell[data-h="3"] { background: var(--heat-3); } table.matrix td.cell[data-h="4"] { background: var(--heat-4); }
table.matrix td.cell[data-h="5"] { background: var(--heat-5); } table.matrix td.cell[data-h="6"] { background: var(--heat-6); }
table.matrix td.cell[data-h="0"] { color: var(--ink-3); background: var(--heat-0); }
table.matrix td.cell[data-ink="hi"] { color: var(--heat-text-hi); }
table.matrix td.cell.diag { font-weight: 700; box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--ink); }
table.matrix td.cell.empty-row { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
/* hover and keyboard focus: an accent ring OUTSIDE the cell with a surface gap, so it never reads as the double ink ring
   of a correct (diagonal) cell and stays visible on every heat shade in both modes */
table.matrix td.cell:hover { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 2px var(--surface); z-index: 3; }
table.matrix td.cell.diag:hover { box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--ink), 0 0 0 2px var(--surface); }
table.matrix td.cell:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 2px var(--surface); border-radius: 0; z-index: 3; }
table.matrix td.cell.diag:focus-visible { box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--ink), 0 0 0 2px var(--surface); }
table.matrix td.cell.fam-edge { border-left: 2px solid var(--surface-3); }
table.matrix tr.fam-top td.cell { border-top: 2px solid var(--surface-3); }
table.matrix thead th { position: sticky; background: var(--surface); z-index: 5; font-weight: 500; color: var(--ink-2); }
table.matrix thead tr.fam-row th { top: 0; height: 30px; padding: 0 2px; font-size: 11px; line-height: 1.15; color: var(--ink-3); border-bottom: 1px solid var(--border); border-left: 2px solid var(--surface-3); font-weight: 600; overflow: hidden; overflow-wrap: anywhere; }
table.matrix thead tr.col-row th { top: 30px; height: 112px; vertical-align: bottom; padding-bottom: 6px; border-bottom: 1px solid var(--border-strong); }
table.matrix.no-fam thead tr.col-row th { top: 0; height: auto; padding: 8px 2px; vertical-align: bottom; }
table.matrix.no-fam thead th.col-head span { writing-mode: horizontal-tb; transform: none; white-space: normal; max-height: none; overflow-wrap: anywhere; line-height: 1.2; }
table.matrix.no-fam { min-width: calc(var(--k, 6) * 64px + 190px); }
table.matrix thead th.fam-single { font-size: 9px; letter-spacing: 0; padding: 0; overflow: hidden; white-space: nowrap; }
table.matrix th.fam-col.fam-single { font-size: 9px; letter-spacing: 0; }
table.matrix thead th.col-head span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 104px; overflow: hidden; text-overflow: ellipsis; }
table.matrix thead th.col-head.fam-edge { border-left: 2px solid var(--surface-3); }
table.matrix thead th.corner { left: 0; z-index: 7; text-align: left; vertical-align: bottom; padding: 0 10px 6px; font-size: 10px; color: var(--ink-3); line-height: 1.4; border-bottom: 1px solid var(--border-strong);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
table.matrix thead tr.fam-row th.corner { border-left: 0; }
table.matrix th.fam-col { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--border); border-top: 2px solid var(--surface-3); width: 26px; font-size: 10px; color: var(--ink-3);
  font-weight: 600; line-height: 1.1; }
table.matrix th.fam-col span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: normal; text-align: center; overflow: hidden; }
table.matrix th.row-head { position: sticky; left: 26px; z-index: 4; background: var(--surface); text-align: left; padding: 0 10px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; width: 134px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--surface); }
table.matrix th.row-head .few { color: var(--warn-ink); font-weight: 700; margin-left: 4px; cursor: help; }
table.matrix tr.fam-top th.row-head { border-top: 2px solid var(--surface-3); }
table.matrix th.row-total, table.matrix td.row-total { width: 58px; color: var(--ink-3); font-size: 11px; background: var(--surface); border-bottom: 1px solid var(--surface); border-left: 1px solid var(--border); }
table.matrix tr.fam-top th.row-total, table.matrix tr.fam-top td.row-total { border-top: 2px solid var(--surface-3); }
table.matrix tfoot td, table.matrix tfoot th { height: 28px; font-size: 11px; color: var(--ink-3); background: var(--surface); border-top: 1px solid var(--border-strong); position: sticky; bottom: 0; z-index: 4; }
table.matrix tfoot th { text-align: left; padding: 0 10px; left: 0; z-index: 6; }
table.matrix .is-hot { color: var(--ink); background: var(--surface-3); font-weight: 700; }
table.matrix th.row-head.is-hot { box-shadow: inset 3px 0 0 var(--ink); }
table.matrix thead th.is-hot { background: var(--surface-3); box-shadow: inset 0 -3px 0 var(--ink); }
@media (min-width: 768px) { .matrix-scroll { max-height: none; } }
@media (max-width: 700px) {
  table.matrix { min-width: calc(var(--k, 22) * 34px + 188px); }
  table.matrix col.c-row { width: 104px; }
  table.matrix th.row-head { width: 104px; padding: 0 6px; }
  .matrix-scroll { max-height: 80vh; }
}
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); font-size: 12px; color: var(--ink-2); }
.heat-legend__ramp { display: inline-flex; gap: 2px; align-items: center; }
.heat-legend__ramp i { display: inline-block; width: 22px; height: 12px; border-radius: 2px; }
.heat-legend__ramp i[data-h="0"] { background: var(--heat-0); box-shadow: inset 0 0 0 1px var(--border); }
.heat-legend__ramp i[data-h="1"] { background: var(--heat-1); } .heat-legend__ramp i[data-h="2"] { background: var(--heat-2); }
.heat-legend__ramp i[data-h="3"] { background: var(--heat-3); } .heat-legend__ramp i[data-h="4"] { background: var(--heat-4); }
.heat-legend__ramp i[data-h="5"] { background: var(--heat-5); } .heat-legend__ramp i[data-h="6"] { background: var(--heat-6); }
.diag-key { display: inline-block; width: 14px; height: 14px; border-radius: 2px; background: var(--heat-3); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--ink); vertical-align: -3px; margin-right: 4px; }
.heat-legend .few { color: var(--warn-ink); font-weight: 700; }
.matrix-head { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); align-items: flex-end; justify-content: space-between; }

/* ------------------------------------------------------------------ tooltip */
.tip { position: fixed; z-index: 50; max-width: 320px; padding: 6px 10px; font-size: 12px; line-height: 1.4; background: var(--ink); color: var(--surface);
  border-radius: var(--radius-sm); pointer-events: none; white-space: pre-line; }

/* ------------------------------------------------------------------ leaderboard */
.board-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.board-section__head { display: flex; flex-direction: column; gap: 2px; }
.board-section--apart { border: 1px dashed var(--border-strong); background: transparent; }
.cell-dash { color: var(--ink-3); }
.person-ci { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.run-name { font-weight: 600; color: var(--ink); }
.run-code { color: var(--ink-3); font-size: 11px; font-weight: 400; overflow-wrap: anywhere; }
.run-code-line { display: block; margin-top: 1px; }
.run-title__name { color: var(--ink); font-weight: 600; }
.gesture-title__name { color: var(--ink); font-weight: 600; }
.gesture-code { margin-left: 2px; white-space: nowrap; overflow-wrap: normal; }
table.data tbody th a.mono { white-space: nowrap; }                       /* trial ids (b1-28) never break at the hyphen */
@media (max-width: 700px) { .conf-list a, table.data .gesture-name { white-space: nowrap; } }   /* long gesture names: scroll the table, keep rows short */
.gesture-code-line { display: block; margin-top: 1px; line-height: 1.2; }
.class-explain { margin: 0; max-width: 72ch; }
.twobytwo-card h3 .gesture-code { font-weight: 400; }
.chip--run { white-space: normal; align-items: baseline; gap: 6px; }
.chip--run .run-title { overflow-wrap: anywhere; }
select optgroup { font-style: normal; font-weight: 600; }
.only-narrow { display: none; }
.score-main { display: flex; justify-content: flex-end; align-items: center; }
.ci--caveat { color: var(--ink-3); white-space: nowrap; text-align: right; }
table.board .ci { white-space: nowrap; }
.trials--diff { color: var(--warn-ink); font-weight: 600; }
.dagger { margin-left: 2px; font-weight: 700; cursor: help; }
.note--diff { color: var(--warn-ink); }
.night-cell .badges { display: flex; margin-top: 4px; font-weight: 400; }
.provenance { margin-top: var(--sp-2); }
@media (max-width: 700px) {
  .hide-narrow, .sub { display: none; }
  table.data thead th { white-space: normal; min-width: 80px; }      /* wraps, but never one word per line (each area may widen it) */
  table.data th.night-cell { max-width: 150px; }
  .night-cell .badge { white-space: normal; line-height: 1.25; }
  .only-narrow { display: inline; }
  .run-n, .also { display: block; }
  .also { margin-top: var(--sp-2); font-weight: 400; }
  .run-n { color: var(--ink-3); font-size: 12px; font-weight: 400; }
  table.board .col-wide, table.board .col-group, table.board .run-sub { display: none; }

  table.board th, table.board td { padding: 8px; }
  table.board td.rank, table.board th.rank { width: 28px; }
  .col-person { display: none; }
}
/* sortable leaderboard headers: each th holds one button (Enter and Space work natively); the arrow marks the active one */
table.board th .sort { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font: inherit; color: inherit;
  min-height: 24px; padding: 0 2px; border-radius: 4px; white-space: nowrap; }
table.board th.r .sort { flex-direction: row-reverse; }
table.board th .sort:hover { color: var(--ink); }
table.board th .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.board th[aria-sort] .sort { color: var(--ink); font-weight: 600; }
.sort__arrow { display: inline-block; min-width: 0.9em; font-size: 9px; color: var(--accent-ink); }
.sort-bar { display: none; align-items: center; gap: var(--sp-2); font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.sort-bar select { min-height: 32px; }
.seg__btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.seg__btn[aria-disabled="true"]:hover { color: var(--ink-2); }
.lat, .samp { white-space: nowrap; }
.lat--none { color: var(--ink-3); font-weight: 400; }
table.board thead th { vertical-align: middle; }
table.board td.duty { white-space: nowrap; }
@media (max-width: 700px) {
  .sort-bar { display: flex; }
  .controls-bar__row .seg { flex-wrap: wrap; max-width: 100%; }
  table.board .bar { display: none; }
  table.board .run-n { white-space: normal; }
  table.board .lat { white-space: normal; }
  table.board th, table.board td { padding: 8px 4px; }
  table.board th .sort { gap: 2px; padding: 0; }
  table.board .ci { font-size: 10.5px; }
  table.board .run-n .nl { display: block; }
}
.samp { font-weight: 500; }
td.part { font-weight: 500; white-space: nowrap; }
table.board .badges { display: flex; margin-top: 2px; }
.run-sub { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ login */
.login-body { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-5) var(--sp-4); }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--sp-4); }
.login__brand { display: flex; align-items: center; gap: 10px; }
.login__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); display: flex; flex-direction: column; gap: 14px; }
.login__card form { display: flex; flex-direction: column; gap: var(--sp-3); }
.login__card .field { font-size: 13px; color: var(--ink-2); }
.login__card .field input { padding-right: 10px; min-height: 38px; }
.form-error { background: var(--crit-soft); padding: 8px 12px; border-radius: var(--radius-md); font-size: 13px; }
.login__foot { margin-top: var(--sp-4); font-size: 12px; color: var(--ink-3); }

@media (forced-colors: active) {
  .badge, .btn, .seg__btn { border: 1px solid CanvasText; }
  table.matrix td.cell { border: 1px solid CanvasText; forced-color-adjust: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
table.matrix.no-fam th.row-head { left: 0; white-space: normal; text-overflow: clip; line-height: 1.15; }   /* family names wrap, never cut */
table.matrix thead th.row-total { vertical-align: bottom; padding-bottom: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border-strong); font-weight: 600; }
.fold__title { font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -0.005em; }
.fold__sub { font-weight: 400; font-size: 13px; margin-left: var(--sp-2); }
.panel--fold > details > summary { display: flex; }
.panel--fold > details[open] > summary { margin-bottom: var(--sp-4); }
[hidden] { display: none !important; }
.res--wrong { color: var(--crit-ink); font-weight: 600; }

/* ------------------------------------------------------------------ chart switch, scroll cue */
.chart-tools { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: center; font-size: 13px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); font-weight: 500; }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
/* a table or matrix that scrolls sideways gets a shaded edge on the side that has more (js/scroll-cue.js adds the classes) */
.scroll-cue { position: relative; min-width: 0; max-width: 100%; }
.scroll-cue::before, .scroll-cue::after { content: ""; position: absolute; top: 1px; bottom: 1px; width: 22px; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 8; }
.scroll-cue::before { left: 1px; background: linear-gradient(to right, var(--shade), transparent); border-radius: var(--radius-md) 0 0 var(--radius-md); }
.scroll-cue::after { right: 1px; background: linear-gradient(to left, var(--shade), transparent); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.scroll-cue.has-more-l::before, .scroll-cue.has-more-r::after { opacity: 1; }
@media (max-width: 700px) { .self-agree--narrow { display: flex; flex-direction: column; align-items: flex-start; margin-top: 6px; font-weight: 400; } }   /* self review: agreement under the trial id, no sideways scroll to find it */
.self-later { max-width: 30ch; }   /* self review: a post-reveal edit note wraps instead of widening its column */
