/* Interfacing — interface phenomena laboratory (web)
   v00000-016 — top-bar live filter, fact fixes, version sync
   KRAUTROCK palette extracted from Interfacing/Shared/InterfacingPalette.swift
   Hexes converted from Swift Color(red:g:b:) literals — DO NOT GUESS. */

:root {
  /* ── Surfaces (from Swift) ──────────────────────────────── */
  --bg:           #0f121a;  /* 0.06 0.07 0.10 — near-black cool */
  --surface:      #1a1c29;  /* 0.10 0.11 0.16 — slate w/ blue */
  --surface-2:    #242736;  /* 0.14 0.15 0.21 — elevated panel */
  --surface-hover:#2b2f40;  /* 0.17 0.18 0.25 — hover */

  /* ── Accents ────────────────────────────────────────────── */
  --phosphor:        #33d98c;  /* 0.20 0.85 0.55 — oscilloscope green */
  --phosphor-bright: #4cf2a6;  /* 0.30 0.95 0.65 */
  --phosphor-dim:    #268c61;  /* 0.15 0.55 0.38 */
  --signal:          #e6382e;  /* 0.90 0.22 0.18 — deviation/warning red */
  --signal-dim:      #99261f;
  --info:            #4ca6f2;  /* 0.30 0.65 0.95 — electronic blue */
  --info-dim:        #3373b3;
  --motorik:         #ebb840;  /* 0.92 0.72 0.25 — warm amber */
  --motorik-dim:     #a68040;

  /* ── Text ───────────────────────────────────────────────── */
  --ink:        #ebedf2;  /* 0.92 0.93 0.95 */
  --ink-dim:    #8c919e;  /* 0.55 0.57 0.62 */
  --ink-muted:  #595e6b;  /* 0.35 0.37 0.42 */

  /* ── Borders ────────────────────────────────────────────── */
  --rule:       #333847;  /* 0.20 0.22 0.28 */
  --rule-soft:  rgba(51,217,140,0.15);

  /* ── Severity (deviations) ──────────────────────────────── */
  --sev-mild:      var(--info);
  --sev-bold:      var(--motorik);
  --sev-heretical: var(--signal);

  /* ── Type ───────────────────────────────────────────────── */
  --sans:  -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --serif: "New York", "Times New Roman", Georgia, serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ── Spacing tokens (mirror native xs8 sm14 md16 lg20 xl24) */
  --pad-xs: 8px;
  --pad-sm: 14px;
  --pad-md: 16px;
  --pad-lg: 20px;
  --pad-xl: 24px;
}

/* ── Reset ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
::selection { background: var(--phosphor); color: var(--bg); }

a {
  color: var(--phosphor);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
a:hover { border-bottom-color: var(--phosphor); }

:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; border-radius: 2px; }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--ink-muted) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--ink-muted); border-radius: 5px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }

/* ── Shell ──────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  background:
    linear-gradient(to bottom, rgba(51,217,140,0.03), transparent 40%),
    var(--bg);
  border-right: 1px solid var(--rule);
  padding: 24px 14px 14px 14px;
  font-family: var(--sans);
  font-size: 13px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
}

/* Italic-serif wordmark — "Inter" in ink, "facing" in phosphor.
   Native uses an HStack of two Text views. We use a span split
   in HTML; for legacy single-string `.wordmark` lowercase, we
   restyle via CSS. */
/* Brand block holds wordmark + tagline; we right-align the inline-block
   so the tagline's right edge sets the rail and the wordmark right-aligns
   to it. Whichever is wider sets the column width; the other right-aligns. */
.brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0 4px 18px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-soft);
}
.brand-block .wordmark,
.brand-block .tagline { text-align: right; margin: 0; }
.brand-block .wordmark { margin-bottom: 4px; }
.brand-block + .nav-section { margin-top: 4px; }

.wordmark {
  font-family: var(--serif);
  font-weight: 200;
  font-style: normal;
  font-size: 26px;
  letter-spacing: 0;
  margin: 0 0 4px 0;
  color: var(--ink);
  text-align: center;
  line-height: 1;
  text-transform: lowercase;
}
.wordmark .facing { font-style: italic; }
.wordmark::first-letter { /* fallback shimmer */ }
.wordmark .inter { color: var(--ink); }
.wordmark .facing { color: var(--phosphor); text-shadow: 0 0 6px rgba(51,217,140,0.35); }

.tagline {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  margin: 0 0 18px 0;
  text-align: center;
  text-transform: lowercase;
}

/* Phosphor separator under wordmark */
.sidebar > .wordmark + .tagline {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-soft);
}

.nav-section {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--motorik);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 18px 8px 6px;
  font-weight: 600;
}

.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list li { margin: 1px 0; }

