:root {
  --bg: #fbfbf9; --fg: #1d1f21; --muted: #6b6f76; --line: #e3e3de; --panel: #ffffff; --code: #f4f4f0;
  --accent: #2f5bd3; --open: #d9dad5; --open-main: #a9aba4; --proved: #2e9e5b; --refuted: #e08a1e; --conflict: #d23c3c;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #14161a; --fg: #e6e6e3; --muted: #9aa0a8; --line: #2a2e35; --panel: #1b1e23; --code: #22262c;
  --accent: #7aa2ff; --open: #353a42; --open-main: #5b616b;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #14161a; --fg: #e6e6e3; --muted: #9aa0a8; --line: #2a2e35; --panel: #1b1e23; --code: #22262c;
  --accent: #7aa2ff; --open: #353a42; --open-main: #5b616b; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow: auto; margin: 6px 0 10px; white-space: pre; }

#bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
#brand { font-weight: 700; color: var(--fg); white-space: nowrap; }
#brand span { font-weight: 400; color: var(--muted); }
nav { display: flex; gap: 4px; }
nav a { color: var(--muted); padding: 4px 10px; border-radius: 6px; }
nav a.on { color: var(--fg); background: var(--code); }
nav a:hover { text-decoration: none; color: var(--fg); }
#searchwrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
#search { width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; }
#results { position: absolute; top: 36px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  max-height: 60vh; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
#results a { display: block; padding: 6px 10px; color: var(--fg); border-bottom: 1px solid var(--line); }
#results a:hover, #results a.sel { background: var(--code); text-decoration: none; }
#results small { color: var(--muted); }
#theme { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 6px; padding: 5px 8px 3px; cursor: pointer; }

#main { display: flex; min-height: calc(100% - 53px); }
#view { flex: 1; min-width: 0; padding: 26px 32px 60px; }
#side { width: min(620px, 46vw); position: sticky; border-left: 1px solid var(--line); background: var(--panel); position: sticky; top: 53px;
  height: calc(100vh - 53px); overflow: auto; padding: 22px 26px 60px; }
