/* ═══════════════════════════════════════════════════════════════════════
   ND // SIGNAL — an observation system for impossible objects
   Single stylesheet. No frameworks, no external fonts, no network deps.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* surfaces — the room is almost blindingly white */
  --paper:      #fbfcfd;
  --paper-sunk: #f3f5f8;
  --paper-lift: #ffffff;

  /* ink */
  --ink:    #0e1116;
  --ink-2:  #4a515c;
  --ink-3:  #8b93a0;
  --ink-4:  #b7bdc7;

  /* hairlines */
  --line:      rgba(14, 17, 22, .10);
  --line-soft: rgba(14, 17, 22, .055);
  --line-hard: rgba(14, 17, 22, .22);

  /* the one accent */
  --blue:      #2166fa;
  --blue-deep: #1348c9;
  --blue-wash: #e6eeff;
  --blue-line: rgba(33, 102, 250, .34);

  --top-h:    52px;
  --bottom-h: 34px;
  --gut:      clamp(20px, 4.4vw, 64px);

  --sans: "Helvetica Neue", Inter, "Segoe UI", Roboto, system-ui, -apple-system, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-io: cubic-bezier(.65, .05, .36, 1);
}

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

/* A class that sets `display` outranks the UA's [hidden] rule, so elements
   toggled with the hidden attribute would stay on screen. Settle it once. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: .005em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* A very fine paper grain over everything. Costs nothing, reads expensive. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .5;
  background-image: var(--nd-grain, none);
  background-size: 200px 200px;
  mix-blend-mode: multiply;
}

::selection { background: var(--blue-wash); color: var(--ink); }

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

.nd-vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.nd-skiplink {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 400;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .2s var(--ease);
}
.nd-skiplink:focus { transform: none; }

/* ─── numerals ──────────────────────────────────────────────────────── */

.nd-num, .nd-mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ═══ TOP BAR ════════════════════════════════════════════════════════ */

.nd-top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--gut);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.nd-top__left, .nd-top__right { display: flex; align-items: center; gap: 14px; }

.nd-wordmark {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  font: 600 13px/1 var(--sans);
  letter-spacing: .18em;
}
.nd-wordmark span { color: var(--blue); font-weight: 400; }

.nd-top__div { width: 1px; height: 14px; background: var(--line); }

.nd-top__sub {
  font: 400 10px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.nd-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 500 10px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-2);
}
.nd-live i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--blue);
  animation: nd-pulse 2.4s var(--ease-io) infinite;
}
@keyframes nd-pulse {
  0%, 100% { opacity: 1;  box-shadow: 0 0 0 0 var(--blue-line); }
  55%      { opacity: .45; box-shadow: 0 0 0 5px rgba(33,102,250,0); }
}

/* ═══ BOTTOM TELEMETRY STRIP ═════════════════════════════════════════ */

.nd-bottom {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  height: var(--bottom-h);
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 40px);
  padding: 0 var(--gut);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft);
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
}
.nd-bottom b { color: var(--ink); font-weight: 500; margin-left: 7px; }
.nd-bottom__cell--net { margin-left: auto; }
@media (max-width: 720px) {
  .nd-bottom__cell--net { display: none; }
  .nd-bottom { gap: 14px; font-size: 9px; }
}

/* ═══ BOOT OVERLAY ═══════════════════════════════════════════════════ */

.nd-boot {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--paper);
  transition: opacity .6s var(--ease), visibility .6s;
}
.nd-boot[data-done="1"] { opacity: 0; visibility: hidden; pointer-events: none; }

.nd-boot__inner { width: min(420px, 82vw); text-align: left; }

.nd-boot__mark {
  margin: 0 0 34px;
  font: 600 13px/1 var(--sans);
  letter-spacing: .26em;
}
.nd-boot__mark span { color: var(--blue); font-weight: 400; }

