/* ── Game screen ──────────────────────────────────────────────────────────
   Chrome around the board: top bar, floating panels, deck, hints.
   Tokens only — see css/tokens.css.                                        */

.game { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ── floating chrome ──────────────────────────────────────────────────────
   Nothing frames the board any more; the controls float over the canvas,
   Euclidea-style. The goal sits top-left, the live count top-centre, the
   undo/redo/menu rail top-right, and the golden target bottom-right.        */

.goal-card {
  position: absolute; top: calc(var(--space-5) + var(--sat)); left: calc(var(--space-5) + var(--sal)); z-index: var(--z-panel);
  max-width: 156px;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: var(--hairline) solid var(--line-2); border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  text-align: left; cursor: pointer;
  transition: border-color var(--t), transform var(--t);
}
.goal-card:hover { border-color: var(--accent-line); transform: translateY(-1px); }

.goal-num {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--accent);
}
.goal-mini { pointer-events: none; }
.goal-mini .ttable { margin: 0; font-size: var(--text-2xs); }
.goal-mini .ttable th, .goal-mini .ttable td { padding: 1.5px var(--space-2); }
.goal-mini .ttable-note { display: none; }   /* the card is a glance, not the whole table */

.goal-io { display: inline-flex; align-items: center; gap: var(--space-2); }
.goal-io svg { width: var(--icon-sm); height: var(--icon-sm); color: var(--mute); }
.goal-free { font-size: var(--text-md); color: var(--dim); }
.goal-par {
  font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--mute);
  letter-spacing: 0.04em;
}
.goal-par b { color: var(--dim); font-weight: 500; }

/* the live circuit tally, floating top-centre */
.g-count {
  position: absolute; top: calc(var(--space-5) + var(--sat)); left: 50%; transform: translateX(-50%);
  z-index: var(--z-panel);
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-3) var(--space-5);
  border: var(--hairline) solid var(--line); border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.g-count i { color: var(--mute); font-style: normal; margin: 0 1px; }
.g-count b { color: var(--text); font-weight: 500; }
.g-count.met { border-color: var(--accent-line); color: var(--accent); }
.g-count.met b { color: var(--accent); }