#close { float: right; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
@media (max-width: 900px) { #side { position: fixed; inset: 53px 0 0 0; width: auto; z-index: 6; } #view { padding: 18px; } }

.hero { display: grid; grid-template-columns: minmax(260px, 1.1fr) 2fr; gap: 28px; align-items: start; margin-bottom: 26px; }
@media (max-width: 1000px) { .hero { grid-template-columns: 1fr; } }
#main.split .hero { grid-template-columns: 1fr; }
.big { font-size: 46px; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.big small { font-size: 17px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.lede { color: var(--muted); max-width: 62ch; margin: 0; }
.lede p { margin: 0 0 10px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--open); margin: 12px 0 8px; }
.bar i { display: block; height: 100%; }
.figs { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 10px 30px; margin-top: 10px; }
.fig b { display: block; font-size: 20px; }
.fig span { color: var(--muted); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.legend i, .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; }
.mapctl { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.mapctl select { font: inherit; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
h2 { font-size: 15px; margin: 22px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
canvas.map { display: block; width: 100%; cursor: pointer; }
#tip { position: fixed; z-index: 9; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.14); max-width: 360px; }
#tip small { color: var(--muted); }

.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--code); color: var(--muted); margin: 0 4px 4px 0; }
.chip.E { color: #2e9e5b; } .chip.M { color: #c07a12; } .chip.H { color: #d23c3c; }
.st { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; color: #fff; white-space: nowrap; }
.st.open { background: var(--open-main); } .st.proved { background: var(--proved); } .st.refuted { background: var(--refuted); } .st.conflict { background: var(--conflict); }

#insp h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.25; }
#insp .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 12px; }
.tabs a { padding: 6px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--fg); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--fg); }
.thm { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; background: var(--bg); }
.thm.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thm .hd { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.thm .hd b { color: var(--fg); font-family: var(--mono); font-size: 13px; }
.thm .hd .st { margin-left: auto; }
.thm p { margin: 6px 0; }
.thm .pre { color: var(--muted); font-size: 13.5px; }
details { margin: 4px 0; }
summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.desc { white-space: pre-wrap; font-size: 14px; }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px; position: sticky; top: 53px; background: var(--bg); }
table.list td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
table.list tr:hover td { background: var(--code); cursor: pointer; }
table.list td.n { white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; font-size: 13px; }
.filters select, .filters input { font: inherit; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.pager { display: flex; gap: 8px; align-items: center; margin: 14px 0; font-size: 13px; color: var(--muted); }
.pager button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 6px; padding: 3px 10px; cursor: pointer; }

.prose { max-width: 78ch; }
.prose h1 { font-size: 26px; margin: 0 0 10px; }
.prose h3 { margin: 22px 0 6px; }
.tracks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.track { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel); }
.track b { display: block; margin-bottom: 4px; }
.track p { margin: 0; color: var(--muted); font-size: 14px; }
.kw { color: #8a3ffc; } .ty { color: #0f7b8a; } .cm { color: var(--muted); font-style: italic; } .sr { color: #a3512a; }
[data-theme="dark"] .kw { color: #c79bff; } [data-theme="dark"] .ty { color: #5cc8d6; } [data-theme="dark"] .sr { color: #e3a07a; }
.foot { color: var(--muted); font-size: 12.5px; margin-top: 34px; }
@media (max-width: 700px) {
  #bar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  #brand span { display: none; }
  #searchwrap { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
  #theme { margin-left: auto; }
  .big { font-size: 38px; }
  #side { inset: 96px 0 0 0; height: auto; }
}

/* home: cards, breakdown rows, topics */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 14px; margin: 0 0 26px; }
#main.split .cards { grid-template-columns: 1fr 1fr; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
a.card { color: var(--fg); } a.card:hover { text-decoration: none; border-color: var(--accent); }
.card.next b { font-size: 16px; margin: 2px 0 4px; }
.card.next span { color: var(--muted); font-size: 14px; }
.card.next .go { color: var(--accent); margin-top: auto; padding-top: 8px; }
.kicker { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
a.row { display: grid; grid-template-columns: minmax(0, 1fr) auto 70px; gap: 10px; align-items: center; padding: 3px 4px; margin: 0 -4px; border-radius: 4px; color: var(--fg); font-size: 13.5px; }
a.row:hover { background: var(--code); text-decoration: none; }
a.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.row .num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.rbar { display: block; height: 6px; background: var(--open); border-radius: 3px; overflow: hidden; }
.rbar i { display: block; height: 100%; background: var(--proved); }
.card .row:only-child { grid-template-columns: 1fr auto; }
.more { font-size: 13px; margin-top: 8px; }
.topics { columns: 3 260px; column-gap: 28px; }
.topics a.row { break-inside: avoid; }
.hint { color: var(--muted); font-size: 14px; max-width: 90ch; }
kbd { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); color: var(--fg); }
a.fig { color: var(--fg); } a.fig:hover { text-decoration: none; } a.fig:hover span { color: var(--accent); }
.figs .fig b { font-variant-numeric: tabular-nums; }

/* program panel */
.pnav { display: flex; gap: 12px; font-size: 13px; color: var(--muted); margin: -2px 0 6px; }
.pnav a { color: var(--muted); } .pnav a:hover { color: var(--accent); }
.tfilter { display: flex; gap: 6px; margin: 0 0 10px; }
.tfilter button { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 12px; padding: 1px 10px; cursor: pointer; }
.tfilter button.on { color: var(--fg); border-color: var(--accent); }
.thm .hd .lnk { color: var(--muted); font-family: var(--mono); border: 0; background: none; cursor: pointer; padding: 0 2px; font-size: 13px; }
.thm .hd .lnk:hover { color: var(--accent); }
.prewrap { position: relative; }
.prewrap .cp { position: absolute; top: 6px; right: 6px; font: 11.5px var(--sans); border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 4px; padding: 1px 7px; cursor: pointer; opacity: 0; transition: opacity .12s; }
.prewrap:hover .cp, .prewrap .cp:focus { opacity: 1; }
.prewrap .cp.done { color: var(--proved); opacity: 1; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 6px 14px; border-radius: 6px; font-size: 13px; z-index: 20; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card a.row:not(:has(.rbar)) { grid-template-columns: minmax(0, 1fr) auto; }
.tw { overflow-x: auto; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs a { white-space: nowrap; }
table.list td a { color: var(--fg); }
@media (max-width: 700px) {
  #bar { display: grid; grid-template-columns: auto 1fr auto; }
  nav { overflow-x: auto; }
  #searchwrap { grid-column: 1 / -1; }
  #side { inset: 0; height: 100vh; z-index: 30; padding-top: 16px; }
  table.list td:nth-child(3) { min-width: 220px; }
}
.st.superseded { background: var(--line); color: var(--muted); }
#maps { position: relative; }
.hoverbox { position: absolute; border: 1.5px solid var(--accent); border-radius: 2px; pointer-events: none; }
/* names linked to their definitions */
a.lk { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
a.lk.loc { border-bottom-color: color-mix(in srgb, var(--accent) 55%, transparent); }
a.lk.aen { border-bottom: 1px dashed color-mix(in srgb, var(--proved) 70%, transparent); }
a.lk.ml { border-bottom: 1px dotted color-mix(in srgb, var(--muted) 80%, transparent); }
a.lk:hover { color: var(--accent); text-decoration: none; }
span.lk { border-bottom-width: 1px; padding-bottom: 0; }
span.lk.loc { border-bottom: 1px solid var(--accent); } span.lk.aen { border-bottom: 1px dashed var(--proved); } span.lk.ml { border-bottom: 1px dotted var(--muted); }
.ln.flash { background: color-mix(in srgb, var(--accent) 22%, transparent); transition: background .3s; }
.ln { display: inline-block; min-width: 100%; }
.dn { font-weight: 600; }
.prewrap, .prose { max-width: 100%; min-width: 0; }
.prose .prewrap { max-width: 78ch; }
.foot { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  nav a { padding: 4px 7px; font-size: 14px; }
  #brand { font-size: 14px; }
}

/* structure: kinds and relations (blue: it depends on, red: depends on it) */
:root { --k-program: #7b5cd6; --k-helper: #2a9db0; --k-external: #9a7b4f; --dep: #2f6fd8; --dep2: #a9c3f0; --use: #d6453d; --use2: #f0b2ad; }
[data-theme="dark"] { --dep2: #2c4a7a; --use2: #6e3431; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dep2: #2c4a7a; --use2: #6e3431; } }
.kdot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; flex: none; }
.k-program { background: var(--k-program); } .k-helper { background: var(--k-helper); } .k-external { background: var(--k-external); }
.k-open { background: var(--open-main); } .k-proved { background: var(--proved); } .k-refuted { background: var(--refuted); } .k-conflict { background: var(--conflict); } .k-superseded { background: var(--line); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; margin: 4px 0 12px; }
.stats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; } .stats span { color: var(--muted); font-size: 12.5px; }
.slegend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.slegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.slegend i.r-dep { background: var(--dep); } .slegend i.r-dep2 { background: var(--dep2); } .slegend i.r-use { background: var(--use); } .slegend i.r-use2 { background: var(--use2); }
.slegend .sep { width: 1px; height: 14px; background: var(--line); } .slegend .tr { margin-left: auto; }
.ssel { border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; background: var(--bg); }
.ssel .hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .ssel .hd b { font-family: var(--mono); font-size: 13px; } .ssel .hd span:last-child { color: var(--muted); font-size: 12.5px; }
.decls { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.fhd { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 6px 10px; background: var(--code); border-top: 1px solid var(--line); }
.fhd:first-child { border-top: 0; }
a.drow { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 40px; gap: 8px; align-items: center; padding: 3px 10px; color: var(--fg); font-size: 13px; border-left: 3px solid transparent; }
a.drow:hover { background: var(--code); text-decoration: none; }
a.drow .nm { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.drow .wh { color: var(--muted); font-size: 12px; } a.drow .num { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
a.drow.r-sel { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
a.drow.r-dep { border-left-color: var(--dep); background: color-mix(in srgb, var(--dep) 18%, transparent); }
a.drow.r-dep2 { border-left-color: var(--dep2); background: color-mix(in srgb, var(--dep) 7%, transparent); }
a.drow.r-use { border-left-color: var(--use); background: color-mix(in srgb, var(--use) 18%, transparent); }
a.drow.r-use2 { border-left-color: var(--use2); background: color-mix(in srgb, var(--use) 7%, transparent); }
p.uses { font-size: 13px; color: var(--muted); margin: 4px 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
a.usechip { display: inline-flex; gap: 5px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--fg); background: var(--code); border-radius: 4px; padding: 0 6px; }
a.usechip:hover { text-decoration: none; outline: 1px solid var(--accent); }
.h2n { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.mains { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; margin: 0 0 24px; }
.mainc { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); color: var(--fg); min-width: 0; }
.mainc:hover { border-color: var(--accent); }
.mainc .hd a { color: var(--fg); }
.mainc .hd { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.mainc .hd span { color: var(--muted); font-size: 12.5px; }
.mainc pre { margin: 8px 0 0; font-size: 12px; }
.chip.topic { color: var(--fg); font-weight: 600; }
.legend i.dl { height: 2px; width: 12px; vertical-align: 3px; margin-left: 4px; }
nav a.ext::after { content: " ↗"; font-size: 11px; }
.paperline { font-size: 13.5px; color: var(--muted); border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 12px; margin: 0 0 22px; }
.paperline a { white-space: nowrap; }
/* the sticky table header works against the window; inside a scrolling wrapper it would overlap rows */
@media (min-width: 701px) { .tw { overflow: visible; } }
@media (max-width: 700px) { table.list th { position: static; } }
@media (max-width: 700px) { .paperline a { white-space: normal; } .figs { grid-template-columns: repeat(2, auto); } }
.prose.wide { max-width: 1100px; }
table.lb td.rk { font-weight: 700; color: var(--muted); width: 32px; }
table.lb td.n { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lb tr.podium td.rk { color: var(--fg); }
table.lb .star { color: #d99a2b; }
.muted { color: var(--muted); }
.lbchart { width: 100%; max-width: 820px; height: auto; margin: 14px 0 4px; }
.lbchart .ax { stroke: var(--line); } .lbchart .tk { font: 11px var(--sans); fill: var(--muted); }
.cards { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.cards.two { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.vmark { color: var(--proved); font-weight: 700; text-decoration: none; }