.nd-boot__steps { list-style: none; margin: 0 0 26px; padding: 0; }
.nd-boot__steps li {
  font: 400 11px/1.9 var(--mono);
  letter-spacing: .15em;
  color: var(--ink-4);
  opacity: .35;
  transition: opacity .3s var(--ease), color .3s var(--ease);
}
.nd-boot__steps li::before {
  content: "○ ";
  color: var(--ink-4);
}
.nd-boot__steps li[data-on="1"] { opacity: 1; color: var(--ink-2); }
.nd-boot__steps li[data-on="1"]::before { content: "◐ "; color: var(--blue); }
.nd-boot__steps li[data-on="2"] { opacity: 1; color: var(--ink); }
.nd-boot__steps li[data-on="2"]::before { content: "● "; color: var(--blue); }

.nd-boot__bar {
  height: 1px;
  background: var(--line);
  overflow: hidden;
}
.nd-boot__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
  transition: width .35s var(--ease);
}

.nd-boot__skip { margin-top: 26px; }

/* ═══ BUTTONS ════════════════════════════════════════════════════════ */

.nd-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid var(--line-hard);
  border-radius: 0;
  background: var(--paper-lift);
  color: var(--ink);
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease),
              border-color .18s var(--ease), transform .18s var(--ease);
}
.nd-btn:hover:not(:disabled) { border-color: var(--ink); }
.nd-btn:active:not(:disabled) { transform: translateY(1px); }
.nd-btn:disabled { opacity: .34; cursor: not-allowed; }

.nd-btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.nd-btn--primary:hover:not(:disabled) { background: var(--blue); border-color: var(--blue); }

.nd-btn--ghost {
  background: none;
  border-color: var(--line);
  color: var(--ink-2);
}
.nd-btn--ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--line-hard); }

.nd-btn--small { min-height: 34px; padding: 0 14px; font-size: 9.5px; }

.nd-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.nd-actions--tight { margin-top: 18px; align-items: center; }

/* ═══ STAGE ══════════════════════════════════════════════════════════ */

.nd-stage {
  position: fixed;
  top: var(--top-h);
  right: 0;
  bottom: var(--bottom-h);
  width: 56%;
  z-index: 10;
  pointer-events: none;
}

.nd-stage__frame {
  position: absolute;
  inset: clamp(16px, 3vh, 40px) clamp(16px, 3vw, 52px);
  pointer-events: none;
}

.nd-stage__gl,
.nd-stage__ui {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.nd-stage__ui { pointer-events: none; }

.nd-stage__hit {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}
.nd-stage__hit[data-drag="1"] { cursor: grabbing; }
.nd-stage__hit[data-reticle="1"] { cursor: none; }

.nd-stage__corner {
  position: absolute;
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-3);
  pointer-events: none;
  white-space: nowrap;
}
.nd-stage__corner--tl { top: 0; left: 0; }
.nd-stage__corner--tr { top: 0; right: 0; }
.nd-stage__corner--bl { bottom: 0; left: 0; }
.nd-stage__corner--br { bottom: 0; right: 0; }

.nd-stage__loading {
  position: absolute;
  left: 0;
  bottom: 22px;
  margin: 0;
  font: 400 10px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--blue);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.nd-stage__loading[data-on="1"] { opacity: 1; }

.nd-stage__notice {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(300px, 78%);
  padding: 22px;
  background: color-mix(in srgb, var(--paper-lift) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-hard);
  text-align: center;
  pointer-events: auto;
}
.nd-stage__notice-title {
  margin: 0 0 6px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink);
}
.nd-stage__notice-body {
  margin: 0 0 16px;
  font: 400 9.5px/1.6 var(--mono);
  letter-spacing: .14em;
  color: var(--ink-3);
}

/* ═══ FLOW / SECTIONS ════════════════════════════════════════════════ */

.nd-flow {
  position: relative;
  z-index: 20;
  width: 44%;
  padding: calc(var(--top-h) + 8vh) var(--gut) calc(var(--bottom-h) + 12vh);
}

