/* ==========================================================================
   Water Workbench (FSD-W1) — Mobile-First 3D Observatory Design System
   ========================================================================== */

:root {
  --bg-primary: #06090d;
  --bg-hud: rgba(12, 18, 26, 0.85);
  --bg-card: rgba(18, 27, 38, 0.95);
  --bg-chip: #162230;
  --border: #223245;
  --border-focus: #3b5a80;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #475569;

  --cyan: #00e5ff;
  --green: #00ff88;
  --purple: #b388ff;
  --amber: #ffd600;
  --rose: #ff2a55;

  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Space Grotesk', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 12px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  touch-action: none;
  user-select: none;
}

#app-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   1. 3D WebGL Canvas
   ========================================================================== */

#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* ==========================================================================
   2. Top Mobile HUD Bar
   ========================================================================== */

#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  gap: 8px;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.hud-logo {
  font-size: 18px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.hud-title-col {
  display: flex;
  flex-direction: column;
}

.hud-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.hud-mock-badge {
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(255, 179, 0, 0.15);
  border: 1px solid rgba(255, 179, 0, 0.4);
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.hud-tier {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--cyan);
  font-weight: 600;
}

.hud-telemetry-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(6, 9, 13, 0.8);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-family: var(--font-mono);
}

.pill-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.p-label {
  font-size: 7px;
  color: var(--text-muted);
}

.p-val {
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.p-val.green { color: var(--green); }
.p-val.cyan { color: var(--cyan); }

.hud-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-chip);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--border-focus);
  border-color: var(--cyan);
}

.icon-btn.highlight {
  background: #17382e;
  border-color: #2b775f;
  color: var(--green);
}

/* ==========================================================================
   3. Floating Tier Zoom Selector
   ========================================================================== */

/* ==========================================================================
   4. Floating HUD Reticle & Notifications
   ========================================================================== */

#reticle-hud {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.reticle-ring {
  width: 64px;
  height: 64px;
  border: 2px dashed var(--purple);
  border-radius: 50%;
  background: rgba(179, 136, 255, 0.15);
  box-shadow: 0 0 14px rgba(179, 136, 255, 0.5);
  animation: rotateRing 8s linear infinite;
}

@keyframes rotateRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.reticle-label {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--purple);
  background: rgba(0, 0, 0, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
}

#refinement-banner {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 42, 85, 0.2);
  border: 1px solid var(--rose);
  color: var(--rose);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  box-shadow: 0 0 15px rgba(255, 42, 85, 0.4);
}

.settling-pill {
  position: absolute;
  bottom: 120px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hud);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 14px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #fff;
  z-index: 10;
}

.settling-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.settling-pill.settling .dot {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
  animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
  from { opacity: 0.3; }
  to { opacity: 1.0; }
}

.hidden { display: none !important; }

/* ==========================================================================
   5. Bottom Floating Dock & Expandable Control Sheet (Mobile-First)
   ========================================================================== */


.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-row label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.sub-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  background: #1c2b3c;
  border-radius: 3px;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: ew-resize;
}

.sheet-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  min-width: 65px;
  text-align: right;
}

.unit-pills {
  display: flex;
  gap: 3px;
}

.u-pill {
  padding: 2px 6px;
  font-size: 9px;
  background: var(--bg-chip);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}

.u-pill.active {
  background: #18283a;
  border-color: var(--cyan);
  color: var(--cyan);
}

.mix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mix-chip {
  padding: 6px 8px;
  background: var(--bg-chip);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.mix-chip.active {
  background: #18283a;
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-micro {
  padding: 2px 6px;
  font-size: 9px;
  background: #1b2838;
  border: 1px solid var(--border-focus);
  color: var(--cyan);
  border-radius: 4px;
  cursor: pointer;
}

/* ==========================================================================
   6. Slide-Out Telemetry Drawer (WB-5)
   ========================================================================== */

.drawer {
  position: absolute;
  top: 54px;
  bottom: 48px;
  right: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.7);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--cyan);
}

