/* CircuitCoach: palette and type per spec §5.
   PCB green ground, copper accents, monospace for every readout. */

:root {
  --pcb:        #14332B;
  --pcb-deep:   #0E241E;
  --pcb-raise:  #1B4034;
  --pcb-lift:   #235045;
  --copper:     #C08552;
  --copper-hi:  #D9A06B;
  --silk:       #EDEAE2;
  --solder:     #7C8983;
  --amber:      #E8A33D;
  --brick:      #B8493F;

  --edge:       #2A5648;
  --edge-soft:  #21473C;

  /* dimmed steps off silkscreen white, previously inline literals that had
     drifted apart between sessions */
  --silk-dim:   #C9CFC9;
  --silk-faint: #B4BFB8;
  --log-stamp:  #46564F;
  --log-mute:   #5C6B64;

  --display: "Chakra Petch", "Eurostile", "Bahnschrift", system-ui, sans-serif;
  --body:    "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --topbar-h: 52px;
  --gap: 14px;
}

* { box-sizing: border-box; }

/* display rules on .sp/.block would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--pcb);
  color: var(--silk);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; }

/* ---------- top bar ---------------------------------------------------- */

.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 18px;
  background: var(--pcb-deep);
  border-bottom: 1px solid var(--edge);
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark { width: 19px; height: 19px; fill: none; stroke: var(--copper); stroke-width: 1.6; }
.brand-mark circle { fill: none; }

.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .11em;
  color: var(--silk);
}
.brand-name em { font-style: normal; color: var(--copper); }

.tier-rail { display: flex; align-items: stretch; gap: 0; margin-left: 6px; }

.tier {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  font: inherit;
}
button.tier { cursor: pointer; }
button.tier:hover .tier-name { color: var(--copper-hi); }
button.tier:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.tier-n {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--solder);
}
.tier-name { font-family: var(--display); font-size: 12.5px; letter-spacing: .04em; color: var(--solder); }

.tier.current { border-color: var(--edge); background: var(--pcb-raise); }
.tier.current .tier-n { color: var(--copper); }
.tier.current .tier-name { color: var(--silk); }
.tier.locked { opacity: .38; }

/* ---------- buttons ---------------------------------------------------- */

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .09em;
  border: 1px solid var(--edge);
  background: transparent;
  color: var(--silk);
  border-radius: 3px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { border-color: var(--copper); color: var(--copper-hi); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-ghost { background: var(--pcb-deep); }
#btn-restart { margin-left: auto; }

.btn.small { padding: 7px 10px; font-size: 11px; flex: 1; }
.btn.small em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--solder);
  margin-left: 5px;
}
.btn[aria-pressed="true"] {
  background: var(--copper);
  border-color: var(--copper);
  color: var(--pcb-deep);
}
.btn[aria-pressed="true"] em { color: var(--pcb); }

.btn-power {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--copper);
  border-color: var(--copper);
  color: var(--pcb-deep);
  font-size: 14px;
  letter-spacing: .13em;
  padding: 13px 16px;
}
.btn-power:hover:not(:disabled) { background: var(--copper-hi); border-color: var(--copper-hi); color: var(--pcb-deep); }
.btn-power .btn-key {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  opacity: .6;
}
.btn-power.on { background: var(--amber); border-color: var(--amber); }

.btn-next {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  border-color: var(--amber);
  color: var(--amber);
  padding: 11px 16px;
}
.btn-next:hover { background: var(--amber); color: var(--pcb-deep); border-color: var(--amber); }

/* ---------- workspace layout ------------------------------------------- */

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 340px;
  gap: var(--gap);
  padding: var(--gap);
}

.panel {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.block {
  background: var(--pcb-deep);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  padding: 14px;
}
/* stays reachable when the left column has to scroll. the rule reads the
   boundary as a docked edge rather than content being sliced */
.block-power {
  border: none;
  border-top: 1px solid var(--edge-soft);
  padding: 10px 0 0;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--pcb);
}

/* clearance so the final block can scroll past the pinned controls rather than
   being cut mid row by their background */
.panel-left > .block:has(+ .block-power) { margin-bottom: 84px; }

.block-head { display: flex; align-items: center; justify-content: space-between; }

.block-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--solder);
}
.block-head .block-title { margin-bottom: 0; }

.chip {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--copper);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 2px 7px;
}

.ch-title {
  margin: 12px 0 10px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.15;
}

