:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5a5a5a;
  --accent: #2b6cb0;
  --card: #f5f5f7;
  --border: #e2e2e6;
  --warn-bg: #fff4e5;
  --warn-border: #f0a500;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --fg: #e8e8ea;
    --muted: #a0a0a8;
    --accent: #7aa2ff;
    --card: #1e2027;
    --border: #2c2e36;
    --warn-bg: #2a2310;
    --warn-border: #c98a00;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}
:root { --page-max: 760px; --header-h: 64px; }
body.layout-topic { --page-max: 1040px; }
.site-header, .content, .site-footer { max-width: var(--page-max); margin: 0 auto; padding: 0 20px; }
.site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); padding-bottom: 12px; }
[id] { scroll-margin-top: var(--header-h); }
.site-header { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: baseline; padding-top: 18px; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.site-nav { display: flex; flex-wrap: wrap; gap: 0; font-size: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 0 14px; border-left: 1px solid var(--border); }
.site-nav a:first-child { border-left: 0; padding-left: 0; }
.site-nav a:hover { color: var(--fg); }
.site-nav a.active { color: var(--accent); font-weight: 600; }
.content a { color: var(--accent); }
.content { padding-top: 12px; padding-bottom: 48px; }
.site-footer { color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); padding-top: 16px; padding-bottom: 40px; }
.site-footer .caveat { font-size: 13px; line-height: 1.5; margin: 0 0 12px; }

/* Hub */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { display: block; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--fg); }
.tile:hover { border-color: var(--accent); }
.tile b { display: block; }
.tile span { color: var(--muted); font-size: 13px; }

.section-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 28px 0; }
.section-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--fg); }
.section-card:hover { border-color: var(--accent); }
.section-card b { font-size: 16px; }
.section-card span { color: var(--muted); font-size: 13px; }
.section-card .count { color: var(--muted); font-size: 12px; margin-top: auto; }

/* Topic pages */
details { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; margin: 14px 0; }
details > summary { cursor: pointer; font-weight: 600; }
.pitfall { background: var(--warn-bg); border-left: 4px solid var(--warn-border); padding: 12px 16px; border-radius: 6px; margin: 16px 0; }
.header-anchor { text-decoration: none; opacity: 0; margin-left: 6px; }
:hover > .header-anchor { opacity: 0.5; }

/* Examples table */
.examples { width: 100%; border-collapse: collapse; font-size: 14px; }
.examples th, .examples td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.examples code { white-space: nowrap; }
.examples .err { color: #c0392b; }

/* Canonical value comparison */
.verdict-legend { list-style: none; padding: 0; margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.verdict-legend li { margin: 2px 0; }
.canonical-value { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 16px 0; background: var(--card); }
.canonical-value > h3 { margin: 0 0 6px; }
.canonical-raw code { font-size: 15px; word-break: break-all; }
.canonical-format { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.badges { margin: 0 0 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.badge.yes { border-color: #2e7d32; color: #2e7d32; }
.badge.no { border-color: var(--border); color: var(--muted); }
.badge.human { border-color: var(--accent); color: var(--accent); }
.engine-headlines { list-style: none; padding: 0; margin: 0; }
.engine-headlines li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; flex-wrap: wrap; }
.engine-headlines .engine-name { font-weight: 600; min-width: 5.5em; }
.go-deeper { margin-top: 8px; }
table.ops { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
table.ops caption { text-align: left; font-weight: 600; padding: 6px 0 2px; }
table.ops th, table.ops td { text-align: left; vertical-align: top; padding: 4px 8px; border-top: 1px solid var(--border); }
table.ops tr.op-note td { color: var(--muted); border-top: none; padding-top: 0; font-size: 13px; }
table.ops .err { color: #b00020; }
.canonical-value .your-zone { color: var(--accent); font-size: 14px; margin-top: 6px; }

/* Topic 2-column layout */
.topic-layout { display: block; }
.topic-article { min-width: 0; }
@media (min-width: 900px) {
  .topic-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; }
  .rail { position: sticky; top: calc(var(--header-h) + 8px); max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto; font-size: 14px; }
  .topic-article { max-width: 720px; }
}

/* Rail: section nav — sibling pages, with the current page expanded to its TOC */
.rail-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 0 0 6px; }
.rail-h a { color: inherit; text-decoration: none; }
.rail-h a:hover { color: var(--fg); }
.rail-nav ul { list-style: none; padding: 0; margin: 0; }
.rail-siblings > li { margin: 2px 0; }
.rail-siblings > li > a { color: var(--muted); text-decoration: none; }
.rail-siblings > li > a:hover { color: var(--fg); }
.rail-siblings > li > a.current { color: var(--fg); font-weight: 600; }

/* The current page's table of contents, nested under it */
.page-toc { font-size: 14px; margin: 2px 0 8px; }
.page-toc a { display: block; color: var(--muted); text-decoration: none; padding: 3px 0 3px 11px; border-left: 3px solid transparent; line-height: 1.35; }
.page-toc a:hover { color: var(--fg); }
.page-toc a.active { color: var(--fg); font-weight: 600; border-left-color: var(--accent); }
.page-toc li ul { padding-left: 10px; }

/* Mobile/narrow: rail sits above the article; siblings become horizontal pills,
   and the current page's TOC drops below them, compact (top-level only). */
@media (max-width: 899px) {
  .rail { margin-bottom: 18px; }
  .rail-siblings { display: flex; flex-wrap: wrap; gap: 6px; }
  .rail-siblings > li { margin: 0; }
  .rail-siblings > li > a { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; white-space: nowrap; display: inline-block; }
  .rail-siblings > li > a.current { border-color: var(--accent); color: var(--accent); }
  .rail-siblings > li:has(.page-toc) { flex-basis: 100%; }
  .page-toc { margin-top: 6px; }
  .page-toc li ul { display: none; }
}