.drawer-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-content {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-card {
  background: rgba(10, 15, 22, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
}

.tag {
  font-family: var(--font-mono);
  font-size: 7px;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
}

.tag.audit { background: rgba(0, 255, 136, 0.15); color: var(--green); }
.tag.holon { background: rgba(255, 214, 0, 0.15); color: var(--amber); }
.tag.ledger { background: rgba(41, 121, 255, 0.15); color: #2979ff; }
.tag.live { background: rgba(0, 229, 255, 0.15); color: var(--cyan); }

.phase-display {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 6px;
  border-radius: 4px;
}

.phase-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
}

.phase-prob { font-size: 8px; color: var(--text-muted); }

.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.param-cell {
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 6px;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
}

.pc-lbl { font-size: 7px; color: var(--text-muted); }
.pc-val { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: #fff; }

.lens-rows, .ledger-rows, .scale-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.lens-row, .ledger-row {
  display: flex;
  justify-content: space-between;
}

.ledger-row.purple { color: var(--purple); }
.ledger-row.total { font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 2px 0; }

/* ==========================================================================
   7. Modal Dialogs (WB-3.4)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-focus);
  border-radius: 10px;
  width: 580px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manifest-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 8px;
}

.manifest-table th, .manifest-table td {
  padding: 4px 6px;
  border: 1px solid var(--border);
  text-align: left;
}

.gtag {
  background: rgba(0, 255, 136, 0.15);
  color: var(--green);
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
}

.integrity-text {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   8. Desktop & Tablet Breakpoints
   ========================================================================== */

@media (max-width: 600px) {
  .mobile-hide { display: none !important; }
}


/* ==========================================================================
   THE REAL-ENGINE SHELL
   Added when the WB-7.1 mock's physics core was replaced by the wasm engine.
   The mock's layout vocabulary above is kept deliberately (WB-7.2 records that
   the interaction prototype was the valuable half); what follows dresses the
   panels the real engine needs, and above all the two states every displayed
   quantity is now in: LIVE, or FENCED.
   ========================================================================== */

/* The honesty tag. There is no third colour on purpose: a quantity either traces
   to an engine readout or it is fenced, and the eye should be able to sort a
   drawer full of them at a glance without reading a word. */
.tag[data-tag="live"] {
  background: rgba(0, 229, 255, 0.14);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.35);
}

.tag[data-tag="fenced"] {
  background: rgba(255, 42, 85, 0.12);
  color: var(--rose);
  border: 1px solid rgba(255, 42, 85, 0.4);
  letter-spacing: 0.08em;
}

.hud-engine-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.35);
  white-space: nowrap;
}

.p-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 1px;
}


/* --- the readout grid. Label left, value right, monospace on the right only:
   the numbers have to line up for a drift and a bound to be comparable at a
   glance, and the labels read better proportionally. */
.ledger-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
}

.ledger-grid.tight {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.lrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.lrow > span:first-child {
  color: var(--text-muted);
  white-space: nowrap;
}

.lrow > span:last-child {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-main);
  text-align: right;
  word-break: break-word;
}

.lrow.accent > span:last-child { color: var(--amber); }

.lrow.verdict {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

.val.green { color: var(--green); }
.val.red { color: var(--rose); }

.mono-wrap {
  font-family: var(--font-mono);
  font-size: 9px !important;
  word-break: break-all;
  max-width: 60%;
}

/* --- the note under a panel. Load-bearing prose, not filler: several of these
   say what the number does NOT mean, which is the part a reader gets wrong. */
.card-note,
.sheet-note {
  margin-top: 9px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.sheet-note.fence {
  color: var(--rose);
  border-left: 2px solid rgba(255, 42, 85, 0.5);
  padding-left: 9px;
}

.fenced-panel label { color: var(--rose); }

/* --- the pair bank */
.bank-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 10px;
}

.bank-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 3px 6px 3px 0;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bank-table td {
  padding: 3px 6px 3px 0;
  border-bottom: 1px solid rgba(34, 50, 69, 0.5);
}

.bank-table tr.ok td:last-child { color: var(--green); }
.bank-table tr.fenced td { color: var(--rose); }

/* --- the fence register (WB-5.2). Fences are RENDERED, and they are rendered
   as prose with a reason, because a fence whose reason is not readable is a
   shrug with a border around it. */
.fence-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.fence-list li {
  border-left: 2px solid var(--rose);
  padding-left: 9px;
}

.fence-list li.none { border-left-color: var(--green); }
.fence-list li.none b { color: var(--green); }

.fence-list b {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--rose);
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.fence-list span {
  display: block;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.fenced-card { border-color: rgba(255, 42, 85, 0.3); }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 6px;
}

.check-row input { margin-top: 2px; }


.manifest-section + .manifest-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* --- the boot failure. An engine that did not load draws NOTHING and says so;
   the mock's failure mode was to keep animating a scene with no physics behind
   it, which is the vacuous-success shape at its most literal. */
.boot-failure {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(6, 9, 13, 0.96);
  z-index: 50;
}

.boot-failure h2 {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--rose);
}

