/* SPDX-License-Identifier: GPL-3.0-or-later
   Copyright (C) 2026 Hashem Aldhaheri */

/* ============================================================
   Secure Remote Access — shared stylesheet
   Theme-aware: light palette on :root, dark overrides guarded
   so the toggle wins in both directions.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

:root {
  /* ---- light palette (default) ---- */
  --bg:            #f7f8fa;
  --bg-raised:     #ffffff;
  --bg-sunken:     #eef0f4;
  --bg-code:       #f4f5f8;
  --border:        #dfe3ea;
  --border-strong: #c3cad6;

  --text:          #1a1f2b;
  --text-muted:    #5a6478;
  --text-faint:    #8b94a7;

  --accent:        #0d7a6f;
  --accent-soft:   #e2f2f0;
  --accent-text:   #0a5d55;

  --danger:        #b3261e;
  --danger-soft:   #fdeceb;
  --warn:          #8a5a00;
  --warn-soft:     #fdf4e0;
  --info:          #1d5fa8;
  --info-soft:     #e8f1fc;
  --ok:            #1f6b3a;
  --ok-soft:       #e7f5ec;

  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.05);
  --shadow-lg: 0 8px 32px rgba(16,24,40,.12);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;

  --sidebar-w: 280px;
  --toc-w: 220px;
  --radius: 10px;
  --maxw: 820px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0e1116;
    --bg-raised:     #161b22;
    --bg-sunken:     #0a0d12;
    --bg-code:       #12171f;
    --border:        #262d38;
    --border-strong: #3a4452;

    --text:          #e4e8ef;
    --text-muted:    #9aa5b6;
    --text-faint:    #6b7688;

    --accent:        #3ddbc7;
    --accent-soft:   #10302d;
    --accent-text:   #6feadb;

    --danger:        #ff6b5e;
    --danger-soft:   #341916;
    --warn:          #e8b04b;
    --warn-soft:     #302614;
    --info:          #6aaef5;
    --info-soft:     #131f2e;
    --ok:            #56d67f;
    --ok-soft:       #12261a;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
  }
}

:root[data-theme="dark"] {
  --bg:            #0e1116;
  --bg-raised:     #161b22;
  --bg-sunken:     #0a0d12;
  --bg-code:       #12171f;
  --border:        #262d38;
  --border-strong: #3a4452;

  --text:          #e4e8ef;
  --text-muted:    #9aa5b6;
  --text-faint:    #6b7688;

  --accent:        #3ddbc7;
  --accent-soft:   #10302d;
  --accent-text:   #6feadb;

  --danger:        #ff6b5e;
  --danger-soft:   #341916;
  --warn:          #e8b04b;
  --warn-soft:     #302614;
  --info:          #6aaef5;
  --info-soft:     #131f2e;
  --ok:            #56d67f;
  --ok-soft:       #12261a;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- layout ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 0 40px;
}

.main { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; padding: 0 32px 96px; }
.content { width: 100%; max-width: var(--maxw); padding-top: 28px; }

.toc {
  width: var(--toc-w); flex: 0 0 var(--toc-w);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 32px 20px 40px 0; font-size: 13px;
}
.toc h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); margin-bottom: 10px; }
.toc a { display: block; padding: 4px 0 4px 10px; color: var(--text-muted); text-decoration: none; border-left: 2px solid var(--border); line-height: 1.4; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); font-weight: 600; }
.toc a.lvl3 { padding-left: 22px; font-size: 12.5px; }

/* ---------------- sidebar nav ---------------- */
.brand { padding: 0 20px 18px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.brand a { text-decoration: none; color: var(--text); display: block; }
.brand .mark {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
}
.brand .mark svg { flex: 0 0 auto; }
.brand .sub { display: block; font-size: 12px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }

.nav-search { padding: 0 16px 14px; }
.nav-search input {
  width: 100%; padding: 8px 11px; font-size: 13px; font-family: var(--sans);
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; outline: none;
}
.nav-search input:focus { border-color: var(--accent); }
.nav-search input::placeholder { color: var(--text-faint); }

.nav-group { padding: 12px 16px 4px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-faint); font-weight: 700; }