.g-actions {
  position: absolute; left: calc(var(--space-5) + var(--sal)); top: 50%; transform: translateY(-50%);
  z-index: var(--z-panel);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.g-actions .icon-btn {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
.g-actions .icon-btn:disabled { opacity: 0.32; pointer-events: none; }

/* the golden target — a reactive bullseye that opens the problem you can poke */
.target-btn {
  position: absolute; z-index: var(--z-panel);
  right: var(--space-6); bottom: var(--space-6);
  width: var(--control); height: var(--control);
  display: grid; place-items: center;
  border: var(--hairline) solid var(--accent-line); border-radius: var(--radius-full);
  background: var(--accent-dim); color: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  animation: target-pulse 2.6s var(--ease) infinite;
  transition: transform var(--t), background var(--t);
}
.target-btn:hover { transform: scale(1.06); background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.target-btn svg {
  width: var(--icon-lg); height: var(--icon-lg);
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
@keyframes target-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  50%      { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* build mode keeps a deliberate Publish button where the target would sit */
.publish-btn {
  position: absolute; z-index: var(--z-panel);
  right: var(--space-6); bottom: var(--space-6);
}

/* an active toggle (the grab/hand tool) reads as pressed */
.g-actions .icon-btn.active {
  border-color: var(--accent-line); color: var(--accent); background: var(--accent-dim);
}

/* ── target preview: the goal shown on the board, not in a popup ───────── */

/* while previewing, the golden button is lit and steady, and everything that
   edits the hidden circuit rests until the player returns */
.showing-target .target-btn {
  background: var(--accent); color: var(--on-accent);
  border-color: var(--accent); animation: none;
}
.showing-target .deck,
.showing-target [data-undo],
.showing-target [data-redo],
.showing-target [data-grab] { opacity: 0.35; pointer-events: none; }

.target-hint {
  position: absolute; left: 50%; bottom: var(--space-6); transform: translateX(-50%);
  z-index: var(--z-panel); display: none; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: var(--hairline) solid var(--accent-line); border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px);
  color: var(--dim); font-size: var(--text-sm); white-space: nowrap;
}
.target-hint svg {
  width: var(--icon-sm); height: var(--icon-sm); color: var(--accent);
  vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.showing-target .target-hint { display: inline-flex; }

/* ── board ────────────────────────────────────────────────────────────── */

.board-host {
  position: relative; flex: 1; min-height: 0;
  overflow: hidden; touch-action: none;
}
/* touch-action does not inherit, and the finger lands on the canvas, not its
   host — without this a phone claims every drag as a scroll and cancels it. */
.board-host canvas { display: block; touch-action: none; }

/* Drag-to-delete: a dashed target the board floats over its own bottom edge
   while a card is being dragged, right where the deck it came from sits. It
   arms (fills in) when the card is held over it; releasing there removes it. */
.board-trash {
  position: absolute; left: 50%; bottom: var(--space-7); transform: translateX(-50%);
  display: none; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border: var(--hairline) dashed var(--danger-line); border-radius: var(--radius);
  background: var(--surface); color: var(--danger-text);
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  z-index: var(--z-panel); pointer-events: none;
  transition: transform 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}
.board-trash.on { display: inline-flex; }
.board-trash.armed {
  background: var(--danger-line); color: var(--on-accent);
  border-style: solid; transform: translateX(-50%) scale(1.06);
}
.board-trash svg { width: var(--icon-lg); height: var(--icon-lg); flex: none; }

/* ── rotate hint ────────────────────────────────────────────────────────────
   Only a portrait phone sees this; every other context hides it (below).      */
.rotate-hint {
  position: absolute; left: 50%; bottom: var(--space-6); transform: translateX(-50%);
  z-index: var(--z-panel);
  display: none; align-items: center; gap: var(--space-4);
  max-width: calc(100vw - 2 * var(--space-5));   /* never flush at 280px */
  padding: var(--space-4) var(--space-6);
  border: var(--hairline) solid var(--line-2); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--dim);
  font-size: var(--text-md); white-space: normal; text-align: left;
  animation: fade var(--duration-2) var(--ease) both;
}
/* a near-square viewport (fold cover) gains nothing from rotating — don't nag */
@media (min-aspect-ratio: 3/4) { .rotate-hint { display: none !important; } }
.rotate-hint .ic { display: grid; place-items: center; color: var(--accent); }
.rotate-hint .ic svg {
  width: var(--icon); height: var(--icon);
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── options menu (a sheet) ───────────────────────────────────────────── */

.opt-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-5); }
.opt-row {
  display: flex; align-items: center; gap: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: var(--hairline) solid var(--line); border-radius: var(--radius);
  font-size: var(--text-base); color: var(--dim); text-align: left;
  transition: var(--t);
}
.opt-row:hover { border-color: var(--accent-line); color: var(--text); background: var(--surface); }
.opt-ic { flex: none; display: grid; place-items: center; color: var(--mute); }
.opt-row:hover .opt-ic { color: var(--accent); }
.opt-ic svg {
  width: var(--icon); height: var(--icon);
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* ── selection bar, bottom-left of the board ──────────────────────────── */

.selbar {
  position: absolute; left: var(--space-5); bottom: var(--space-5); z-index: var(--z-panel);
  display: flex; align-items: center; gap: var(--space-5);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
  border: var(--hairline) solid var(--line-2);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--dim);
  animation: fade var(--duration-1) var(--ease) both;
}
.selbar kbd {
  font-family: var(--font-mono); font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border: var(--hairline) solid var(--line-2); border-radius: 3px;
  color: var(--mute);
}
.selbar .icon-btn { width: var(--control-sm); height: var(--control-sm); }
.selbar .icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); }

/* ── deck ─────────────────────────────────────────────────────────────── */

.deck {
  flex: none;
  border-top: var(--hairline) solid var(--line);
  padding: var(--space-5) var(--space-5) calc(var(--space-5) + var(--sab));
  display: flex; align-items: center; gap: var(--space-5);
  z-index: var(--z-chrome);
}

.deck-scroll {
  flex: 1; min-width: 0;
  display: flex; gap: var(--space-3);
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: var(--space-1);
  scrollbar-width: none;
}

.deck-empty {
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute);
  padding: var(--space-8) var(--space-2);
}

