/* PEER TO PEER: the Module 5 skin (TRACE-BOT palette, CIPHER-BOT panels), with the
   courier board swapped for a network of laptops and envelopes. Lines up to the
   board and from the bloom onward are copied from CIPHER-BOT's styles.css. */

: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;
  --code-ink: #f2fbf6;
  --code-soft: #a6c8b6;
  --code-comment: #74a08a;
  --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;
}
/* Desktop: the two editor panels split the column and the CODE scrolls inside
   each panel, so the RUN button in the Main head can never leave the screen. */
.left-col .editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.left-col .editor-panel-main { flex: 1 1 62%; min-height: 176px; }
.left-col .editor-panel-fns { flex: 1 1 38%; min-height: 130px; }
.editor-panel .panel-head { flex: 0 0 auto; }
.editor-panel .editor,
.editor-panel .CodeMirror.cm-s-courier {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.editor-panel .editor { overflow: auto; resize: none; }
.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, and the
     panels go back to growing with their content (the page itself scrolls) */
  .left-col { overflow: visible; }
  .left-col .editor-panel { flex: none; min-height: 0; }
  .editor-panel .editor { min-height: 120px; resize: vertical; }
  .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(--code-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(--code-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(--code-comment); font-style: italic; }
.cm-s-courier span.cm-def { color: var(--accent-2); }
.cm-s-courier span.cm-variable { color: var(--code-ink); }
.cm-s-courier span.cm-variable-2 { color: var(--code-ink); }
.cm-s-courier span.cm-property { color: var(--code-ink); }
.cm-s-courier span.cm-operator { color: var(--code-soft); }
.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); }
/* ---- the toolkit row ----
   The most important thing on the mission card, so it reads as a set of tools
   rather than a footnote. Each chip is a disclosure BUTTON that opens one
   shared explanation panel underneath (see renderToolkit in ui.js for why it is
   a disclosure and not a hover tooltip). No underline and no help cursor: the
   chip is a button, and it looks and behaves like one. */
.api-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 9px 13px 0;
  line-height: 1.5;
}
.api-chip {
  display: inline-block;
  margin: 0;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(69, 255, 178, 0.3);
  background: rgba(69, 255, 178, 0.09);
  color: var(--trace);
  font-family: var(--font-code);
  font-size: 11.5px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
button.api-chip {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
button.api-chip:hover {
  background: rgba(69, 255, 178, 0.18);
  border-color: rgba(69, 255, 178, 0.55);
  color: #ddffef;
}
button.api-chip:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
/* Open state is never colour alone: the chip inverts entirely, swapping a dark
   mark on a light ground for a light mark on a dark one. */
button.api-chip.is-open {
  background: var(--trace);
  border-color: var(--trace);
  color: #08170f;
}

/* The explanation. Collapsed it is genuinely zero height, so a student who does
   not ask a question pays nothing for the feature. The 0fr/1fr grid animates
   open without a hard-coded height, so a two-line sentence is never clipped. */
.api-help {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s var(--ease-settle, ease);
  margin: 0 13px;
}
.api-help.is-open {
  grid-template-rows: 1fr;
  margin-top: 8px;
}
.api-help-text {
  overflow: hidden;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--code-ink);
}
.api-help.is-open .api-help-text {
  border-left: 2px solid var(--trace);
  padding: 1px 0 1px 9px;
}
@media (prefers-reduced-motion: reduce) {
  .api-chip { transition: none; }
  .api-help { transition: none; }
}

/* ---- the win verdict: a drawn tick and one line ---- */
.v-tick {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-block;
}
.v-tick svg { width: 100%; height: 100%; display: block; overflow: visible; }
.v-tick .ring {
  fill: none;
  stroke: rgba(69, 255, 178, 0.3);
  stroke-width: 2;
}
.v-tick .mark {
  fill: none;
  stroke: var(--pass);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
  animation: tick-draw 0.42s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.v-tick.is-cleared .ring {
  fill: rgba(69, 255, 178, 0.16);
  stroke: var(--pass);
  filter: drop-shadow(0 0 7px var(--trace-glow));
}
@keyframes tick-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .v-tick .mark { animation: none; stroke-dashoffset: 0; }
}
.v-win-line {
  font-size: 15px;
  color: var(--code-ink);
  letter-spacing: 0.2px;
}

/* ---- 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; }

/* 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, .verdict-slot .v-win-line, .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; }
/* A win is a tick, a line, and the NEXT button pushed to the far end. */
.verdict-slot.pass {
  animation: verdict-pass 900ms ease-out;
  display: flex;
  align-items: center;
  gap: 13px;
}
.verdict-slot.pass .next-btn { margin-left: auto; }
.verdict-slot .v-win-line { animation: verdict-rise 340ms var(--ease-settle) 60ms both; }
@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;
}

