/* Layout: workbench — device rack (left) · patch canvas (center) · inspector (right) · packet timeline (bottom) */
:root {
  --bg: #e4e9e9;
  --chrome: #f4f7f7;
  --panel: #fbfcfc;
  --panel-2: #edf2f2;
  --line: #d1dada;
  --line-2: #b9c6c6;
  --fg: #142224;
  --muted: #586a6c;
  --faint: #889999;
  --accent: #0a7a74;
  --accent-2: #07625d;
  --accent-soft: #d2ebe8;
  --on-accent: #ffffff;
  --canvas: #ecf1f0;
  --grid: #c2cecd;
  --ok: #1d9750;
  --warn: #c48100;
  --bad: #d03a3a;
  --cat6: #2d66d2;
  --cross: #cf5038;
  --mmf: #0d9fb4;
  --smf: #c79600;
  --coax: #3d3d3d;
  --rj11: #8f6f48;
  --wifi: #7360e6;
  --cell: #b04ad0;
  --p-http: #2f6fd8;
  --note-bg: #fbf1c7;
  --note-line: #e2cd7d;
  --p-ctl: #8a7f6b;
  --p-vpn: #2a9d8f;
  --p-arp: #d89800;
  --p-icmp: #c23c8a;
  --p-dns: #0c8865;
  --p-dhcp: #df641a;
  --p-ip: #586a6c;
  --tile-end: #e2e7f0;
  --tile-net: #d3e9e6;
  --tile-wan: #f1e5cb;
  --tile-line: #b5c4c3;
  --glyph: #19312f;
  --term-bg: #0e191a;
  --term-fg: #cde7e1;
  --term-dim: #6f8c88;
  --shadow: 0 1px 2px rgba(16, 40, 40, 0.08), 0 6px 20px rgba(16, 40, 40, 0.08);
  --f-disp: 'Barlow Semi Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;
  --f-body: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Consolas, 'Courier New', monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1213;
    --chrome: #101a1b;
    --panel: #131d1f;
    --panel-2: #192527;
    --line: #243335;
    --line-2: #324548;
    --fg: #e1ebe9;
    --muted: #92a6a5;
    --faint: #637778;
    --accent: #3cc2b6;
    --accent-2: #62d6cb;
    --accent-soft: #153936;
    --on-accent: #04201e;
    --canvas: #0e1718;
    --grid: #213133;
    --ok: #3bcd7a;
    --warn: #efb33a;
    --bad: #ff6a6a;
    --cat6: #5c8ef2;
    --cross: #f07a61;
    --mmf: #3ed1e2;
    --smf: #f0c432;
    --coax: #b8b2a6;
    --rj11: #c9a479;
    --wifi: #a396ff;
    --cell: #d98cf0;
    --p-http: #6aa0ff;
    --note-bg: #3a3420;
    --note-line: #6b5d2c;
    --p-ctl: #b3a78f;
    --p-vpn: #4fd1c1;
    --p-arp: #f1c02d;
    --p-icmp: #ee6eb5;
    --p-dns: #3ed2a2;
    --p-dhcp: #ff904f;
    --p-ip: #92a6a5;
    --tile-end: #202a3a;
    --tile-net: #173838;
    --tile-wan: #392f1f;
    --tile-line: #34484a;
    --glyph: #d8ebe8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1213;
  --chrome: #101a1b;
  --panel: #131d1f;
  --panel-2: #192527;
  --line: #243335;
  --line-2: #324548;
  --fg: #e1ebe9;
  --muted: #92a6a5;
  --faint: #637778;
  --accent: #3cc2b6;
  --accent-2: #62d6cb;
  --accent-soft: #153936;
  --on-accent: #04201e;
  --canvas: #0e1718;
  --grid: #213133;
  --ok: #3bcd7a;
  --warn: #efb33a;
  --bad: #ff6a6a;
  --cat6: #5c8ef2;
  --cross: #f07a61;
  --mmf: #3ed1e2;
  --smf: #f0c432;
  --coax: #b8b2a6;
  --rj11: #c9a479;
  --wifi: #a396ff;
  --cell: #d98cf0;
  --p-http: #6aa0ff;
  --note-bg: #3a3420;
  --note-line: #6b5d2c;
  --p-ctl: #b3a78f;
  --p-vpn: #4fd1c1;
  --p-arp: #f1c02d;
  --p-icmp: #ee6eb5;
  --p-dns: #3ed2a2;
  --p-dhcp: #ff904f;
  --p-ip: #92a6a5;
  --tile-end: #202a3a;
  --tile-net: #173838;
  --tile-wan: #392f1f;
  --tile-line: #34484a;
  --glyph: #d8ebe8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 var(--f-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.mono {
  font-family: var(--f-mono);
  font-size: 12.5px;
}
.muted {
  color: var(--muted);
}