.card {
  position: relative; flex: none;
  width: 68px; height: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--t), background var(--t);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.card:hover { border-color: var(--line-2); background: var(--surface); }
.card:hover .card-glyph { color: var(--text); }
.card.dragging { opacity: 0.35; cursor: grabbing; }
.card.armed { border-color: var(--accent-line); background: var(--accent-dim); }
.card.armed .card-glyph { color: var(--accent); }

.card-glyph { width: 40px; height: 33px; color: var(--dim); transition: color var(--t); }
/* glyphs only — a label under every card read as clutter (owner's call) */
.deck .card-name { display: none; }
.card { height: 56px; }
.card-glyph svg { width: 100%; height: 100%; overflow: visible; }
.card-glyph svg [data-fill] { fill: none; }
.card-glyph svg [data-stroke] {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.card-glyph svg text { fill: currentColor; }

.card-name { font-size: 8.5px; color: var(--mute); letter-spacing: 0.1em; }
.card.armed .card-name { color: var(--accent); }

.card .new-flag {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: var(--space-2); height: var(--space-2);
  border-radius: var(--radius-full); background: var(--accent);
}

/* the card that follows the cursor while dragging out of the deck */
.card-ghost {
  position: fixed; z-index: var(--z-ghost); pointer-events: none;
  width: 68px; height: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  border: var(--hairline) solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--surface);
  transform: translate(-50%, -50%);
  opacity: 0.9;
}
.card-ghost .card-glyph { color: var(--accent); }
.card-ghost .card-name { color: var(--accent); }

/* the pan hand lives with the left cluster, a step above the golden target */
.grab-btn {
  position: absolute; z-index: var(--z-panel);
  left: calc(var(--space-6) + var(--sal)); bottom: calc(var(--space-6) + var(--sab) + 56px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: var(--hairline) solid var(--line); border-radius: var(--radius);
}
.grab-btn.on { color: var(--accent); border-color: var(--accent-line); }
/* the target sits under it on the same left edge, every layout */
.target-btn { right: auto; left: calc(var(--space-6) + var(--sal)); }

/* ── top bar & counters (chip editor) ──────────────────────────────────────
   The game screen floats its chrome now; the chip editor keeps the old framed
   top bar, so these styles live on for it.                                   */

.topbar {
  flex: none;
  display: flex; align-items: center; gap: var(--space-5);
  padding: var(--space-5) var(--space-5);
  padding-top: calc(var(--space-5) + var(--sat));   /* clear the status bar / notch */
  border-bottom: var(--hairline) solid var(--line);
  z-index: var(--z-chrome);
}
.topbar .heading {
  flex: 1; min-width: 0;
  display: flex; align-items: baseline; gap: var(--space-5);
  padding-left: var(--space-2);
}
.topbar .heading .chapter-tag { font-size: var(--text-2xs); color: var(--accent); flex: none; }
.topbar .heading .name {
  font-size: var(--text-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.counters { display: flex; gap: var(--space-3); flex: none; }
.counter {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono); font-size: var(--text-md); color: var(--dim);
}
.counter .k { font-size: var(--text-2xs); color: var(--mute); }
.counter .v { font-variant-numeric: tabular-nums; }
.counter.met { border-color: var(--accent-line); color: var(--accent); }
.counter.met .k { color: var(--accent); opacity: 0.7; }
.counter.over { border-color: var(--over); color: var(--over-text); }

/* the chip editor's tool rail, top-right of its board */
.rail {
  position: absolute; top: var(--space-5); right: var(--space-5); z-index: var(--z-panel);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.rail .icon-btn { background: var(--bg); }

/* ── check ────────────────────────────────────────────────────────────── */

.check-btn {
  flex: none;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-5) var(--space-8);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500;
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  transition: var(--t);
  position: relative; overflow: hidden;
}
.check-btn:hover:not(:disabled) { background: var(--accent-hi); }
.check-btn:disabled { background: none; border: var(--hairline) solid var(--line); color: var(--mute); }
.check-btn svg {
  width: var(--icon-sm); height: var(--icon-sm);
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.check-btn.busy { pointer-events: none; }
/* the sweep lightens the accent in the dark and darkens it on paper */
.check-btn.busy::after {
  content: ""; position: absolute; inset: 0;
  background: var(--sweep);
  animation: sweep 0.7s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%) } to { transform: translateX(100%) } }

/* ── hints ────────────────────────────────────────────────────────────── */

.hint-step {
  display: flex; gap: var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: var(--hairline) solid var(--line);
}
.hint-step:last-child { border-bottom: 0; }
.hint-step .n {
  flex: none; width: var(--space-8); height: var(--space-8);
  display: grid; place-items: center; border-radius: var(--radius-sm);
  border: var(--hairline) solid var(--line-2);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--mute);
}
.hint-step.revealed .n { border-color: var(--accent-line); color: var(--accent); }
.hint-step p { flex: 1; padding-top: var(--space-1); }
.hint-step.hidden p { filter: blur(4px); user-select: none; opacity: 0.4; }
.hint-step .reveal {
  align-self: center; flex: none;
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim); padding: var(--space-3) var(--space-5);
  border: var(--hairline) solid var(--line-2); border-radius: var(--radius-sm);
  transition: var(--t);
}
.hint-step .reveal:hover { color: var(--accent); border-color: var(--accent-line); }