.nav-list a {
  display: flex;
  align-items: center;
  padding: 7px 8px 7px 6px;
  color: var(--ink);
  border-radius: 8px;
  border: 1px solid transparent;
  border-bottom: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nav-list a:hover {
  background: var(--surface-2);
  border-bottom: none;
}
.nav-list a.current {
  background: rgba(51,217,140,0.12);
  border-color: rgba(51,217,140,0.25);
  color: var(--phosphor);
  font-weight: 700;
}

/* Numbered badge — circular, mono, phosphor */
.nav-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  margin-right: 10px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  background: rgba(51,217,140,0.10);
  border-radius: 50%;
  letter-spacing: 0;
}
.nav-list a.current .nav-num {
  background: var(--phosphor);
  color: var(--bg);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px 4px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
}
.sidebar-footer .ver { color: rgba(51,217,140,0.45); }

/* ── Main ───────────────────────────────────────────────── */
main {
  padding: 0;
  max-width: none;
  background: var(--bg);
}

/* Page headers (non-lab) */
main > h1 {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  padding: 28px 32px 4px;
  letter-spacing: -0.01em;
}
main > .subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-dim);
  margin: 0;
  padding: 0 32px 24px;
}
main > p, main > h2, main > h3, main > ul, main > ol,
main > blockquote, main > hr, main > .epigraph,
main > .principle, main > .self-aware, main > .citation,
main > .dev-toolbar, main > .dev-grid, main > .conc-list {
  margin-left: 32px;
  margin-right: 32px;
}
main > p { max-width: 68ch; }

h2 {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--phosphor);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 32px 32px 10px;
  font-weight: 700;
}
h3 { font-size: 16px; margin: 22px 32px 8px; font-weight: 700; }

p { margin: 0 0 14px; }

.epigraph {
  border-left: 2px solid var(--phosphor);
  padding: 6px 0 6px 18px;
  margin: 26px 32px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
}
.epigraph cite {
  display: block; margin-top: 6px;
  font-family: var(--mono); font-style: normal;
  font-size: 11px; color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 36px 32px; }

/* ── Lab page header (matches LabContainerView) ────────── */
.lab-header {
  background: var(--surface);
  border-bottom: 1px solid var(--rule-soft);
  padding: 16px 24px;
  margin: 0;
}

.lab-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lab-num, .lab-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  background: rgba(51,217,140,0.10);
  padding: 2px 6px;
  border-radius: 3px;
  margin: 0 8px 0 0;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: middle;
}
.lab-header h1, .lab-title {
  display: inline;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

.lab-principle, .lab-header .principle, .principle-line {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-dim);
  margin: 6px 0 0;
  max-width: 70ch;
}
/* Legacy .principle box neutralised */
.principle {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 6px 0 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  font-size: 14px;
}
.principle strong { color: var(--phosphor); font-family: var(--mono); font-style: normal; font-size: 11px; }

/* Top-right pills */
.lab-header-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.self-aware-pill, .source-chip {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.self-aware-pill {
  color: var(--motorik);
  background: rgba(235,184,64,0.12);
  border: 0;
}
.source-chip {
  color: var(--info);
  background: rgba(76,166,242,0.10);
  font-family: var(--mono);
  font-weight: 500;
  display: inline-block;
}

/* Try-this row — phosphor outlined */
.try-this {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 12px 0 0;
  padding: 8px 12px;
  background: rgba(51,217,140,0.06);
  border-radius: 6px;
  border-left: none;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}
.try-this::before {
  content: "▶";
  color: var(--phosphor);
  font-size: 11px;
  flex-shrink: 0;
  text-shadow: 0 0 6px rgba(51,217,140,0.4);
}
.try-this .label {
  display: inline;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--phosphor);
  text-transform: none;
  letter-spacing: 0;
  margin: 0 4px 0 0;
}

/* ── Lab back link / instrument area ────────────────────── */
.back {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  margin: 14px 0 4px 24px;
  letter-spacing: 0.04em;
}
.back:hover { color: var(--phosphor); }

.instrument {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 22px;
  margin: 18px 24px;
}
.instrument-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
@media (max-width: 720px) { .instrument-grid { grid-template-columns: 1fr; } }
.instrument-grid .canvas-wrap { min-height: 220px; }

.canvas-wrap {
  background: #000;
  border: 1px solid var(--rule);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
canvas { display: block; width: 100%; height: auto; }

/* ── Controls panel ─────────────────────────────────────── */
.controls {
  display: block;
  font-family: var(--sans);
  padding: 4px 0;
}
.controls .control { margin-bottom: 16px; }
.controls .section-label,
.controls h4 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 8px;
  text-shadow: 0 0 6px rgba(51,217,140,0.25);
}
.control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: 500;
}
.control .readout,
.readout {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--phosphor);
  font-weight: 600;
}
.control input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 18px;
}
.control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right,
    var(--phosphor) 0%,
    var(--phosphor) var(--fill, 50%),
    var(--surface-2) var(--fill, 50%),
    var(--surface-2) 100%);
  border-radius: 2px;
}
.control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--phosphor);
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(51,217,140,0.5);
  cursor: pointer;
  border: 0;
}
.control input[type="range"]::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right,
    var(--phosphor) 0%,
    var(--phosphor) var(--fill, 50%),
    var(--surface-2) var(--fill, 50%),
    var(--surface-2) 100%);
  border-radius: 2px;
}
.control input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--phosphor); border: 0;
  box-shadow: 0 0 6px rgba(51,217,140,0.5);
}
.controls .toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }

/* Phenomenon + bio disclosure blocks (added v00000-016) */
details.phenomenon, details.bio {
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--surface-1);
  border-left: 3px solid var(--phosphor);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
details.bio {
  border-left-color: var(--motorik, #ffc857);
}
details.phenomenon > summary, details.bio > summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin-bottom: 8px;
  list-style: none;
}
details.phenomenon > summary::-webkit-details-marker,
details.bio > summary::-webkit-details-marker { display: none; }
details.phenomenon[open] > summary, details.bio[open] > summary { color: var(--phosphor); }
details.bio[open] > summary { color: var(--motorik, #ffc857); }
details.phenomenon p, details.bio p { margin: 6px 0; }
details.phenomenon p.mechanism { color: var(--ink-dim); padding-top: 4px; border-top: 1px dashed var(--rule); margin-top: 10px; }
details.bio p.cite-line { font-size: 11px; color: var(--ink-dim); font-family: var(--mono); }
.readout-block {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  letter-spacing: 0.04em;
}
.readout-block span { color: var(--phosphor); }

/* Buttons */
button, .btn {
  background: transparent;
  color: var(--phosphor);
  border: 1px solid var(--phosphor);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 120ms ease, color 120ms ease;
}
button:hover, .btn:hover {
  background: var(--phosphor);
  color: var(--bg);
}
.controls button { width: 100%; margin-top: 4px; }

/* ── Self-aware disclosure ──────────────────────────────── */
.self-aware {
  margin: 12px 24px;
  border: 1px solid rgba(235,184,64,0.30);
  border-radius: 6px;
  padding: 12px 16px;
  background: rgba(235,184,64,0.06);
}
.self-aware summary {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--motorik);
  cursor: pointer;
  letter-spacing: 0;
  text-transform: none;
  list-style: none;
}
.self-aware summary::-webkit-details-marker { display: none; }
.self-aware summary::before { content: "▸ "; }
.self-aware[open] summary::before { content: "▾ "; }
.self-aware p {
  color: var(--ink);
  font-size: 13px;
  margin-top: 8px;
}

.citation {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  margin: 30px 24px 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  letter-spacing: 0.04em;
}

/* ── Lab bottom navigation (pagination dots) ────────────── */
.lab-footnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 30px 0 0;
  padding: 12px 24px 14px;
  background: var(--surface);
  border-top: 1px solid var(--rule-soft);
  font-family: var(--sans);
  font-size: 12px;
}
.lab-footnav a {
  color: var(--ink-dim);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 5px;
  border-bottom: none;
  background: var(--surface-2);
}
.lab-footnav a:hover { color: var(--ink); border-bottom: none; }
.lab-footnav a.next {
  color: var(--bg);
  background: var(--phosphor);
  font-weight: 700;
  text-shadow: none;
}
.lab-footnav a.next:hover { background: var(--phosphor-bright); }
.lab-footnav .pager-dots {
  display: flex;
  gap: 5px;
  flex: 1;
  justify-content: center;
}
.lab-footnav .pager-dots .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--surface-2);
}
.lab-footnav .pager-dots .dot.current {
  background: var(--phosphor);
  box-shadow: 0 0 6px rgba(51,217,140,0.5);
}

/* ── Contrast lab bits (kept compatible) ────────────────── */
.swatch { padding: 32px 24px; border-radius: 4px; font-size: 18px; margin: 14px 0; }
.swatch .big { font-size: 28px; font-weight: 700; }
.swatch .small { font-size: 13px; }
.ratio-readout { font-family: var(--mono); font-size: 22px; color: var(--phosphor); margin: 8px 0; font-weight: 600; }
.grade-row { display: flex; gap: 14px; font-family: var(--mono); font-size: 11px; margin: 10px 0; }
.grade { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 3px; letter-spacing: 0.06em; }
.grade.pass { border-color: var(--phosphor); color: var(--phosphor); }
.grade.fail { border-color: var(--signal); color: var(--signal); }