#app {
  display: grid;
  height: 100%;
  grid-template-columns: 236px minmax(0, 1fr) min(var(--insp-w, 392px), 64vw);
  grid-template-rows: 52px minmax(0, 1fr) min(var(--sim-h, 236px), 70vh);
  grid-template-areas: 'top top top' 'pal stage insp' 'pal sim insp';
}

/* ---------- top bar ---------- */
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
}
.brand svg {
  flex: none;
}
.brand b {
  font: 700 20px/1 var(--f-disp);
  letter-spacing: 0.01em;
}
.brand span {
  font: 500 12.5px/1.2 var(--f-disp);
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font: 600 13.5px/1 var(--f-disp);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--line-2);
  background: var(--panel-2);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn.primary:hover {
  background: var(--accent-2);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--panel-2);
}
.btn.sm {
  height: 27px;
  padding: 0 9px;
  font-size: 12.5px;
  border-radius: 7px;
}
.btn.danger {
  color: var(--bad);
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.insp textarea.notetext {
  height: 150px;
  padding: 10px;
  font: 400 13.5px/1.45 var(--f-body);
  resize: vertical;
}
.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.topmenu {
  position: relative;
}
.pop {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 50;
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

/* ---------- palette ---------- */
.pal {
  grid-area: pal;
  background: var(--chrome);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px 12px 20px;
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 0;
}
.pal h2 {
  margin: 0 0 8px 4px;
  font: 600 11.5px/1 var(--f-disp);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.pal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.pal-item {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 4px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  touch-action: none;
  user-select: none;
}
.pal-item:hover {
  background: var(--panel);
  border-color: var(--line);
}
.pal-item .pi {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  border: 1px solid var(--tile-line);
}
.pal-item .pi svg {
  width: 30px;
  height: 30px;
}
.pal-item span {
  font: 500 12.5px/1.15 var(--f-disp);
  text-align: center;
  color: var(--fg);
}
.t-end {
  fill: var(--tile-end);
  background: var(--tile-end);
}
.t-net {
  fill: var(--tile-net);
  background: var(--tile-net);
}
.t-wan {
  fill: var(--tile-wan);
  background: var(--tile-wan);
}
.glyph,
.pi svg,
.gl {
  fill: none;
  stroke: var(--glyph);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cables {
  display: grid;
  gap: 3px;
}
.pal-item .pi {
  position: relative;
}
.vdot {
  position: absolute;
  right: -3px;
  top: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--chrome);
}
.pal-note {
  margin: 6px 4px 0;
  font-size: 11.5px;
  color: var(--muted);
}
#palVendor {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 8px;
  font: 500 13px/1 var(--f-body);
}
.vendorbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #fff;
  font: 600 13px/1.2 var(--f-disp);
  letter-spacing: 0.02em;
}
.vendorbar small {
  display: block;
  font: 500 11.5px/1.3 var(--f-body);
  opacity: 0.9;
  letter-spacing: 0;
}
.st-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font: 600 10.5px/1.4 var(--f-disp);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.st-fwd {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}
.st-blk {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: var(--warn);
}
.st-bad {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
}
.cable-btn {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}
.cable-btn:hover {
  background: var(--panel);
  border-color: var(--line);
}
.cable-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cable-btn svg {
  width: 34px;
  height: 12px;
  overflow: visible;
}
.cable-btn b {
  display: block;
  font: 600 13px/1.15 var(--f-disp);
}
.cable-btn small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.25;
}

.hovercard {
  position: fixed;
  z-index: 80;
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  pointer-events: none;
}
.hovercard h4 {
  margin: 0;
  font: 700 17px/1.2 var(--f-disp);
}
.hovercard .layer {
  font: 600 11px/1 var(--f-disp);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 4px 0 8px;
}
.hovercard p {
  margin: 0 0 8px;
  font-size: 13px;
}
.hovercard ul {
  margin: 0;
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--muted);
  display: grid;
  gap: 3px;
}

