/* COURIER·BOT — TRACE-BOT aesthetic continuation over block-monster movement.
   Palette lifted verbatim from rh-trace-bot app/globals.css so the two apps
   read as one series. */

:root {
  color-scheme: dark;
  --board-0: #050d08;
  --board-1: #0a1a10;
  --panel: #0c1710;
  --panel-2: #0f2015;
  --panel-3: #132819;
  --line: #1e3a29;
  --line-bright: #2c5238;
  --copper: #c98d4b;
  --copper-dim: rgba(201, 141, 75, 0.16);
  --copper-faint: rgba(201, 141, 75, 0.07);
  --ink: #d9efe2;
  --muted: #7fa392;
  --dim: #52705f;
  --trace: #45ffb2;
  --trace-glow: rgba(69, 255, 178, 0.5);
  --ghost: #62766c;
  --accent: #748df4;
  --accent-2: #63d7f4;
  --magenta: #b526ef;
  --warn: #ffb454;
  --err: #ff6161;
  --pass: #45ffb2;
  --radius: 10px;
  --font-display: "Chakra Petch", sans-serif;
  --font-code: "JetBrains Mono", monospace;

  /* motion language — one servo curve for the chassis, one settle curve for
     everything that reacts to it. Keeping these named stops the app drifting
     into a dozen unrelated easings. */
  --ease-servo: cubic-bezier(0.38, 0.04, 0.16, 1);
  --ease-settle: cubic-bezier(0.2, 0.85, 0.3, 1);
  --step-ms: 340ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.chip:focus-visible, .btn-mini:focus-visible, .lpill:focus-visible, .dev-btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

html, body { height: 100%; }
body {
  font-family: var(--font-display);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1100px 500px at 75% -10%, rgba(116, 141, 244, 0.09), transparent 60%),
    radial-gradient(900px 600px at -5% 110%, rgba(69, 255, 178, 0.05), transparent 55%),
    linear-gradient(160deg, var(--board-1), var(--board-0) 55%);
  background-attachment: fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 3px);
  pointer-events: none;
  z-index: 999;
}

.mono { font-family: var(--font-code); }

/* ---- masthead ---- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px 12px;
}
.masthead .rh-logo { height: 26px; width: auto; display: block; }
.dev-badge {
  display: none;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--warn);
  border: 1px dashed var(--warn);
  border-radius: 5px;
  padding: 2px 7px;
  vertical-align: 3px;
  margin-left: 8px;
}
.masthead h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.masthead h1 .dot { color: var(--copper); }
.masthead h1 .bot-word {
  color: var(--trace);
  text-shadow: 0 0 14px var(--trace-glow);
}
.masthead .sub {
  margin-top: 3px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
}
.bus {
  height: 2px;
  margin: 0 26px;
  background: linear-gradient(90deg, transparent, var(--copper), transparent);
  opacity: 0.5;
}

/* ---- layout ---- */
.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 5fr) minmax(380px, 6fr);
  gap: 16px;
  padding: 14px 26px 16px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}
.left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
@media (max-width: 980px) {
  html, body { height: auto; }
  body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; }
  /* narrow screens: the task and board come FIRST, editors after */
  .left-col { overflow: visible; }
  .right-col { order: -1; }
  .right-col .board-pane { flex: none; height: min(62vw, 420px); }
}