/* the last step is the circuit itself, read off the reference the checker proves */
.hint-step.solution { border-top: var(--hairline) solid var(--line-2); margin-top: var(--space-3); }
.hint-step.solution .n svg {
  width: var(--icon-sm); height: var(--icon-sm);
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.hint-step .soln { flex: 1; }
.hint-step .soln p { padding-top: var(--space-1); font-size: var(--text-base); color: var(--dim); }
.hint-step .soln ol {
  margin: var(--space-5) 0 0; padding: var(--space-5) var(--space-5);
  list-style: none; counter-reset: step;
  border: var(--hairline) solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--text-md);
  line-height: 1.9; color: var(--text);
}
.hint-step.solution > div { flex: 1; }

/* The revealed answer, drawn on a read-only board rather than written out. */
.soln-board {
  width: 100%; height: min(58vh, 440px);
  margin-top: var(--space-5);
  border: var(--hairline) solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--bg);
}
.soln-board canvas { display: block; width: 100%; height: 100%; }


/* ── compact ──────────────────────────────────────────────────────────────
   On a phone the floating chrome shrinks a step and the goal card drops its
   truth-table thumbnail (tap it for the whole problem) so it never covers the
   circuit it describes.

   The breakpoint is by EITHER dimension: a phone in portrait is narrow, a
   phone in landscape is short. Board.fit() reads the same rule; move one and
   move the other.                                                            */