.nd-sec {
  position: relative;
  /* the fixed top bar must not eat the heading when a section is scrolled to */
  scroll-margin-top: calc(var(--top-h) + 28px);
  padding: 0 0 clamp(90px, 16vh, 190px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}

/* Locked sections exist in the DOM but are inert until the flow reaches
   them — the page reveals itself rather than presenting everything at once. */
.nd-sec--locked {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  padding-bottom: 0;
}
.nd-sec--unlocking {
  visibility: visible;
  height: auto;
  overflow: visible;
  padding-bottom: clamp(90px, 16vh, 190px);
}
.nd-sec--open { opacity: 1; transform: none; pointer-events: auto; }

.nd-sec__tag {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 26px;
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .24em;
  color: var(--ink-3);
}
.nd-sec__tag b {
  font-weight: 500;
  color: var(--blue);
}
.nd-sec__tag::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.nd-h1 {
  display: flex;
  flex-direction: column;
  margin: 0 0 24px;
  font-size: clamp(46px, 7.2vw, 104px);
  font-weight: 500;
  line-height: .92;
  letter-spacing: -.028em;
}
.nd-h1 span:last-child { color: var(--ink-2); }

.nd-h2 {
  margin: 0 0 20px;
  font-size: clamp(26px, 3.4vw, 46px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -.02em;
}

.nd-h3 {
  margin: 52px 0 18px;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .22em;
  color: var(--ink-2);
  text-transform: uppercase;
}

.nd-lead {
  max-width: 40ch;
  margin: 0 0 36px;
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.62;
  color: var(--ink-2);
}
.nd-lead--sm { font-size: 14px; margin-bottom: 30px; }

.nd-hint {
  margin: 22px 0 0;
  font: 400 9.5px/1.7 var(--mono);
  letter-spacing: .14em;
  color: var(--ink-4);
}

.nd-note {
  margin: 18px 0 0;
  font: 400 10px/1.7 var(--mono);
  letter-spacing: .13em;
  color: var(--ink-3);
}
.nd-note b { color: var(--blue); font-weight: 500; }

.nd-result {
  margin: 30px 0 0;
  padding: 16px 18px;
  border-left: 2px solid var(--blue);
  background: linear-gradient(90deg, var(--blue-wash), transparent 88%);
  font: 500 11.5px/1.6 var(--mono);
  letter-spacing: .16em;
  color: var(--ink);
}

/* ─── record table ──────────────────────────────────────────────────── */

.nd-record { margin: 0; border-top: 1px solid var(--line); }
.nd-record > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.nd-record dt {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-3);
}
.nd-record dd {
  margin: 0;
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
  color: var(--ink);
}

/* ─── meters ────────────────────────────────────────────────────────── */

.nd-meter {
  position: relative;
  height: 2px;
  background: var(--line-soft);
  overflow: hidden;
}
.nd-meter--lg { height: 3px; }
.nd-meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width .28s var(--ease);
}
.nd-meter--live i { background: var(--blue); transition: width .09s linear; }

/* ─── scan ──────────────────────────────────────────────────────────── */

.nd-scan__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.nd-scan__label {
  font: 500 10px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink-2);
}
.nd-scan__head .nd-num { font-size: 22px; font-weight: 500; letter-spacing: -.01em; }

.nd-channels { list-style: none; margin: 26px 0 0; padding: 0; }
.nd-channels li {
  display: grid;
  grid-template-columns: 92px 1fr 52px;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.nd-channels span {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-3);
}
.nd-channels b { font-size: 10.5px; font-weight: 500; text-align: right; color: var(--ink); }

/* ─── anomalies ─────────────────────────────────────────────────────── */

.nd-distort {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 4px 14px;
  margin-bottom: 30px;
}
.nd-distort__label {
  grid-column: 1 / -1;
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink-3);
  transition: color .2s var(--ease);
}
.nd-distort[data-near="1"] .nd-distort__label { color: var(--blue); }
.nd-distort .nd-num { grid-column: 2; text-align: right; font-size: 10.5px; color: var(--ink-2); }
.nd-distort .nd-meter { grid-column: 1; align-self: center; }

.nd-anoms { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.nd-anoms li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  font: 400 10px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-4);
  transition: color .3s var(--ease);
}
.nd-anoms li[data-found="1"] { color: var(--ink); }
.nd-anoms li[data-found="1"] .nd-anoms__id { color: var(--blue); font-weight: 500; }
.nd-anoms li[data-found="1"] .nd-anoms__id::before { content: "● "; }
.nd-anoms li:not([data-found="1"]) .nd-anoms__id::before { content: "○ "; }