/* ---- panels ---- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.head-hint {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--dim);
}
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.led.copper { background: var(--copper); box-shadow: 0 0 8px rgba(201, 141, 75, 0.7); }
.led.cyan { background: var(--accent-2); box-shadow: 0 0 8px rgba(99, 215, 244, 0.7); }
.led.mint { background: var(--trace); box-shadow: 0 0 8px var(--trace-glow); }

/* ---- mission (compact strip above the board) ---- */
.mission-panel { padding-bottom: 11px; }
.mission-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 13px 0;
  flex-wrap: wrap;
}
.lpill {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  padding: 7px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  cursor: pointer;
  transition: border-color 220ms ease, color 220ms ease, background 220ms ease;
}
.lpill-1.active {
  border-color: var(--trace);
  color: var(--trace);
  background: rgba(69, 255, 178, 0.08);
}
.lpill-2.active {
  border-color: var(--magenta);
  color: #c887ff;
  background: rgba(181, 38, 239, 0.1);
}
/* students: the LaunchPad URL chose the level, so pills read as state */
.mission-nav.static .lpill {
  cursor: default;
  pointer-events: none;
}
.mission-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.chips {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}
.chip {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-code);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 220ms ease, color 220ms ease, box-shadow 220ms ease,
              transform 160ms var(--ease-settle);
}
.chip:not(.locked):hover { transform: translateY(-2px); border-color: var(--line-bright); }
.chip.current {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 2px rgba(116, 141, 244, 0.25);
}
.chip.done { border-color: var(--trace); color: var(--trace); }
.chip.locked { opacity: 0.32; cursor: default; }
/* a rung just cleared: the chip flips to mint with one confident pop */
.chip.pop { animation: chip-pop 620ms var(--ease-settle); }
@keyframes chip-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(69, 255, 178, 0.5); }
  30% { transform: scale(1.2); box-shadow: 0 0 0 4px rgba(69, 255, 178, 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(69, 255, 178, 0); }
}
#mission-title { font-size: 14.5px; font-weight: 600; padding: 9px 13px 0; }
#mission-brief {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  padding: 4px 13px 0;
}
.ticks { display: flex; align-items: center; gap: 7px; padding: 9px 13px 0; flex-wrap: wrap; }
.tick-note { font-size: 10px; color: var(--dim); letter-spacing: 0.04em; }
.tick-pill {
  font-family: var(--font-code);
  font-size: 11px;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.tick-pill.banked {
  border-color: var(--trace);
  color: var(--trace);
  background: rgba(69, 255, 178, 0.1);
}
/* the pill that was just earned drops into place; the others stay put */
.tick-pill.just-banked { animation: pill-bank 520ms var(--ease-settle); }
@keyframes pill-bank {
  0% { transform: scale(0.82) translateY(3px); opacity: 0.25; box-shadow: 0 0 0 0 rgba(69, 255, 178, 0.5); }
  55% { transform: scale(1.06) translateY(0); opacity: 1; box-shadow: 0 0 0 6px rgba(69, 255, 178, 0.1); }
  100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 12px rgba(69, 255, 178, 0); }
}
/* ticks dropped: they fall left-to-right, so the loss reads as a sequence */
.ticks-dropped .tick-pill {
  animation: tick-drop 520ms ease;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes tick-drop {
  0% { border-color: var(--warn); color: var(--warn); transform: translateY(0); }
  30% { border-color: var(--warn); color: var(--warn); transform: translateY(3px); }
  100% { transform: translateY(0); }
}

/* ---- editors ---- */
.editor {
  display: block;
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 0;
  outline: none;
  background: #0a130d;
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.55;
  padding: 11px 13px;
  caret-color: var(--accent-2);
  tab-size: 2;
}
.editor-main { min-height: 120px; }
.editor-fns { min-height: 88px; }

/* ---- CodeMirror (theme: courier) ---- */
.CodeMirror.cm-s-courier {
  height: auto;
  background: #0a130d;
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.55;
  padding: 6px 7px;
}
.cm-s-courier.cm-main .CodeMirror-scroll { min-height: 120px; }
.cm-s-courier.cm-fns .CodeMirror-scroll { min-height: 88px; }
.cm-s-courier .CodeMirror-cursor { border-left: 2px solid var(--accent-2); }
.cm-s-courier .CodeMirror-selected { background: rgba(44, 82, 56, 0.55); }
.cm-s-courier .CodeMirror-focused .CodeMirror-selected { background: rgba(44, 82, 56, 0.7); }
.cm-s-courier .CodeMirror-lines { padding: 4px 0; }
.cm-s-courier .CodeMirror-matchingbracket {
  color: var(--accent-2) !important;
  outline: 1px solid rgba(99, 215, 244, 0.4);
  background: transparent;
}
.cm-s-courier span.cm-keyword { color: #c887ff; }
.cm-s-courier span.cm-string { color: var(--trace); }
.cm-s-courier span.cm-string-2 { color: var(--trace); }
.cm-s-courier span.cm-number { color: var(--warn); }
.cm-s-courier span.cm-atom { color: var(--warn); }
.cm-s-courier span.cm-comment { color: var(--dim); font-style: italic; }
.cm-s-courier span.cm-def { color: var(--accent-2); }
.cm-s-courier span.cm-variable { color: var(--ink); }
.cm-s-courier span.cm-variable-2 { color: var(--ink); }
.cm-s-courier span.cm-property { color: var(--ink); }
.cm-s-courier span.cm-operator { color: var(--muted); }
.cm-s-courier span.cm-punctuation { color: var(--muted); }
.cm-s-courier span.cm-bracket { color: var(--muted); }
.cm-s-courier span.cm-error { color: var(--err); background: transparent; }

/* ---- run / reset, compact in the Main program panel head ---- */
.head-actions { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.btn-mini {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  border-radius: 6px;
  padding: 5px 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 120ms var(--ease-settle), box-shadow 240ms ease,
              border-color 240ms ease, color 240ms ease;
}
.btn-mini:active { transform: translateY(1px); }
.btn-mini.run {
  background: linear-gradient(180deg, #58ffc0, #23d68a);
  color: #04120a;
  box-shadow: 0 0 12px rgba(69, 255, 178, 0.3);
}
.btn-mini.run:hover { box-shadow: 0 0 18px rgba(69, 255, 178, 0.5); }
.btn-mini.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line-bright);
}
.btn-mini.ghost:hover { color: var(--ink); border-color: var(--trace); }
.api-hint { font-size: 10.5px; color: var(--dim); line-height: 1.6; padding: 6px 13px 0; }

/* ---- board ---- */
.board-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.board-pane {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: hidden;
  background:
    repeating-linear-gradient(to right, var(--copper-faint) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(to bottom, var(--copper-faint) 0 1px, transparent 1px 26px),
    var(--board-0);
}
.board-scale { position: absolute; transform-origin: top left; }
.board { position: relative; }

.tile {
  position: absolute;
  border-radius: 10px;
  background: linear-gradient(180deg, #0d1f13, #0a1810);
  border: 1px solid rgba(201, 141, 75, 0.22);
  box-shadow: inset 0 1px 0 rgba(217, 239, 226, 0.05);
}
.tile::after {
  content: "";
  position: absolute;
  inset: 42% 42%;
  border-radius: 50%;
  background: var(--copper-faint);
}

/* zone = landing ring, styled like TRACE-BOT pose markers.
   The dashes live on ::before so they can creep at rest — a target still
   searching — while the zone itself handles the lock-on. */
.zone {
  position: absolute;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-code);
  font-weight: 700;
  font-size: 15px;
  color: rgba(99, 215, 244, 0.8);
  z-index: 1;
  transition: color 320ms ease, text-shadow 320ms ease;
}
.zone.long { font-size: 12px; letter-spacing: 0.02em; }
.zone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px dashed rgba(99, 215, 244, 0.55);
  transition: border-color 320ms ease;
  animation: zone-drift 20s linear infinite;
}
/* the ring answers the docking bot: the creep stops dead WHERE IT IS
   (paused, not reset — no snap), the ring clamps in, then blooms out as a
   halo. Delayed 200ms so it reads as a response, not a twin. */
.zone.won {
  color: var(--trace);
  text-shadow: 0 0 10px var(--trace-glow);
  animation: zone-lock 720ms var(--ease-settle) 200ms both;
}
.zone.won::before { border-color: var(--trace); animation-play-state: paused; }
@keyframes zone-drift { to { transform: rotate(360deg); } }
@keyframes zone-lock {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(69, 255, 178, 0.5); }
  24% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(69, 255, 178, 0.5); }
  56% { transform: scale(1.3); box-shadow: 0 0 0 10px rgba(69, 255, 178, 0.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 26px rgba(69, 255, 178, 0); }
}

/* note tile */
.note {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(180deg, #14281a, #0f2015);
  border: 1px solid var(--line-bright);
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  box-shadow: 0 0 10px rgba(69, 255, 178, 0.12);
  transition: color 240ms ease, border-color 240ms ease,
              box-shadow 240ms ease, text-shadow 240ms ease;
}
/* reading = the courier lifts the note and turns it over. It has to rise
   ABOVE the bot (z-index 5) — the bot is standing on it — and the face swaps
   at the edge-on midpoint (ui.js), so the code is never visible through the
   flip. ui.js drops the class on animationend so the note sinks back under. */
.note.reading {
  z-index: 5;
  animation: note-flip 540ms cubic-bezier(0.45, 0.05, 0.25, 1);
}
@keyframes note-flip {
  0% { transform: perspective(420px) translateY(0) rotateX(0deg) scale(1); }
  46% { transform: perspective(420px) translateY(-10px) rotateX(86deg) scale(1.12); }
  54% { transform: perspective(420px) translateY(-10px) rotateX(-86deg) scale(1.12); }
  100% { transform: perspective(420px) translateY(0) rotateX(0deg) scale(1); }
}
.note.revealed {
  color: var(--trace);
  border-color: var(--trace);
  text-shadow: 0 0 8px var(--trace-glow);
  box-shadow: 0 0 16px rgba(69, 255, 178, 0.22);
}

/* keypad */
.keypad {
  position: absolute;
  z-index: 1;
  border-radius: 6px;
  background: linear-gradient(180deg, #241a0e, #1a1309);
  border: 1px solid rgba(201, 141, 75, 0.55);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  place-items: center;
  padding: 5px;
}
.keypad i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--copper);
  opacity: 0.65;
  transition: background 200ms ease, opacity 200ms ease;
}
/* accept: the code is entered dot by dot, THEN the frame confirms */
.keypad.accept { border-color: var(--trace); box-shadow: 0 0 14px var(--trace-glow); animation: key-accept 760ms ease-out; }
.keypad.accept i { background: var(--trace); opacity: 1; animation: key-dot 420ms ease-out both; }
.keypad.accept i:nth-child(1) { animation-delay: 0ms; }
.keypad.accept i:nth-child(2) { animation-delay: 34ms; }
.keypad.accept i:nth-child(3) { animation-delay: 68ms; }
.keypad.accept i:nth-child(4) { animation-delay: 102ms; }
.keypad.accept i:nth-child(5) { animation-delay: 136ms; }
.keypad.accept i:nth-child(6) { animation-delay: 170ms; }
.keypad.accept i:nth-child(7) { animation-delay: 204ms; }
.keypad.accept i:nth-child(8) { animation-delay: 238ms; }
.keypad.accept i:nth-child(9) { animation-delay: 272ms; }
/* reject: no sequence — the whole pad says no at once */
.keypad.reject {
  border-color: var(--err);
  box-shadow: 0 0 14px rgba(255, 97, 97, 0.5);
  animation: shake-x 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.keypad.reject i { background: var(--err); opacity: 1; animation: key-dot-bad 380ms ease-out; }
@keyframes key-dot {
  0% { transform: scale(1); background: var(--copper); opacity: 0.65; box-shadow: none; }
  35% { transform: scale(2); background: var(--trace); opacity: 1; box-shadow: 0 0 8px var(--trace-glow); }
  100% { transform: scale(1); background: var(--trace); opacity: 1; box-shadow: 0 0 4px var(--trace-glow); }
}
@keyframes key-dot-bad {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.7); }
}
@keyframes key-accept {
  0%, 40% { border-color: rgba(201, 141, 75, 0.55); box-shadow: 0 0 0 rgba(69, 255, 178, 0); transform: scale(1); }
  56% { border-color: var(--trace); box-shadow: 0 0 22px var(--trace-glow), 0 0 0 3px rgba(69, 255, 178, 0.15); transform: scale(1.07); }
  100% { border-color: var(--trace); box-shadow: 0 0 14px var(--trace-glow); transform: scale(1); }
}