/* ---------- stage ---------- */
.stage-wrap {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background: var(--canvas);
  min-width: 0;
  min-height: 0;
}
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}
#stage.tool-connect,
#stage.tool-pdu {
  cursor: crosshair;
}
#stage.tool-delete {
  cursor: not-allowed;
}
#stage.panning {
  cursor: grabbing;
}
.gridbg {
  fill: url(#dots);
}
#dots circle {
  fill: var(--grid);
}

.dev {
  cursor: grab;
}
.dev .tile {
  stroke: var(--tile-line);
  stroke-width: 1;
  transition: stroke 0.15s;
}
.dev .halo {
  fill: none;
  stroke: none;
}
.dev:hover .tile {
  stroke: var(--accent);
}
.dev.sel .halo {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  fill: var(--accent-soft);
  fill-opacity: 0.55;
}
.dev.src .halo {
  stroke: var(--p-icmp);
  stroke-width: 2.5;
  fill: none;
}
.dev.hl .halo {
  stroke: var(--warn);
  stroke-width: 2.5;
  fill: none;
}
.dname {
  font: 600 13.5px/1 var(--f-disp);
  fill: var(--fg);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--canvas);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.dip {
  font: 500 10.5px/1 var(--f-mono);
  fill: var(--muted);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--canvas);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.badge circle {
  stroke: var(--canvas);
  stroke-width: 2;
}
.badge.bad circle {
  fill: var(--bad);
}
.badge.warn circle {
  fill: var(--warn);
}
.badge text {
  font: 700 11px/1 var(--f-body);
  fill: #fff;
  text-anchor: middle;
}

.link .hit {
  stroke: transparent;
  stroke-width: 14;
  cursor: pointer;
}
.link .wire {
  fill: none;
  stroke-linecap: round;
}
.link.down .wire {
  opacity: 0.45;
}
.link.sel .wire {
  filter: drop-shadow(0 0 3px var(--accent));
}
.link .selline {
  stroke: var(--accent);
  stroke-width: 9;
  opacity: 0.18;
  stroke-linecap: round;
}
.link .glow {
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-dasharray: 2 18;
  opacity: 0.75;
  animation: flow 1.4s linear infinite;
  pointer-events: none;
}
@keyframes flow {
  to {
    stroke-dashoffset: -40;
  }
}
.led {
  stroke: var(--canvas);
  stroke-width: 1.5;
}
.led.up {
  fill: var(--ok);
}
.led.dn {
  fill: var(--bad);
}
.led.blk {
  fill: var(--warn);
}
.note {
  cursor: grab;
}
.note rect {
  fill: var(--note-bg);
  stroke: var(--note-line);
  stroke-width: 1;
}
.note.sel rect {
  stroke: var(--accent);
  stroke-width: 2;
}
.note text {
  font: 500 13px/1 var(--f-body);
  fill: var(--fg);
}
.browser {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
}
.bbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.bbar input {
  flex: 1;
}
.bmarks {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.bmarks button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 500 12px/1 var(--f-body);
  padding: 4px 6px;
  border-radius: 6px;
}
.bmarks button:hover {
  background: var(--accent-soft);
}
.bview {
  min-height: 190px;
  padding: 22px 20px;
  background: var(--panel);
}
.bview h2 {
  margin: 0 0 8px;
  font: 700 24px/1.15 var(--f-disp);
  text-wrap: balance;
}
.bview p {
  margin: 0 0 10px;
  max-width: 60ch;
}
.bview .foot {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 16px;
}
.bview.err h2 {
  color: var(--bad);
}
.bview code {
  font: 500 12px/1 var(--f-mono);
  color: var(--muted);
}
.blog {
  margin: 0;
  padding: 8px 12px;
  background: var(--term-bg);
  color: var(--term-fg);
  font: 400 11.5px/1.5 var(--f-mono);
  white-space: pre-wrap;
  max-height: 130px;
  overflow: auto;
}
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes sp {
  to {
    transform: rotate(360deg);
  }
}
.subrow {
  display: grid;
  grid-template-columns: auto 64px 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  font: 500 12px/1 var(--f-mono);
}
.subrow input {
  height: 27px !important;
}
.ace code {
  font: 500 11.5px/1.3 var(--f-mono);
  color: var(--accent);
}
.calc-out {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  font-size: 13px;
}
.calc-out dt {
  color: var(--muted);
}
.calc-out dd {
  margin: 0;
  font: 500 12.5px/1.3 var(--f-mono);
}
.bin {
  font: 500 11.5px/1.7 var(--f-mono);
  overflow-x: auto;
  white-space: nowrap;
  background: var(--panel-2);
  border-radius: 9px;
  padding: 8px 10px;
}
.bin .nb {
  color: var(--accent);
  font-weight: 700;
}
.bin .hb {
  color: var(--muted);
}
.quiz-q {
  font: 600 17px/1.35 var(--f-disp);
}
.streak {
  font: 700 13px/1 var(--f-disp);
  letter-spacing: 0.06em;
  color: var(--accent);
}
.fb-ok {
  color: var(--ok);
  font-weight: 600;
}
.fb-bad {
  color: var(--bad);
  font-weight: 600;
}
details.spoil summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12.5px;
  margin-top: 3px;
}
details.spoil p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.cat-h {
  margin: 6px 0 0;
  font: 700 15px/1.2 var(--f-disp);
}
.plabel {
  font: 500 9.5px/1 var(--f-mono);
  fill: var(--muted);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--canvas);
  stroke-width: 3px;
  pointer-events: none;
}
.rubber {
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
  fill: none;
  pointer-events: none;
}