/* ─── resolution ladder ─────────────────────────────────────────────── */

.nd-ladder { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.nd-ladder li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  transition: opacity .3s var(--ease);
  opacity: .4;
}
.nd-ladder li[data-state="active"],
.nd-ladder li[data-state="done"] { opacity: 1; }

.nd-ladder__lv {
  font: 500 12px/1 var(--mono);
  letter-spacing: .06em;
  color: var(--ink-3);
}
.nd-ladder li[data-state="done"] .nd-ladder__lv { color: var(--blue); }
.nd-ladder__meta { display: flex; flex-direction: column; gap: 5px; }
.nd-ladder__name {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-2);
}
.nd-ladder__state {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-4);
  text-align: right;
}
.nd-ladder li[data-state="done"] .nd-ladder__state { color: var(--ink); }
.nd-ladder li[data-state="failed"] .nd-ladder__state { color: var(--blue-deep); }

/* live map of which CDN tiles have actually arrived */
.nd-tilegrid {
  --cols: 6;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 2px;
  width: min(224px, 60%);
  margin: 26px 0 12px;
  aspect-ratio: 1;
}
.nd-tilegrid i {
  display: block;
  background: var(--line-soft);
  transition: background .35s var(--ease);
}
.nd-tilegrid i[data-t="pending"] { background: var(--blue-wash); }
.nd-tilegrid i[data-t="done"]    { background: var(--ink-3); }
.nd-tilegrid i[data-t="failed"]  { background: var(--blue); }

/* ─── decoder ───────────────────────────────────────────────────────── */

.nd-decoder__pattern {
  margin: 0 0 24px;
  padding: 22px 20px;
  border: 1px solid var(--line);
  background: var(--paper-lift);
  font: 400 20px/1 var(--mono);
  letter-spacing: .34em;
  color: var(--ink);
  text-align: center;
  word-spacing: .5em;
}

.nd-slots {
  list-style: none;
  display: flex;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
}
.nd-slots li {
  flex: 1;
  min-width: 0;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--paper-lift);
  font: 500 17px/1 var(--mono);
  letter-spacing: .04em;
  color: var(--ink);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.nd-slots li[data-filled="1"] { border-color: var(--ink); }
.nd-decoder[data-state="ok"]  .nd-slots li { border-color: var(--blue); background: var(--blue-wash); }
.nd-decoder[data-state="bad"] .nd-slots li { animation: nd-shake .34s var(--ease); }

@keyframes nd-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-4px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

.nd-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 1px;
  margin: 0 0 22px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
}
.nd-legend div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  font: 400 11px/1 var(--mono);
  letter-spacing: .12em;
}
.nd-legend b { color: var(--blue); font-weight: 500; }
.nd-legend span { color: var(--ink-2); letter-spacing: .2em; }

.nd-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.nd-keys button {
  appearance: none;
  min-width: 46px;
  min-height: 46px;
  border: 1px solid var(--line-hard);
  background: var(--paper-lift);
  color: var(--ink);
  font: 500 14px/1 var(--mono);
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.nd-keys button:hover:not(:disabled) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.nd-keys button:disabled { opacity: .3; cursor: not-allowed; }

.nd-decoder__state {
  font: 500 10px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-3);
}
.nd-decoder[data-state="ok"]  .nd-decoder__state { color: var(--blue); }
.nd-decoder[data-state="bad"] .nd-decoder__state { color: var(--ink); }

/* ═══ SECTORS ════════════════════════════════════════════════════════ */

.nd-sectors { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); }

.nd-sector {
  padding: 22px 0 26px;
  background: var(--paper);
  opacity: .32;
  transition: opacity .5s var(--ease);
}
.nd-sector[data-open="1"] { opacity: 1; }

.nd-sector__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.nd-sector__code {
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
  color: var(--blue);
}
.nd-sector__name {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .22em;
  color: var(--ink-3);
}
.nd-sector__lock {
  margin-left: auto;
  font: 400 9px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-4);
}
.nd-sector[data-open="1"] .nd-sector__lock { color: var(--blue); }