@media (max-width: 760px), (max-height: 560px) {
  /* the nudge belongs to the portrait phone only */
  .rotate-hint { display: flex; }

  /* the goal card keeps its truth-table thumbnail on a phone too, only smaller */
  .goal-card { top: calc(var(--space-4) + var(--sat)); left: calc(var(--space-4) + var(--sal)); max-width: 46vw; padding: var(--space-3) var(--space-4); }
  .goal-mini .ttable { font-size: 7px; }
  .goal-mini .ttable th, .goal-mini .ttable td { padding: 1px 2px; }
  .goal-mini .cell-switch, .goal-mini .cell-led { height: 10px; }

  .g-count { top: calc(var(--space-4) + var(--sat)); padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
  /* ≤400px: the centre-anchored tally collides with the top-right actions —
     tuck it under the goal card on the left instead (declared here, after the
     top re-anchor above, so the cascade cannot undo it) */
}
@media (max-width: 400px) {
  .g-count { left: var(--space-5); top: calc(128px + var(--sat)); transform: none; }
  .g-actions { left: calc(var(--space-3) + var(--sal)); gap: var(--space-2); }
  .g-actions .icon-btn { width: var(--control-sm); height: var(--control-sm); }
  .g-actions .icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); }

  .target-btn { right: var(--space-5); bottom: var(--space-5); }

  /* chip editor's framed top bar */
  .topbar { gap: var(--space-4); padding: var(--space-4); }
  .topbar .heading { gap: var(--space-4); padding-left: 0; }
  .topbar .heading .chapter-tag { display: none; }
  .topbar .heading .name { font-size: var(--text-md); }
  .topbar > .icon-btn { width: var(--control-sm); height: var(--control-sm); }
  .counters { gap: var(--space-2); }
  .counter { padding: var(--space-3) var(--space-4); gap: var(--space-2); font-size: var(--text-sm); }

  .deck { padding: var(--space-4) var(--space-4) calc(var(--space-4) + var(--sab)); gap: var(--space-4); }
  .card, .card-ghost { width: 54px; height: 58px; gap: var(--space-1); }
  .card-glyph { width: 32px; height: 26px; }
  .card-name { font-size: var(--text-2xs); letter-spacing: 0.06em; }

  /* the word is a courtesy; the tick is the button */
  .check-btn { padding: var(--space-5); }
  .check-btn span { display: none; }
  .check-btn svg { width: var(--icon); height: var(--icon); }

  .veil { padding: var(--space-5); }
  .sheet { padding: var(--space-7); max-height: 88vh; }
}

/* ── landscape phone ───────────────────────────────────────────────────────
   Wide but short. Vertical pixels are scarce and horizontal ones are spare, so
   the deck leaves the bottom and becomes a strip down the RIGHT — the tool rail
   in Euclidea. The undo/redo/menu actions sit above it in the top-right corner;
   the goal card takes the free top-left, and the golden target the bottom-left.

   The right strip is 78px wide; Board.fit() insets by the same. The deck scrolls
   vertically.                                                                  */

@media (max-height: 700px) and (orientation: landscape) {
  .rotate-hint { display: none; }   /* already sideways */

  .topbar { padding: var(--space-2) var(--space-5); gap: var(--space-4); }
  .topbar .heading .name { font-size: var(--text-sm); }
  .counter { padding: var(--space-2) var(--space-3); }

  .goal-card { top: calc(var(--space-3) + var(--sat)); left: calc(var(--space-3) + var(--sal)); }
  .g-count { top: calc(var(--space-3) + var(--sat)); left: 50%; transform: translateX(-50%); }


  /* the golden target and publish stay on the free left, above the grab hand's slot */
  .target-btn, .publish-btn { right: auto; left: var(--space-4); bottom: calc(var(--space-4) + var(--sab)); }
  .grab-btn { left: var(--space-4); bottom: calc(var(--space-4) + var(--sab) + 52px); }

  .deck {
    position: absolute; right: 0; bottom: 0;
    top: 0;                          /* the rail runs the full edge — no orphan gap */
    width: 78px;
    flex-direction: column; align-items: stretch; gap: var(--space-3);
    padding: calc(var(--space-4) + var(--sat)) var(--space-3) calc(var(--space-4) + var(--sab));
    border-top: 0; border-left: var(--hairline) solid var(--line);
    z-index: var(--z-chrome);
  }
  .deck-scroll {
    flex: 1; flex-direction: column;
    overflow-x: hidden; overflow-y: auto;
    gap: var(--space-3); padding-bottom: 0;
  }
  /* deck cards fill the strip, but the ghost is fixed on the body — 100% there
     would be the whole screen, so it keeps a card's width */
  .card, .card-add { width: 100%; height: 48px; gap: 0; flex-direction: row; justify-content: center; }
  .card-add { margin-top: auto; flex: none; }   /* floats at the rail's foot, apart from the gates */
  .card-ghost { width: 58px; height: 48px; gap: 0; }
  .card-glyph { width: 30px; height: 22px; }
  .card-name { font-size: 7px; }

  /* The chip editor's Save leaves the right deck strip and floats at the
     bottom-left, clear of the tools. Fixed (viewport), not absolute — the deck
     is a positioned ancestor. */
  .check-btn {
    position: fixed; z-index: var(--z-chrome);
    left: var(--space-4);
    bottom: calc(var(--space-4) + var(--sab));
    width: auto; padding: var(--space-5) var(--space-6); justify-content: center;
  }

  /* Short screens leave little vertical room for a sheet, so most needed a
     scroll. Trim the padding, heading, and inter-element gaps and let the sheet
     use nearly the full height — the common popups (success, problem, solution,
     settings) then fit without scrolling. */
  .veil { padding: var(--space-4); }
  .sheet { padding: var(--space-5) var(--space-7); max-height: 94vh; }
  .sheet .eyebrow { margin-bottom: var(--space-2); }
  .sheet h2 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
  .sheet p + p { margin-top: var(--space-3); }
  .sheet .btn-row { margin-top: var(--space-5); }
  .sheet .close-row { margin-top: var(--space-5); }
}