.boot-failure p {
  max-width: 520px;
  font-size: 12px;
  line-height: 1.6;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.boot-failure .sub {
  font-family: var(--font-sans);
  color: var(--text-muted);
}

/* --- the stage overlay. Named stages while the engine's own solves block the main
   thread; a frozen page with no explanation is indistinguishable from a broken one. */
.boot-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(6, 9, 13, 0.9);
  z-index: 40;
  pointer-events: none;
}

.boot-overlay.hidden { display: none; }

.boot-overlay p {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--cyan);
  text-align: center;
  max-width: 460px;
  padding: 0 20px;
  line-height: 1.6;
}

.boot-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(0, 229, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin { to { transform: rotate(360deg); } }

/* --- curves the engine permits but that have not been paid for. Deliberately a
   BUTTON: the cost is the user's to spend, and the page does not spend it for them. */
.priced-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 9px;
}

.priced-list:empty { display: none; }

.btn-micro.pay {
  width: 100%;
  text-align: left;
  border-color: var(--amber);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
}

/* A scene that cannot step gets its own state, distinct from settling: the two look the
   same on a still frame and mean opposite things. */
.settling-pill.halted {
  border-color: rgba(255, 42, 85, 0.5);
  color: var(--rose);
}

.settling-pill.halted .dot { background: var(--rose); }

/* --- RECORD: cited from a committed artifact, neither live nor fenced. A third state
   because these numbers are real and are not this engine's; the tag says which. */
.tag[data-tag="record"] {
  background: rgba(179, 136, 255, 0.14);
  color: var(--purple);
  border: 1px solid rgba(179, 136, 255, 0.4);
}

.record-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.rec { border-left: 2px solid var(--purple); padding-left: 10px; }

.rec-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rec-head b { font-family: var(--font-mono); font-size: 13px; color: var(--purple); }
.rec-head span { font-size: 10.5px; color: var(--text-muted); }
.rec p { margin: 3px 0 4px 0; font-size: 10.5px; line-height: 1.5; color: var(--text-muted); }
.rec code {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  word-break: break-all;
}

/* --- the scale ladder. A band is live or fenced; there is no third state, and the
   fenced ones carry their owner and exit because a fence without them is a shrug. */
.ladder-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.lad { border-left: 2px solid var(--border); padding-left: 10px; }
.lad.live { border-left-color: var(--cyan); }
.lad.fenced { border-left-color: var(--rose); }

.lad-head { display: flex; align-items: baseline; gap: 8px; }
.lad-head b { font-family: var(--font-mono); font-size: 11px; color: var(--text-main); }
.lad-head span { font-size: 10px; color: var(--text-dim); }
.lad-runs { font-size: 10.5px; color: var(--text-muted); margin: 2px 0; }
.lad-status { font-size: 10.5px; line-height: 1.5; }
.lad-live { color: var(--cyan); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.05em; }
.lad-fenced { color: var(--rose); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.05em; }
.lad-detail { display: block; color: var(--text-muted); }
.lad-detail b { color: var(--text-dim); font-weight: 600; }
.lad code { display: block; font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); margin-top: 3px; }

/* --- acuity: what this view can actually distinguish, per band. */
.lad-viewline {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-top: 8px;
}
.lad-acuity { display: block; font-size: 10px; color: var(--purple); font-family: var(--font-mono); }
.lad-acuity.zero { color: var(--text-dim); }

/* --- a fence's provenance: who owns it, what lifts it, and which register row it is.
   Rendered on every fence the page displays, because a fence without an owner and an
   exit is a shrug, and one outside the register is invisible to the register's law. */
.fence-meta {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  line-height: 1.5;
}
.fence-meta b { color: var(--text-muted); font-weight: 600; }

/* A fenced band's POSITIVE finding. Green, deliberately: a refusal is not the whole
   result, and rung 2 measured hydrodynamics' premise real on the way to failing to
   certify it. Showing only the fence would report half of what the lane found. */
.lad-positive { color: var(--green); margin-top: 3px; }
.lad-positive b { color: var(--green); }

/* --- an EXPORT-GATED band. Not a third state on the ladder: it is FENCED until the
   exports that serve it are in the artifact, and LIVE the moment they are. The border
   is the fenced rose because that is what it is today; app.js repaints the state word
   from the artifact every frame, so nothing here has to be edited when it flips. */