.nd-sector__map {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 16px;
  background: var(--paper-sunk);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.nd-sector__map img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s var(--ease), filter .8s var(--ease);
  filter: blur(6px);
}
.nd-sector__map img[data-loaded="1"] { opacity: 1; filter: none; }

.nd-sector__line {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -.012em;
}
.nd-sector__body {
  margin: 0 0 16px;
  max-width: 46ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.nd-sector__tele {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0 0 16px;
  font: 400 9.5px/1.7 var(--mono);
  letter-spacing: .14em;
  color: var(--ink-3);
}
.nd-sector__tele b { color: var(--ink); font-weight: 500; margin-left: 6px; }

.nd-sector__task {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper-lift);
}
.nd-sector__taskname {
  font: 500 10px/1.5 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-2);
  flex: 1 1 200px;
}
.nd-sector__taskname em { font-style: normal; color: var(--blue); }
.nd-sector[data-done="1"] .nd-sector__task { border-color: var(--blue-line); background: var(--blue-wash); }

/* ═══ GLYPH ARCHIVE ══════════════════════════════════════════════════ */

.nd-glyphs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
}
.nd-glyph {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink-4);
  transition: color .4s var(--ease), background .4s var(--ease);
}
.nd-glyph svg, .nd-glyph img { width: 46%; height: 46%; display: block; }
.nd-glyph[data-has="1"] { color: var(--ink); background: var(--paper-lift); }
.nd-glyph__locked {
  font: 400 15px/1 var(--mono);
  color: var(--ink-4);
  opacity: .5;
}
.nd-glyph__name {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  text-align: center;
  font: 400 7.5px/1 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.nd-glyph[data-has="1"] .nd-glyph__name { opacity: 1; }

/* ═══ FINAL ══════════════════════════════════════════════════════════ */

.nd-final { display: flex; flex-direction: column; gap: 18px; }
.nd-final p {
  margin: 0;
  font-size: clamp(17px, 1.7vw, 22px);
  font-weight: 500;
  line-height: 1.34;
  letter-spacing: -.014em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.nd-final p[data-on="1"] { opacity: 1; transform: none; }
.nd-final p[data-tone="soft"] { color: var(--ink-2); font-weight: 400; font-size: 15px; }
.nd-final p[data-tone="blue"] { color: var(--blue); }

/* ═══ WHITE-OUT + RESULT CARD ════════════════════════════════════════ */

.nd-whiteout {
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
}
.nd-whiteout[data-on="1"] { opacity: 1; }

.nd-whiteout__inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 54px;
  padding: 12vh var(--gut);
}

.nd-reveal {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
  max-width: 30ch;
}
.nd-reveal p {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 34px);
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -.022em;
  opacity: 0;
  filter: blur(6px);
  transition: opacity 1.1s var(--ease), filter 1.1s var(--ease);
}
.nd-reveal p[data-on="1"] { opacity: 1; filter: none; }
.nd-reveal p[data-tone="quiet"] { font-size: clamp(13px, 1.2vw, 15px); font-weight: 400; color: var(--ink-3); letter-spacing: .1em; font-family: var(--mono); }

.nd-card {
  width: min(430px, 100%);
  padding: 34px 32px 30px;
  border: 1px solid var(--line-hard);
  background: var(--paper);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.nd-card[data-on="1"] { opacity: 1; transform: none; }

.nd-card__mark {
  margin: 0 0 26px;
  font: 600 11px/1 var(--sans);
  letter-spacing: .24em;
}
.nd-card__mark span { color: var(--blue); font-weight: 400; }

.nd-card__id {
  margin: 0 0 24px;
  font: 400 10px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink-3);
}
.nd-card__id b {
  display: block;
  margin-top: 8px;
  font-size: 38px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--ink);
}

.nd-card__stats { margin: 0 0 24px; border-top: 1px solid var(--line); }
.nd-card__stats > div {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.nd-card__stats dt {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-3);
}
.nd-card__stats dd {
  margin: 0;
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
}