/* ======================================================================
   PEER TO PEER additions: one code panel, and the network board.
   ====================================================================== */

/* one code panel fills the left column */
.left-col .editor-panel-main { flex: 1 1 100%; }

/* ---- the network: laptops on a 640 x 360 stage ---- */
.board { width: 640px; height: 360px; }

.laptop {
  position: absolute;
  width: 176px;
  transform: translate(-50%, -50%);
  background: var(--panel-2);
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  padding: 8px 9px 9px;
  transition: opacity 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.lap-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.lap-name { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; color: var(--ink); }
.lap-host {
  font-family: var(--font-code);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--board-0);
  background: var(--warn);
  border-radius: 4px;
  padding: 1px 5px;
  visibility: hidden;
}
.laptop.is-host .lap-host { visibility: visible; }
.lap-state { margin-left: auto; font-size: 10px; color: var(--dim); letter-spacing: 0.04em; }

.lap-screen {
  height: 44px;
  border-radius: 7px;
  background: #050c08;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--trace);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lap-screen.flash { animation: screen-flash 0.6s var(--ease-settle); }
@keyframes screen-flash {
  0% { box-shadow: 0 0 0 0 var(--trace-glow); border-color: var(--trace); }
  100% { box-shadow: 0 0 0 10px transparent; border-color: var(--line); }
}

.lap-typed {
  margin-top: 6px;
  height: 22px;
  border-radius: 6px;
  border: 1px dashed var(--line-bright);
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--code-soft);
  display: flex;
  align-items: center;
  padding: 0 7px;
  overflow: hidden;
  white-space: nowrap;
}
.lap-buttons { display: flex; gap: 6px; margin-top: 6px; }
.lap-btn {
  flex: 1 1 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 0;
  border-radius: 6px;
  background: var(--panel-3);
  border: 1px solid var(--line-bright);
  color: var(--muted);
}
.lap-btn.pressed { animation: btn-press 0.45s var(--ease-settle); }
@keyframes btn-press {
  0% { background: var(--accent); color: #fff; transform: scale(0.94); }
  100% { background: var(--panel-3); color: var(--muted); transform: scale(1); }
}

/* not on the channel at all, not here yet, or gone */
.laptop.is-away { opacity: 0.38; border-style: dashed; }
.laptop.is-waiting { opacity: 0.38; border-style: dashed; }
.laptop.is-gone { opacity: 0.3; }
.laptop.arrives { animation: lap-arrive 0.5s var(--ease-settle); }
@keyframes lap-arrive { from { transform: translate(-50%, -50%) scale(0.92); opacity: 0.4; } }
.laptop.crashed { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }

/* ---- envelopes ---- */
.env {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  pointer-events: none;
  min-width: 46px;
  max-width: 120px;
  padding: 3px 7px 4px;
  border-radius: 6px;
  background: #f2e3c4;
  color: #2a1d0b;
  border: 1px solid #c98d4b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  font-family: var(--font-code);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition-property: transform, opacity;
  transition-timing-function: linear;
}
.env .env-label { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.env .env-content { display: block; font-size: 11px; color: #5a4320; overflow: hidden; text-overflow: ellipsis; }
.env.self { animation: env-self 0.5s var(--ease-settle) forwards; }
@keyframes env-self {
  0% { opacity: 0; margin-top: 0; }
  40% { opacity: 1; margin-top: -26px; }
  100% { opacity: 0; margin-top: 0; }
}
.env.nowhere { animation: env-nowhere 0.9s ease-out forwards; }
@keyframes env-nowhere {
  0% { opacity: 1; }
  100% { opacity: 0; margin-top: -40px; }
}
.env.lost { opacity: 0; transition: opacity 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .env { transition-duration: 0s !important; }
  .env.self, .env.nowhere, .lap-screen.flash, .lap-btn.pressed, .laptop.arrives { animation: none; }
}

/* ---- live mode ---- */
.live-bar { display: flex; align-items: center; gap: 8px; padding: 10px 13px; }
.live-bar input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--code-ink);
  background: #050c08;
  border: 1px solid var(--line-bright);
  border-radius: 7px;
  padding: 7px 9px;
}
.live-log {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  padding: 10px 13px;
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--code-soft);
}
.live-log .line { padding: 3px 0; border-bottom: 1px solid var(--line); }
.live-log .line.mine { color: var(--trace); }
.live-who { padding: 0 13px 10px; font-size: 12px; color: var(--muted); min-height: 18px; }

/* the hidden attribute must win over the panels' display rules */
[hidden] { display: none !important; }
