:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #fcfcfb;
  --ink: #14171f;
  --ink-2: #4a4f5c;
  --muted: #6b7080;
  --line: #e3e1d8;
  --grid: #ebe9e1;
  --brand: #1f3b73;
  --gold: #b88a2a;
  --accent: #2a78d6;
  --live: #1baf7a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 23, 31, .05), 0 4px 16px rgba(20, 23, 31, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111318;
    --surface: #1a1d24;
    --ink: #f3f2ec;
    --ink-2: #c3c2b7;
    --muted: #9599a6;
    --line: #2b2f39;
    --grid: #262a33;
    --brand: #9bb6ec;
    --gold: #deb860;
    --accent: #3987e5;
    --live: #199e70;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318; --surface: #1a1d24; --ink: #f3f2ec; --ink-2: #c3c2b7; --muted: #9599a6;
  --line: #2b2f39; --grid: #262a33; --brand: #9bb6ec; --gold: #deb860; --accent: #3987e5; --live: #199e70; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-family: Georgia, "Times New Roman", serif; }
h2 { font-size: 1.05rem; }
code { background: var(--grid); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #1f3b73; color: #deb860; font: 700 20px Georgia, serif; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top nav a { color: var(--ink-2); padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.top nav a:hover { background: var(--grid); text-decoration: none; }
.top nav a[aria-current] { color: var(--ink); background: var(--grid); font-weight: 600; }
.pager a { padding: 6px 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; background: var(--accent); color: #fff; font: 600 .95rem/1 inherit; font-family: inherit; padding: 12px 18px; border-radius: 10px; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn-sm { padding: 8px 12px; font-size: .875rem; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

main { padding-block: 28px 48px; display: grid; gap: 20px; }

/* hero */
.hero { padding-block: 24px 8px; }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p { color: var(--ink-2); max-width: 560px; margin: 12px 0 20px; font-size: 1.05rem; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: clamp(1.4rem, 2.6vw, 1.9rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.tile-value small { font-size: 1.1rem; color: var(--ink-2); margin-left: 2px; }
.tile-hint { color: var(--muted); font-size: .8rem; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 a { color: var(--ink); }
.qtext { white-space: normal; color: var(--ink); margin-bottom: 14px; overflow-wrap: anywhere; }
.live { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--live); margin-right: 8px; vertical-align: middle; box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 22%, transparent); }
.pill { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.live-pill { background: color-mix(in srgb, var(--live) 16%, transparent); color: var(--live); }
.ok-pill { background: color-mix(in srgb, var(--live) 16%, transparent); color: var(--live); justify-self: start; }

/* chart */
.chart-box { position: relative; overflow-x: auto; }
.chart-svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .bar { fill: var(--accent); }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg .hit:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: .8rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); }
.table-view { margin-top: 10px; font-size: .9rem; }
.table-view summary { cursor: pointer; color: var(--muted); }

/* tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }
tbody tr:last-child td { border-bottom: 0; }
.board td:nth-child(2) { font-weight: 500; overflow-wrap: break-word; min-width: 7rem; max-width: 11rem; }
.board .pos { width: 40px; text-align: center; color: var(--muted); }

/* layout columns */
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.side { display: grid; gap: 20px; }
.shop, .recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.shop li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shop li:last-child { border-bottom: 0; }
.shop b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.recent li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.recent li:last-child { border-bottom: 0; }
.recent a { color: var(--ink); }
.recent .muted { font-size: .8rem; }

/* questions */
.page-head { display: grid; gap: 8px; }
.search { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.search input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.q .meta { font-size: .85rem; margin-top: 12px; }
.answer summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.answer p { margin: 8px 0 0; padding: 10px 14px; border-left: 3px solid var(--gold); background: color-mix(in srgb, var(--gold) 9%, transparent); border-radius: 0 8px 8px 0; font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; }
.crumb { margin: 0; color: var(--muted); font-size: .9rem; }
.about p { color: var(--ink-2); margin: 0 0 10px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2); background: var(--surface); }
.tabs a:hover { text-decoration: none; background: var(--grid); }
.tabs a[aria-current] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.filter { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; min-width: 0; width: 220px; max-width: 100%; }
.qfull summary { cursor: pointer; color: var(--ink-2); margin-bottom: 8px; }
.answer-line { margin: 8px 0 12px; }
.about h2 { margin-bottom: 10px; }
.empty { text-align: center; padding: 48px 0; display: grid; gap: 12px; }

/* certificate */
.cert { display: grid; gap: 8px; justify-items: start; }
.cert p { margin: 0; }
.cert-img { margin-top: 12px; border-radius: 10px; width: 100%; max-width: 512px; height: auto; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .hide-sm { display: none; }
  .top-in { gap: 8px; padding-block: 8px; }
  .top nav { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  .card { padding: 16px; }
}