.lad.export-gated { border-left-color: var(--rose); }

/* The one readout a fenced band is granted (the cube's hydrostatic column, FSD-W3
   §11.2). Amber rather than cyan: it is arithmetic on measured constants, which is
   neither the band's certified dynamics nor a refusal. */
.lad-readout { color: var(--amber); margin-top: 3px; }
.lad-readout b { color: var(--amber); }

/* ==========================================================================
   THE LADDER'S READOUTS (FSD-W3 §11.2)
   ==========================================================================

   Four kinds of number in one card, so the tag goes BESIDE each number rather than
   once over the lot: a single panel tag would have to be the weakest of them, and a
   reader would have no way to tell which digit was which. The tag word is drawn from
   `data-tag` in CSS so no markup carries it and no row can be given digits without one.
   A PENDING row is never passed digits at all — its text is the export it waits for. */

.desc-sec {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.dval::after {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  margin-left: 6px;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
}

.dval[data-tag="live"] { color: var(--cyan); }
.dval[data-tag="live"]::after {
  content: "LIVE";
  background: rgba(0, 229, 255, 0.14);
  color: var(--cyan);
}

.dval[data-tag="declared"] { color: var(--purple); }
.dval[data-tag="declared"]::after {
  content: "DECLARED";
  background: rgba(179, 136, 255, 0.14);
  color: var(--purple);
}

.dval[data-tag="computed"] { color: var(--amber); }
.dval[data-tag="computed"]::after {
  content: "COMPUTED";
  background: rgba(255, 214, 0, 0.14);
  color: var(--amber);
}

.dval[data-tag="pending"] { color: var(--rose); }
.dval[data-tag="pending"]::after {
  content: "FENCED — PENDING";
  background: rgba(255, 42, 85, 0.12);
  color: var(--rose);
}

/* The bit-identity verdict keeps its own colour when it has one: EQUAL TO THE BIT is
   green and a mismatch is red, and neither is a tag state. */
.dval.green, .dval.green[data-tag="computed"] { color: var(--green); }
.dval.red, .dval.red[data-tag="computed"] { color: var(--rose); }

/* ==========================================================================
   THE SURFACE (FSD-W3 §11.5): a cube, four selectors, the tier as the zoom,
   and everything else under ☰. The dock, its tabs and the four-tier pill
   (WB-1.1, retired by §11.3) are gone; their controls live in the drawer's
   MORE CONTROLS card with the ids they always had.
   ========================================================================== */
#tier-rail {
  position: absolute;
  right: 10px;
  top: 64px;
  bottom: 168px;
  width: 132px;
  display: flex;
  align-items: stretch;
  z-index: 12;
  pointer-events: none;
}
#tier-rail input[type="range"] {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  width: 8px;
  height: 100%;
  margin: 0 0 0 auto;
  background: linear-gradient(#162433, #1c2b3c);
  border-radius: 4px;
  outline: none;
}
#tier-rail input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.7);
  cursor: ns-resize;
}
#tier-rail input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--cyan);
  cursor: ns-resize;
}
.tier-stops {
  position: relative;
  flex: 1;
  margin-right: 10px;
}
.tier-stop {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  pointer-events: auto;
  background: var(--bg-hud);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-muted);
  text-align: right;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.tier-stop b {
  display: block;
  font-size: 9px;
  color: var(--text-main);
}
.tier-stop.fenced { border-style: dashed; }
.tier-stop.fenced b { color: var(--rose); }
.tier-stop.active { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 8px rgba(0, 229, 255, 0.35); }
.tier-stop.active b { color: var(--cyan); }
.band-card {
  position: absolute;
  left: 12px;
  top: 64px;
  max-width: 300px;
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 11;
}
.band-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.band-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}
.band-scale {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}
.band-text {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.35;
  max-height: 40vh;
  overflow-y: auto;
}
/* The band's statement is behind "more info" by default: the card must not cover the
   simulation. The text stays in the DOM (hidden), so nothing the page says is removed. */
