:root {
  color-scheme: light;
  --surface-1: #fcfcfb;      /* page */
  --surface-2: #ffffff;      /* cards */
  --border: #e4e3df;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a897f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #ecebe7;
  --axis: #d4d3cd;
  --seq-lo: #cde2fb;
  --seq-hi: #0d366b;
  --up: #1baf7a;
  --down: #e34948;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #222221;
    --border: #383734;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e85;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid: #2c2b29;
    --axis: #45443f;
    --seq-lo: #184f95;
    --seq-hi: #b7d3f6;
    --up: #199e70;
    --down: #e66767;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-1);
  color: var(--text-primary);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.page { max-width: 76rem; margin-inline: auto; padding: 24px max(16px, env(safe-area-inset-left)) 40px; display: grid; gap: 16px; }

header.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
header.top h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
header.top .sub { color: var(--text-secondary); }
header.top .tag { margin-left: auto; color: var(--text-muted); font-size: 12px; }
header.top .nav { display: flex; gap: 14px; font-size: 13px; }
header.top .nav a { color: var(--text-secondary); text-decoration: none; padding-bottom: 2px; }
header.top .nav a:hover { color: var(--text-primary); }
header.top .nav a[aria-current="page"] { color: var(--text-primary); border-bottom: 2px solid var(--series-1); }

.stack { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button {
  font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: var(--series-1); color: #fff; border: 1px solid transparent;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: default; }
button.mini {
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
  padding: 3px 9px; font-size: 12px; border-radius: 6px; margin-right: 6px;
}
button.mini:hover { color: var(--text-primary); border-color: var(--text-muted); filter: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.stack input, textarea {
  font: inherit; padding: 8px 12px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { display: block; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1.35em; }
.tile .l { color: var(--text-secondary); font-size: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card .note { margin: 4px 0 12px; color: var(--text-secondary); font-size: 12px; }
.chart { position: relative; min-height: 240px; }
.chart.tall { min-height: 300px; }
.chart svg { display: block; width: 100%; }
.chart text { font-size: 11px; }

.tip {
  position: absolute; pointer-events: none; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.14); padding: 6px 9px; font-size: 12px;
  font-variant-numeric: tabular-nums; z-index: 5;
}
.tip .d { color: var(--text-secondary); }

.tablebox { max-height: 26rem; overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: var(--surface-2); text-align: right; font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); }

.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input {
  flex: 1; min-width: 0; padding: 8px 12px; font: inherit; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
}
.search input:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.hint { color: var(--text-muted); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px; padding: 0; list-style: none; font-size: 12px; color: var(--text-secondary); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

footer.src { color: var(--text-muted); font-size: 12px; max-width: 60rem; }
.skel { position: relative; overflow: hidden; }
.skel::after { content: ""; position: absolute; inset: 0; border-radius: 6px; background: var(--grid); animation: pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }
@keyframes pulse { 50% { opacity: 0.55; } }
