:root {
  color-scheme: dark;
  --bg: #0b0e13; --panel: #11151c; --line: #262c38; --text: #e9edf3; --muted: #8e98a8; --dim: #5d6675;
  --accent: #5b7cfa; --good: #83d9b2; --warn: #d5a64a; --pink: #d97ad1;
  --head: #10151c; --head-line: #1c232e; --mount: #2a1b31; --mount-line: #b84e9c; --sel: #b84e9c;
  --ico: #9aa6b5; --ico-dim: #56606f; --ico-close: #f19aa7; --ico-hover: #252d3a; --label: #a9b3c1; --label-mount: #f4f7fb;
  font-family: "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg);
}
@font-face { font-family: "Hack"; src: url("Hack-Regular.ttf") format("truetype"); font-display: swap; }
* { 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: 900px; margin: 0 0 22px; }
.lede em { color: var(--text); font-style: normal; font-family: Hack, Consolas, monospace; font-size: 13.5px; }
.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; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 18px 0; border-bottom: 1px solid var(--line); font-size: 13px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.ctl-group { display: flex; align-items: center; gap: 10px; }
.ctl-name { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin-right: 4px; }
.ctl-group label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text); }
.ctl-group input { accent-color: var(--good); margin: 0; }

.reference { padding: 26px 0 10px; }
.ref-head { display: flex; align-items: baseline; gap: 14px; }
.ref-head p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.variants { display: grid; grid-template-columns: 1fr; gap: 28px 32px; padding: 20px 0 30px; }
.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; flex-direction: column; gap: 10px; align-items: flex-start; overflow-x: auto; }
.stage-row { display: flex; align-items: center; gap: 12px; }
.stage-note { font-size: 11px; color: var(--dim); min-width: 78px; }
.strip { display: inline-flex; flex-direction: column; gap: 6px; }
.strip .sheet { display: inline-flex; flex-direction: column; gap: 2px; }
.ico-sheet { display: flex; gap: 6px; align-items: center; }
.ico-sheet .cell { width: 20px; height: 18px; display: flex; align-items: center; justify-content: center; color: var(--ico); }
.ico-sheet .cell.close { color: var(--ico-close); }
.ico-sheet .cell svg, .head .btn svg, .head .kind svg { display: block; }

/* ---------- the pane head, as drawn by tile_head / pane_ux_actions ---------- */
.head { display: inline-flex; align-items: center; gap: 8px; height: 18px; padding: 0 10px; width: 300px;
  background: var(--head); border: 1px solid var(--head-line); font-size: 11px; color: var(--label); white-space: nowrap; }
.head.mount { background: var(--mount); border-color: var(--mount-line); color: var(--label-mount); }
.frame { display: inline-block; border: 1px solid var(--line); background: #0a0f16; }
.frame.mount { border-color: var(--sel); }
.frame .glass { height: 28px; }
.head .kind { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 14px; color: var(--ico); font-family: Hack, Consolas, monospace; font-size: 10px; }
.head.mount .kind { color: var(--label-mount); }
.head .route { color: var(--label); }
.head.mount .route { color: var(--label-mount); }
.head .signal { display: inline-flex; align-items: center; gap: 4px; height: 13px; padding: 0 5px; margin-left: 4px; border: 1px solid #234a3b; background: #0f2a20; color: var(--good); font-size: 8.5px; letter-spacing: .4px; font-weight: 600; }
.head .signal .q { width: 6px; height: 6px; display: inline-grid; grid-template-columns: 3px 3px; gap: 0; }
.head .signal .q i { width: 3px; height: 3px; background: #2f5a4a; }
.head .signal .q i:first-child { background: var(--good); }
.head .fill { flex: 1; min-width: 0; }
.head .btns { display: inline-flex; align-items: center; gap: 4px; }
.head .btn { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 4px; color: var(--ico); font-size: 11px; line-height: 1; }
.head .btn.text-swap { font-size: 12px; }
.head .btn.close { color: var(--ico-close); }
.head .btn.hov { background: var(--ico-hover); }
.head.dead .btn, .head.dead .kind { color: var(--ico-dim); }
body.face-mono .head { font-family: Hack, Consolas, monospace; font-size: 10.5px; }

/* ---------- per-variant tweaks ---------- */
.v-gap .head .btns { gap: 2px; }
.v-gap .head .btn { min-width: 18px; }
.v-hairline .head .btn { color: #7f8998; }
.v-hairline .head .btn.close { color: #d98b98; }
.v-hover .head .btn:not(.close):not(.menu) { opacity: 0; transition: opacity .12s; }
.v-hover .head.hovered .btn { opacity: 1; }
.v-hover .head:hover .btn { opacity: 1; }
.v-two .head .btn .ac { color: var(--accent); }
.v-two .head.mount .btn .ac { color: #9fb4ff; }
.v-chip .head .btns { gap: 3px; }
.v-chip .head .btn { min-width: 18px; height: 14px; border: 1px solid var(--head-line); background: #0d1218; }
.v-chip .head.mount .btn { border-color: #5a3a63; background: #3a2542; }
.v-chip .head .btn.hov { background: var(--ico-hover); border-color: #3a4353; }
.v-chip .head .btn.close { border-color: #4a2a33; }

.legend { padding: 10px 0 30px; border-top: 1px solid var(--line); }
.legend-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 20px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.legend-grid b { color: var(--text); font-family: Hack, Consolas, monospace; font-weight: 500; margin-right: 6px; }

/* ---------- pick bar ---------- */
.pickbar { position: fixed; left: 0; right: 0; bottom: 0; background: #0d1117; border-top: 1px solid var(--line); z-index: 6; }
.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, .rules { grid-template-columns: 1fr; }
  .legend-grid { grid-template-columns: 1fr 1fr; }
  .mast-inner, main { padding: 20px 16px; }
}

/* ---------- zoom + text glyphs ---------- */
.z1 .frame, .z1 .ico-sheet { zoom: 1; }
.z2 .frame, .z2 .ico-sheet { zoom: 2; }
.z3 .frame, .z3 .ico-sheet { zoom: 3; }
.head .tx { font-size: 11px; line-height: 1; }
.head .tx.text-swap { font-size: 12px; }
.head .kind .tx { font-family: Hack, Consolas, monospace; font-size: 10px; }
.ico-sheet .cell .tx { font-size: 12px; }
.head { --cut: var(--head); }
.head.mount { --cut: var(--mount); }
.head.mount .btn, .head.mount .kind { color: #c9c2d6; }
.head.mount .btn.close { color: var(--ico-close); }
.head.mount .btn.hov { background: #3d2a44; }
.v-hairline .head.mount .btn { color: #a49bb0; }
