/* Gate Closure: a calm control room. Tokens first; both themes selected, not flipped. */
:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #dddcd6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0a7d3b;
  --bad: #b3261e;
  --grid: #e6e5e0;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8d85;
    --accent: #3987e5;
    --good: #4cc27d;
    --bad: #f07470;
    --grid: #262624;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #2e2e2c;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8d85;
  --accent: #3987e5;
  --good: #4cc27d;
  --bad: #f07470;
  --grid: #262624;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

header.top { border-bottom: 1px solid var(--border); background: var(--surface-1); }
header.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--text-primary); text-decoration: none; }
.brand span { color: var(--text-muted); font-weight: 400; }
nav.main { display: flex; gap: 14px; flex: 1; }
nav.main a { color: var(--text-secondary); text-decoration: none; }
nav.main a[aria-current="page"] { color: var(--text-primary); font-weight: 600; }
.who { color: var(--text-secondary); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.linkbutton { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }

main { padding: 20px 0 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.sub { color: var(--text-secondary); margin: 0 0 16px; }
.muted { color: var(--text-muted); }
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.clock { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--text-secondary); }
.clock strong { color: var(--text-primary); font-family: var(--mono); }
.brief { font-size: 15px; color: var(--text-primary); margin: 0; }

.task h3 { margin: 0 0 4px; font-size: 16px; }
.task p.prompt { margin: 0 0 12px; color: var(--text-secondary); }
.task .context { font-size: 13px; color: var(--text-muted); margin: -6px 0 12px; }
form.entry { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
form.entry label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
form.entry input, form.entry select {
  font: inherit; font-family: var(--mono);
  padding: 8px 10px; min-width: 110px; max-width: 150px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-0); color: var(--text-primary);
}
.steps { display: grid; grid-template-columns: repeat(3, auto); gap: 8px 10px; }
button, .button {
  font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 6px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; display: inline-block;
}
.saved { font-size: 13px; color: var(--good); margin: 10px 0 0; }
.error { font-size: 13px; color: var(--bad); margin: 10px 0 0; }
.yours { font-size: 13px; color: var(--text-secondary); margin: 10px 0 0; font-family: var(--mono); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.points { font-family: var(--mono); font-weight: 600; }
.points.neg { color: var(--bad); }

.windows { display: flex; gap: 8px; margin: 0 0 12px; }
.windows a { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text-secondary); font-size: 13px; }
.windows a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Charts */
.chart-wrap { position: relative; margin: 0; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .zero { stroke: var(--text-muted); stroke-width: 1; }
svg.chart .tick { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); }
svg.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
svg.chart .line.series-1 { stroke: var(--series-1); }
svg.chart .line.series-2 { stroke: var(--series-2); }
svg.chart .line.series-3 { stroke: var(--series-3); }
svg.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart .hit { fill: transparent; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-secondary); margin: 0 0 6px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch.series-1 { background: var(--series-1); }
.swatch.series-2 { background: var(--series-2); }
.swatch.series-3 { background: var(--series-3); }
.tooltip {
  position: absolute; top: 28px; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 12px; font-family: var(--mono); white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
}
details.table-view { margin-top: 8px; font-size: 13px; }
details.table-view summary { color: var(--text-muted); cursor: pointer; }
details.table-view table { margin-top: 6px; }

code, .hash { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-secondary); }
footer { color: var(--text-muted); font-size: 12px; padding: 24px 0 40px; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  nav.main { order: 3; flex-basis: 100%; }
  form.entry input, form.entry select { min-width: 0; max-width: none; width: 100%; }
  form.entry label { flex: 1 1 40%; }
  .steps { grid-template-columns: 1fr 1fr; }
}