.pkt {
  cursor: pointer;
}
.pkt rect {
  stroke: var(--canvas);
  stroke-width: 1.5;
}
.pkt path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1.4;
}
.fx-drop path {
  stroke: var(--bad);
  stroke-width: 3.5;
  stroke-linecap: round;
  fill: none;
}
.fx-ok circle {
  fill: none;
  stroke: var(--ok);
  stroke-width: 3;
}

.toolbar {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.tb {
  width: 36px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.tb:hover {
  background: var(--panel-2);
  color: var(--fg);
}
.tb.on {
  background: var(--accent);
  color: var(--on-accent);
}
.tb svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tbsep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.cablepill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  font: 600 12px/1 var(--f-disp);
  margin: 0 4px 0 2px;
  border: 0;
}
.cablepill i {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  display: block;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 5;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--fg);
  color: var(--bg);
  font: 500 13px/1.35 var(--f-body);
  box-shadow: var(--shadow);
  text-align: center;
}
.portmenu {
  position: absolute;
  z-index: 30;
  min-width: 230px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.portmenu h5 {
  margin: 4px 8px 6px;
  font: 600 12px/1.2 var(--f-disp);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.portmenu button {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}
.portmenu button:hover:not(:disabled) {
  background: var(--accent-soft);
}
.portmenu button:disabled {
  opacity: 0.45;
  cursor: default;
}
.portmenu b {
  font: 600 13px/1 var(--f-mono);
}
.portmenu small {
  color: var(--muted);
  font-size: 11.5px;
}
.portmenu i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}
.zoomrow {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.toasts {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 6px;
  z-index: 40;
  max-width: min(380px, calc(100% - 24px));
}
.toast {
  padding: 9px 12px 9px 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: tin 0.2s ease-out;
}
.toast.bad {
  border-left-color: var(--bad);
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.warn {
  border-left-color: var(--warn);
}
@keyframes tin {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}

/* ---------- simulation panel ---------- */
.sim {
  grid-area: sim;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
}
.simhead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.seg button {
  border: 0;
  background: transparent;
  padding: 0 12px;
  height: 26px;
  border-radius: 6px;
  font: 600 13px/1 var(--f-disp);
  letter-spacing: 0.02em;
  color: var(--muted);
}
.seg button.on {
  background: var(--panel);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.seg button.on.simon {
  background: var(--accent);
  color: var(--on-accent);
}
.clock {
  font: 500 12px/1 var(--f-mono);
  color: var(--muted);
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.speed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 12px/1 var(--f-disp);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.speed input {
  width: 86px;
  accent-color: var(--accent);
}
.filters {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font: 600 11.5px/1 var(--f-disp);
  letter-spacing: 0.05em;
}
.chip i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: block;
}
.chip.off {
  opacity: 0.4;
}
.simbody {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  min-height: 0;
}
.evlist {
  overflow-y: auto;
  min-height: 0;
  border-right: 1px solid var(--line);
  font-size: 12.5px;
}
.evrow {
  display: grid;
  grid-template-columns: 44px 92px 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.evrow:hover {
  background: var(--panel-2);
}
.evrow.sel {
  background: var(--accent-soft);
}
.evrow .t {
  font: 500 11px/1 var(--f-mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.evrow .d {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.evrow .x {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.evrow.drop .x {
  color: var(--bad);
}
.evrow.ok .x {
  color: var(--ok);
}
.ptag {
  display: inline-block;
  font: 700 10px/1 var(--f-disp);
  letter-spacing: 0.06em;
  padding: 3px 5px;
  border-radius: 4px;
  color: #fff;
  text-align: center;
}
.evempty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
}
.evdetail {
  overflow-y: auto;
  padding: 12px 16px;
  min-height: 0;
  font-size: 13px;
}
.evdetail h2 {
  margin: 0 0 6px;
  font: 700 15px/1.25 var(--f-disp);
}
.evdetail p {
  margin: 0 0 10px;
}
.osi {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.osi td {
  padding: 5px 8px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
.osi td:first-child {
  width: 96px;
  font: 600 11px/1.3 var(--f-disp);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.osi td:last-child {
  font-family: var(--f-mono);
  font-size: 11.5px;
  word-break: break-word;
}

/* ---------- inspector ---------- */
.insp {
  grid-area: insp;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
}
.insp-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
}
.insp-head .seg {
  width: 100%;
}
.insp-head .seg button {
  flex: 1;
}
.insp-body {
  overflow-y: auto;
  min-height: 0;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 16px;
}
.dhead {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.dhead .pi {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  border: 1px solid var(--tile-line);
}
.dhead .pi svg {
  width: 36px;
  height: 36px;
}
.dhead input {
  width: 100%;
  font: 700 20px/1.2 var(--f-disp);
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: -6px;
}
.dhead input:hover,
.dhead input:focus {
  border-color: var(--line);
  background: var(--panel-2);
}
.dhead small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  padding-left: 1px;
}
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: none;
  min-height: 34px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 8px 10px 9px;
  font: 600 13.5px/1 var(--f-disp);
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button.on {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.sec {
  display: grid;
  gap: 10px;
}
.sec > h3 {
  margin: 0;
  font: 600 12px/1 var(--f-disp);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec > h3 .btn {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0.02em;
}
.sec > p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.fgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.fld {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.fld > span {
  font: 600 11.5px/1 var(--f-disp);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.fld small {
  font-size: 11.5px;
  color: var(--muted);
}
.insp input:not([type]),
.insp input[type='text'],
.insp select,
.insp textarea,
.modal textarea {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font: 500 13px/1 var(--f-mono);
}
.insp select {
  font-family: var(--f-body);
  font-size: 13px;
  padding-right: 4px;
}
.insp input:focus,
.insp select:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--panel);
}
.insp input:disabled {
  opacity: 0.55;
}
.insp input.bad {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, var(--panel));
}
.tgl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.tgl input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
}
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel);
  display: grid;
  gap: 10px;
}
.prow {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  gap: 7px;
}
.prow-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.prow-top b {
  font: 600 13px/1 var(--f-mono);
}
.prow-top .peer {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.prow-top select {
  width: auto;
  height: 27px;
}
.prow-top input.vl {
  width: 64px;
  height: 27px;
}
.prow .fgrid input {
  height: 28px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.dot.up {
  background: var(--ok);
}
.dot.dn {
  background: var(--bad);
}
.dot.off {
  background: var(--line-2);
}
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.t th {
  text-align: left;
  font: 600 11px/1 var(--f-disp);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 8px 6px;
  background: var(--panel-2);
  white-space: nowrap;
}
table.t td {
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.t td.wrap {
  white-space: normal;
  font-family: var(--f-body);
  font-size: 12.5px;
}
table.t input {
  height: 27px !important;
  font-size: 12px !important;
  padding: 0 6px !important;
}
.empty {
  padding: 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-family: var(--f-body);
}
.diag {
  display: grid;
  gap: 6px;
}
.diag div {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--panel-2);
}
.diag div::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-1px);
}
.diag .bad::before {
  background: var(--bad);
}
.diag .warn::before {
  background: var(--warn);
}
.diag .ok::before {
  background: var(--ok);
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  font-size: 13px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.learn h3 {
  margin: 0;
  font: 700 22px/1.15 var(--f-disp);
  text-wrap: balance;
}
.learn .layer {
  font: 600 11.5px/1 var(--f-disp);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.learn p {
  margin: 0;
}
.learn ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.tip {
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  background: var(--panel-2);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row > input {
  flex: 1;
}

.term {
  background: var(--term-bg);
  color: var(--term-fg);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: min(56vh, 520px);
  min-height: 280px;
  border: 1px solid var(--line);
}
.term-scroll {
  overflow: auto;
  padding: 12px 12px 4px;
}
.term-out {
  margin: 0;
  font: 400 12px/1.5 var(--f-mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.term-in {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 12px;
  font: 500 12px/1 var(--f-mono);
}
.term-in .prompt {
  color: var(--term-fg);
  opacity: 0.8;
  white-space: nowrap;
}
.term-in input {
  flex: 1;
  min-width: 0;
  height: 24px !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--term-fg);
  font: 400 12px/1 var(--f-mono) !important;
  padding: 0 !important;
  outline: none;
  caret-color: #6ff0de;
}
.qcmds {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qcmds button {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font: 500 11.5px/1 var(--f-mono);
}
.qcmds button:hover {
  border-color: var(--accent);
}

.welcome h2 {
  margin: 0;
  font: 700 26px/1.1 var(--f-disp);
  text-wrap: balance;
}
.welcome p {
  margin: 0;
}
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  counter-reset: s;
}
.steps li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  font-size: 13.5px;
}
.steps li::before {
  content: counter(s);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 13px/1 var(--f-disp);
}
.try {
  display: grid;
  gap: 6px;
}
.try button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}
.try button:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}
.try code {
  font: 500 12px/1.3 var(--f-mono);
  color: var(--accent);
}
.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
}
.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend i {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  flex: none;
}
.legend .pk {
  width: 14px;
  height: 10px;
  border-radius: 2px;
}
.kbd {
  font: 500 11px/1 var(--f-mono);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}

.lesson {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}
.lesson.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.lesson h4 {
  margin: 0;
  font: 700 17px/1.2 var(--f-disp);
}
.lesson .meta {
  font: 600 11px/1 var(--f-disp);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lesson p {
  margin: 0;
  font-size: 13px;
}
.tasks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.tasks li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  font-size: 13.5px;
}
.tasks .box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-2);
  display: grid;
  place-items: center;
}
.tasks li.done .box {
  background: var(--ok);
  border-color: var(--ok);
}
.tasks li.done .box svg {
  stroke: #fff;
}
.tasks li.done > div > span {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--line-2);
}
.tasks small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.tasks .box svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: transparent;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.confirm {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
}
.gloss details {
  border-bottom: 1px solid var(--line);
  padding: 10px 2px;
}
.gloss summary {
  cursor: pointer;
  font: 600 15px/1.3 var(--f-disp);
  list-style-position: outside;
}
.gloss details p {
  margin: 8px 0 2px;
  font-size: 13.5px;
  color: var(--fg);
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 15, 0.45);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 12px;
}
.modal h3 {
  margin: 0;
  font: 700 22px/1.2 var(--f-disp);
}
.modal textarea {
  height: 260px;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
}

@media (prefers-reduced-motion: reduce) {
  .link .glow {
    animation: none;
  }
  .toast {
    animation: none;
  }
}

/* ---------- narrow screens ---------- */
@media (max-width: 1180px) {
  #app {
    grid-template-columns: 200px minmax(0, 1fr) min(var(--insp-w, 340px), 64vw);
  }
}
/* when the inspector is dragged wide, the timeline gets narrow: stack the event list over the detail pane */
.sim {
  container-type: inline-size;
}
@container (max-width: 640px) {
  .simbody {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr);
  }
  .evlist {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
/* drag handles: inspector width and timeline height */
.insp,
.sim {
  position: relative;
}
.split {
  position: absolute;
  z-index: 20;
  touch-action: none;
}
.split::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}
.split:hover::after,
.split.drag::after {
  opacity: 0.4;
}
.split-v {
  left: -3px;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
}
.split-h {
  top: -3px;
  left: 0;
  right: 0;
  height: 7px;
  cursor: row-resize;
}
@media (max-width: 900px) {
  body {
    overflow: auto;
  }
  #app {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 62vh 360px auto;
    grid-template-areas: 'top' 'pal' 'stage' 'sim' 'insp';
  }
  .split {
    display: none;
  }
  .pal {
    align-items: flex-start;
  }
  #palVendor {
    width: 170px;
  }
  .top {
    padding-block: 8px;
    flex-wrap: wrap;
  }
  .brand span {
    display: none;
  }
  .pal {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 16px;
    gap: 14px;
  }
  .pal-sec {
    flex: none;
  }
  .pal-grid {
    display: flex;
  }
  .pal-item {
    width: 72px;
  }
  .cables {
    display: flex;
  }
  .cable-btn {
    width: 150px;
  }
  .insp {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .simbody {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .evlist {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .filters {
    margin-left: 0;
  }
  .zoomrow {
    top: auto;
    bottom: 64px;
  }
}