/* ── custom chips in the deck ───────────────────────────────────────────── */

.chip-card .card-name { font-family: var(--font-mono); letter-spacing: 0.04em; color: var(--dim); }
.chip-card.warned { border-color: var(--danger-line); }
.chip-card .warn-flag { position: absolute; top: var(--space-2); right: var(--space-2); color: var(--danger-text); }
.chip-card .warn-flag svg { width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }

/* the maker's plus — anchored in the footer itself (right end of the bottom
   bar; pinned to the rail's bottom in landscape), same size as the cards */
.card-add {
  flex: none; width: 68px; height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  border: var(--hairline) dashed var(--line-2); border-radius: var(--radius);
  color: var(--mute); transition: var(--t);
}
.card-add:hover { border-color: var(--accent-line); color: var(--accent); }
.card-add svg { width: var(--icon-lg); height: var(--icon-lg); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.card-add .card-name { font-size: 8.5px; letter-spacing: 0.1em; }

/* ── chip editor: the +/× that float over the terminals ─────────────────── */

.pin-overlay { position: absolute; inset: 0; z-index: var(--z-panel); pointer-events: none; }
.pin-btn {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; pointer-events: auto;
  display: grid; place-items: center;
  border: var(--hairline) solid var(--line-2); border-radius: var(--radius-full);
  background: var(--surface);
}
.pin-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pin-btn.add { color: var(--accent); border-color: var(--accent-line); }
.pin-btn.del { color: var(--dim); }
.pin-btn.del:hover { color: var(--danger-text); border-color: var(--danger-line); }
.pin-btn.add:hover { background: var(--accent-dim); }

/* the chip editor wears the accent on its top edge, to read as a mode apart */
.chip-edit .topbar { border-bottom-color: var(--accent-line); }
.chip-edit .check-btn span { display: inline; }

/* ── deck scroll arrows ─────────────────────────────────────────────────────
   Shown only when the deck overflows (deck-scroll.js toggles .show). Tap to
   nudge, hold to keep scrolling. `.vert` is the landscape side-strip.        */

.deck-arrow {
  display: none; flex: none; align-self: stretch;
  width: var(--control); place-items: center;
  border: var(--hairline) solid var(--line-2); border-radius: var(--radius);
  background: var(--bg); color: var(--dim);
  transition: color var(--t), border-color var(--t);
}
.deck-arrow.show { display: grid; }
.deck-arrow:active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.deck-arrow svg {
  width: var(--icon-sm); height: var(--icon-sm);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.deck-arrow.start svg { transform: rotate(180deg); }   /* ◀ back */
.deck-arrow.end   svg { transform: rotate(0deg); }     /* ▶ forward */
/* the landscape side-strip runs top-to-bottom, so the arrows point up / down */
.deck-arrow.vert { align-self: center; width: 100%; height: var(--control-sm); }
.deck-arrow.vert.start svg { transform: rotate(-90deg); }
.deck-arrow.vert.end   svg { transform: rotate(90deg); }
