:root {
  --bg: #fbfbfe; --surface: #ffffff; --surface-2: #f6f7fd; --text: #1c1f3a; --muted: #5d6386; --faint: #8b90ad;
  --line: #e1e3f1; --primary: #5b63d3; --primary-ink: #3c43a8; --primary-soft: #eceefc; --amber: #f2a200;
  --up: #11a36b; --down: #e5484d; --new: #5b63d3; --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0e17; --surface: #121522; --surface-2: #171b2b; --text: #e7e8f4; --muted: #a0a5c8; --faint: #6f7497;
    --line: #262a40; --primary: #7c84ec; --primary-ink: #a3a9ff; --primary-soft: #1d2140; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 20px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.search svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; }
.search input { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text);
  padding: 0 12px 0 34px; font: inherit; outline: none; }
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.toplinks { display: flex; gap: 16px; align-items: center; font-size: 13px; }
.toplinks a { color: var(--muted); }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 6px; height: 32px; width: 36px; cursor: pointer; }

/* shell */
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr) 280px; gap: 24px; max-width: 1320px; margin: 0 auto; padding: 24px 20px; align-items: start; }
.sidenav { position: sticky; top: 80px; font-size: 13px; }
.sidenav .group { margin-bottom: 18px; }
.sidenav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; margin: 0 10px 6px; }
.sidenav a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: var(--radius); color: var(--text); }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.sidenav .sub a { padding-left: 30px; color: var(--muted); }
.sidenav .sub a.active { color: var(--primary-ink); }
.sidenav .count { margin-left: auto; color: var(--faint); font-size: 11px; }
.ico { width: 16px; text-align: center; font-size: 13px; }
.rail { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 16px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.pad { padding: 16px 18px; }
.card-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.015em; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 15px; margin: 0 0 4px; }
h3 { font-size: 12px; margin: 0; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.sub { color: var(--muted); font-size: 13px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.seg a, .seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 5px; cursor: pointer; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg .on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 24, 60, .08); }
select, .chip-toggle { height: 30px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 6px; padding: 0 8px; font: inherit; font-size: 13px; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chip-toggle input { margin: 0; accent-color: var(--primary); }
.spacer { flex: 1; }
.meta-note { font-size: 12px; color: var(--faint); }

/* ranked rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.m1 { background: linear-gradient(135deg, #ffd65a, #f2a200); color: #5a3a00; }
.rank.m2 { background: linear-gradient(135deg, #e9ecf5, #b6bccf); color: #3b4157; }
.rank.m3 { background: linear-gradient(135deg, #f4c7a1, #c9844f); color: #4d2a10; }
.title { font-weight: 650; font-size: 15px; color: var(--primary-ink); word-break: break-word; }
.title:hover { text-decoration: underline; }
.ext { color: var(--faint); font-size: 12px; margin-left: 4px; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 2px; font-size: 11px; }
.pf { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 1px 5px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.pf i { width: 14px; height: 14px; border-radius: 4px; display: inline-grid; place-items: center; font-style: normal; font-size: 8.5px; font-weight: 800; color: #fff; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.badge.new { color: var(--new); background: var(--primary-soft); }
.badge.also { color: var(--muted); padding: 0; }
.badge.warn { color: #9a5b00; background: #fff1d6; }
.badge.bad { color: #b42318; background: #fde8e8; }
.desc { color: var(--muted); font-size: 13px; margin: 4px 0 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.info { color: var(--faint); font-size: 12px; margin-top: 3px; }
.lang-chip { font-size: 11px; color: var(--muted); }
.score { text-align: right; white-space: nowrap; }
.score b { font-size: 15px; font-variant-numeric: tabular-nums; }
.score b::before { content: "⚡"; color: var(--amber); margin-right: 3px; font-size: 12px; }
.score small { display: block; color: var(--faint); font-size: 11px; }
.delta { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.same { color: var(--faint); font-weight: 400; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.more { display: block; width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--primary-ink); font: inherit; cursor: pointer; border-radius: 0 0 8px 8px; }
.more:hover { background: var(--surface-2); }

/* rail */
.rail .card h3 { padding: 12px 14px 8px; display: flex; align-items: center; gap: 6px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 25%, transparent); }
.mini { list-style: none; margin: 0; padding: 0 0 6px; }
.mini li { padding: 7px 14px; border-top: 1px solid var(--line); font-size: 12.5px; }
.mini li a.t { color: var(--text); font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--faint); font-size: 11px; margin-top: 2px; }
.health-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 4px 14px 12px; font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--up); } .dot.failing { background: var(--down); } .dot.stale { background: var(--amber); } .dot.disabled, .dot.pending { background: var(--faint); }