.nav a {
  display: flex; align-items: baseline; gap: 9px;
  padding: 7px 16px 7px 18px; color: var(--text-muted);
  text-decoration: none; font-size: 14px; line-height: 1.4;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--bg-sunken); color: var(--text); }
.nav a.active { color: var(--accent-text); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav a .num { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: 0 0 auto; min-width: 16px; }
.nav a.active .num { color: var(--accent); }
.nav a.hidden { display: none; }

/* ---------------- typography ---------------- */
h1 { font-size: 34px; line-height: 1.18; letter-spacing: -.022em; font-weight: 750; margin-bottom: 14px; }
h2 { font-size: 23px; line-height: 1.28; letter-spacing: -.014em; font-weight: 700; margin: 46px 0 14px;
     padding-top: 10px; border-top: 1px solid var(--border); }
h3 { font-size: 17.5px; line-height: 1.35; font-weight: 680; margin: 30px 0 10px; }
h4 { font-size: 15px; font-weight: 680; margin: 22px 0 8px; }
p  { margin-bottom: 15px; }
a  { color: var(--accent-text); text-underline-offset: 2px; }

.eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 10px; }
.lede { font-size: 18px; line-height: 1.6; color: var(--text-muted); margin-bottom: 26px; }

ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 7px; }
li > ul, li > ol { margin-top: 7px; }

strong { font-weight: 660; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

/* ---------------- code ---------------- */
code {
  font-family: var(--mono); font-size: .875em;
  background: var(--bg-code); border: 1px solid var(--border);
  padding: .1em .36em; border-radius: 5px; word-break: break-word;
}
pre {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; overflow-x: auto;
  margin-bottom: 16px; position: relative;
}
pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.6; display: block; }

.code-wrap { position: relative; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  padding: 4px 9px; border-radius: 6px; cursor: pointer;
  background: var(--bg-raised); color: var(--text-muted);
  border: 1px solid var(--border); opacity: 0; transition: opacity .12s;
}
.code-wrap:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.done { color: var(--ok); border-color: var(--ok); }

.filename {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-faint);
  background: var(--bg-sunken); border: 1px solid var(--border); border-bottom: 0;
  padding: 6px 12px; border-radius: var(--radius) var(--radius) 0 0;
}
.filename + .code-wrap pre { border-radius: 0 0 var(--radius) var(--radius); }

