:root {
  --bg: #f3f5ef;
  --surface: #ffffff;
  --surface-2: #e9ede2;
  --border: #d8ddcf;
  --grid: #e6e9df;
  --text: #1b1f17;
  --muted: #5f6757;
  --accent: #4a7d24;
  --accent-soft: #e0ecd3;
  --danger: #b3261e;
  --warn: #9a6400;
  --lag: rgba(179, 38, 30, .16);
  --spike: rgba(217, 130, 43, .14);
  --hatch: rgba(27, 31, 23, .14);
  --hero-from: #1f3b4d;
  --hero-to: #2f6a4a;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11140f;
    --surface: #191d16;
    --surface-2: #21261d;
    --border: #2d3328;
    --grid: #252a21;
    --text: #e5e9df;
    --muted: #98a08d;
    --accent: #84bd4c;
    --accent-soft: #24331b;
    --danger: #ef6b5f;
    --warn: #e3b341;
    --lag: rgba(239, 107, 95, .2);
    --spike: rgba(227, 179, 65, .14);
    --hatch: rgba(229, 233, 223, .16);
    --hero-from: #12232e;
    --hero-to: #1b3b2a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }

.hero { background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; padding: 22px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; text-decoration: none; opacity: .92; }
.brand img { image-rendering: pixelated; border-radius: 6px; }
.pill-link { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.pill-link:hover { background: rgba(255,255,255,.12); }
.hero h1 { font-size: clamp(26px, 5vw, 38px); margin: 10px 0 14px; letter-spacing: -.02em; }
.now { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; flex-direction: column; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.22); border-radius: 10px; padding: 5px 12px; font-weight: 600; min-width: 80px; }
.chip small { font-size: 11px; font-weight: 500; opacity: .8; }
.chip.ok { background: rgba(132, 189, 76, .3); }
.chip.warn { background: rgba(227, 179, 65, .32); }
.chip.bad { background: rgba(239, 107, 95, .38); }
.ranges { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.ranges button { font: inherit; font-size: 13px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 4px 12px; cursor: pointer; }
.ranges button.active { background: #fff; color: var(--hero-from); font-weight: 600; }
.ranges button:focus-visible, .event:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.banner { background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
.legend-note { margin: -6px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; border: 1px solid var(--border); }
.swatch.hatch { background: repeating-linear-gradient(135deg, var(--hatch) 0 2px, transparent 2px 5px); }
.swatch.lag { background: var(--lag); }

.chart { width: 100%; min-height: 230px; }
.chart .u-legend { font-size: 12px; color: var(--text); }
.chart .u-legend .u-marker { width: 10px; height: 10px; }
.chart .u-select { background: rgba(74, 125, 36, .15); }
.chart .u-over { cursor: crosshair; }

.events, .hints, .causes, .plain, .bars { list-style: none; margin: 0; padding: 0; }
.events { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; }
.event { width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.event:hover { border-color: var(--border); }
.event-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.tag.lag { background: var(--lag); color: var(--danger); }
.tag.spike { background: var(--spike); color: var(--warn); }
.causes { margin-top: 4px; font-size: 14px; }
.causes li::before, .hints li::before { content: "→ "; color: var(--muted); }
.hints { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.detail { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-left: 18px; }

.snap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px 24px; }
.snap-grid .wide { grid-column: 1 / -1; }
.bars { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.bars li { display: grid; grid-template-columns: minmax(80px, 40%) 1fr auto; gap: 8px; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { background: var(--surface-2); border-radius: 4px; height: 10px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { font-variant-numeric: tabular-nums; color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); margin: 8px 0 6px; }
.plain li { font-size: 14px; padding: 2px 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

footer { padding: 8px 16px 28px; }