/* detail */
.detail-head { padding: 20px 20px 16px; }
.detail-head h1 { font-size: 24px; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); border-top: 1px solid var(--line); }
.stat { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.section { margin-top: 20px; }
.section > h2 { font-size: 18px; margin: 0 0 2px; }
.section > p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.chart-card { padding: 14px 16px 10px; }
.chart-card .ch-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 8px; }
.chart-card .ch-head strong { font-size: 13px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--faint); font-size: 10px; font-family: var(--mono); }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .pt:hover { r: 4.5; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; margin-top: 6px; }
.strip div { height: 26px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--faint); }
.strip div.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.strip div.on.lo { background: color-mix(in srgb, var(--primary) 45%, var(--surface)); color: var(--text); }
.strip-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); font-family: var(--mono); margin-top: 4px; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font: 12px/1.5 var(--mono); overflow-x: auto; margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; }

/* boards grid */
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.board .bh { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 22px 34px 1fr; gap: 6px; padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.board li:last-child { border-bottom: 0; }
.board .r { color: var(--faint); text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.board a.t { color: var(--text); }
.board .bm { color: var(--faint); font-size: 11.5px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.prose { padding: 20px 22px; font-size: 14px; }
.prose h2 { font-size: 16px; margin: 20px 0 6px; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.formula { font: 14px/1.7 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }

.footer { max-width: 1320px; margin: 10px auto 0; padding: 24px 20px 40px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

@media (max-width: 1180px) { .shell { grid-template-columns: 200px minmax(0, 1fr); } .rail { display: none; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; padding: 12px; }
  .sidenav { display: none; position: static; } .sidenav.open { display: block; }
  .menu-btn { display: inline-block; } .toplinks a { display: none; }
  .topbar { gap: 10px; padding: 0 12px; } .brand span { display: none; }
  .row { grid-template-columns: 30px minmax(0, 1fr); padding: 12px; } .row .score { grid-column: 2; text-align: left; }
  .row .score small { display: inline; margin-left: 6px; }
}

/* ---- v3 (server-rendered) additions ---- */
.shell.no-rail { grid-template-columns: 210px minmax(0, 1fr); max-width: 1100px; }
main { min-width: 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; padding: 0; font-size: 12.5px; color: var(--faint); }
.crumbs li + li::before { content: "›"; margin-right: 4px; color: var(--faint); }
.crumbs a { color: var(--muted); }
.crumbs [aria-current] { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.intro { max-width: 72ch; line-height: 1.55; }
.score b.plain::before { content: none; }
.score b.plain { font-size: 13px; font-weight: 600; color: var(--muted); }
.pfm { width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; font-style: normal; font-size: 8px; font-weight: 800; color: #fff; vertical-align: middle; }
.sidenav .sub { display: none; }
.sidenav .sub.open { display: block; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pf-card { display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: var(--text); }
.pf-card:hover { text-decoration: none; border-color: var(--primary); }
.pf-card .pfm { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; flex: none; }
.pf-card small { display: block; color: var(--faint); font-size: 11.5px; }
.board h2 { font-size: 14px; margin: 0; }
.board h2 a { color: var(--text); }
.related .rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; }
.related ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.related li { padding: 3px 0; }
.summary p { margin: 0 0 6px; line-height: 1.6; }
.stat b.sm { font-size: 14px; }
.inp { height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--surface-2); color: var(--text); min-width: 260px; }
pre[data-copied]::after { content: " ✓ copied"; color: var(--up); }
svg.chart { aspect-ratio: 640 / 170; height: auto; }
.row[hidden] { display: none; }
@media (max-width: 820px) { .shell.no-rail { grid-template-columns: 1fr; } }