/* door — bars unlatch (a beat DOWN) before they retract, bottom bar last */
.door {
  position: absolute;
  z-index: 1;
  border-radius: 8px;
  border: 1px solid rgba(255, 97, 97, 0.5);
  background: rgba(255, 97, 97, 0.06);
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 6px 8px;
  overflow: hidden;
  transition: border-color 420ms ease, background 420ms ease;
}
.door i {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 97, 97, 0.75);
}
.door.open {
  border-color: rgba(69, 255, 178, 0.4);
  background: rgba(69, 255, 178, 0.04);
  animation: door-unlock 620ms ease-out;
}
.door.open i {
  transform: translateY(-18px);
  opacity: 0;
  animation: door-bar 500ms cubic-bezier(0.55, 0, 0.25, 1) both;
}
.door.open i:nth-child(1) { animation-delay: 40ms; }
.door.open i:nth-child(2) { animation-delay: 100ms; }
.door.open i:nth-child(3) { animation-delay: 160ms; }
@keyframes door-bar {
  0% { transform: translateY(0); opacity: 1; }
  16% { transform: translateY(2.5px); opacity: 1; }
  100% { transform: translateY(-18px); opacity: 0; }
}
@keyframes door-unlock {
  0% { box-shadow: 0 0 0 rgba(69, 255, 178, 0); }
  25% { box-shadow: 0 0 16px rgba(69, 255, 178, 0.35), inset 0 0 12px rgba(69, 255, 178, 0.18); }
  100% { box-shadow: 0 0 0 rgba(69, 255, 178, 0); }
}

