:root {
  --bg: #ffffff; --surface: #f6f8fa; --border: #d0d7de; --text: #1f2328; --muted: #59636e;
  --accent: #d1600f; --accent-soft: #fff1e5; --link: #0969da;
  --ok: #1a7f37; --ok-soft: #dafbe1; --bad: #cf222e; --bad-soft: #ffebe9;
  --junior: #1a7f37; --mid: #9a6700; --senior: #8250df;
  --code-bg: #f6f8fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #161b22; --border: #30363d; --text: #e6edf3; --muted: #9198a1;
    --accent: #f0883e; --accent-soft: #2b1c10; --link: #58a6ff;
    --ok: #3fb950; --ok-soft: #12261a; --bad: #f85149; --bad-soft: #2d1416;
    --junior: #3fb950; --mid: #d29922; --senior: #bc8cff;
    --code-bg: #161b22;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
a { color: var(--link); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

header { border-bottom: 1px solid var(--border); padding: 28px 0 20px; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.02em; }
h1 span { color: var(--accent); }
.lede { margin: 6px 0 14px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; }
.links code { overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

.controls { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border);
            padding: 12px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 8px; }
input[type=search], select { font: inherit; color: var(--text); background: var(--surface);
            border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
input[type=search] { flex: 1 1 240px; min-width: 0; }
select { max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; background: var(--surface); color: var(--muted);
              padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { color: var(--muted); font-size: 14px; margin-left: auto; }
@media (max-width: 600px) { .controls { position: static; } }

main { padding: 20px 0 64px; }
.topic { margin-bottom: 36px; }
.topic h2 { font-size: 22px; margin: 0 0 4px; }
.topic > p { color: var(--muted); margin: 0 0 10px; }
pre.diagram { max-width: 100%; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
              overflow-x: auto; font-size: 13px; line-height: 1.35; }

details.q { border: 1px solid var(--border); border-radius: 10px; margin: 8px 0; background: var(--bg); }
details.q[open] { border-color: var(--accent); }
details.q > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px;
                      align-items: baseline; }
details.q > summary::-webkit-details-marker { display: none; }
.num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.2em; }
.prompt { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.level { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.level.junior { color: var(--junior); } .level.mid { color: var(--mid); } .level.senior { color: var(--senior); }
.body { padding: 0 14px 14px 14px; border-top: 1px solid var(--border); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.tag { font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
       padding: 1px 8px; color: var(--muted); cursor: pointer; }
.permalink { font-size: 13px; color: var(--muted); }

.md :not(pre) > code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 5px;
                       padding: 0 4px; font-size: .9em; }
.md pre { max-width: 100%; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
          overflow-x: auto; font-size: 14px; line-height: 1.45; }
.md pre code.hljs { background: transparent; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 10px; }
.prompt code { font-size: .9em; }

.card { border: 1px solid var(--border); border-radius: 12px; padding: 18px; background: var(--bg); }
.card .meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; }
.card h2 { font-size: 20px; margin: 8px 0 14px; }
.opts { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px;
       padding: 10px 12px; cursor: pointer; background: var(--surface); }
.opt input { margin-top: 5px; accent-color: var(--accent); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.hint { color: var(--muted); font-size: 14px; margin: -6px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 16px; cursor: pointer;
       border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--ok); } .verdict.bad { color: var(--bad); }
.explain { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; padding: 18px 0 32px; }

/* The static list the build writes into index.html, shown until the script takes over. */
.static-list { padding-left: 2.4em; margin: 8px 0 0; }
.static-list li { margin: 6px 0; }
.static-list a { color: var(--text); text-decoration: none; font-weight: 600; }
.static-list a:hover { color: var(--link); text-decoration: underline; }

/* A page per question. */
.site-bar { border-bottom: 1px solid var(--border); padding: 14px 0; }
.home { color: var(--text); font-weight: 800; font-size: 18px; text-decoration: none; }
.home span { color: var(--accent); }
.article { padding: 22px 16px 48px; }
.article h1 { font-size: clamp(22px, 4vw, 30px); line-height: 1.3; margin: 6px 0 18px; overflow-wrap: anywhere; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; color: var(--muted); font-size: 14px; margin: 0; }
.opts.static .opt { cursor: default; display: block; }
.article .actions { margin: 18px 0; gap: 16px; }
.article .btn { text-decoration: none; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.pager a { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
           color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.pager a:hover { border-color: var(--accent); }
.pager a[rel=next] { text-align: right; }
.pager small { display: block; color: var(--muted); }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
