/* ==========================================================================
   ROMEO guide · PDA terminal theme
   Dark  = the ROMEO main menu inverted (the default, the "unofficial" look).
   Light = the original menu colours (opt-in via the status bar switch).
   Rules: tiled panes fill the screen and only the centre pane scrolls;
          CRT scanlines/glow ONLY on decorative parts (.deco), never on text;
          red/gold "hazard" colour is for danger only.
   Approved mock-up: notes/mockups/v2 (git-ignored).
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #141516;        /* negative of the menu's pale paper */
  --pane: #17191a;
  --raise: #1d2022;
  --line: #2b3133;
  --line-hi: #3d4a4d;
  --text: #e6e5e2;      /* negative of the menu's black ink */
  --muted: #9a9d9f;
  --dim: #6c8f93;
  --cyan: #3fd0dc;      /* negative of the banner red: links, current page, prompt */
  --cyan-dim: #23707a;
  --gold: #f2e6b0;      /* negative of the banner navy: numbers and dates */
  --hazard: #f2e6b0;    /* warnings, toxic 0.2+, over budget */
  --bar: #3fd0dc;       /* toxic but under 0.2 */
  --ok: #7fd99a;
  --hover: #1c2a2c;
  --sel: #1a2b2e;
  --rec: #ff7a6b;
  --wm-bg: rgba(20, 21, 22, .84);
  --feed-bg: #0f1011;
  --k1: #1d5056; --k2: #2b8e98; --k3: #3fd0dc; --k4: #f2e6b0;   /* feed characters, faint to peak */
  --scan: rgba(0, 0, 0, .32);
  --glow: 0 0 10px rgba(63, 208, 220, .55), 2px 0 rgba(242, 230, 176, .25), -2px 0 rgba(63, 208, 220, .25);
  --cam-bg: #0e0f10;
  --cam-blend: screen;
  --cam-tint: linear-gradient(160deg, rgba(63, 208, 220, .55), rgba(242, 230, 176, .25));
  --shadow: rgba(0, 0, 0, .6);
  --icon-bg: rgba(230, 229, 226, .06);
  --tag: var(--cyan);

  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --pix: "VT323", "JetBrains Mono", monospace;
  --prose: "Recursive", "JetBrains Mono", ui-monospace, monospace;   /* served with MONO fixed at 0.5 */
  --bar-h: 34px;
  --tree-w: 248px;
  --info-w: 300px;
  color-scheme: dark;
}
/* Light: the ORIGINAL ROMEO menu. Interactive things go ink-black and underlined; red is danger only. */
:root[data-theme="light"] {
  --bg: #ebeae9;
  --pane: #f3f2ef;
  --raise: #e3e2de;
  --line: #c9c8c3;
  --line-hi: #a3a29c;
  --text: #141516;
  --muted: #55585a;
  --dim: #6c7072;
  --cyan: #141516;
  --cyan-dim: #7d8082;
  --gold: #2b3a67;      /* banner navy */
  --hazard: #b5301d;    /* banner red */
  --bar: #2b3a67;
  --ok: #2e6b3a;
  --hover: #e0dfda;
  --sel: #dcdfe6;
  --rec: #b5301d;
  --wm-bg: rgba(243, 242, 239, .88);
  --feed-bg: #efeeeb;
  --k1: #dccdca; --k2: #d08a80; --k3: #b5301d; --k4: #2b3a67;
  --scan: rgba(20, 21, 22, .07);
  --glow: none;
  --cam-bg: #e3e2de;
  --cam-blend: multiply;
  --cam-tint: linear-gradient(160deg, rgba(181, 48, 29, .30), rgba(43, 58, 103, .22));
  --shadow: rgba(20, 21, 22, .18);
  --icon-bg: rgba(20, 21, 22, .07);
  color-scheme: light;
}
@media (prefers-contrast: more) {
  :root { --muted: #c4c6c8; --dim: #a9c4c7; --line: #4a5254; }
  :root[data-theme="light"] { --muted: #3a3c3e; --dim: #44484a; --line: #8c8b85; }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: 125%; }   /* 1rem = 20px, which the builder/map rem sizes were written for */
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 var(--mono); overflow: hidden; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
::selection { background: var(--cyan); color: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr, .skip:not(:focus) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 100; left: 8px; top: 8px; background: var(--cyan); color: var(--bg); padding: 4px 10px; }

/* ---------- Status bar ---------- */
.status { height: var(--bar-h); display: flex; align-items: center; gap: 16px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--pane); font-size: 12px; white-space: nowrap; }
.status .home { flex: none; border: 1px solid var(--cyan-dim); padding: 1px 8px; color: var(--cyan); font-size: 11.5px; }
.status .home:hover { background: var(--cyan); color: var(--bg); text-decoration: none; }
.status .home[aria-current] { background: var(--cyan); color: var(--bg); }
.status .prompt { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.status .prompt b { color: var(--cyan); font-weight: 600; }
.status .prompt a { color: var(--text); }
.status .prompt a[aria-current] { color: var(--gold); }
.status .facts { color: var(--muted); margin-left: auto; }
.status .facts b { color: var(--text); font-weight: 400; }
.grep { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); padding: 2px 8px; width: 240px; }
.grep span { color: var(--cyan); }
.grep input { background: none; border: 0; outline: 0; width: 100%; font-size: 12px; min-width: 0; }
.grep input::-webkit-search-cancel-button { display: none; }
.grep:focus-within { border-color: var(--cyan-dim); }
.grep kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); padding: 0 4px; }
.clock { color: var(--muted); }
.switches { display: flex; gap: 8px; }
.crt { background: none; border: 1px solid var(--line); padding: 1px 8px; cursor: pointer; font-size: 11px; color: var(--muted); }
.crt[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan-dim); }
.theme { display: flex; border: 1px solid var(--line); }
.theme button { background: none; border: 0; padding: 1px 8px; font-size: 11px; color: var(--muted); cursor: pointer; }
.theme button[aria-pressed="true"] { background: var(--cyan); color: var(--bg); }