/* the courier bot — block-monster body, trace-bot skin.
   .bot is the chassis (translate only, so playback maths stays simple);
   .bot-body is the shell, free to squash, lean, dock and shake. */
.bot {
  position: absolute;
  z-index: 3;
  transition: transform var(--step-ms) var(--ease-servo);
  will-change: transform;
}
.bot.no-anim { transition: none; }
.bot.no-anim .bot-body { animation: none; }
.bot-body {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #14352a, #0e2a1c);
  border: 1px solid var(--accent-2);
  box-shadow: 0 0 16px rgba(99, 215, 244, 0.45), 0 4px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: border-color 320ms ease, box-shadow 320ms ease;
}
/* the shell trails the chassis on the way out and catches up on arrival —
   the whole reaction resolves inside one tick, so consecutive steps in the
   same direction never stack or overshoot the grid square */
.bot.stepping .bot-body { animation: step-h 380ms cubic-bezier(0.4, 0.1, 0.2, 1); }
.bot.stepping[data-facing="right"] .bot-body { --lean: 1; }
.bot.stepping[data-facing="left"] .bot-body { --lean: -1; }
.bot.stepping[data-facing="up"] .bot-body { --lean: -1; animation-name: step-v; }
.bot.stepping[data-facing="down"] .bot-body { --lean: 1; animation-name: step-v; }
@keyframes step-h {
  0% { transform: translateX(calc(var(--lean, 1) * -1px)) scale(0.95, 1.05); }
  35% { transform: translateX(calc(var(--lean, 1) * -2.5px)) scale(1.08, 0.93); }
  70% { transform: translateX(calc(var(--lean, 1) * 2px)) scale(1.03, 0.97); }
  100% { transform: translateX(0) scale(1, 1); }
}
@keyframes step-v {
  0% { transform: translateY(calc(var(--lean, 1) * -1px)) scale(1.05, 0.95); }
  35% { transform: translateY(calc(var(--lean, 1) * -2.5px)) scale(0.93, 1.08); }
  70% { transform: translateY(calc(var(--lean, 1) * 2px)) scale(0.97, 1.03); }
  100% { transform: translateY(0) scale(1, 1); }
}
.bot .eye {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #eafcf4;
  position: relative;
}
.bot .eye::after {
  content: "";
  position: absolute;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: #06231a;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 220ms cubic-bezier(0.34, 1.45, 0.5, 1);
}
.bot[data-facing="right"] .eye::after { transform: translate(calc(-50% + 2px), -50%); }
.bot[data-facing="left"] .eye::after { transform: translate(calc(-50% - 2px), -50%); }
.bot[data-facing="up"] .eye::after { transform: translate(-50%, calc(-50% - 2px)); }
.bot[data-facing="down"] .eye::after { transform: translate(-50%, calc(-50% + 2px)); }
.bot .nose {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--trace);
  box-shadow: 0 0 6px var(--trace-glow);
}
/* wait: one held breath of a ring, nothing more */
.bot-body::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  border: 1.5px solid var(--trace);
  opacity: 0;
  pointer-events: none;
}
.bot.is-waiting .bot-body::after { animation: wait-ring 700ms var(--ease-settle); }
@keyframes wait-ring {
  0% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.6); }
}
/* DOCKING — the hero moment. Lift (inhale), press down into the ring,
   squash wide on contact, two decaying settles. Shell goes mint on impact. */