/* ── Footer ─────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--rule);
  padding: 18px 32px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  text-align: center;
  letter-spacing: 0.06em;
}
footer a { color: var(--ink-dim); border-bottom-color: var(--rule); }
footer a:hover { color: var(--phosphor); }

/* ── Deviations / Concordance / Help shared ─────────────── */
.dev-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 20px 32px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.dev-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-filter {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dev-filter:hover { color: var(--phosphor); border-color: var(--phosphor); }
.dev-filter.active { background: var(--phosphor); color: var(--bg); border-color: var(--phosphor); }
.dev-filter[data-sev="MILD"]:hover,
.dev-filter[data-sev="MILD"].active { color: var(--bg); background: var(--sev-mild); border-color: var(--sev-mild); }
.dev-filter[data-sev="BOLD"]:hover,
.dev-filter[data-sev="BOLD"].active { color: var(--bg); background: var(--sev-bold); border-color: var(--sev-bold); }
.dev-filter[data-sev="HERETICAL"]:hover,
.dev-filter[data-sev="HERETICAL"].active { color: var(--ink); background: var(--sev-heretical); border-color: var(--sev-heretical); }
.dev-search {
  flex: 1;
  min-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
}
.dev-search:focus { border-color: var(--phosphor); outline: none; }
.dev-search::placeholder { color: var(--ink-muted); }
.dev-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--phosphor);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.dev-grid { display: grid; gap: 8px; margin: 0 32px; }
.dev-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: 4px;
  transition: background 120ms ease;
}
.dev-card:hover { background: var(--surface-2); }
.dev-card.sev-MILD       { border-left-color: var(--sev-mild); }
.dev-card.sev-BOLD       { border-left-color: var(--sev-bold); }
.dev-card.sev-HERETICAL  { border-left-color: var(--sev-heretical); }
.dev-card summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--sans);
  list-style: none;
}
.dev-card summary::-webkit-details-marker { display: none; }
.dev-id {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  background: rgba(51,217,140,0.10);
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dev-title { font-size: 14px; color: var(--ink); flex: 1; font-weight: 500; }
.dev-sev {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--ink-dim);
}
.dev-card.sev-MILD .dev-sev      { color: var(--sev-mild); }
.dev-card.sev-BOLD .dev-sev      { color: var(--sev-bold); }
.dev-card.sev-HERETICAL .dev-sev { color: var(--sev-heretical); }

.dev-body { padding: 6px 16px 16px; border-top: 1px solid var(--rule); }
.dev-sec {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 2px solid var(--info);
  background: rgba(76,166,242,0.04);
}
.dev-sec:nth-of-type(2) { border-left-color: var(--phosphor); background: rgba(51,217,140,0.04); }
.dev-sec:nth-of-type(3) { border-left-color: var(--motorik); background: rgba(235,184,64,0.04); }
.dev-sec:nth-of-type(4) { border-left-color: var(--signal); background: rgba(230,56,46,0.04); }
.dev-lbl {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--info);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.dev-sec:nth-of-type(2) .dev-lbl { color: var(--phosphor); }
.dev-sec:nth-of-type(3) .dev-lbl { color: var(--motorik); }
.dev-sec:nth-of-type(4) .dev-lbl { color: var(--signal); }
.dev-sec p, .conc-source, .conc-note {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.dev-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--rule);
}

/* Concordance */
.conc-list { display: grid; gap: 8px; margin: 0 32px; }
.conc-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.conc-card summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
  list-style: none;
  font-family: var(--sans);
}
.conc-card summary::-webkit-details-marker { display: none; }
.conc-term { flex: 1; font-size: 14px; color: var(--ink); font-weight: 600; }
.conc-cat {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--phosphor);
  text-transform: uppercase;
  font-weight: 700;
}
.conc-body { padding: 4px 16px 14px; border-top: 1px solid var(--rule); font-size: 13px; }
.conc-def { margin: 10px 0; color: var(--ink); line-height: 1.5; }
.conc-link { font-family: var(--mono); font-size: 11px; color: var(--phosphor); margin: 6px 0; }
.conc-source {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-dim); margin: 10px 0;
  padding: 8px 10px;
  background: rgba(76,166,242,0.04);
  border-left: 2px solid var(--info);
}
.conc-note {
  font-size: 12px; margin: 10px 0;
  padding: 8px 10px;
  background: rgba(235,184,64,0.04);
  border-left: 2px solid var(--motorik);
  color: var(--ink);
}

/* ── Reduce Motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Stub leftovers ─────────────────────────────────────── */
.stub { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); padding: 18px; }