/* ---------------- callouts ---------------- */
.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--text-faint);
  background: var(--bg-raised); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 13px 16px; margin: 18px 0;
}
.callout .ct { font-weight: 680; font-size: 13px; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger .ct { color: var(--danger); }
.callout.warn   { border-left-color: var(--warn);   background: var(--warn-soft); }
.callout.warn .ct { color: var(--warn); }
.callout.info   { border-left-color: var(--info);   background: var(--info-soft); }
.callout.info .ct { color: var(--info); }
.callout.ok     { border-left-color: var(--ok);     background: var(--ok-soft); }
.callout.ok .ct { color: var(--ok); }
.callout.tip    { border-left-color: var(--accent); background: var(--accent-soft); }
.callout.tip .ct { color: var(--accent-text); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunken); font-weight: 660; font-size: 12.5px;
     text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { font-size: 12.5px; }

/* ---------------- checklists ---------------- */
.checklist { list-style: none; padding-left: 0; }
.checklist li {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 10px 13px; margin-bottom: 7px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px;
}
.checklist input[type="checkbox"] {
  margin-top: 4px; flex: 0 0 auto; width: 15px; height: 15px;
  accent-color: var(--accent); cursor: pointer;
}
.checklist label { cursor: pointer; flex: 1; font-size: 14.5px; }
.checklist li.done { opacity: .55; }
.checklist li.done label { text-decoration: line-through; }

.progress-bar { height: 5px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; margin: 10px 0 20px; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.progress-label { font-size: 12.5px; color: var(--text-muted); font-family: var(--mono); }

/* ---------------- diagrams ---------------- */
.diagram {
  margin: 26px 0; padding: 20px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto;
}
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram figcaption {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); line-height: 1.55;
}
.diagram figcaption b { color: var(--text); }

/* SVG theming hooks */
.svg-surface  { fill: var(--bg-sunken); }
.svg-card     { fill: var(--bg-raised); }
.svg-stroke   { stroke: var(--border-strong); }
.svg-label    { fill: var(--text); font-family: var(--sans); font-size: 12px; font-weight: 600; }
.svg-sub      { fill: var(--text-muted); font-family: var(--mono); font-size: 10px; }
.svg-accent   { fill: var(--accent); }
.svg-accent-s { stroke: var(--accent); }
.svg-danger   { fill: var(--danger); }
.svg-warn     { fill: var(--warn); }
.svg-mono-danger { fill: var(--danger); font-family: var(--mono); font-size: 11px; }
.svg-mono-accent { fill: var(--accent); font-family: var(--mono); font-size: 11px; }
.svg-mono-warn   { fill: var(--warn);   font-family: var(--mono); font-size: 11px; }
.svg-danger-s { stroke: var(--danger); }
.svg-warn-s   { stroke: var(--warn); }
.svg-muted-s  { stroke: var(--text-faint); }
.svg-ok-s     { stroke: var(--ok); }
.svg-info-s   { stroke: var(--info); }

/* ---------------- animated diagrams (sim) ---------------- */
/* Without JS nothing below applies: every layer stays visible and the
   figure reads as a normal static diagram. anim.js adds .sim-on. */
.sim { padding-top: 16px; }
.sim:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* No-JS (or pre-init) fallback: collapse to a single static picture by
   keeping only the layers tagged data-poster out of each scenario's
   alternatives, and drop the controls that would do nothing. */
.sim:not(.sim-on) [data-scn]:not([data-poster]) { display: none; }
.sim:not(.sim-on) .sim-bar,
.sim:not(.sim-on) .sim-controls,
.sim:not(.sim-on) .sim-term { display: none; }

.sim-on [data-at] {
  opacity: 0;
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}
.sim-on [data-at].is-on { opacity: 1; pointer-events: auto; }
/* Opt-in pop, only on cards. Flow paths must never be transformed —
   anim.js samples them with getPointAtLength() in untransformed
   user-space coordinates. */
.sim-on svg .sim-pop { transform-box: fill-box; transform-origin: center; }
.sim-on svg .sim-pop:not(.is-on) { transform: scale(.96); }
.sim-on svg .sim-pop.is-on { transform: none; }

/* scenario switcher */
.sim-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.sim-bar-label {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; margin-right: 2px;
}
.sim-scn {
  font: inherit; font-size: 12.5px; line-height: 1;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px solid var(--border);
  transition: background .18s, color .18s, border-color .18s;
}
.sim-scn:hover { color: var(--text); border-color: var(--border-strong); }
.sim-scn.is-on {
  background: var(--accent-soft); color: var(--accent-text);
  border-color: var(--accent); font-weight: 600;
}
.sim-scn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* transport controls */
.sim-controls {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sim-btn {
  font: inherit; font-size: 12.5px; line-height: 1;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border);
}
.sim-btn:hover { border-color: var(--border-strong); }
.sim-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sim-btn-play { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.sim-glyph { font-size: 10px; }

/* step dots */
.sim-track { display: flex; align-items: center; gap: 6px; margin-left: 4px; }
.sim-dot {
  font: inherit; font-size: 10px; font-family: var(--mono);
  width: 24px; height: 24px; padding: 0; cursor: pointer;
  border-radius: 50%; background: var(--bg-sunken); color: var(--text-faint);
  border: 1px solid var(--border);
  transition: background .2s, color .2s, border-color .2s;
}
.sim-dot:hover { color: var(--text); }
.sim-dot.is-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.sim-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sim-progress {
  flex: 1; height: 3px; min-width: 40px;
  background: var(--bg-sunken); border-radius: 2px; overflow: hidden;
}
.sim-progress > span { display: block; height: 100%; width: 0; background: var(--accent); }
.sim:not(.is-playing) .sim-progress > span { width: 0 !important; }

/* narration — stacked in one grid cell so the box reserves the height of
   the tallest variant instead of clipping the longest one */
.sim-steps { list-style: none; margin: 14px 0 0; padding: 0; }
.sim-on .sim-steps { display: grid; }
.sim-on .sim-steps > li { grid-area: 1 / 1; }
.sim-steps > li {
  font-size: 13.5px; line-height: 1.55; color: var(--text-muted);
  padding-left: 14px; border-left: 2px solid var(--accent);
}
.sim-steps > li b { color: var(--text); display: block; margin-bottom: 3px; font-size: 13px; }
.sim-steps > li code { font-size: 12px; }

/* live terminal readout */
.sim-term {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  background: var(--bg-code); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.85;
  overflow-x: auto;
}
.sim-on .sim-term { display: grid; }
.sim-on .sim-term > div[data-at] { grid-area: 1 / 1; white-space: nowrap; }

/* Hand off between stacked variants instead of cross-fading them: the
   outgoing one clears before the incoming one arrives. */
.sim-on .sim-steps > li,
.sim-on .sim-term > div[data-at] { transition: opacity .16s ease; }
.sim-on .sim-steps > li.is-on,
.sim-on .sim-term > div[data-at].is-on { transition: opacity .28s ease .15s; }
.sim-term .tp { color: var(--text-faint); }
.sim-term .tok { color: var(--ok); }
.sim-term .twarn { color: var(--warn); }
.sim-term .tdim { color: var(--text-muted); }

/* packets */
.sim-packet { pointer-events: none; }
.sim-packet-accent { fill: var(--accent); }
.sim-packet-warn   { fill: var(--warn); }
.sim-packet-muted  { fill: var(--text-faint); }
.sim-packet-info   { fill: var(--info); }

@media (prefers-reduced-motion: reduce) {
  .sim-on [data-at] { transition: none; }
  .sim-progress { display: none; }
}

@media (max-width: 620px) {
  .sim-controls { flex-wrap: wrap; }
  .sim-progress { order: 10; flex-basis: 100%; }
  .sim-btn-text { display: none; }
}

/* ============================================================
   the sandbox — an operable model rather than a timeline.
   Without JS the poster and the topology stay; sandbox.js adds
   .sb-on and reveals the console.
   ============================================================ */
.sandbox {
  /* break out of the reading column when, and only when, there is
     genuinely room either side of it */
  margin: 26px calc(-1 * clamp(0px, (100vw - 1400px) / 2, 150px));
  padding: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sb-on .sb-poster { display: none; }
.sandbox:not(.sb-on) .sb-grid,
.sandbox:not(.sb-on) .sb-verdict,
.sandbox:not(.sb-on) .sb-crypto { display: none; }

.sb-poster {
  font-size: 13.5px; line-height: 1.6; color: var(--text-muted);
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 16px;
}
.sb-poster b { display: block; color: var(--text); margin-bottom: 3px; }

.sb-stage { overflow-x: auto; }
.sb-stage svg { display: block; margin: 0 auto; max-width: 100%; height: auto; min-width: 620px; }

/* ---- the drawing ---- */
.sb-svg-seg { fill: var(--danger-soft); stroke: var(--danger); stroke-width: 1.2; stroke-dasharray: 5 4; }
.sb-svg-seg-label { fill: var(--danger); }

/* the public-internet band along the bottom — always there, lit only when
   the focused route actually dips into it */
.sb-svg-lane { fill: var(--danger-soft); stroke: var(--danger); stroke-width: 1.2;
  stroke-dasharray: 5 4; opacity: .3; transition: opacity .25s; }
.sb-svg-lane.is-live { opacity: 1; }
.sb-svg-lane-label { fill: var(--text-faint); font-family: var(--mono); font-size: 10px;
  transition: fill .25s; }
.sb-svg-lane-label.is-live { fill: var(--danger); }
.sb-svg-cond { font-size: 10px; }
.sb-svg-wire { stroke: var(--text-faint); stroke-width: 1.3; }
.sb-svg-tap { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 3 3; }
.sb-svg-route { stroke: var(--border-strong); stroke-width: 2.4; stroke-linecap: round; }
.sb-svg-route.is-live { stroke: var(--accent); stroke-dasharray: 7 6; }
.sb-svg-route.is-dead { stroke: var(--danger); stroke-dasharray: 2 5; }
/* The tailcat route never borrows the accent the tailnet paths use. A tunnel
   that works is not good news, so it reads as the hatch it is whichever way
   it resolves, and the verdict text carries whether that was good or bad. */
.sb-svg-route-hatch.is-live,
.sb-svg-route-hatch.is-dead { stroke: var(--warn); stroke-dasharray: 11 4; }
.sb-stage [data-el].is-off { opacity: .38; }
.sb-stage .is-hidden { display: none; }

@keyframes sb-svg-march { to { stroke-dashoffset: -26; } }
.sb-on:not(.sb-still) .sb-svg-route.is-live { animation: sb-svg-march 1.1s linear infinite; }

.sb-legend {
  margin: 10px 2px 0; font-size: 11.5px; line-height: 1.6; color: var(--text-faint);
}
.sb-legend b { color: var(--text-muted); font-weight: 660; }

/* ---- the verdict line ---- */
.sb-verdict {
  margin: 14px 0 0; padding: 11px 14px; border-radius: 8px;
  font-size: 13.5px; line-height: 1.55;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint); color: var(--text-muted);
}
.sb-verdict.is-ok   { background: var(--ok-soft);     border-left-color: var(--ok);     color: var(--text); }
.sb-verdict.is-bad  { background: var(--danger-soft); border-left-color: var(--danger); color: var(--text); }
.sb-verdict.is-warn { background: var(--warn-soft);   border-left-color: var(--warn);   color: var(--text); }
.sb-verdict code { font-size: 12.5px; }

/* ---- the two columns ---- */
.sb-grid { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 16px; margin-top: 16px; }
.sb-col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.sb-col-readout { position: sticky; top: 14px; align-self: start; }

.sb-panel {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 13px;
}
.pp-title { font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); font-weight: 700; margin: 0 0 4px; }
.pp-note { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin: 0 0 10px; }
.pp-hr { height: 1px; background: var(--border); margin: 9px 0; }
.pp-sublabel { display: block; font-size: 11px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .06em; margin: 2px 0 6px; }

/* ---- toggles ---- */
.pp-row { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; }
.pp-toggle { cursor: pointer; }
.pp-toggle input { margin: 3px 0 0; flex: 0 0 auto; width: 15px; height: 15px;
  accent-color: var(--accent); cursor: pointer; }
.pp-toggle.is-danger input { accent-color: var(--danger); }
.pp-text { display: flex; flex-direction: column; min-width: 0; }
.pp-label { font-size: 13px; line-height: 1.35; color: var(--text); }
.pp-mono { font-family: var(--mono); font-size: 11.5px; }
.pp-sub { font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }
.pp-toggle.is-danger .pp-label { color: var(--danger); }
.pp-row.is-disabled { opacity: .4; cursor: not-allowed; }
.pp-grants { margin: 4px 0 2px; }

/* ---- segmented picker ---- */
.pp-segrow { flex-direction: column; gap: 6px; align-items: stretch; }
.pp-seg { display: flex; gap: 5px; }
.pp-seg-btn {
  font: inherit; font-size: 11.5px; line-height: 1; flex: 1;
  padding: 7px 8px; border-radius: 7px; cursor: pointer;
  background: var(--bg-raised); color: var(--text-muted);
  border: 1px solid var(--border);
}
.pp-seg-btn:hover { color: var(--text); border-color: var(--border-strong); }
.pp-seg-btn.is-on { background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-text); font-weight: 650; }