.bot.is-home .bot-body {
  border-color: var(--trace);
  box-shadow: 0 0 22px var(--trace-glow), 0 4px 10px rgba(0, 0, 0, 0.5);
  transition-delay: 220ms; /* the shell goes mint on contact, not on arrival */
  transform-origin: 50% 88%; /* squash presses DOWN into the ring, feet planted */
  animation: bot-dock 640ms cubic-bezier(0.3, 0.6, 0.3, 1);
}
@keyframes bot-dock {
  0% { transform: translateY(0) scale(1, 1); }
  16% { transform: translateY(-6px) scale(0.94, 1.08); }
  44% { transform: translateY(1px) scale(1.14, 0.86); }
  64% { transform: translateY(-2px) scale(0.98, 1.03); }
  82% { transform: translateY(0) scale(1.02, 0.98); }
  100% { transform: translateY(0) scale(1, 1); }
}
.bot.is-crashed .bot-body {
  border-color: var(--err);
  box-shadow: 0 0 20px rgba(255, 97, 97, 0.6);
  animation: shake-x 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake-x {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); }
  62% { transform: translateX(2px); }
  80% { transform: translateX(-1px); }
}

/* speech bubble — rises out of the bot, drops back fast */
.bubble {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  white-space: nowrap;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--trace);
  background: rgba(5, 13, 8, 0.9);
  border: 1px solid var(--line-bright);
  border-radius: 7px;
  padding: 4px 9px;
  opacity: 0;
  transform: translateX(-50%) translateY(5px) scale(0.94);
  transform-origin: 50% 110%;
  pointer-events: none;
  transition: opacity 130ms ease, transform 130ms ease;
}
.bubble.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  transition: opacity 150ms ease, transform 260ms var(--ease-settle);
}
.bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--line-bright);
}