/* ── Top bar (v00000-009) ───────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-crumb {
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.topbar-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.topbar-nav a {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink-dim);
  border: 1px solid transparent;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.topbar-nav a:hover {
  color: var(--phosphor);
  background: rgba(51,217,140,0.06);
  border-bottom-color: transparent;
  border-color: rgba(51,217,140,0.18);
}
.topbar-nav a[aria-current="page"] {
  color: var(--phosphor);
  background: rgba(51,217,140,0.10);
  border-color: rgba(51,217,140,0.30);
}
.topbar-nav .help-pill {
  color: var(--phosphor);
  border-color: rgba(51,217,140,0.30);
  background: rgba(51,217,140,0.06);
  margin-left: 6px;
}
.topbar-nav .help-pill:hover {
  background: rgba(51,217,140,0.14);
}
/* ── Top-bar live filter (v00000-016) ─────────────────────── */
.topbar-filter {
  display: flex;
  align-items: center;
  margin-left: 10px;
}
.topbar-filter input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  height: 22px;
  width: 150px;
  padding: 0 8px;
  border-radius: 11px;
  outline: none;
  transition: border-color 120ms ease, width 160ms ease;
}
.topbar-filter input[type="search"]::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}
.topbar-filter input[type="search"]:focus {
  border-color: rgba(51,217,140,0.55);
  width: 200px;
}
/* Sidebar must sit below the topbar; the shell already uses sticky too. */
.shell { position: relative; }
.sidebar { top: 36px; max-height: calc(100vh - 36px); }

/* ── Control section header (v00000-009) ────────────────── */
.control-section {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--motorik);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 10px 0 4px 0;
  font-weight: 700;
}

/* ── v00000-016 additions ───────────────────────────────── */

/* Source chip is now a real button */
button.source-chip {
  cursor: pointer;
  border: 1px solid rgba(76,166,242,0.35);
  text-transform: none;
  letter-spacing: 0;
  padding: 4px 10px;
}
button.source-chip:hover {
  background: rgba(76,166,242,0.20);
  color: var(--info);
}

/* What's happening box (rendered below try-this on every lab) */
.whats-happening {
  margin: 12px 24px 0;
  padding: 12px 16px;
  background: rgba(76,166,242,0.06);
  border-left: 3px solid var(--info, #4ca6f2);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.whats-happening .label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--info, #4ca6f2);
  margin-bottom: 6px;
  font-weight: 700;
}

/* Concordance fly-over panel */
.concord-flyover-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 9000;
  display: flex; justify-content: flex-end;
  animation: fadeIn 160ms ease;
}
.concord-flyover {
  width: min(520px, 92vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--rule);
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  padding: 26px 30px 30px;
  overflow-y: auto;
  font-family: var(--sans);
  color: var(--ink);
  animation: slideIn 220ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.concord-flyover .close {
  float: right;
  background: transparent; border: 1px solid var(--rule);
  color: var(--ink-dim); cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 16px; padding: 0; line-height: 1;
  text-transform: none; letter-spacing: 0;
}
.concord-flyover .close:hover { color: var(--phosphor); border-color: var(--phosphor); background: transparent; }
.concord-flyover h2 {
  font-family: var(--mono); color: var(--phosphor);
  font-size: 18px; margin: 0 0 4px; padding-right: 36px;
}
.concord-flyover .cat {
  font-family: var(--mono); font-size: 10px;
  color: var(--motorik); text-transform: uppercase;
  letter-spacing: 0.10em; margin-bottom: 14px;
}
.concord-flyover .def { font-size: 14px; line-height: 1.6; margin: 10px 0 14px; }
.concord-flyover .src {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-dim); padding: 10px 12px;
  background: var(--surface-1); border-left: 2px solid var(--info, #4ca6f2);
  border-radius: 0 3px 3px 0; white-space: pre-wrap;
}
.concord-flyover .lab-link {
  display: inline-block; margin-top: 14px;
  font-family: var(--mono); font-size: 11px;
  color: var(--phosphor); text-decoration: none;
  border: 1px solid var(--phosphor); padding: 5px 10px;
  border-radius: 3px;
}
.concord-flyover .lab-link:hover { background: var(--phosphor); color: var(--bg); }
.concord-flyover .design-note {
  margin-top: 14px; font-size: 12px; color: var(--ink-dim);
  font-style: italic; padding-top: 10px; border-top: 1px dashed var(--rule);
}

/* Dark Patterns wing */
.dp-essay {
  margin: 14px 24px 22px;
  padding: 16px 20px;
  background: rgba(255,76,94,0.06);
  border-left: 3px solid #ff4c5e;
  border-radius: 0 4px 4px 0;
  font-size: 14px; line-height: 1.6;
  color: var(--ink);
}
.dp-essay strong { color: #ff4c5e; }
.dp-toolbar {
  display: flex; gap: 12px; align-items: center;
  margin: 0 24px 16px; flex-wrap: wrap;
}
.dp-search {
  flex: 1; min-width: 200px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--rule); padding: 7px 10px;
  font-family: var(--mono); font-size: 12px; border-radius: 4px;
}
.dp-count { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.dp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px; margin: 0 24px 30px;
}
.dp-card {
  background: var(--surface-1);
  border: 1px solid var(--rule);
  border-left: 3px solid #ff4c5e;
  border-radius: 4px;
  padding: 16px 18px;
  font-size: 13px; line-height: 1.55;
}
.dp-card h3 {
  font-family: var(--mono); font-size: 14px;
  color: #ff4c5e; margin: 0 0 8px;
  text-transform: none; letter-spacing: 0;
}
.dp-card .dp-sec { margin: 8px 0; }
.dp-card .dp-lbl {
  display: block; font-family: var(--mono);
  font-size: 9px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.10em;
  margin-bottom: 2px;
}
.dp-card .dp-cite {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed var(--rule);
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-dim);
}