.dots { display: flex; gap: 6px; margin-bottom: 12px; }
.dot {
  width: 26px; height: 5px;
  padding: 0;
  border: none;
  border-radius: 1px;
  background: var(--pcb-lift);
  cursor: pointer;
}
.dot.cleared { background: var(--solder); }
.dot.active { background: var(--copper); }
.dot:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.ch-brief { margin: 0; color: var(--silk-dim); font-size: 13px; }

.objectives { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; }
.objectives li {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--solder);
}
.obj-box {
  width: 13px; height: 13px;
  flex: 0 0 13px;
  border: 1px solid var(--edge);
  border-radius: 2px;
  display: grid; place-items: center;
  font-size: 9px;
  color: var(--pcb-deep);
}
.objectives li.done { color: var(--silk); }
.objectives li.done .obj-box { background: var(--copper); border-color: var(--copper); }

/* ---------- device spec ------------------------------------------------- */

.spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--edge-soft); }
.spec .sp {
  background: var(--pcb);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.spec span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .13em;
  color: var(--solder);
}
.spec b {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--copper);
  white-space: nowrap;
}
#sp-band-row b, #sp-cond-row b { color: var(--amber); }
/* the three device figures sit one row; a band or condition spans beneath */
#sp-band-row, .spec .sp.span2 { grid-column: 1 / -1; }

/* ---------- parts bin --------------------------------------------------- */

.parts { display: grid; gap: 7px; }

.part {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--pcb);
  border: 1px solid var(--edge-soft);
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s;
}
.part:hover:not(:disabled) { border-color: var(--copper); }
.part:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.part[aria-pressed="true"] { border-color: var(--copper); background: var(--pcb-lift); }
.part.empty { opacity: .4; }
.part:disabled { cursor: not-allowed; }

.part-ico { width: 40px; height: 24px; }
.pi-leg { stroke: var(--copper); stroke-width: 1.8; }
.pi-led { fill: #5E2A28; stroke: #8A3D38; stroke-width: 1.2; }
.pi-bar { stroke: #8A3D38; stroke-width: 1.6; }
.pi-body { fill: #A3906E; }
.pi-wire { fill: none; stroke: var(--amber); stroke-width: 2.4; stroke-linecap: round; }
.pi-boot { fill: var(--amber); }
.part[aria-pressed="true"] .pi-led { fill: var(--amber); stroke: var(--amber); }

.part-name {
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  display: flex;
  flex-direction: column;
}
.part-name em {
  font-style: normal;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--solder);
}
.part-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--copper);
  min-width: 14px;
  text-align: right;
}
.part-key {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--solder);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 1px 5px;
}

/* E12 stock strip: the drawer you pick a value out of */
.rvals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.rval {
  padding: 8px 2px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--silk);
  background: var(--pcb);
  border: 1px solid var(--edge-soft);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, background .12s, color .12s;
}
.rval:hover { border-color: var(--copper); color: var(--copper-hi); }
.rval:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.rval.on {
  background: var(--copper);
  border-color: var(--copper);
  color: var(--pcb-deep);
  font-weight: 600;
}

/* press-and-hold control for the digital input */
.btn-hold {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  font-size: 13px;
  letter-spacing: .1em;
  border-color: var(--solder);
}
.btn-hold .btn-key { font-family: var(--mono); font-size: 10px; opacity: .6; }
.btn-hold.on {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--pcb-deep);
}
.btn-hold.on:hover { background: var(--amber); border-color: var(--amber); color: var(--pcb-deep); }
.hold-note {
  margin: 5px 0 9px;
  text-align: right;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: var(--solder);
}

.pi-cap { fill: #9BA6A0; }

.tool-row { display: flex; gap: 6px; margin-top: 10px; }

/* ---------- stage ------------------------------------------------------- */

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.verdict {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  color: transparent;
}
.verdict.good { color: var(--amber); border-color: rgba(232,163,61,.4); background: rgba(232,163,61,.07); }
.verdict.bad  { color: var(--brick); border-color: rgba(184,73,63,.45); background: rgba(184,73,63,.07); }

/* the frame hugs the board instead of letterboxing it inside a tall box */
.board-wrap {
  width: 100%;
  aspect-ratio: 758 / 576;
  max-height: 100%;
  align-self: center;
  background: var(--pcb-deep);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  padding: 8px;
  display: grid;
}
#board { width: 100%; height: 100%; display: block; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  80% { transform: translateX(-1px); }
}
.board-wrap.shake { animation: shake .34s ease-out; }

