:root {
  color-scheme: dark;
  --bg: #0b0e13; --panel: #11151c; --line: #262c38; --text: #e9edf3; --muted: #8e98a8; --dim: #5d6675;
  --accent: #5b7cfa; --good: #83d9b2; --warn: #d5a64a; --pink: #d97ad1; --sel: #b84e9c; --selbg: #2b1d2d;
  --rail-bg: #14171d; --rail-row: #1c2028; --rail-head: #1a1e26; --rail-line: #2a2f3a;
  font-family: "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: 72px; }
a { color: var(--good); }

.masthead { border-bottom: 1px solid var(--line); background: var(--panel); }
.mast-inner, main { max-width: 1180px; margin: 0 auto; padding: 28px 28px; }
.mast-brand { font-size: 12px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }
.mast-dot { margin: 0 6px; }
h1 { font-size: 38px; font-weight: 500; letter-spacing: -.8px; margin: 10px 0 14px; }
.lede { font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 860px; margin: 0 0 22px; }
.lede em { color: var(--text); font-style: normal; }
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.rule { font-size: 13px; line-height: 1.5; color: var(--muted); border-left: 2px solid var(--line); padding-left: 12px; }
.rule-name { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

h2 { font-size: 20px; font-weight: 500; margin: 0 0 6px; }
.mods { padding: 26px 0; border-bottom: 1px solid var(--line); }
.mods-head p, .ref-head p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.mods-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mod { display: grid; grid-template-columns: 20px 1fr; gap: 4px 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.mod:hover { border-color: var(--dim); }
.mod.on { border-color: var(--good); background: #10201a; }
.mod input { margin: 3px 0 0; accent-color: var(--good); }
.mod-name { font-size: 14px; font-weight: 600; }
.mod-body { grid-column: 2; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

.reference { padding: 26px 0 10px; }
.ref-head { display: flex; align-items: baseline; gap: 14px; }
.variants { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 32px; padding: 20px 0 40px; }
.variant { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--panel); cursor: pointer; transition: border-color .15s; }
.variant:hover { border-color: var(--dim); }
.variant.picked { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.v-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.v-tag { font-size: 13px; font-weight: 700; color: var(--bg); background: var(--good); border-radius: 6px; padding: 3px 8px; }
.variant.picked .v-tag { background: var(--text); }
.v-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.v-lines { font-size: 12px; color: var(--muted); margin-top: 2px; }
.variant > p { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin: 12px 0 8px; }
.cost { font-size: 12px; color: var(--muted); }
.cost b { color: var(--text); font-weight: 600; margin-right: 6px; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }

.stage { background: #080a0e; border-radius: 8px; padding: 14px; display: flex; justify-content: center; overflow-x: auto; }

/* ---------- the rail ---------- */
.rail { width: 400px; min-width: 0; background: var(--rail-bg); font-size: 13px; line-height: 1.35; border: 1px solid var(--rail-line); }
.railhead { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--rail-line); font-size: 12px; }
.rh-name { font-weight: 600; letter-spacing: .4px; }
.rh-live { color: var(--muted); margin-right: auto; }
.rh-ctl { color: var(--dim); font-size: 11px; }
.rh-menu { color: var(--dim); }

.srv { display: flex; align-items: center; gap: 7px; padding: 8px 10px; margin-top: 8px; background: var(--rail-head); font-size: 12px; letter-spacing: .4px; }
.srv .dot { width: 8px; height: 8px; background: var(--good); border-radius: 1px; }
.srv-name { font-weight: 600; margin-right: auto; }
.live { color: var(--good); font-size: 11px; }
.fold { color: var(--dim); font-size: 11px; }
.box { color: var(--dim); font-size: 11px; }
.space { display: flex; align-items: center; gap: 7px; padding: 8px 10px 8px 18px; }
.space-name { font-weight: 500; margin-right: auto; }
.space-branch { display: none; font-size: 11.5px; color: var(--muted); }
.space-state { font-size: 11.5px; color: var(--muted); display: inline-flex; gap: 6px; }
.body { margin-left: 24px; border-left: 1px solid var(--rail-line); padding-left: 6px; padding-bottom: 4px; }

.ctl { color: var(--muted); font-size: 11px; margin-left: auto; padding: 2px 6px; border: 1px solid var(--rail-line); border-radius: 3px; white-space: nowrap; }
.ctl.pause { padding: 1px 6px; }
.ctl.resume { color: var(--good); border-color: #2f5a4a; }
.ctl.quiet { border: 0; padding: 0; margin-left: 10px; }

.pane, .tab { position: relative; margin: 4px 6px 4px 0; }
.pane { background: var(--rail-row); padding: 7px 10px 7px 12px; border-left: 3px solid transparent; }
.pane.working { border-left-color: var(--good); }
.pane.idle { border-left-color: var(--warn); }
.pane.done { border-left-color: var(--pink); }
.pane.sel, .tab.sel { outline: 1px solid var(--sel); background: var(--selbg); }
.tab { padding: 6px 6px 4px 8px; }
.tab > .pane { margin-left: 6px; margin-right: 0; }
.row { display: flex; align-items: flex-start; gap: 7px; min-height: 18px; }
.row + .row { margin-top: 3px; }
.title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.title.small { font-size: 12px; color: var(--muted); }
.muted, .meta { font-size: 11.5px; color: var(--muted); flex-wrap: wrap; row-gap: 2px; }
.meta > * + *::before, .muted > * + *::before, .statebox > * + *::before, .space-state > * + *::before { content: "· "; color: var(--dim); }
.meta > .ctl::before, .muted > .ctl::before { content: none; }
.meta > .ctl { margin-left: auto; }
.meta.cap { color: var(--muted); }
.sub { font-size: 11.5px; color: var(--muted); }
.statebox { display: inline-flex; gap: 6px; margin-top: 5px; padding: 3px 8px; border: 1px solid var(--rail-line); background: #171a21; font-size: 11.5px; color: var(--muted); }
.glyph { color: var(--dim); font-size: 12px; width: 12px; text-align: center; flex-shrink: 0; margin-top: 1px; }
.who { color: var(--muted); }
.pid { font-family: Consolas, "Hack", monospace; font-size: 11px; color: var(--dim); }
.ico { margin-right: 4px; }
.state { white-space: nowrap; }
.state.working { color: var(--good); }
.state.idle { color: var(--warn); }
.state.done { color: var(--pink); }
.state.none { color: var(--muted); }
.state.right { margin-left: auto; font-size: 11.5px; }
.age { color: var(--muted); white-space: nowrap; }
.branch { color: var(--muted); white-space: nowrap; }
.ahead { color: var(--good); }
.caption { color: var(--muted); }
.echo { }

/* 3 · ledger */
.pane.ledger { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding-left: 8px; }
.pane.ledger .col { font-size: 11.5px; }
.pane.ledger .col .age { display: block; font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.pane.ledger .col .age::before { content: none; }
.pane.ledger .main { min-width: 0; }
.pane.ledger.tabrow { background: transparent; border-left-color: transparent; }

/* 4 · thin pane rows under a tab */
.pane.thin { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 4px 8px 4px 10px; font-size: 12px; }
.pane.thin .who { white-space: nowrap; }
.pane.thin .title.small { flex: 1; }
.pane.thin .age { font-size: 11px; }

/* 5 / 6 · one line */
.pane.one { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; padding: 5px 8px 5px 10px; }
.pane.one .title { flex: 1 1 170px; }
.pane.one .glyph { align-self: flex-start; }
.pane.one .who, .pane.one .pid, .pane.one .age, .pane.one .branch { font-size: 11.5px; white-space: nowrap; }
.pane.one .pid::before { content: "· "; color: var(--dim); }
.pane.one .ctl { margin-left: 0; }
.pane.one.tabrow { background: transparent; border-left-color: transparent; }
.pane.card .row + .row { margin-top: 4px; }

/* ---------- cleanups ---------- */
body.m-age .age.working { display: none; }
body.m-branch .pane .branch, body.m-branch .tab .branch, body.m-branch .tab .row .branch { display: none; }
body.m-branch .space-branch { display: inline; }
body.m-branch .row.sub:has(> .branch:only-child) { display: none; }
body.m-echo .title.echo { display: none; }
body.m-echo .pane .row:has(> .title.echo:only-child) { display: none; }
body.m-hover .ctl.pause, body.m-hover .ctl.resume { opacity: 0; }
body.m-hover :is(.pane, .tab, .space):hover .ctl { opacity: 1; }
body.m-pid .pid { display: none; }
body.m-icons .ico { display: none; }
body.m-icons .caption::before { content: "«"; }
body.m-icons .caption::after { content: "»"; }

/* ---------- pick bar ---------- */
.pickbar { position: fixed; left: 0; right: 0; bottom: 0; background: #0d1117; border-top: 1px solid var(--line); }
.pick-inner { max-width: 1180px; margin: 0 auto; padding: 12px 28px; display: flex; align-items: center; gap: 20px; font-size: 13px; }
.pick-inner > div { flex: 1; }
.codes { color: var(--muted); }
#pick-link { font-family: Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .variants, .mods-grid, .rules { grid-template-columns: 1fr; }
  .mast-inner, main { padding: 20px 16px; }
  .rail { width: 100%; }
}