.nd-card__classlabel {
  margin: 0 0 6px;
  font: 400 9.5px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink-3);
}
.nd-card__class {
  margin: 0 0 22px;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.018em;
  color: var(--blue);
}
.nd-card__foot {
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font: 400 9.5px/1.7 var(--mono);
  letter-spacing: .16em;
  color: var(--ink-3);
}

/* ═══ TOAST ══════════════════════════════════════════════════════════ */

.nd-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-h) + 22px);
  z-index: 250;
  transform: translate(-50%, 16px);
  padding: 13px 20px;
  background: var(--ink);
  color: var(--paper);
  font: 500 10px/1 var(--mono);
  letter-spacing: .2em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  max-width: min(88vw, 460px);
  text-align: center;
}
.nd-toast[data-on="1"] { opacity: 1; transform: translate(-50%, 0); }

/* ═══ DEBUG PANEL (?debug=1 only) ════════════════════════════════════ */

.nd-debug {
  position: fixed;
  /* Over the stage, never over the flow column: this panel is on top of
     everything and would otherwise swallow clicks meant for the content. */
  right: var(--gut);
  top: calc(var(--top-h) + 16px);
  z-index: 220;
  width: 248px;
  padding: 14px;
  background: var(--paper-lift);
  border: 1px solid var(--line-hard);
  font: 400 9.5px/1.65 var(--mono);
  letter-spacing: .08em;
  color: var(--ink-2);
  box-shadow: 0 12px 40px rgba(14, 17, 22, .09);
}
.nd-debug h4 {
  margin: 0 0 10px;
  font: 500 9.5px/1 var(--mono);
  letter-spacing: .22em;
  color: var(--ink);
}
.nd-debug dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0 0 12px; }
.nd-debug dt { color: var(--ink-3); }
.nd-debug dd { margin: 0; color: var(--ink); text-align: right; }
.nd-debug__btns { display: grid; gap: 4px; }
.nd-debug__btns button {
  appearance: none;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font: 400 9px/1 var(--mono);
  letter-spacing: .14em;
  text-align: left;
  cursor: pointer;
}
.nd-debug__btns button:hover { border-color: var(--ink); color: var(--ink); }

/* ═══ MOBILE ═════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
  .nd-stage {
    position: sticky;
    top: var(--top-h);
    right: auto;
    bottom: auto;
    width: 100%;
    height: 56vh;
    min-height: 300px;
    margin-top: var(--top-h);
    z-index: 15;
    background: linear-gradient(180deg, var(--paper) 74%, transparent);
  }
  .nd-stage__frame { inset: 8px 16px 18px; }

  .nd-flow {
    width: 100%;
    padding: 6vh var(--gut) calc(var(--bottom-h) + 14vh);
  }

  /* the sticky stage occupies the top of the viewport on small screens */
  .nd-sec { padding-bottom: clamp(72px, 12vh, 130px); scroll-margin-top: calc(var(--top-h) + 56vh + 18px); }
  .nd-sec--unlocking { padding-bottom: clamp(72px, 12vh, 130px); }

  .nd-h1 { font-size: clamp(42px, 13vw, 76px); }
  .nd-tilegrid { width: min(200px, 62%); }
  .nd-debug { width: calc(100% - 2 * var(--gut)); right: var(--gut); left: var(--gut); }
}

@media (max-width: 620px) {
  :root { --gut: 20px; }
  .nd-top__sub { display: none; }
  .nd-top__div { display: none; }
  .nd-top__right .nd-top__sub { display: inline; }
  .nd-legend { grid-template-columns: repeat(2, 1fr); }
  .nd-channels li { grid-template-columns: 76px 1fr 44px; gap: 10px; }
  .nd-decoder__pattern { font-size: 16px; letter-spacing: .22em; padding: 18px 12px; }
}

/* Pointer-coarse devices never get hover-only affordances. */
@media (hover: none) {
  .nd-hint { display: none; }
}

/* ═══ REDUCED MOTION ═════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .nd-sec--locked { opacity: 0; }
  .nd-reveal p { filter: none; }
}

/* Before the script boots, the stage should not flash empty chrome. */
.nd-preboot .nd-stage__frame > *:not(.nd-stage__hit) { opacity: 0; }