/* ---- the link grid ---- */
.lg { display: flex; flex-direction: column; gap: 5px; }
.lg-row { display: grid; grid-template-columns: 1fr 46px 50px 52px 62px; gap: 4px; align-items: center; }
.lg-head span { font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); text-align: center; }
.lg-head span:first-child { text-align: left; }
.lg-name { font-family: var(--mono); font-size: 11.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; }
.lg-btn, .lg-sel {
  font: inherit; font-family: var(--mono); font-size: 10.5px; line-height: 1;
  padding: 6px 2px; border-radius: 6px; cursor: pointer; text-align: center;
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
  width: 100%; -webkit-appearance: none; appearance: none;
}
.lg-btn.is-ok  { color: var(--ok); border-color: var(--ok); }
.lg-btn.is-bad { color: var(--danger); border-color: var(--danger); font-weight: 700; }
.lg-sel { padding: 6px 4px; }

/* ---- probe row ---- */
.probe { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.probe select {
  font: inherit; font-family: var(--mono); font-size: 11.5px;
  padding: 7px 6px; border-radius: 7px; min-width: 0; flex: 1 1 84px;
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
}
.probe-arrow, .probe-colon { color: var(--text-faint); font-size: 12px; }

.pp-btn {
  font: inherit; font-size: 12px; line-height: 1; padding: 8px 12px;
  border-radius: 7px; cursor: pointer;
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
}
.pp-btn:hover { border-color: var(--border-strong); }
.pp-btn.is-primary { background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-text); font-weight: 650; }
/* The one button on this panel that is not an attack. Its label is the lab's,
   word for word, so a reader who can drive one half can drive the other blind —
   which makes it long, and makes a line-height that assumes one line wrong. */