.band-more {
  margin-top: 4px;
  font-size: 9px;
  opacity: 0.8;
}
#control-rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--bg-hud);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  z-index: 20;
}
.rail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}
.rail-head label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.rail-head .sub-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-item input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #1c2b3c;
  border-radius: 3px;
  outline: none;
}
.rail-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
  cursor: ew-resize;
}
.rail-item input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--cyan);
  cursor: ew-resize;
}
.rail-item .sheet-val {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.density-axis {
  position: relative;
  height: 30px;
  font-family: var(--font-mono);
  font-size: 7px;
  color: var(--text-dim);
  overflow: visible;
}
.density-axis .dmark.off {
  position: absolute;
  left: 0;
  top: 20px;
  transform: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.dmark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.dmark::before {
  content: "";
  display: block;
  width: 1px;
  height: 4px;
  background: var(--text-dim);
  margin: 0 auto 1px;
}
.dmark.off {
  position: static;
  display: inline-block;
  transform: none;
  color: var(--rose);
  margin-right: 6px;
}
.dmark.off::before { display: none; }
.rail-item.mix .mix-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.rail-item.mix .mix-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 3px 6px;
  font-size: 9px;
  line-height: 1.2;
  min-width: 0;
}
.rail-item.mix .mix-chip span {
  font-family: var(--font-mono);
  font-size: 7px;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-item.mix .mix-chip.active span { color: var(--cyan); }
/* the drawer runs to the floor now that the dock is gone */
.drawer { bottom: 0; }
@media (max-width: 760px) {
  #control-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tier-rail { bottom: 250px; width: 100px; }
  .tier-stop span { display: none; }
  .band-card { max-width: 58vw; }
}

/* The drawer's card notes are behind "more info" by default (2026-09-06): the notes stay in
   the DOM, the card shows its head and its numbers, and the drawer stops being a wall of
   text over the simulation. */
.drawer-card:not(.expanded) .card-note { display: none; }
.card-more { margin-left: auto; font-size: 9px; opacity: 0.8; }

/* --- MEASURED: the ladder's third state (WB-9.2). Not a softer fence and not a live
   band. `fenced` means there is nothing to show; `live` means a node-G closure
   certificate flipped the band. A MEASURED band has its physics read and its
   certificate still owed, so it is amber: the readings are drawn with their citations,
   the word beside them says the certificate is owed, and the flip law is untouched. */
.lad.measured { border-left-color: var(--amber, #d8a657); }
.lad-measured {
  color: var(--amber, #d8a657);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
}

/* A band's own readings, each with the line of the record it came from — the water
   story's shape, applied inside a band. */
.lad-readings { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 4px 0; }
.lad-reading { border-left: 1px solid var(--border); padding-left: 8px; }
.lad-reading b { font-family: var(--font-mono); font-size: 11px; color: var(--text-main); }
.lad-reading span { font-size: 10px; color: var(--text-dim); margin-left: 6px; }
.lad-reading p { margin: 2px 0 3px 0; font-size: 10px; line-height: 1.5; color: var(--text-muted); }
.lad-reading code {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  word-break: break-all;
}

/* The live box's refusal, and the boundary door's own two numbers under it. Rose when
   the door refuses this scene, muted when it would admit it: the sentence above is
   about a 16-water cell, and the line below is about the box you are looking at. */
.lad-livebox { color: var(--text-muted); margin-top: 3px; }
.lad-door {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.lad-door.refused { color: var(--rose); }

/* --- the ledger by channel (WB-9.1). Nine columns of prose need to scroll inside the
   card rather than widen the drawer, so the table gets its own overflow box. */
.chan-wrap { overflow-x: auto; margin-top: 10px; }
.chan-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  font-size: 10px;
}
.chan-table th, .chan-table td {
  border: 1px solid var(--border);
  padding: 5px 6px;
  vertical-align: top;
  text-align: left;
}
.chan-table thead th {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
}
.chan-table tbody th b {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-main);
}
.chan-table tbody th span { font-size: 9.5px; color: var(--text-dim); }
.chan-live { font-size: 10px; color: var(--text-muted); line-height: 1.5; }
/* NOT SERVED, and not zero. Muted rather than rose: this is the engine reporting the
   shape of its own ledger, which is a fact about the sectors and not a debt. */
.chan-live.absent { color: var(--text-dim); font-style: italic; }
.chan-cell { color: var(--text-dim); }
.chan-cell.filled { color: var(--text-muted); }
.chan-cell code {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-dim);
  word-break: break-all;
}

/* --- the fluid element's live cell (WB-10). The canvas is square by construction — the
   lattice is L x L cells — and is scaled with `image-rendering: pixelated` rather than
   smoothed: the whole readability of the picture is that a bond is visibly a link between
   two cells, and an interpolating scale-up blurs the link into the cells it joins. */
.fluid-wrap {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  background: #05080c;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px;
}
#fluid-canvas {
  width: 100%;
  max-width: 512px;
  height: auto;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  display: block;
}
