:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --surface-2: #eef2f6;
  --text: #1d232b;
  --muted: #5a6673;
  --border: #dde3ea;
  --accent: #1f4e79;
  --accent-ink: #0f2b46;
  --accent-soft: #e8f0f8;
  --code-bg: #f6f8fa;
  --mark: #fff3b0;
  --sidebar: 300px;
  --topbar: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #161d25;
    --surface-2: #1c2530;
    --text: #e3e8ee;
    --muted: #9aa7b4;
    --border: #2a3542;
    --accent: #7fb2e5;
    --accent-ink: #a9cdf0;
    --accent-soft: #1a2a3b;
    --code-bg: #0d1117;
    --mark: #5c4a00;
  }
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar) + 12px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

code, pre, kbd {
  font-family: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 6px 10px; z-index: 100;
}
.skip:focus { left: 8px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar); padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.toplinks { margin-left: auto; display: flex; gap: 16px; font-size: 14px; }
.toplinks a { text-decoration: none; white-space: nowrap; }
.toplinks a:hover { text-decoration: underline; }
.toc-toggle {
  display: none; font: inherit; font-size: 14px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer;
}

/* Layout */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

.toc {
  position: sticky; top: var(--topbar);
  height: calc(100vh - var(--topbar)); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--surface);
  padding: 16px 12px 40px;
  font-size: 14px;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc .toc-part > a { display: block; font-weight: 600; color: var(--text); margin-top: 14px; padding: 2px 6px; }
.toc .toc-part ol a { display: block; padding: 2px 6px 2px 14px; color: var(--muted); line-height: 1.4; margin: 1px 0; }
.toc a { text-decoration: none; border-radius: 4px; }
.toc a:hover { background: var(--surface-2); color: var(--text); }
.toc a.active { background: var(--accent-soft); color: var(--accent-ink); }
.toc li[hidden] { display: none; }

.search { position: sticky; top: -16px; background: var(--surface); padding: 0 0 8px; z-index: 1; }
.search input {
  width: 100%; font: inherit; font-size: 15px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.count { margin: 6px 2px 0; color: var(--muted); font-size: 13px; min-height: 1em; }

main { min-width: 0; padding: 0 40px 80px; }
.doc, .hero, .foot, .noresults { max-width: 860px; margin-left: auto; margin-right: auto; }

/* Hero */
.hero { padding: 48px 0 28px; border-bottom: 2px solid var(--accent); margin-bottom: 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; color: var(--accent); margin: 0 0 12px; }
.subtitle { font-size: 19px; margin: 0 0 12px; }
.tracks { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-top: 3px solid var(--accent); padding: 12px 14px; display: flex; flex-direction: column; }
.stat .num { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat .lab { font-size: 14px; }
.stat .sub { font-size: 13px; color: var(--muted); }
.baseline { font-size: 13px; color: var(--muted); margin: 0; }

/* Document content */
.doc h2 {
  font-size: 28px; color: var(--accent); margin: 56px 0 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--accent); line-height: 1.25;
}
.doc h3 { font-size: 20px; margin: 36px 0 4px; line-height: 1.35; }
.doc h3.q { color: var(--accent-ink); padding-top: 22px; border-top: 1px solid var(--border); }
.doc h4.label { font-size: 15px; margin: 18px 0 6px; color: var(--accent-ink); }
.doc .meta { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.doc p { margin: 10px 0; }
.doc p strong:first-child { color: var(--accent-ink); }
.doc p.th { margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--border); }
.doc p.th em { font-style: normal; font-weight: 600; }
.doc ul, .doc ol { padding-left: 24px; margin: 8px 0 12px; }
.doc li { margin: 4px 0; }
.doc :not(pre) > code {
  font-size: .86em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-word;
}
.doc pre {
  background: var(--code-bg); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-size: 13.5px; line-height: 1.5; margin: 10px 0 14px;
}
.doc pre code.hljs { background: transparent; padding: 0; }
.doc pre code.language-plaintext { color: var(--text); }

.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: 6px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc th { background: var(--accent); color: #fff; text-align: left; padding: 8px 10px; font-weight: 600; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .doc th { color: #0f141a; } }
.doc td { padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: top; }
.doc tbody tr:nth-child(even) td { background: var(--surface); }

section.item[hidden], section.part[hidden] { display: none; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

.noresults { padding: 40px 0; color: var(--muted); font-size: 17px; }
.foot { border-top: 1px solid var(--border); margin-top: 48px; padding-top: 16px; font-size: 14px; color: var(--muted); }

/* Landing page */
.landing { max-width: 980px; margin: 0 auto; padding: 64px 24px 80px; }
.landing-head h1 { font-size: clamp(32px, 6vw, 52px); color: var(--accent); margin: 0 0 12px; line-height: 1.1; }
.landing-head .subtitle { max-width: 640px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 36px; }
.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent);
  border-radius: 8px; padding: 22px;
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 4px; font-size: 22px; color: var(--accent); line-height: 1.25; }
.card p { margin: 0; }
.card .for { font-weight: 600; font-size: 15px; }
.card-stats { color: var(--muted); font-size: 14px; }
.card .go { margin-top: auto; padding-top: 10px; color: var(--accent); font-weight: 600; }

/* Mobile */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .toc-toggle { display: inline-block; }
  .toc {
    position: fixed; top: var(--topbar); left: 0; width: min(88vw, 340px); z-index: 30;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 24px rgba(0, 0, 0, .25);
  }
  .toc.open { transform: none; }
  main { padding: 0 16px 64px; }
  .hero { padding-top: 28px; }
  .toplinks { gap: 10px; }
  .doc pre { font-size: 12.5px; }
}
@media (max-width: 520px) {
  .brand { display: none; }
}

@media print {
  .topbar, .toc, .foot { display: none; }
  .layout { display: block; }
  main { padding: 0; }
  .doc pre { white-space: pre-wrap; }
}

/* Experience levels */
.hero .years { font-size: .55em; color: var(--muted); font-weight: 600; margin-left: .3em; white-space: nowrap; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 14px; }
.levels a {
  text-decoration: none; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.levels a span { color: var(--muted); font-weight: 400; margin-left: 4px; }
.levels a:hover { border-color: var(--accent); }
.levels a.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.levels a.current span { color: rgba(255, 255, 255, .8); }
@media (prefers-color-scheme: dark) { .levels a.current, .levels a.current span { color: #0f141a; } }
.levels-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card.bank { cursor: default; }
.card.bank h2 a { text-decoration: none; color: var(--accent); }
.level-links { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.level-links a {
  display: flex; justify-content: space-between; gap: 10px; text-decoration: none; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-weight: 600;
}
.level-links a span { color: var(--muted); font-weight: 400; font-size: 14px; }
.level-links a:hover { border-color: var(--accent); }
.guide h3 { color: var(--accent-ink); }
.hero .status {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; font-size: 14px;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--border);
}
