/* compair: one stylesheet for participant and admin pages. Light + dark via tokens. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.12);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #006300;
  --warn-bg: #fff4d6;
  --bad: #b42323;
  --bad-bg: #fde8e8;
  /* chart slots (dataviz reference palette) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --div-neg: #e34948; --div-mid: #f0efec; --div-pos: #2a78d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9a988f;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.12);
    --accent: #3987e5; --accent-wash: rgba(57,135,229,0.16);
    --good: #0ca30c; --warn-bg: #3a300f; --bad: #e66767; --bad-bg: #3a1a1a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --div-neg: #e66767; --div-mid: #383835; --div-pos: #3987e5;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9a988f;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.12);
  --accent: #3987e5; --accent-wash: rgba(57,135,229,0.16);
  --good: #0ca30c; --warn-bg: #3a300f; --bad: #e66767; --bad-bg: #3a1a1a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --div-neg: #e66767; --div-mid: #383835; --div-pos: #3987e5;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* ---------- layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 12px; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 3px; font-weight: 400; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
       border-radius: 8px; padding: 9px 16px; border: 1px solid var(--axis); background: var(--surface);
       color: var(--ink); cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn.link { border: none; background: none; color: var(--accent); padding: 0; min-height: 0; }
form.inline { display: inline; }

.flash { background: var(--accent-wash); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.errors { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 18px; }

/* ---------- participant ---------- */
.p-head { text-align: center; margin: 8px 0 20px; }
.p-head h1 { font-size: 1.35rem; }
.prompt { font-size: 1.25rem; font-weight: 650; text-align: center; margin: 4px 0 18px; }
.progress { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.progress-label { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 16px; min-height: 1.3em; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }
.choice { font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--border);
          border-radius: 14px; padding: 28px 18px; min-height: 140px; cursor: pointer; box-shadow: var(--shadow);
          display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
          transition: border-color .12s, transform .08s, background .12s; position: relative; }
.choice:hover { border-color: var(--accent); }
.choice:active, .choice.picked { transform: scale(.98); background: var(--accent-wash); border-color: var(--accent); }
.choice .label { font-size: 1.25rem; font-weight: 650; overflow-wrap: anywhere; }
.choice .desc { color: var(--ink-2); font-size: .92rem; margin-top: 6px; }
.choice kbd { position: absolute; top: 8px; right: 10px; }
.secondary-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: .72rem; color: var(--muted); border: 1px solid var(--axis);
      border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); }
.keys-hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 18px; }
@media (hover: none) { .keys-hint, .choice kbd, .secondary-actions kbd { display: none; } }
.busy .choice, .busy .secondary-actions button { pointer-events: none; opacity: .6; }
.done-box { text-align: center; padding: 40px 20px; }
.preview-banner { background: var(--warn-bg); text-align: center; padding: 6px; font-size: .85rem; }

/* ---------- admin ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .wrap { padding-block: 10px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { font-weight: 750; letter-spacing: -.01em; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 20px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.badge { display: inline-block; font-size: .75rem; font-weight: 650; padding: 2px 8px; border-radius: 99px;
         background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.badge.open { color: var(--good); border-color: var(--good); }
.badge.closed { color: var(--bad); border-color: var(--bad); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: middle; }
table.t .num { text-align: right; }
table.t th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 650; }
table.t tr.inactive td { color: var(--muted); text-decoration: line-through; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 650; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.copy { display: flex; gap: 8px; }
.row select, .row input[type=search] { width: auto; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
details.edit summary { cursor: pointer; color: var(--accent); font-size: .85rem; list-style: none; }
details.edit[open] { background: var(--surface-2); padding: 10px; border-radius: 8px; }
.danger-zone { border-color: var(--bad); }

/* ---------- results / charts ---------- */
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.controls .field { margin: 0; min-width: 150px; }
.loading { opacity: .5; transition: opacity .2s; }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.chart text { fill: var(--ink-2); font-size: 12px; font-family: inherit; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.tooltip { position: fixed; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border);
           border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 4px 16px rgba(0,0,0,.15); z-index: 50; max-width: 280px; }
.tooltip strong { font-size: .95rem; }
.tooltip .tk { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.ci-cell { width: 220px; }
.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; font-size: .8rem; min-width: 56px; }
.heat td.na { color: var(--muted); }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; font-size: .88rem; color: var(--ink-2); }