/* ============ dark pattern demos (v012) ============ */
.dpd-intro { max-width: 760px; margin: 40px auto 24px; }
.dpd-intro h2 { font-family: var(--mono); font-size: 18px; color: #ff4c5e; margin: 0 0 10px; letter-spacing: 0.02em; }
.dpd-intro p { font-size: 14px; line-height: 1.6; color: var(--ink); margin: 0 0 8px; }
.dpd-intro .dpd-warn { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.10em; }
.dpd-demo-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  margin: 0 auto 48px; max-width: 1100px;
}
.dpd-box {
  border: 1px solid #ff4c5e; border-radius: 4px;
  padding: 14px; background: rgba(255,76,94,0.04);
  display: flex; flex-direction: column;
}
.dpd-box:focus { outline: 2px solid #ff4c5e; outline-offset: 2px; }
.dpd-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px dashed var(--rule); padding-bottom: 8px; margin-bottom: 10px; }
.dpd-head h3 { font-family: var(--mono); font-size: 13px; color: #ff4c5e; margin: 0; text-transform: none; }
.dpd-lever { font-family: var(--mono); font-size: 9px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.10em; }
.dpd-stage { min-height: 120px; padding: 10px 4px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.dpd-modal { border: 1px solid var(--rule); padding: 12px; background: var(--paper); border-radius: 3px; }
.dpd-modal-t { font-size: 13px; margin: 0 0 6px; color: var(--ink); font-weight: 600; }
.dpd-modal-s { font-family: var(--mono); font-size: 10px; color: var(--ink-dim); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.dpd-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dpd-btn { font-family: var(--mono); font-size: 11px; padding: 6px 12px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; border-radius: 2px; }
.dpd-btn:hover { background: rgba(0,0,0,0.04); }
.dpd-btn.primary { background: #1a8f3c; color: #fff; border-color: #1a8f3c; }
.dpd-btn.neutral { background: var(--paper); }
.dpd-btn.shame { font-size: 10px; color: var(--ink-dim); text-decoration: underline; background: transparent; border: none; padding: 6px 4px; }
.dpd-btn.huge { font-size: 14px; padding: 10px 20px; background: #1a8f3c; color: #fff; border-color: #1a8f3c; box-shadow: 0 0 0 2px rgba(26,143,60,0.25); }
.dpd-btn.tiny-grey { font-size: 9px; color: #bbb; background: transparent; border: none; padding: 4px 2px; text-decoration: underline; }
.dpd-btn.accept-glow { background: #1a8f3c; color: #fff; border-color: #1a8f3c; padding: 10px 22px; font-size: 13px; box-shadow: 0 0 12px rgba(26,143,60,0.6); animation: dpd-pulse 2s infinite; }
@keyframes dpd-pulse { 0%,100% { box-shadow: 0 0 12px rgba(26,143,60,0.6);} 50% { box-shadow: 0 0 20px rgba(26,143,60,0.9);} }
.dpd-btn.hidden-decline { font-size: 7px; color: #d4d4d0; background: #eae8e0; border: none; padding: 2px 3px; }
.dpd-check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.5; cursor: pointer; }
.dpd-check input { margin-top: 2px; }
.dpd-timer { font-family: var(--mono); font-size: 24px; color: #ff4c5e; text-align: center; letter-spacing: 0.05em; }
.dpd-stock { font-family: var(--mono); font-size: 11px; color: #ff4c5e; text-align: center; text-transform: uppercase; letter-spacing: 0.08em; animation: dpd-blink 1.2s infinite; }
@keyframes dpd-blink { 50% { opacity: 0.5; } }
.dpd-bill { border: 1px solid var(--rule); padding: 10px; background: var(--paper); font-family: var(--mono); font-size: 11px; }
.dpd-bill-row { display: flex; justify-content: space-between; padding: 3px 0; }
.dpd-bill-row.total { border-top: 1px solid var(--rule); margin-top: 6px; padding-top: 6px; font-weight: 700; color: #ff4c5e; }
.dpd-gotcha { font-family: var(--mono); font-size: 11px; color: transparent; min-height: 40px; padding: 6px 0; line-height: 1.5; transition: color 0.2s; }
.dpd-gotcha.on { color: #ff4c5e; }
.dpd-controls { border-top: 1px dashed var(--rule); padding-top: 8px; margin-top: auto; }
.dpd-toggle { font-family: var(--mono); font-size: 10px; color: var(--ink-dim); background: transparent; border: 1px solid var(--rule); padding: 5px 10px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.08em; border-radius: 2px; }
.dpd-toggle:hover { color: var(--ink); border-color: var(--ink); }

/* ── v00000-016 — Cmd+K command palette ──────────────────────────── */
.if-palette-pill {
  margin-left: 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  background: rgba(51,217,140,0.08);
  border: 1px solid rgba(51,217,140,0.35);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.if-palette-pill:hover {
  background: rgba(51,217,140,0.18);
  color: var(--phosphor-bright);
}
.if-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding-top: 12vh;
}
.if-palette-backdrop.open { display: flex; }
.if-palette {
  width: 640px;
  max-width: calc(100vw - 32px);
  max-height: 500px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--phosphor);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(51,217,140,0.18);
  overflow: hidden;
  font-family: var(--mono);
}
.if-palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51,217,140,0.18);
}
.if-palette-prompt {
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  letter-spacing: 0.06em;
}
.if-palette-search input[type="search"] {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  padding: 4px 0;
}
.if-palette-search input[type="search"]::placeholder {
  color: var(--ink-muted);
  font-size: 14px;
}
.if-palette-hint {
  font-size: 11px;
  color: var(--ink-muted);
  border: 1px solid var(--ink-muted);
  border-radius: 3px;
  padding: 1px 5px;
}
.if-palette-list {
  flex: 1;
  overflow: auto;
  padding: 6px 0 8px;
}
.if-palette-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor-dim);
  letter-spacing: 0.12em;
  padding: 10px 14px 4px;
  text-transform: uppercase;
}
.if-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.if-palette-row.selected {
  background: rgba(51,217,140,0.10);
  border-left-color: var(--phosphor);
}
.if-palette-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--phosphor);
  background: rgba(51,217,140,0.12);
  border: 1px solid rgba(51,217,140,0.30);
  border-radius: 3px;
  padding: 2px 6px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 92px;
  text-align: center;
}
.if-palette-row-body {
  flex: 1;
  min-width: 0;
}
.if-palette-row-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.if-palette-row-preview {
  font-size: 11px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.if-palette-row-hint {
  font-size: 11px;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.if-palette-empty {
  padding: 24px 18px;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.5;
}
.if-palette-footer {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--ink-muted);
  border-top: 1px solid rgba(51,217,140,0.12);
}

/* ── PHONE MODE ────────────────────────────────────────────────
   Enabled by phone-mode init in global-palette.js when
   viewport is narrow or ?phone=1 or localStorage flag is set.
   Signals that the user is seeing a minimal feature set and
   strips the page down to the parts that work under a thumb. */
.if-phone-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 9000;
  padding: 10px 14px;
  background: #0c1a14;
  color: #9ef0c6;
  font: 500 13px/1.35 "Questrial", system-ui, sans-serif;
  border-bottom: 1px solid rgba(51,217,140,0.35);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.if-phone-banner strong { color: #33d98c; font-weight: 700; letter-spacing: 0.02em; }
.if-phone-banner a { color: #9ef0c6; text-decoration: underline; margin-left: 10px; white-space: nowrap; }
body.phone .if-phone-banner { display: block; }
body.phone .desktop-only { display: none !important; }
body.phone main { padding: 16px 14px 80px; font-size: 15px; }
body.phone main h1 { font-size: 28px; }
body.phone main h2 { font-size: 18px; margin-top: 22px; }
body.phone .sidebar { padding: 14px; }
body.phone .sidebar .nav-list a { padding: 12px 8px; font-size: 15px; }
body.phone .sidebar-footer { justify-content: space-between; }
body.phone canvas, body.phone .instrument, body.phone .instrument-grid > * {
  max-width: 100% !important;
}
body.phone .instrument-grid { grid-template-columns: 1fr !important; gap: 14px; }
body.phone footer { padding: 14px; font-size: 11px; text-align: center; }
.if-phone-link { display: inline-block; margin-top: 8px; font-size: 11px; color: var(--ink-muted); }
@media (min-width: 820px) { .if-phone-link { display: inline-block; } }
body.phone .phone-only { display: block !important; }

/* ── PHONE MODE v2 — bulletproof lab layout ────────────────────
   Overrides the earlier phone-mode block. On phone, a lab page
   is: sticky top bar (✕ / title / ← →), instrument, nothing
   else. Everything decorative is hidden. The index is trimmed
   to a single tappable lab list with a notice banner. */
body.phone {
  /* Make sure nothing horizontally scrolls under a thumb. */
  overflow-x: hidden;
}
body.phone .shell { display: block !important; padding-top: 96px; }
body.phone .topbar,
body.phone .sidebar,
body.phone .if-license-credit,
body.phone footer,
body.phone .lab-footnav,
body.phone .pager-dots,
body.phone details.phenomenon,
body.phone details.self-aware,
body.phone details.bio,
body.phone .whats-happening,
body.phone .citation,
body.phone .lab-header-meta,
body.phone .concord-flyover-backdrop { display: none !important; }

body.phone .if-phone-banner {
  /* Taller tap target, safe-area aware. */
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
}

/* Sticky lab nav — injected by lab-common.js phone block. */
.if-phone-labnav {
  display: none !important;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9500;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px;
  background: #0c1a14;
  color: #9ef0c6;
  border-bottom: 1px solid rgba(51,217,140,0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 13px/1.1 "Questrial", system-ui, sans-serif;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
body.phone .if-phone-labnav { display: flex !important; }
/* On lab pages the labnav is the signal — hide the general banner
   to keep a single sticky bar. Index still gets the full banner. */
body.phone[data-lab] .if-phone-banner { display: none !important; }
body.phone[data-lab] .shell { padding-top: calc(env(safe-area-inset-top, 0px) + 70px); }

.if-phone-labnav .pn-close {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; line-height: 1;
  color: #9ef0c6; text-decoration: none;
  border: 1px solid rgba(51,217,140,0.25);
  border-radius: 6px;
}
.if-phone-labnav .pn-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
}
.if-phone-labnav .pn-num {
  font-size: 10px;
  color: rgba(158,240,198,0.65);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.if-phone-labnav .pn-name {
  font-size: 14px;
  font-weight: 600;
  color: #e8fff1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.if-phone-labnav .pn-arrows {
  flex: 0 0 auto;
  display: flex; gap: 6px;
}
.if-phone-labnav .pn-arrows a,
.if-phone-labnav .pn-arrows span {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: #9ef0c6; text-decoration: none;
  border: 1px solid rgba(51,217,140,0.25);
  border-radius: 6px;
}
.if-phone-labnav .pn-arrows span { opacity: 0.25; }

/* Lab page content reflow on phone. */
body.phone main {
  padding: 14px 12px 40px !important;
  max-width: 100vw;
}
body.phone .lab-header {
  margin-bottom: 12px;
}
body.phone .lab-header-top > div { min-width: 0; }
body.phone .lab-badge { display: none; }
body.phone .lab-title {
  font-size: 20px !important;
  display: block;
}
body.phone .principle-line {
  font-size: 13px !important;
  margin-top: 6px;
}
body.phone .try-this {
  font-size: 13px;
  padding: 10px;
  margin-top: 10px;
}
body.phone .instrument {
  padding: 0 !important;
  margin: 0 -12px;
}
body.phone .instrument-grid {
  grid-template-columns: 1fr !important;
  gap: 10px;
  padding: 8px;
}
body.phone .canvas-wrap,
body.phone .canvas-wrap canvas {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}
body.phone .controls {
  padding: 10px !important;
}
body.phone .control label {
  font-size: 13px !important;
}
body.phone .control input[type="range"] {
  height: 32px;
}

/* Index page: show only the lab list. */
body.phone main > h1 { font-size: 26px; margin: 4px 0 2px; }
body.phone main > .subtitle { font-size: 12px; margin-bottom: 14px; }
body.phone .phone-only {
  display: block !important;
  font-size: 14px;
  color: #9ef0c6;
  margin: 10px 0 16px;
}
body.phone .desktop-only { display: none !important; }

/* On the INDEX page, synthesize a tappable lab list from the
   existing sidebar nav (which is hidden via .sidebar rule above).
   Easier path: unhide the sidebar lists but only on the index,
   and style them as full-width cards. */
body.phone:not([data-lab]) .sidebar {
  display: block !important;
  position: static !important;
  width: 100% !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  max-height: none !important;
}
body.phone:not([data-lab]) .sidebar .brand-block,
body.phone:not([data-lab]) .sidebar .sidebar-footer { display: none !important; }
body.phone:not([data-lab]) .sidebar .nav-section {
  margin: 18px 0 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(158,240,198,0.7);
  padding: 0 2px;
}
body.phone:not([data-lab]) .sidebar .nav-list {
  list-style: none;
  margin: 0; padding: 0;
}
body.phone:not([data-lab]) .sidebar .nav-list li { margin: 0; }
body.phone:not([data-lab]) .sidebar .nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  min-height: 48px;
  border: 1px solid rgba(51,217,140,0.14);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 15px;
  color: #e8fff1;
  text-decoration: none;
  background: rgba(12,26,20,0.55);
}
body.phone:not([data-lab]) .sidebar .nav-list a .nav-num {
  color: rgba(51,217,140,0.75);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}
/* Hide Elsewhere nav group on phone index to keep the feature set small. */
body.phone:not([data-lab]) .sidebar .nav-section:nth-of-type(4),
body.phone:not([data-lab]) .sidebar .nav-section:nth-of-type(4) + .nav-list {
  display: none !important;
}