/* crash vignette + pass bloom */
.board-pane.crashed::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 90px rgba(255, 97, 97, 0.22);
  pointer-events: none;
  animation: vignette-in 520ms ease-out both;
}
@keyframes vignette-in {
  0% { box-shadow: inset 0 0 0 rgba(255, 97, 97, 0); }
  40% { box-shadow: inset 0 0 120px rgba(255, 97, 97, 0.32); }
  100% { box-shadow: inset 0 0 90px rgba(255, 97, 97, 0.22); }
}
/* fired by ui.js at the moment of contact, not on arrival */
.bloom {
  position: absolute;
  border: 2px solid var(--trace);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 18px var(--trace-glow), inset 0 0 12px rgba(69, 255, 178, 0.22);
  animation: bloom-ring 860ms cubic-bezier(0.16, 0.7, 0.3, 1) forwards;
  z-index: 4;
}
@keyframes bloom-ring {
  0% { transform: scale(0.45); opacity: 0; border-width: 3px; }
  12% { transform: scale(0.72); opacity: 1; border-width: 3px; }
  100% { transform: scale(2.7); opacity: 0; border-width: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  .bot, .bot-body, .bot-body::after, .bot .eye::after, .bubble, .bubble.show,
  .zone, .zone::before, .note, .keypad, .keypad i, .door, .door i,
  .bloom, .board-pane::after, .verdict-slot, .verdict-slot .v-kicker,
  .verdict-slot .v-body, .chip, .tick-pill {
    transition: none !important;
    animation: none !important;
  }
  /* every end state above is class-defined, so nothing is lost — except the
     wait ring, which only exists as motion. Hold it still instead. */
  .bot.is-waiting .bot-body::after { opacity: 0.8; }
}

/* ---- dev bar (?dev=1) — amber dashed, per TRACE-BOT convention ---- */
.dev-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--warn);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--warn);
}
.dev-label { letter-spacing: 0.24em; font-weight: 700; }
.dev-btn {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 180, 84, 0.5);
  background: rgba(255, 180, 84, 0.07);
  color: var(--warn);
  cursor: pointer;
  white-space: nowrap;
}
.dev-btn:active { transform: translateY(1px); }
select.dev-btn {
  flex: 1 1 100px;
  min-width: 0;
  max-width: 190px;
  appearance: none;
  -webkit-appearance: none;
}

/* ---- verdict ---- */
.next-btn { margin-left: 12px; flex: 0 0 auto; }
.verdict-slot {
  min-height: 64px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 320ms ease;
}
/* the slot never resizes, so the verdict arrives by rising into it */
.verdict-slot .v-kicker {
  font-family: var(--font-code);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
  animation: verdict-rise 300ms var(--ease-settle) both;
}
.verdict-slot .v-body { display: block; animation: verdict-rise 340ms var(--ease-settle) 70ms both; }
.verdict-slot.pass { animation: verdict-pass 900ms ease-out; }
@keyframes verdict-rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@keyframes verdict-pass {
  0% { box-shadow: inset 0 0 0 rgba(69, 255, 178, 0); }
  25% { box-shadow: inset 0 0 26px rgba(69, 255, 178, 0.13); }
  100% { box-shadow: inset 0 0 0 rgba(69, 255, 178, 0); }
}
.verdict-slot.idle { color: var(--dim); }
.verdict-slot.tracing .v-kicker { color: var(--accent-2); }
.verdict-slot.pass { border-color: rgba(69, 255, 178, 0.5); }
.verdict-slot.pass .v-kicker { color: var(--pass); }
.verdict-slot.fail { border-color: rgba(255, 180, 84, 0.4); }
.verdict-slot.fail .v-kicker { color: var(--warn); }
.verdict-slot.crash { border-color: rgba(255, 97, 97, 0.45); }
.verdict-slot.crash .v-kicker { color: var(--err); }
.verdict-slot .v-body { color: var(--ink); }
.verdict-slot .v-body code {
  font-family: var(--font-code);
  color: var(--trace);
  font-size: 12px;
}