.pp-demo { width: 100%; line-height: 1.35; }
.pp-reset { margin-top: 10px; width: 100%; }

.pp-quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.pp-chip {
  font: inherit; font-size: 11px; line-height: 1; padding: 6px 9px;
  border-radius: 999px; cursor: pointer;
  background: var(--bg-raised); color: var(--text-muted); border: 1px solid var(--border);
}
.pp-chip:hover { color: var(--text); border-color: var(--accent); }

/* ---- named configurations ---- */
.pp-presets { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.pp-preset {
  font: inherit; text-align: left; cursor: pointer; padding: 9px 11px;
  border-radius: 7px; background: var(--bg-raised);
  border: 1px solid var(--border); border-left-width: 3px;
  display: flex; flex-direction: column; gap: 2px;
}
.pp-preset:hover { border-color: var(--border-strong); }
.pp-preset b { font-size: 13px; font-weight: 660; color: var(--text); }
.pp-preset span { font-size: 11px; color: var(--text-faint); line-height: 1.45; }
.pp-preset.is-ok   { border-left-color: var(--ok); }
.pp-preset.is-ok:hover   { border-color: var(--ok); }
.pp-preset.is-warn { border-left-color: var(--warn); }
.pp-preset.is-warn:hover { border-color: var(--warn); }
.pp-preset.is-bad  { border-left-color: var(--danger); }
.pp-preset.is-bad:hover  { border-color: var(--danger); }
.pp-audit { width: 100%; }

/* ---- the scorecard ---- */
.sb-score {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 8px; margin-bottom: 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--text-faint);
  background: var(--bg-sunken);
}
.sb-score b { font-family: var(--mono); font-size: 24px; font-weight: 700; line-height: 1; }
.sb-score span { font-size: 12px; color: var(--text-muted); }
.sb-score.is-ok   { background: var(--ok-soft);     border-left-color: var(--ok); }
.sb-score.is-ok b { color: var(--ok); }
.sb-score.is-warn { background: var(--warn-soft);   border-left-color: var(--warn); }
.sb-score.is-warn b { color: var(--warn); }
.sb-score.is-bad  { background: var(--danger-soft); border-left-color: var(--danger); }
.sb-score.is-bad b { color: var(--danger); }