/* ---------- Shell: tiled panes ---------- */
.shell { height: calc(100% - var(--bar-h)); display: grid; grid-template-columns: var(--tree-w) minmax(0, 1fr) var(--info-w); gap: 8px; padding: 8px; }
body.is-tool .shell { grid-template-columns: var(--tree-w) minmax(0, 1fr) 30px; }
body.is-tool.info-open .shell { grid-template-columns: var(--tree-w) minmax(0, 1fr) var(--info-w); }
body.is-home .shell, body.is-article .shell { grid-template-columns: var(--tree-w) minmax(0, 1fr); }

.pane { position: relative; border: 1px solid var(--line); background: var(--pane); min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.pane > .t { flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 4px 10px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.pane > .t b { color: var(--text); font-weight: 600; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: 0; flex: none; }
.pane > .body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; scrollbar-color: var(--line-hi) transparent; scrollbar-width: thin; }
.main:focus { outline: none; }
.main > .t { box-shadow: inset 3px 0 0 var(--tag); }

/* ---------- Tree ---------- */
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li { line-height: 1.75; white-space: nowrap; }
.tree .dir > button { display: flex; align-items: center; width: 100%; background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); text-align: left; }
.tree .dir > button::before { content: "▸"; color: var(--dim); width: 1.4em; flex: none; }
.tree .dir.open > button::before { content: "▾"; color: var(--cyan); }
.tree .dir > button:hover { color: var(--cyan); }
.tree .dir > ul { display: none; padding-left: 10px; border-left: 1px solid var(--line); margin: 0 0 4px 5px; }
.tree .dir.open > ul { display: block; }
.tree .dir ul a { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; }
.tree .dir ul a::before { content: "├─ "; color: var(--line-hi); }
.tree .dir ul li:last-child a::before { content: "└─ "; }
.tree .dir ul a:hover { color: var(--text); }
.tree .dir ul a.here { color: var(--bg); background: var(--cyan); padding: 0 4px; text-decoration: none; }
.tree a.here::before { color: var(--bg) !important; }
.tree .homelink { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.tree .homelink a { color: var(--text); display: block; }
.tree .homelink a::before { content: "⌂ "; color: var(--cyan); }
.tree .homelink a.here { color: var(--bg); background: var(--cyan); padding: 0 4px; text-decoration: none; }
.tree .homelink a.here::before { color: var(--bg); }
.tree .count { color: var(--dim); font-size: 11px; margin-left: 8px; }
.legal { margin-top: 18px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--muted); line-height: 1.55; white-space: normal; }
.prefs { display: none; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Content (plain English, sharp text) ---------- */
.doc { max-width: 92ch; font-size: 14px; }
.doc .cmd { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.doc .cmd b { color: var(--cyan); font-weight: 600; }
.doc h1 { font: 400 clamp(38px, 4vw, 58px)/.95 var(--pix); color: var(--text); margin: 0 0 14px; letter-spacing: .01em; }
.doc h1::before { content: "# "; color: var(--cyan-dim); }
.doc h2 { font: 600 15px/1.4 var(--mono); color: var(--text); margin: 32px 0 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.doc h2::before { content: "## "; color: var(--cyan-dim); }
.doc h3 { font: 600 13.5px var(--mono); color: var(--gold); margin: 22px 0 8px; }
.doc h3::before { content: "### "; color: var(--dim); }
.doc h4, .doc h5, .doc h6 { font: 600 12px var(--mono); color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin: 18px 0 6px; }
.doc .headerlink { margin-left: .5em; color: var(--line-hi); opacity: 0; font-weight: 400; text-decoration: none; }
.doc :is(h1, h2, h3, h4):hover .headerlink, .doc .headerlink:focus { opacity: 1; }
.doc p, .doc li { margin: 0 0 10px; }
.doc ul, .doc ol { padding-left: 2.4ch; margin: 0 0 14px; }
.doc ul > li::marker { content: "› "; color: var(--cyan-dim); }
.doc ol > li::marker { color: var(--cyan-dim); }
.doc .lede { color: var(--text); font-size: 15px; margin: 0 0 14px; max-width: 72ch; }

/* ---------- Article pages (design review P2) ----------
   No inspector: the patch line sits under the title, contents after the lede, sources and
   prev/next at the end. Prose and table cells use Recursive at half-mono ("semi-mono");
   headings, navigation and the status bar stay JetBrains Mono / VT323. */
body.is-article .doc { max-width: min(100%, 1080px); }
body.is-article .doc p, body.is-article .doc li, body.is-article .doc td { font-family: var(--prose); font-size: 16px; line-height: 1.65; }
body.is-article .doc td { font-size: 15px; }
body.is-article .doc .lede { font-size: 17px; }
/* tables use the width; running text keeps a readable line length */
body.is-article .doc > p, body.is-article .doc > ul, body.is-article .doc > ol, body.is-article .doc .admonition { max-width: 80ch; }
body.is-article .doc .admonition-title, body.is-article .doc details > summary { font-family: var(--mono); font-size: 13.5px; }
.doc .meta { margin: -4px 0 14px; font-size: 12px; color: var(--muted); }
body.is-article .doc .meta { font: 12px/1.6 var(--mono); }
.doc .meta b { color: var(--gold); font-weight: 600; }
.toc-inline { margin: 0 0 22px; padding: 8px 12px; border: 1px solid var(--line); border-left: 3px solid var(--cyan); background: var(--raise); font-size: 12.5px; line-height: 1.8; max-width: 80ch; }
.toc-inline span { color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-size: 11px; margin-right: 8px; }
.toc-inline a + a::before { content: "·"; color: var(--dim); margin: 0 8px; }
.art-src { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--line); }
.art-src h6 { margin: 0 0 6px; font: 600 11px var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.art-src ul { margin: 0; padding-left: 18px; }
body.is-article .doc .art-src li { font: 12px/1.5 var(--mono); color: var(--muted); word-break: break-word; }
.pn-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.pn-foot a { display: flex; flex-direction: column; }
.pn-foot a.next { text-align: right; margin-left: auto; }
.pn-foot a span { color: var(--muted); font-size: 11.5px; }
.doc strong, .doc b { font-weight: 800; }
.doc hr { border: 0; border-top: 1px dashed var(--line); margin: 24px 0; }
.doc img { max-width: 100%; }
.doc a:not(.go):not(.rg-btn):not(.headerlink)::before { content: "["; color: var(--cyan-dim); }
.doc a:not(.go):not(.rg-btn):not(.headerlink)::after { content: "]"; color: var(--cyan-dim); }
.doc a:not(.go):not(.rg-btn):not(.headerlink):hover { text-decoration: none; background: var(--cyan); color: var(--bg); }
:root[data-theme="light"] .doc a:not(.go):not(.rg-btn):not(.headerlink),
:root[data-theme="light"] .info a { text-decoration: underline; text-decoration-color: var(--line-hi); text-underline-offset: 3px; }
:root[data-theme="light"] .doc a::before, :root[data-theme="light"] .doc a::after { color: var(--muted) !important; }
code { font: 12.5px var(--mono); color: var(--gold); background: var(--raise); border: 1px solid var(--line); padding: 0 4px; word-break: break-word; }
pre { background: var(--raise); border: 1px solid var(--line); padding: 10px 12px; overflow: auto; }
pre code { border: 0; padding: 0; background: none; color: var(--text); }
.fixline { margin-top: 32px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }

/* Tables: box borders, hover row. pda.js wraps each in .tw so wide ones scroll sideways. */
.tw { max-width: 100%; overflow-x: auto; margin: 6px 0 16px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; background: var(--raise); }
.doc tbody tr:hover td { background: var(--hover); }
.doc td p { margin: 0; }
/* Opt-in (wrap the table in <div class="stack" markdown>): on phones each row is a block,
   first cell as its heading, the others labelled with their column name (set by pda.js). */
@media (max-width: 760px) {
  .stack .tw { overflow: visible; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; width: auto; }
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .doc .stack tr { padding: 12px 0; border-top: 1px solid var(--line); }
  .doc .stack tr:last-child { border-bottom: 1px solid var(--line); }
  .doc .stack td { border: 0; padding: 3px 0; font-size: 13.5px; }
  .doc .stack td:first-child { font-weight: 800; font-size: 14.5px; color: var(--text); margin-bottom: 2px; }
  .doc .stack td[data-label]:not(:first-child)::before { content: attr(data-label) " · "; font-weight: 800; color: var(--muted); }
  .doc .stack td[data-label]:last-child::before { color: var(--cyan); }
  .doc .stack tbody tr:hover td { background: none; }
}

/* Callouts become log lines: [WARN] / [TIP] / [NOTE] / [INFO] */
.doc .admonition, .doc details { margin: 16px 0; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--cyan); background: var(--raise); font-size: 13.5px; }
.doc .admonition > :last-child, .doc details > :last-child { margin-bottom: 0; }
.doc .admonition-title, .doc details > summary { margin: 0 0 6px; font-weight: 800; color: var(--text); }
.doc .admonition-title::before, .doc details > summary::before { font-weight: 800; margin-right: .6ch; }
.doc .admonition.note, .doc details.note { border-left-color: var(--muted); }
.doc .note > .admonition-title::before { content: "[NOTE]"; color: var(--muted); }
.doc .tip > .admonition-title::before { content: "[TIP]"; color: var(--cyan); }
.doc .admonition.warning, .doc .admonition.danger, .doc .admonition.caution { border-left-color: var(--hazard); }
.doc :is(.warning, .danger, .caution) > .admonition-title::before { content: "[WARN]"; color: var(--hazard); }
.doc details > summary { cursor: pointer; list-style: none; }
.doc details > summary::-webkit-details-marker { display: none; }
.doc details > summary::before { content: "[+] INFO"; color: var(--cyan); }
.doc details[open] > summary::before { content: "[−] INFO"; }
.doc details:not([open]) > summary { margin: 0; }

/* Item icons from {{ item() }}: full colour, they are how players recognise items */
.rg-item { display: inline-flex; align-items: center; gap: 6px; }
img.rg-ico { height: 1.6em; width: 2.4em; object-fit: contain; vertical-align: middle; margin: -0.3em 0; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.rg-patch { display: inline-block; border: 1px solid currentColor; padding: 0 6px; font-size: 12px; }
a.rg-btn, a.go { display: inline-block; margin-top: 12px; border: 1px solid var(--cyan-dim); padding: 3px 10px; font-size: 12px; color: var(--cyan); }
a.rg-btn:hover, a.go:hover { background: var(--cyan); color: var(--bg); text-decoration: none; }

/* ---------- Inspector ---------- */
.info .body > section { margin-bottom: 18px; }
.info h6 { margin: 0 0 6px; font: 600 10.5px var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.info ol, .info ul { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.info li { line-height: 1.65; margin-bottom: 3px; }
.info .toc { counter-reset: t; }
.info .toc > li { counter-increment: t; }
.info .toc > li::before { content: counter(t, decimal-leading-zero) " "; color: var(--dim); }
.info .toc ol { padding-left: 3ch; }
.info .toc ol li::before { content: "└ "; color: var(--line-hi); }
.info .toc a.is-here { color: var(--bg); background: var(--cyan); padding: 0 3px; }
.info .stamp { border: 1px solid var(--line); padding: 8px 10px; font-size: 12px; background: var(--raise); }
.info .stamp b { color: var(--gold); font-weight: 400; }
.info .src li { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-bottom: 6px; word-break: break-word; }
.info .pn span { color: var(--dim); display: inline-block; width: 4.5ch; }
.fold, .unfold { display: none; }
body.is-tool:not(.info-open) .info > .t, body.is-tool:not(.info-open) .info > .body { display: none; }
body.is-tool:not(.info-open) .fold { display: flex; flex: 1; align-items: flex-start; justify-content: center; padding-top: 10px; background: none; border: 0; cursor: pointer; color: var(--cyan); writing-mode: vertical-rl; letter-spacing: .2em; font-size: 11px; }
body.is-tool .unfold { display: inline; background: none; border: 0; color: var(--cyan); cursor: pointer; padding: 0; font-size: 11px; }

/* ---------- Decorative parts: the ONLY place CRT effects apply ---------- */
.deco { position: relative; overflow: hidden; }
:root:not([data-crt="off"]) .deco::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: repeating-linear-gradient(0deg, var(--scan) 0 1px, transparent 1px 3px); }
:root:not([data-crt="off"]) .deco .glow { text-shadow: var(--glow); }
.cam { aspect-ratio: 16 / 9; background: var(--cam-bg); border: 1px solid var(--line); }
.cam img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.15) brightness(.9); mix-blend-mode: var(--cam-blend); opacity: .85; display: block; }
.cam::before { content: ""; position: absolute; inset: 0; background: var(--cam-tint); mix-blend-mode: multiply; z-index: 1; }
.cam .lbl { position: absolute; left: 6px; top: 6px; z-index: 2; font-size: 10.5px; background: var(--bg); color: var(--muted); padding: 1px 6px; border: 1px solid var(--line); }
.cam .lbl i, .feed .rec i { color: var(--rec); font-style: normal; }

/* ---------- Home dashboard ---------- */
body.is-home .main { border: 0; background: none; }
body.is-home .main > .t { display: none; }
body.is-home .main > .body { padding: 0; overflow: hidden; }
.dash { display: grid; height: 100%; gap: 8px; grid-template-columns: 1.15fr 1fr 1fr; grid-template-rows: minmax(190px, 34%) auto 1fr 1fr; grid-template-areas: "feed feed stalker" "newbie newbie newbie" "air kit ls" "air kit patch"; }
/* The obvious first click for GAMMA players (design review P3) */
.newbie { grid-area: newbie; }
.newbie a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 10px 16px; border: 1px solid var(--cyan-dim); background: var(--pane); color: var(--text); }
.newbie b { font: 400 28px/1 var(--pix); color: var(--cyan); }
.newbie span { font-size: 12.5px; color: var(--muted); }
.newbie a:hover { border-color: var(--cyan); background: var(--hover); text-decoration: none; }
.dash > h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.feed { grid-area: feed; }
.feed > .body { padding: 0; position: relative; overflow: hidden; }
.feed canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.feed .wm { position: absolute; right: 18px; bottom: 12px; text-align: right; z-index: 2; background: var(--wm-bg); padding: 8px 12px 10px; border: 1px solid var(--line); max-width: calc(100% - 36px); }
.feed .wm .k { font-size: 10.5px; letter-spacing: .28em; color: var(--cyan); }
.feed .wm h1 { margin: 2px 0 0; font: 400 clamp(52px, 6vw, 92px)/.8 var(--pix); color: var(--text); letter-spacing: .02em; }
.feed .wm p { margin: 6px 0 0; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.feed .rec { position: absolute; left: 10px; top: 10px; z-index: 2; font-size: 11px; background: var(--bg); color: var(--muted); padding: 1px 8px; border: 1px solid var(--line); }
.stalker { grid-area: stalker; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv dd b { color: var(--gold); font-weight: 600; }
.quote { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.air { grid-area: air; }
.bars { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.bars li { display: grid; grid-template-columns: 9.5em 1fr 3.4em; gap: 8px; align-items: center; line-height: 1.55; }
.bars .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .m { height: 7px; background: repeating-linear-gradient(90deg, var(--line) 0 5px, transparent 5px 7px); position: relative; }
.bars .m span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--bar) 0 5px, transparent 5px 7px); }
.bars .hot .m span { background: repeating-linear-gradient(90deg, var(--hazard) 0 5px, transparent 5px 7px); }
.bars .v { text-align: right; color: var(--muted); }
.bars .hot .v { color: var(--hazard); }
.bars .clear .n, .bars .clear .v { color: var(--dim); }
.legend { font-size: 11px; color: var(--muted); margin: 10px 0 0; line-height: 1.6; }
.legend i { font-style: normal; color: var(--bar); } .legend em { font-style: normal; color: var(--hazard); }
.kit { grid-area: kit; }
.kit-f { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.kit-f button { font: 11.5px var(--mono); padding: 2px 7px; color: var(--muted); background: none; border: 1px solid var(--line); cursor: pointer; }
.kit-f button:hover { color: var(--text); border-color: var(--cyan-dim); }
.kit-f button[aria-pressed="true"] { color: var(--bg); background: var(--cyan); border-color: var(--cyan); }
.kit-f sup, .kit-std sup { color: var(--gold); }
.kit h6 { margin: 10px 0 4px; font: 400 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.kit h6 b { font-weight: 400; color: var(--dim); letter-spacing: 0; text-transform: none; }
.kit-rows { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.kit-rows li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.kit-rows img, .kit-rows .kit-noicon { width: 30px; height: 30px; object-fit: contain; display: block; }
.kit-guns .kit-noicon { display: block; width: 64px; height: 32px; }
.kit-rows em, .kit-guns em { font-style: normal; color: var(--gold); }
.kit-rows small { color: var(--muted); font-size: 11px; }
.kit-rows .none { display: block; color: var(--muted); padding: 2px 0; border: 0; }
.kit-guns { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; }
.kit-guns a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border: 1px solid var(--line); color: var(--text); font-size: 11px; text-align: center; line-height: 1.2; }
.kit-guns a:hover { border-color: var(--cyan); text-decoration: none; }
.kit-guns img { width: 64px; height: 32px; object-fit: contain; }
.kit-more { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; }
.kit-std { font-size: 11px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.ls { grid-area: ls; }
.ls ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.ls li a { display: grid; grid-template-columns: 3ch 1fr auto; column-gap: 4px; padding: 2px 4px; color: var(--text); }
.ls li a span { color: var(--dim); }
.ls li a em { font-style: normal; color: var(--muted); font-size: 11.5px; }
.ls li a small { grid-column: 2 / -1; color: var(--muted); font-size: 11px; line-height: 1.4; display: none; }
.ls li a:hover { background: var(--cyan); color: var(--bg); text-decoration: none; }
.ls li a:hover span, .ls li a:hover em, .ls li a:hover small { color: var(--bg); }
.ls li a:hover small, .ls li a:focus small { display: block; }
.patch { grid-area: patch; }
.plog { font-size: 12.5px; margin: 0; padding: 0; list-style: none; }
.plog li { display: grid; grid-template-columns: 11ch 1fr; gap: 10px; }
.plog time { color: var(--gold); }
.plog small { color: var(--muted); display: block; }
.patch .legal b { color: var(--muted); }

/* ---------- Boot log (home, once per session) ---------- */
#boot { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: none; place-items: center; cursor: pointer; padding: 16px; }
#boot.on { display: grid; }
#boot pre { margin: 0; padding: 0; border: 0; background: none; font: 15px/1.95 var(--mono); color: var(--cyan); white-space: pre-wrap; }
#boot pre .ok { color: var(--text); font-weight: 800; }
#boot pre .w { color: var(--hazard); font-weight: 800; }
#boot .skip-hint { position: fixed; right: 18px; bottom: 14px; font-size: 11px; color: var(--muted); }

/* ---------- Grep results ---------- */
#results { position: fixed; top: calc(var(--bar-h) + 2px); right: 12px; width: min(600px, calc(100% - 24px)); max-height: 66vh; overflow: auto; z-index: 80; border: 1px solid var(--cyan-dim); background: var(--pane); box-shadow: 0 12px 40px var(--shadow); font-size: 13px; }
#results[hidden] { display: none; }
#results .rh { padding: 5px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; position: sticky; top: 0; background: var(--pane); }
#results a { display: block; padding: 7px 10px; border-bottom: 1px dotted var(--line); color: var(--text); }
#results a b { font-weight: 600; }
#results a small { display: block; color: var(--dim); font-size: 11px; }
#results a span { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
#results mark { background: none; color: var(--gold); font-weight: 600; }
#results a:hover, #results a.sel { background: var(--hover); text-decoration: none; }
#results .none { padding: 10px; color: var(--muted); }

/* ---------- Phone: panes become a PDA tab bar ---------- */
.tabbar, .m-grep { display: none; }
@media (max-width: 760px) {
  body { overflow: auto; height: auto; }
  html { height: auto; }
  .status { position: sticky; top: 0; z-index: 60; gap: 10px; }
  .status .facts, .status .clock, .status .grep, .status .switches { display: none; }
  .shell, body.is-home .shell, body.is-tool .shell, body.is-tool.info-open .shell { display: block; height: auto; padding: 6px 6px 64px; }
  .pane { display: none; }
  .shell > .pane { min-height: calc(100vh - var(--bar-h) - 74px); }
  body[data-tab="tree"] .tree, body[data-tab="page"] .main, body[data-tab="info"] .info { display: flex; }
  body.is-tool .info > .t, body.is-tool .info > .body { display: block !important; }
  .fold, .unfold { display: none !important; }
  body.is-home .main > .body { overflow: visible; }
  .dash { display: flex; flex-direction: column; height: auto; }
  .dash > .pane { display: flex; }
  .feed { height: 210px; flex: none; }
  .prefs { display: flex; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; border-top: 1px solid var(--line-hi); background: var(--pane); }
  .tabbar button { background: none; border: 0; border-right: 1px solid var(--line); padding: 12px 0 14px; font-size: 12px; color: var(--muted); cursor: pointer; }
  .tabbar button[aria-pressed="true"] { color: var(--bg); background: var(--cyan); }
  .tabbar button[disabled] { opacity: .35; cursor: default; }
  #results { top: auto; bottom: 106px; right: 6px; left: 6px; width: auto; max-height: 64vh; }
  .m-grep { padding: 8px; border-top: 1px solid var(--line); background: var(--pane); position: fixed; left: 0; right: 0; bottom: 49px; z-index: 75; }
  body.grep-open .m-grep { display: flex; }
  .m-grep .grep { width: 100%; }
  .doc h1 { font-size: 40px; }
}
@media (max-width: 1180px) and (min-width: 761px) {
  :root { --tree-w: 210px; --info-w: 250px; }
  .dash { grid-template-columns: 1fr 1fr; grid-template-rows: 210px auto auto auto auto; grid-template-areas: "feed feed" "newbie newbie" "stalker ls" "air kit" "air patch"; height: auto; }
  body.is-home .main > .body { overflow: auto; }
  .status .facts { display: none; }
}

/* ==========================================================================
   Tools (builder, community gallery, zone map): their markup comes from the
   page scripts; sizes are in rem (1rem = 20px), colours use the theme tokens.
   ========================================================================== */
.lede + #lb-app, #lb-app { margin: 1rem 0 1.2rem; }
.lb-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: .8rem; margin-bottom: 1rem; padding: .5rem .6rem; border: 1px solid var(--line); background: var(--raise); }
.lb-controls label, .fm-tool label { display: flex; flex-direction: column; gap: .25rem; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lb-controls :is(select, input, textarea), .fm-tool select { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 0; padding: .3rem .4rem; width: 100%; min-width: 0; }
.lb-controls select option, .fm-tool select option { color: var(--text); background: var(--pane); }
.lb-controls :is(select, input, textarea):focus, .fm-tool select:focus { outline: 1px solid var(--cyan); outline-offset: -1px; }
.lb-controls .lb-description { grid-column: 1 / -1; }
.lb-description textarea { resize: vertical; }
.lb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1rem; align-items: start; }
.lb-picks { columns: 2 20rem; column-gap: .8rem; }
.lb-picks > .lb-note, .lb-picks > .lb-free { column-span: all; }
.lb-group { break-inside: avoid; border: 1px solid var(--line); margin: 0 0 .8rem; padding: .3rem .5rem .4rem; }
.lb-group legend { padding: 0 .3rem; color: var(--gold); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.lb-item { display: grid; grid-template-columns: 2.6rem 2.2rem 1fr auto; gap: .5rem; align-items: center; padding: .2rem .2rem; border-bottom: 1px dotted var(--line); font-size: 12.5px; cursor: pointer; }
.lb-item:hover { background: var(--hover); }
.lb-item input { accent-color: var(--cyan); width: 14px; height: 14px; margin: 0; justify-self: center; }
.lb-item.is-on { background: var(--sel); }
.lb-item.is-on .lb-pts { color: var(--cyan); }
.lb-item.is-off { opacity: .45; cursor: not-allowed; }
.lb-item small { color: var(--muted); }
.lb-pts { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.lb-pts b { color: var(--text); }
.lb-note, .lb-free { font-size: 12px; color: var(--muted); }
.lb-free summary { cursor: pointer; color: var(--text); }
.lb-summary { min-width: 0; position: sticky; top: 0; border: 1px solid var(--line-hi); background: var(--raise); padding: .6rem .7rem; font-size: 12.5px; }
.lb-kicker { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .2rem; color: var(--muted); }
.lb-left { margin: 0; font-size: 12px; color: var(--muted); }
.lb-left strong { font: 400 44px/1 var(--pix); color: var(--cyan); margin-right: .2rem; }
.lb-left.is-over strong { color: var(--hazard); }
.lb-bar { height: 8px; background: repeating-linear-gradient(90deg, var(--line) 0 5px, transparent 5px 7px); margin: .3rem 0 .6rem; position: relative; }
.lb-bar span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--cyan) 0 5px, transparent 5px 7px); }
.lb-bar.is-over span { background: repeating-linear-gradient(90deg, var(--hazard) 0 5px, transparent 5px 7px); }
.lb-over { font-size: 12px; color: var(--hazard); font-weight: 800; margin: 0 0 .6rem; }
.lb-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.doc .lb-list li { display: grid; grid-template-columns: 1.6rem 1fr auto; align-items: center; gap: .4rem; margin: 0; padding: .1rem 0; border-bottom: 1px dotted var(--line); }
.doc .lb-list li::marker { content: none; }
.doc .lb-list li.lb-empty { display: block; color: var(--muted); }
.lb-total { font-size: 12px; text-align: right; margin: .3rem 0 .6rem; font-weight: 800; }
.lb-actions { display: grid; gap: .3rem; }
.lb-actions button { font-size: 12px; padding: .3rem; border: 1px solid var(--cyan-dim); background: transparent; color: var(--cyan); cursor: pointer; }
.lb-actions button.rg-btn-solid { background: var(--cyan); color: var(--bg); font-weight: 600; }
.lb-actions button:hover:not([disabled]) { border-color: var(--cyan); }
.lb-actions button[disabled] { opacity: .4; cursor: not-allowed; }
.lb-status { font-size: 12px; min-height: 1em; margin: .3rem 0 0; color: var(--cyan); }
.lb-icon { width: 100%; height: 1.5rem; object-fit: contain; display: block; background: var(--icon-bg); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.lb-list .lb-icon { height: 1rem; }
.lb-icon--none { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--icon-bg) 4px 5px); }
.lb-step { display: inline-grid; grid-template-columns: 1.2rem 1.1rem 1.2rem; align-items: center; text-align: center; border: 1px solid var(--line-hi); }
.lb-step button { font-weight: 800; line-height: 1; height: 1.1rem; padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.lb-step button:hover:not([disabled]) { background: var(--hover); color: var(--cyan); }
.lb-step button[disabled] { opacity: .3; cursor: not-allowed; }
.lb-step output { font-variant-numeric: tabular-nums; font-weight: 800; }
.lb-item--multi { cursor: default; }
.lb-item.is-off .lb-step { opacity: 1; }
.lb-air { border: 1px solid var(--line); margin: 0 0 .6rem; padding: .4rem .5rem; font-size: 12px; }
.lb-air p { margin: 0 0 .25rem; }
.lb-air__head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lb-air__head strong { font: 400 26px/1 var(--pix); letter-spacing: 0; color: var(--gold); }
.lb-air__what { color: var(--muted); }
.lb-air details { border: 0; background: none; margin: .2rem 0; padding: 0; font-size: inherit; }
.doc .lb-air details > summary { cursor: pointer; font-weight: 600; margin: 0; }
.doc .lb-air details > summary::before { content: "[+] "; color: var(--hazard); }
.doc .lb-air details[open] > summary::before { content: "[−] "; }
.lb-air__list { list-style: none; margin: .2rem 0; padding: 0; max-height: 10rem; overflow: auto; }
.doc .lb-air__list li { display: flex; justify-content: space-between; margin: 0; padding: .05rem 0; border-bottom: 1px dotted var(--line); }
.doc .lb-air__list li::marker { content: none; }
.lb-air__list small { color: var(--muted); }
.lb-air__note { font-size: 11px; color: var(--muted); }
.lb-air__missing, .lb-card__miss { color: var(--hazard); font-size: 12px; line-height: 1.5; }
.lb-air__missing::before, .lb-card__miss::before { content: "[WARN] "; font-weight: 800; }
.lb-air__immune, .lb-card__immune { font-size: 12px; line-height: 1.5; }
.lb-air__immune::before, .lb-card__immune::before { content: "[NOTE] "; font-weight: 800; color: var(--muted); }
@media (max-width: 1100px) {
  .lb-layout { grid-template-columns: 1fr; }
  .lb-summary { position: static; order: -1; }
}
@media (max-width: 560px) {
  .lb-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lb-controls .lb-wide { grid-column: 1 / -1; }
}

/* Community loadouts gallery */
.lb-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .6rem; margin: .8rem 0 1.2rem; }
.lb-card { border: 1px solid var(--line); border-top: 3px solid var(--cyan); background: var(--raise); padding: .6rem; display: flex; flex-direction: column; gap: .3rem; font-size: 12.5px; min-width: 0; }
.lb-card.is-bad { border-top-color: var(--hazard); }
.doc .lb-card h3 { margin: 0; font-size: 14px; color: var(--text); }
.doc .lb-card h3::before { content: "> "; color: var(--cyan-dim); }
.doc .lb-card p { margin: 0; }
.lb-card__kicker { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lb-card__by, .lb-card__note { color: var(--muted); }
.lb-card__note { white-space: pre-line; overflow-wrap: anywhere; }
.lb-card__items { display: flex; flex-wrap: wrap; gap: .25rem; margin: .2rem 0; }
.lb-card__item { position: relative; display: inline-flex; align-items: center; justify-content: center; height: 2rem; min-width: 2rem; padding: .1rem; background: var(--icon-bg); }
.lb-card__item img { height: 100%; width: auto; max-width: 4rem; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.lb-card__item span { font-size: 11px; padding: 0 .2rem; }
.lb-card__item i { position: absolute; right: -.15rem; bottom: -.15rem; font-style: normal; font-size: 10px; font-weight: 800; line-height: 1; padding: .1rem .2rem; background: var(--cyan); color: var(--bg); }
.lb-card__pts b, .lb-card__air b { color: var(--gold); }
.lb-card__warn { color: var(--hazard); font-weight: 800; }
.doc .lb-card .rg-btn { margin-top: auto; align-self: flex-start; }

/* Zone map */
.fm-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .8rem; align-items: end; margin: 0 0 .6rem; padding: .5rem .6rem; border: 1px solid var(--line); background: var(--raise); }
.fm-tool[hidden] { display: none; }
.fm-total { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.fm-total b { display: block; font: 400 32px/1 var(--pix); letter-spacing: 0; color: var(--gold); }
.fm-map { position: relative; max-width: 100%; aspect-ratio: 914 / 777; border: 1px solid var(--line); }
.fm-map img { width: 100%; height: 100%; display: block; }
.fm-pin { position: absolute; transform: translate(-50%, -50%); font: 600 clamp(7px, 1vw, 11px)/1.2 var(--mono); padding: .2em .6em; border-radius: 0; white-space: nowrap; color: #141516; box-shadow: 0 1px 2px rgba(0, 0, 0, .45); border: 0; cursor: pointer; }
.tier-none { background: #ecebe4; }
.tier-basic { background: #cfe5c8; }
.tier-mid { background: #f6d2b4; }
.tier-lab { background: #eec3cf; }
.fm-pin.is-safe, .fm-chip.is-safe { background: #9fd3a0 !important; color: #10301a !important; }
.fm-pin.is-unsafe, .fm-chip.is-unsafe { background: #e8a39b !important; color: #3a0f0a !important; }
.fm-pin.is-current, .fm-chip.is-current { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--cyan); z-index: 2; }
.fm-pin:focus-visible, .fm-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.fm-key { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.fm-key span { font: 11px var(--mono); padding: .15em .6em; color: #141516; }
.fm-info { border: 1px solid var(--line); border-left: 3px solid var(--cyan); background: var(--raise); padding: .5rem .7rem; margin: .6rem 0; font-size: 13px; }
.fm-info[hidden] { display: none; }
.doc .fm-info h3 { margin: 0 0 .2rem; }
.doc .fm-info p { margin: 0 0 .2rem; }
.fm-info small { color: var(--muted); }
.fm-ok { color: var(--ok); font-weight: 800; }
.fm-bad { color: var(--hazard); font-weight: 800; }
.fm-off { margin: .5rem 0; }
.fm-off[hidden] { display: none; }
.fm-off p { margin: 0 0 .2rem; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
#fm-off-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.fm-chip { font: 11px var(--mono); padding: .2em .6em; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
@media (max-width: 560px) {
  .fm-tool { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fm-total { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