.probe {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--pcb-deep);
  border: 1px solid var(--edge-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.probe-label { color: var(--solder); letter-spacing: .16em; font-size: 10px; }
.probe-node { color: var(--copper); min-width: 210px; }
.probe-status { color: var(--solder); }
.probe-status.bad { color: var(--brick); }
.probe-status.good { color: var(--amber); }

/* ---------- breadboard SVG ---------------------------------------------- */

.slab { fill: var(--pcb-raise); stroke: var(--edge); stroke-width: 1; }
.ravine { fill: var(--pcb-deep); }
.ravine-line { stroke: var(--edge); stroke-width: 1; stroke-dasharray: 3 5; }

.hole-pad { fill: #0B201B; stroke: rgba(192,133,82,.30); stroke-width: 1; }
.hole-bore { fill: #061412; }

.rail-stripe { stroke-width: 1.4; }
.rail-stripe.pos { stroke: rgba(192,133,82,.55); }
.rail-stripe.neg { stroke: rgba(124,137,131,.55); }

.silk { font-family: var(--mono); fill: var(--solder); }
.silk.row { font-size: 10px; }
.silk.col { font-size: 9.5px; }
.silk.sign { font-size: 14px; font-weight: 600; }
.silk.sign.pos { fill: var(--copper); }
.silk.sign.neg { fill: var(--solder); }

.psu { fill: var(--pcb-deep); stroke: var(--edge); stroke-width: 1.2; }
.psu-label { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; fill: var(--solder); }
.psu-volts { font-family: var(--mono); font-size: 17px; fill: var(--copper); }
.psu-rule { stroke: var(--edge); stroke-width: 1; }
.psu-term { font-family: var(--mono); font-size: 10px; fill: var(--solder); }
.psu-stub { stroke: var(--solder); stroke-width: 2; }
.psu-post { stroke-width: 2; }
.psu-post.pos { fill: #43301F; stroke: var(--copper); }
.psu-post.neg { fill: #1D2422; stroke: var(--solder); }
.psu-lamp, .psu-lamp.on, 
.hole-hit { fill: transparent; cursor: crosshair; }
.hole-hit.hover, .hole-hit:focus {
  fill: rgba(232,163,61,.16);
  stroke: var(--amber);
  stroke-width: 1.2;
  outline: none;
}
#board:not(.tool-armed) .hole-hit { cursor: default; }

#layer-components { pointer-events: none; }
#board:not(.tool-armed) #layer-components { pointer-events: auto; }
#board:not(.tool-armed) .cmp { cursor: pointer; }

.leg { stroke: var(--copper); stroke-width: 2.2; stroke-linecap: round; }
.leg-anode { stroke-width: 2.9; }

.res-body { fill: #A3906E; stroke: #6E6047; stroke-width: 1; }
.res-band { opacity: .95; }

.led-dome { fill: #6E322F; stroke: #A04C44; stroke-width: 1.4; }
.led-bar { stroke: #3A1E1C; stroke-width: 3; stroke-linecap: round; }
.led-plus {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--copper);
  pointer-events: none;
}
.led-glow { fill: var(--amber); filter: blur(9px); }
.led-core { fill: #FFF3D6; }
.cmp.led.lit .led-dome { fill: #F5C46A; stroke: #FFE0A0; }
.cmp.led.lit .led-bar { stroke: #C9922F; }
.cmp.led.lit .leg { stroke: var(--copper-hi); }

/* drive states: under-driven reads dull, over-driven reads white-hot */
.cmp.led.lit.dim .led-dome { fill: #B9873C; stroke: #D2A55C; }
.cmp.led.lit.dim .led-core { fill: #F5DFAE; }
.cmp.led.lit.hot .led-dome { fill: #FFF3D6; stroke: #FFFFFF; }
.cmp.led.lit.hot .led-core { fill: #FFFFFF; }
.cmp.led.lit.fault .led-dome { stroke: var(--brick); stroke-width: 2.4; }

.cmp.led.cool .led-glow { fill: #BBD6F5; }
.cmp.led.lit.cool .led-dome { fill: #DCEAFB; stroke: #FFFFFF; }
.cmp.led.lit.cool .led-core { fill: #FFFFFF; }
.cmp.led.lit.cool.dim .led-dome { fill: #7E97B4; stroke: #A9BFD6; }
.cmp.led.lit.cool.dim .led-core { fill: #D5E4F5; }

/* momentary button */
.btn-body { fill: #223F36; stroke: var(--solder); stroke-width: 1.3; }
.btn-cap { fill: #9BA6A0; stroke: var(--silk-dim); stroke-width: 1.2; }
.btn-ring { fill: none; stroke: var(--edge); stroke-width: 1.2; }
.cmp.button.pressed .btn-cap { fill: var(--amber); stroke: var(--copper-hi); }
.cmp.button.pressed .btn-body { stroke: var(--copper); }
.cmp.button.fault .btn-body { stroke: var(--brick); stroke-width: 2; }

/* logic block */
#mcu-module, .hole-hit.mcu { display: none; }
.has-logic #mcu-module, .has-logic .hole-hit.mcu { display: inline; }
.mcu { fill: var(--pcb-deep); stroke: var(--edge); stroke-width: 1.2; }
.mcu-post { fill: var(--pcb-lift); stroke: var(--solder); stroke-width: 2; }
.mcu-rule {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  fill: var(--copper);
}

.cmp.damaged .led-dome { fill: #2A1A18; stroke: var(--brick); }
.led-crack { stroke: var(--brick); stroke-width: 1.8; stroke-linecap: round; }

.wire-jacket { fill: none; stroke-width: 3.8; stroke-linecap: round; }
.wire-boot { stroke: rgba(0,0,0,.35); stroke-width: 1; }

.cmp.fault .res-body, .cmp.fault .led-dome { stroke: var(--brick); stroke-width: 2; }
.cmp.fault .wire-jacket { stroke: var(--brick); }
.cmp.fault .leg { stroke: var(--brick); }

.ghost-line { stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 5 4; opacity: .8; }
.ghost-anchor { fill: none; stroke: var(--amber); stroke-width: 1.6; }

/* ---------- terminal panel ---------------------------------------------- */

.term {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #081714;
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  overflow: hidden;
}

.term-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--pcb-deep);
  border-bottom: 1px solid var(--edge-soft);
}
.term-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--silk);
}
.term-state {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  color: var(--solder);
}
.dotlamp { width: 6px; height: 6px; border-radius: 50%; background: var(--solder); opacity: .6; }

.grid-readout {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--edge-soft);
  border-bottom: 1px solid var(--edge-soft);
}
.grid-readout .ro {
  background: #0A1C18;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.grid-readout .ro.wide { grid-column: span 2; }
.grid-readout span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .13em;
  color: var(--solder);
}
.grid-readout b {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--silk);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grid-readout.meas b { color: var(--copper); }

.log {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.log-line { display: flex; gap: 8px; color: var(--silk-faint); }
.log-t { color: var(--log-stamp); flex: 0 0 auto; }
.log-tag { color: var(--solder); flex: 0 0 auto; }
.log-msg { min-width: 0; word-break: break-word; }

.log-line.sys .log-msg { color: var(--silk); }
.log-line.dim .log-msg { color: var(--log-mute); }

/* tutor hints: the one place the log speaks in sentences, not readings */
.log-line.hint .log-tag { color: var(--amber); }
/* stays in the log's monospace voice: this panel is a serial monitor, and the
   spec rules out accent bars, so a hint earns emphasis from colour alone */
.log-line.hint .log-msg { color: var(--silk); }
.log-line.hint.pending .log-msg { color: var(--solder); font-style: italic; }
.term-state.online { color: var(--amber); }
.term-state.online .dotlamp { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.log-line.ok .log-tag, .log-line.ok .log-msg { color: var(--amber); }
.log-line.ok-sub .log-msg { color: #C7A468; }
.log-line.err .log-tag, .log-line.err .log-msg { color: var(--brick); }
.log-line.err-sub .log-msg { color: #C79089; }

.log-rule { height: 1px; background: var(--edge-soft); margin: 8px 0; }

.term-foot {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-top: 1px solid var(--edge-soft);
  background: var(--pcb-deep);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  color: #5C6B64;
}

/* ---------- scrollbars --------------------------------------------------- */

.panel::-webkit-scrollbar, .log::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb, .log::-webkit-scrollbar-thumb {
  background: var(--edge); border-radius: 4px;
}
.panel::-webkit-scrollbar-track, .log::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive --------------------------------------------------- */

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 300px; }
  .tier-rail .tier-name { display: none; }
}

@media (max-width: 1040px) {
  /* drop the fixed-viewport shell so rows size to content and scroll */
  body { display: block; height: auto; min-height: 100%; overflow: auto; }
  .topbar { position: sticky; top: 0; z-index: 5; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }
  .panel { overflow: visible; }
  .stage { grid-template-rows: auto auto auto; }
  .term { min-height: 420px; }
  .block-power { margin-top: 0; }
}

@media (max-width: 620px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .tier-rail { display: none; }
  #btn-restart { font-size: 10px; padding: 7px 9px; }
  .probe { flex-wrap: wrap; }
  .probe-node { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