.sb-scale {
  font-size: 11.5px; line-height: 1.6; color: var(--text-faint);
  margin: 0 0 4px; padding: 0 2px;
}
.sb-scale b { color: var(--text-muted); font-weight: 660; }

/* The blind spot in the score. Deliberately styled like a callout rather than
   like a check, because it is not one and must not be counted as one. */
.sb-tailcat {
  font-size: 11.5px; line-height: 1.6; color: var(--text);
  margin: 10px 0 4px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); border-left: 3px solid var(--text-faint);
  background: var(--bg-sunken);
}
.sb-tailcat b { font-weight: 660; }
.sb-tailcat.is-warn { background: var(--warn-soft);   border-left-color: var(--warn); }
.sb-tailcat.is-warn b { color: var(--warn); }
.sb-tailcat.is-bad  { background: var(--danger-soft); border-left-color: var(--danger); }
.sb-tailcat.is-bad b { color: var(--danger); }

.sb-audit-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); font-weight: 700; margin: 14px 0 6px;
}
.sb-check { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; }
.ck-mark { font-family: var(--mono); font-size: 13px; line-height: 1.4; flex: 0 0 auto; width: 14px; }
.sb-check.is-ok  .ck-mark { color: var(--ok); }
.sb-check.is-bad .ck-mark { color: var(--danger); font-weight: 700; }
.ck-body { display: flex; flex-direction: column; min-width: 0; }
.ck-label { font-size: 12.5px; color: var(--text); line-height: 1.4; }
.sb-check.is-bad .ck-label { color: var(--danger); }
.ck-why { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }

.sb-compare { display: flex; flex-direction: column; gap: 5px; }
.cmp-row { display: grid; grid-template-columns: 74px 1fr 44px; gap: 8px; align-items: center; }
.cmp-name { font-size: 11.5px; color: var(--text-muted); }
.cmp-bar { height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.cmp-bar > span { display: block; height: 100%; background: var(--accent); }
.cmp-score { font-family: var(--mono); font-size: 11px; color: var(--text-muted); text-align: right; }

/* ---- attacks ---- */
.pp-attacks { display: flex; flex-direction: column; gap: 5px; }
.pp-attack {
  font: inherit; text-align: left; cursor: pointer; padding: 8px 10px;
  border-radius: 7px; background: var(--bg-raised); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.pp-attack:hover { border-color: var(--danger); }
.pp-attack b { font-size: 12.5px; font-weight: 650; color: var(--text); }
.pp-attack span { font-size: 11px; color: var(--text-faint); line-height: 1.4; }
.pp-attack code { font-size: 10.5px; padding: .05em .3em; }
.pp-attack.is-danger { border-color: var(--danger); background: var(--danger-soft); }

/* ---- the readout ---- */
/* Five tabs do not fit a 320px column. Let the strip scroll rather than
   letting its min-content width push the whole page sideways. */
.sb-tabs { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.sb-tabs::-webkit-scrollbar { display: none; }
.sb-tab {
  font: inherit; font-family: var(--mono); font-size: 11.5px; line-height: 1;
  padding: 8px 12px; border-radius: 7px 7px 0 0; cursor: pointer; flex: 0 0 auto;
  background: transparent; color: var(--text-faint);
  border: 1px solid transparent; border-bottom: 2px solid transparent;
}
.sb-tab:hover { color: var(--text); }
.sb-tab.is-on { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 650; }

.sb-pane { display: none; }
.sb-pane.is-on { display: block; }
/* The readout column is sticky, so its panes must never exceed the viewport —
   past that, sticky positioning strands the bottom of the content off-screen. */
.sb-pane pre {
  margin: 0; max-height: calc(100vh - 130px); overflow: auto;
  font-size: 11.5px; line-height: 1.65; white-space: pre;
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px;
}
.sb-pane[data-pane="packets"] { max-height: calc(100vh - 130px); overflow-y: auto;
  display: none; flex-direction: column; gap: 7px; }
.sb-pane[data-pane="packets"].is-on { display: flex; }
.sb-pane[data-pane="audit"] { max-height: calc(100vh - 130px); overflow-y: auto; padding-right: 4px; }
.sb-empty { font-size: 12.5px; color: var(--text-faint); line-height: 1.55; margin: 0; padding: 10px 2px; }
.pp-foot { font-size: 11.5px; color: var(--text-faint); margin: 8px 0 0; line-height: 1.5; }

.sb-pkt {
  border: 1px solid var(--border); border-left: 3px solid var(--text-faint);
  border-radius: 0 8px 8px 0; padding: 9px 11px; background: var(--bg-code);
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
}
.sb-pkt.is-ok   { border-left-color: var(--ok); }
.sb-pkt.is-bad  { border-left-color: var(--danger); }
.sb-pkt.is-warn { border-left-color: var(--warn); }
.pk-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.pk-title { color: var(--text); font-weight: 650; }
.pk-rung { color: var(--text-faint); font-size: 10px; flex: 0 0 auto; }
.pk-head { color: var(--accent-text); word-break: break-all; }
.pk-why { color: var(--text); margin: 3px 0; font-family: var(--sans); font-size: 12px; line-height: 1.5; }
.pk-line { color: var(--text-muted); }
.pk-hex { margin-top: 5px; padding: 6px 8px; border-radius: 6px; word-break: break-all;
  background: var(--bg-sunken); color: var(--warn); font-size: 10.5px; line-height: 1.7; }

.sb-crypto { font-size: 11.5px; color: var(--text-faint); margin: 12px 0 0;
  padding-top: 10px; border-top: 1px solid var(--border); line-height: 1.5; }

/* ---- narrow ---- */
@media (max-width: 900px) {
  .sb-grid { grid-template-columns: 1fr; }
  .sb-col-readout { position: static; }
  /* not sticky any more, so the panes can be a comfortable fixed height again */
  .sb-pane pre,
  .sb-pane[data-pane="packets"],
  .sb-pane[data-pane="audit"] { max-height: 70vh; }
}
@media (max-width: 620px) {
  .sandbox { margin-left: -12px; margin-right: -12px; padding: 12px; border-radius: 0; }
  .sb-pane pre { font-size: 10.5px; }
  /* No room for a name column and four controls on one line. Drop the header —
     every control already reads as its own value ("up", "20%", "dropped") —
     and give the machine name a line of its own. */
  .lg-head { display: none; }
  .lg-row { grid-template-columns: repeat(4, 1fr); row-gap: 3px; }
  .lg-name { grid-column: 1 / -1; margin-top: 7px; color: var(--text-muted); }
}
@media (prefers-reduced-motion: reduce) {
  .sb-svg-route.is-live { animation: none !important; }
}
@media print {
  .sb-grid, .sb-verdict, .sb-crypto, .sb-poster { display: none !important; }
  .sandbox { border: 0; padding: 0; margin: 26px 0; }
}

/* ---------------- misc components ---------------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card h4 { margin-top: 0; margin-bottom: 6px; }
.card p:last-child { margin-bottom: 0; }
.card .k { font-family: var(--mono); font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }

.chapter-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 14px; margin: 22px 0; }
.chapter-cards a {
  text-decoration: none; color: inherit; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: block; transition: border-color .15s, transform .15s;
}
.chapter-cards a:hover { border-color: var(--accent); transform: translateY(-2px); }
.chapter-cards .n { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 700; }
.chapter-cards .t { font-weight: 680; font-size: 15.5px; margin: 5px 0 5px; }
.chapter-cards .d { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--border); }
.pager a {
  flex: 1; text-decoration: none; color: inherit; padding: 13px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised);
}
.pager a:hover { border-color: var(--accent); }
.pager .dir { font-size: 11px; color: var(--text-faint); font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.pager .ttl { font-weight: 660; font-size: 14.5px; margin-top: 3px; }
.pager a.next { text-align: right; }

.site-foot {
  margin: 34px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.6; color: var(--text-faint);
}
.site-foot b { color: var(--text-muted); font-weight: 660; }

.badge {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid currentColor; vertical-align: middle;
}
.badge.mac { color: var(--info); }
.badge.ios { color: var(--accent); }
.badge.android { color: var(--ok); }
.badge.linux { color: var(--warn); }
.badge.all { color: var(--text-muted); }

.kbd {
  font-family: var(--mono); font-size: 11.5px; padding: 2px 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--bg-raised); white-space: nowrap;
}

/* topbar (mobile) */
.topbar {
  display: none; position: sticky; top: 0; z-index: 50;
  background: var(--bg-raised); border-bottom: 1px solid var(--border);
  padding: 10px 14px; align-items: center; gap: 12px;
}
.topbar button {
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 15px; line-height: 1;
}
.topbar .tt { font-weight: 680; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.theme-toggle {
  position: fixed; bottom: 18px; right: 18px; z-index: 60;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  color: var(--text); box-shadow: var(--shadow-lg); font-size: 16px; line-height: 1;
}

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) { .toc { display: none; } }

@media (max-width: 860px) {
  .topbar { display: flex; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 100; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg); width: 84vw; max-width: 320px; flex-basis: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
    opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .main { padding: 0 18px 72px; }
  .content { padding-top: 18px; }
  h1 { font-size: 27px; }
  h2 { font-size: 20px; margin-top: 36px; }
  .lede { font-size: 16.5px; }
  body { font-size: 15.5px; }
  .pager { flex-direction: column; }
}

@media print {
  .sidebar, .toc, .topbar, .theme-toggle, .copy-btn, .pager { display: none !important; }
  .main { padding: 0; } .content { max-width: 100%; }
  body { background: #fff; color: #000; }
}
