* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.4 var(--font-ui);
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- menu bar ---------- */
.menubar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 28px;
  padding: 0 10px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 11px; }
.brand img { width: 14px; height: 14px; }

.menubar nav { display: flex; gap: 2px; }
.menubar nav button {
  background: none; border: none; font: inherit; color: var(--text);
  padding: 3px 7px; border-radius: var(--r-s); cursor: pointer;
}
.menubar nav button:hover { background: var(--titlebar); }

/* ---------- toolbars ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
}

.toolbar.primary { height: 38px; }
.toolbar.secondary { height: 34px; }

.toolbar button {
  display: grid; place-items: center;
  width: 26px; height: 26px; padding: 0;
  background: none; border: 1px solid transparent; border-radius: var(--r-m);
  cursor: pointer;
}
.toolbar button:hover { background: var(--titlebar); border-color: var(--line-soft); }
.toolbar img, .toolbar svg { width: 18px; height: 18px; object-fit: contain; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line-soft); margin: 0 4px; }

/* ---------- main split ---------- */
.main {
  display: grid;
  grid-template-columns: 1fr 330px;
  min-height: 0;
  flex: 1;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 4px 6px 0;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
}

.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  font: inherit; font-size: 11px;
  background: var(--bg); border: 1px solid var(--line-soft); border-bottom: none;
  border-radius: var(--r-m) 4px 0 0; cursor: pointer; color: var(--text);
}
.tab.active { background: var(--panel); font-weight: 600; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }

.canvas-wrap { flex: 1; min-height: 0; background: var(--panel); position: relative; }
.canvas-wrap.drop-target { outline: 2px dashed var(--accent); outline-offset: -5px; }
.dev.dragging { opacity: 0.75; }
.dev-tile.dragging { opacity: 0.45; }
#topology { width: 100%; height: 100%; display: block; }
.empty-state { fill: var(--muted); font-size: 14px; }

.link { stroke: var(--ink-2); stroke-width: 1.6; }
.link.selected { stroke: var(--accent); stroke-width: 2.6; }
/* A console cable is out of band: dashed and cool-coloured, like PT's. */
.link.console { stroke: var(--accent-light); stroke-width: 1.6; stroke-dasharray: 7 5; }
.link-led { stroke: var(--white); stroke-width: 1.5; }
.link-led[data-state="green"] { fill: var(--ok-bright); }
.link-led[data-state="amber"] { fill: var(--warn); }
.link-led[data-state="red"] { fill: var(--danger-hot); }
.dev.cable-src rect.sel { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 1.6; }
.canvas-wrap.cable-mode { cursor: crosshair; }
.cable-tool.active, .devices .dev-tile.cable-tool.active,
.devices .dev-tile.note-tool.active {
  border-color: var(--brand-strong);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.cable-chip {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  padding: 5px 12px; border: 1px solid var(--brand-strong); border-radius: var(--r-xl);
  background: var(--brand-soft); color: var(--ink-block);
  font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 5;
}
.link-toast {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  max-width: min(520px, 90%); padding: 7px 14px; border: 1px solid var(--danger-line);
  border-radius: var(--r-l); background: var(--danger-bg); color: var(--danger-ink);
  font-size: 12.5px; cursor: pointer; z-index: 6; box-shadow: 0 2px 8px var(--scrim);
}
.port {
  fill: var(--text-2);
  font-size: 9.5px;
  font-family: var(--font-mono);
  paint-order: stroke;
  stroke: var(--white);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.dev-name { font-size: 11px; fill: var(--ink); text-anchor: middle; }
.dev-model { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.dev.selected image { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 60%, transparent)); }
.dev.selected rect.sel { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 3; }
.dev.selected .dev-name { fill: var(--accent); font-weight: 600; }
.dev.selected .dev-model { fill: var(--accent); }
.dev image { pointer-events: bounding-box; }

/* ---------- mode bar ---------- */
.modebar {
  display: flex; align-items: center; gap: 14px;
  height: 30px; padding: 0 10px;
  background: var(--chrome);
  border-top: 1px solid var(--line-soft);
}
.clock { font-family: var(--font-mono); font-size: 11px; }
.playgroup { display: flex; gap: 3px; }
.playgroup button {
  display: grid; place-items: center;
  width: 24px; height: 20px; border: 1px solid var(--line-soft);
  background: var(--panel); border-radius: var(--r-s); cursor: pointer; font-size: 10px;
}
.playgroup img, .playbar img { width: 14px; height: 14px; }
.modes { margin-left: auto; display: flex; }
.modes .mode {
  padding: 3px 14px; font: inherit; font-size: 11px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line-soft);
}
.modes .mode:first-child { border-radius: var(--r-m) 0 0 4px; }
.modes .mode:last-child { border-radius: 0 4px 4px 0; }
.modes .mode.active { background: var(--accent); border-color: var(--accent); color: var(--white); }

/* ---------- simulation panel ---------- */
.sim {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  font-size: 11px;
}

.lesson-panel {
  flex: 1 1 auto; min-height: 0; overflow: visible;
  padding: 12px; border-bottom: 1px solid var(--line);
  background: linear-gradient(155deg, var(--chrome) 0%, var(--white) 62%);
}
.lesson-panel[hidden] { display: none; }
.lesson-heading { display: flex; align-items: center; gap: 10px; }
.lesson-heading img { flex: 0 0 auto; object-fit: contain; }
.lesson-heading h2 { margin: 1px 0; font-size: 15px; line-height: 1.2; word-break: normal; }
.lesson-kicker, .gallery-kicker {
  display: block; color: var(--accent); font-size: 9px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.lesson-meta { color: var(--muted); font-size: 10px; }
.lesson-goal { margin: 9px 0; color: var(--text-2); line-height: 1.45; }
.lesson-steps { margin: 0 0 10px; padding-left: 22px; }
.lesson-steps li { padding: 3px 0; }
.lesson-steps label { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
.lesson-steps input { flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--accent); }
.lesson-steps input:checked + span { color: var(--muted); text-decoration: line-through; }
.lesson-step.locked label { cursor: default; }
.lesson-step.locked span { color: var(--muted); }
.lesson-checks { display: flex; flex-direction: column; gap: 4px; }
.lesson-finished img { flex: 0 0 auto; object-fit: contain; }
.lesson-check {
  display: flex; align-items: flex-start; gap: 7px; padding: 6px 7px;
  border: 1px solid var(--line-soft); border-radius: 5px; background: var(--white);
}
.lesson-check-icon { width: 14px; font-size: 15px; font-weight: 700; text-align: center; }
.lesson-check strong, .lesson-check small { display: block; }
.lesson-check small { margin-top: 1px; color: var(--muted); font-size: 9.5px; }
.lesson-check.passed { border-color: var(--ok-line); background: var(--ok-bg); }
.lesson-check.passed .lesson-check-icon { color: var(--ok); }
.lesson-check.failed { border-color: var(--danger-line); background: var(--danger-bg); }
.lesson-check.failed .lesson-check-icon { color: var(--danger); }
.lesson-check.running .lesson-check-icon { color: var(--accent); animation: lesson-pulse .8s infinite alternate; }
.lesson-hint { min-height: 0; margin: 7px 0 0; color: var(--danger-ink); font-size: 10px; }
.lesson-hint:empty { display: none; }
.lesson-actions { display: flex; gap: 6px; margin-top: 10px; }
.lesson-check-button { border-color: var(--accent); background: var(--accent); color: var(--white); font-weight: 600; }
.lesson-check-button:hover { background: var(--accent-strong); }
.lesson-check-button:disabled { cursor: wait; opacity: .65; }
@keyframes lesson-pulse { to { opacity: .35; } }

.sim-head {
  padding: 5px 8px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}

.events-wrap { flex: 1 1 140px; min-height: 90px; overflow: auto; }
.events { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 10px; }
.events th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); text-align: left; font-weight: 600;
  padding: 3px 5px; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.events col.c-vis { width: 9%; }
.events col.c-time { width: 19%; }
.events col.c-last { width: 26%; }
.events col.c-at { width: 26%; }
.events col.c-type { width: 20%; }
.events td { padding: 3px 5px; border-bottom: 1px solid var(--bg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sim-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; border-bottom: 1px solid var(--line-soft);
}

.btn { padding: 3px 8px; font: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.btn:hover { background: var(--surface); }
.check { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.capture { margin-left: auto; color: var(--muted); font-size: 10px; }

.playbar { display: flex; gap: 4px; justify-content: center; padding: 5px 8px; border-bottom: 1px solid var(--line-soft); }
.playbar button {
  width: 30px; height: 22px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; font-size: 10px;
}
.playbar button:hover { background: var(--surface); }

.filter-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px; font-weight: 600; border-bottom: 1px solid var(--line-soft);
}
.mini { font: inherit; font-size: 10px; padding: 1px 6px; margin-left: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }

.filter-section { flex: 0 1 auto; max-height: 45%; min-height: 70px; display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); }
.filter-blurb { margin: 0; padding: 3px 8px 0; font-size: 10px; color: var(--muted); }
.filters { display: block; overflow: auto; flex: 1; padding: 2px 8px 6px; }
.filter-group { border-bottom: 1px solid var(--bg); }
.filter-group summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 2px; cursor: pointer; font-size: 11px; font-weight: 600; list-style: none;
}
.filter-group summary::-webkit-details-marker { display: none; }
.filter-group summary::before { content: "\25B8"; color: var(--muted); margin-right: 4px; }
.filter-group[open] summary::before { content: "\25BE"; }
.filter-group summary span { flex: 1; }
.filter-group summary small { color: var(--muted); font-weight: 400; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 1px 6px; padding: 2px 0 6px 14px; }
.filters label { display: flex; align-items: center; gap: 4px; font-size: 10px; white-space: nowrap; }
.filters input { margin: 0; }

/* ---------- palette ---------- */
.palette {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "groups handle" "devices devices";
  height: 118px; padding: 4px 8px 6px; gap: 4px 8px;
  background: var(--chrome);
  border-top: 1px solid var(--line);
}
.palette > .groups { grid-area: groups; }
.palette > .devices { grid-area: devices; }
.palette > .collapse-handle { grid-area: handle; margin: 0; }

/* Category tabs: one labelled button per category, scrolling sideways when the window is narrow. */
.groups { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.groups::-webkit-scrollbar { display: none; }
.group-tab {
  flex: none; display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  font: inherit; font-size: 11px; color: var(--text); white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 13px; cursor: pointer;
}
.group-tab img { width: 16px; height: 16px; object-fit: contain; }
.group-tab:hover { border-color: var(--line); }
.group-tab.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.group-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.palette button.dev-tile, .palette .dev-tile {
  display: grid; place-items: center; background: var(--panel);
  border: 1px solid var(--line-soft); border-radius: var(--r-m); cursor: pointer; padding: 2px;
}

/* Tiles of the chosen category wrap onto more rows and scroll up and down inside the bar. */
.devices {
  display: flex; gap: 6px; flex-wrap: wrap; align-content: flex-start;
  overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
}
.palette-empty { margin: 8px 4px; color: var(--muted); font-size: 11px; }
.devices .dev-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 54px; padding: 3px 2px; flex: 0 0 auto;
  border: 1px solid transparent; border-radius: var(--r-m); background: none; cursor: pointer;
}
.devices .dev-tile:hover { border-color: var(--line-soft); background: var(--white); }
.devices .dev-tile img { width: 30px; height: 30px; object-fit: contain; }
.devices .dev-tile span { font-size: 9px; color: var(--muted); text-align: center; line-height: 1.1; }
.devices .dev-tile.mesh-tool { border-color: var(--line-soft); }
.devices .dev-tile.mesh-tool:hover { border-color: var(--accent); background: var(--accent-bg); }

.tip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--text); color: var(--white); font-size: 10px;
  padding: 3px 6px; border-radius: var(--r-s);
}

/* ---------- menus ---------- */
.menu { position: relative; }
.menu > button {
  background: none; border: none; font: inherit; color: var(--text);
  padding: 3px 7px; border-radius: var(--r-s); cursor: pointer;
}
.menu > button:hover { background: var(--titlebar); }
.menu.open > button { background: var(--accent-bg); }
.menu .drop {
  display: none; position: absolute; top: 100%; left: 0; min-width: 170px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--black) 13%, transparent); z-index: 60; padding: 3px;
}
.menu.open .drop { display: block; }
.menu .drop button,
.menu .drop a {
  display: block; width: 100%; text-align: left; padding: 4px 10px;
  background: none; border: none; font: inherit; cursor: pointer; color: var(--text);
  text-decoration: none;
}
.menu .drop button:hover:not(:disabled),
.menu .drop a:hover { background: var(--accent-bg); }
.menu .drop button:disabled { color: var(--faint); cursor: default; }
.menu .drop .sep { height: 1px; background: var(--line-soft); margin: 3px 4px; }

/* ---------- context menu: the dropdown look, opened at the pointer ---------- */
.ctx-menu {
  position: fixed; z-index: 70; min-width: 170px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--black) 13%, transparent);
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; padding: 4px 10px;
  background: none; border: none; font: inherit; cursor: pointer; color: var(--text);
}
.ctx-menu button:hover:not(:disabled) { background: var(--accent-bg); }
.ctx-menu button:disabled { color: var(--faint); cursor: default; }
.ctx-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ctx-menu button.has-sub::after { content: "›"; float: right; color: var(--faint); }

/* ---------- status bar ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 22px; padding: 0 10px; font-size: 11px; color: var(--muted);
  background: var(--chrome); border-top: 1px solid var(--line);
}
.statusbar #status-mode { border-left: 1px solid var(--line-soft); padding-left: 10px; }
.statusbar #status-icon { vertical-align: middle; }

/* ---------- misc states ---------- */
.toolbar button:disabled { opacity: 0.35; cursor: default; }
.toolbar button:disabled:hover { background: none; border-color: transparent; }
.events tr.current td { background: var(--warn-bg); }
.packet { fill: var(--packet); stroke: var(--white); stroke-width: 2; filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--black) 40%, transparent)); }
.canvas-wrap.crosshair { cursor: crosshair; }

/* ---------- linked engineer views ---------- */
.capture-dock {
  flex: 0 0 304px; min-height: 0; display: flex; flex-direction: column;
  border-top: 1px solid var(--line); background: var(--white);
}
.capture-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; min-height: 34px; padding: 4px 7px; background: var(--chrome); }
.capture-tabs { display: flex; align-self: stretch; }
.capture-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 0 12px; font: 600 11px inherit; cursor: pointer; }
.capture-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.display-filter-label { display: flex; align-items: center; gap: 5px; flex: 1 1 150px; min-width: 0; color: var(--muted); font-size: 10px; }
#display-filter { width: 100%; min-width: 80px; height: 24px; border: 1px solid var(--line); border-radius: var(--r-s); padding: 3px 7px; font: 11px var(--font-mono); background: var(--ok-bg); color: var(--text); }
#display-filter.invalid { border-color: var(--danger); background: var(--danger-bg); outline-color: var(--danger); }
.filter-error { min-height: 0; padding: 0 8px; color: var(--danger); font-size: 10px; }
.filter-error:not(:empty) { padding-bottom: 3px; }
.capture-count { white-space: nowrap; color: var(--muted); font-size: 10px; }
.save-capture { padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--white); color: var(--text); text-decoration: none; white-space: nowrap; font-size: 10px; }
.save-capture:hover { background: var(--accent-bg); border-color: var(--accent); }
.capture-view { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(110px, 1fr) minmax(130px, 1fr); }
.capture-view[hidden], .flow-view[hidden] { display: none !important; }
.capture-table-wrap { min-width: 0; min-height: 0; overflow: auto; border-bottom: 1px solid var(--line); }
.capture-table { width: 100%; border-collapse: collapse; table-layout: fixed; font: 10px/1.35 var(--font-ui); }
.capture-table th { position: sticky; top: 0; z-index: 1; padding: 4px 5px; background: var(--bg); border-bottom: 1px solid var(--line); text-align: left; }
.capture-table td { padding: 3px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 1px solid color-mix(in srgb, var(--white) 53%, transparent); }
.capture-table th:nth-child(1) { width: 10%; }
.capture-table th:nth-child(2) { width: 13%; }
.capture-table th:nth-child(3), .capture-table th:nth-child(4) { width: 17%; }
.capture-table th:nth-child(5) { width: 13%; }
.capture-table th:nth-child(6) { width: 10%; }
.capture-table tbody tr { cursor: pointer; background: color-mix(in srgb, var(--protocol-color) 11%, white); }
.capture-table tbody tr:hover { background: color-mix(in srgb, var(--protocol-color) 21%, white); }
.capture-table tbody tr.current { outline: 2px solid var(--protocol-color); outline-offset: -2px; font-weight: 600; }
.capture-empty { text-align: center; padding: 18px !important; color: var(--muted); }
.packet-inspector { min-width: 0; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; }
.packet-inspector > section { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.packet-inspector > section + section { border-top: 1px solid var(--line); }
.packet-inspector h3 { margin: 0; padding: 3px 7px; background: var(--surface); color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.packet-details, .packet-bytes { flex: 1; min-height: 0; overflow: auto; padding: 4px 7px; font: 10px/1.4 var(--font-mono); }
.detail-layer { border-bottom: 1px solid var(--bg); }
.detail-layer summary { cursor: pointer; padding: 2px 0; color: var(--accent-ink); font-weight: 700; }
.detail-layer summary:hover { background: var(--warn-bg); }
.detail-fields { padding: 1px 0 3px 15px; }
.detail-fields > div { display: grid; grid-template-columns: minmax(85px, .8fr) 1.4fr; gap: 6px; }
.detail-fields span { color: var(--muted); }
.detail-fields strong { overflow-wrap: anywhere; font-weight: 400; }
.detail-empty { color: var(--muted); }
.byte-row { display: flex; gap: 10px; white-space: nowrap; min-height: 14px; }
.byte-offset { color: var(--muted); }
.byte-hex { display: flex; gap: 4px; min-width: 280px; }
.byte-ascii { color: var(--text-2); }
.byte-selected { background: var(--warn-fill); color: var(--navy); outline: 1px solid var(--warn-line); }
.flow-view { flex: 1; min-height: 0; overflow: auto; background: var(--chrome); }
#flow-graph { display: block; width: 100%; min-width: 640px; height: 100%; }
.flow-lane { stroke: var(--line-win); stroke-width: 1; }
.flow-lane-label { fill: var(--navy); font: 600 11px var(--font-ui); }
.flow-arrow { cursor: pointer; outline: none; }
.flow-arrow line { stroke-width: 1.8; }
.flow-arrow:hover line, .flow-arrow:focus line { stroke-width: 4; }
.flow-arrow-label { fill: var(--text-2); font: 9px var(--font-mono); paint-order: stroke; stroke: var(--chrome); stroke-width: 3px; }
.narration { flex: 0 0 42px; display: flex; align-items: center; gap: 8px; padding: 3px 9px; border-top: 1px solid var(--line); background: var(--chrome); color: var(--navy); font-size: 11px; }
.narration img { flex: 0 0 auto; object-fit: contain; }
.playback-speed { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.playback-speed input { width: 72px; accent-color: var(--accent); }
.playback-speed output { width: 28px; color: var(--text); font: 10px var(--font-mono); }
.lesson-check.running .lesson-check-icon { width: 12px; height: 12px; margin: 2px 1px 0; border: 2px solid var(--accent-line); border-top-color: var(--accent); border-radius: 50%; font-size: 0; animation: lesson-spin .7s linear infinite; }
@keyframes lesson-spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .capture-count { display: none; }
}

.dev-ip { font-size: 9px; fill: var(--accent); text-anchor: middle; font-family: var(--font-mono); }
.ip-dialog { max-width: 360px; padding: 0; }
.ip-body { padding: 4px 18px 18px; }
.ipfield { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; font-size: 12px; }
.ipfield input {
  width: 170px; padding: 5px 8px; font: inherit;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-m);
}
.ip-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }

.ip-tabs { display: flex; gap: 6px; margin: 6px 0 12px; }
.ip-tab {
  padding: 4px 16px; font: inherit; font-size: 12px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-m);
}
.ip-tab.active { background: var(--accent); border-color: var(--accent); color: var(--white); }

/* ---------- native lesson gallery ---------- */
.gallery-overlay {
  z-index: 90; overflow: auto;
  background: radial-gradient(circle at 15% 10%, var(--accent-bg) 0, transparent 38%),
    linear-gradient(145deg, var(--hover) 0%, var(--titlebar) 100%);
}
.gallery { max-width: 880px; padding: 28px; border-color: var(--line-win); }
.gallery-hero { display: grid; grid-template-columns: 88px 1fr 104px; align-items: center; gap: 20px; }
.gallery-hero h1 { margin: 4px 0 7px; color: var(--navy); font-size: 26px; line-height: 1.12; letter-spacing: -.025em; }
.gallery-hero p { max-width: 520px; margin: 0; color: var(--muted-2); font-size: 12px; line-height: 1.55; }
.gallery-network, .gallery-mascot { width: 100%; height: auto; object-fit: contain; }
.gallery-cards { display: block; margin-top: 24px; }
.gallery-section + .gallery-section { margin-top: 26px; }
.gallery-section h3 { margin: 0 0 10px; color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.lesson-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  min-height: 210px; padding: 15px; text-align: left; font: inherit; color: var(--text);
  background: var(--white); border: 1px solid var(--line-soft); border-radius: 9px; cursor: pointer;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--shadow-ink) 4%, transparent); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.lesson-card:hover { transform: translateY(-2px); border-color: var(--accent-light); box-shadow: 0 8px 20px color-mix(in srgb, var(--shadow-ink) 8%, transparent); }
.lesson-card img { align-self: center; width: 72px; height: 72px; object-fit: contain; }
.lesson-card strong { font-size: 14px; }
.lesson-card-goal { color: var(--muted-2); line-height: 1.4; }
.lesson-card-meta { color: var(--muted); font-size: 10px; }
.lesson-card-action { margin-top: auto; padding-top: 7px; color: var(--accent); font-weight: 600; }
.gallery-note { min-height: 18px; margin: 16px 0 0; color: var(--muted-2); text-align: center; }
.gallery-start { display: flex; justify-content: center; gap: 8px; margin-top: 16px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.gallery-start .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; }
.gallery-start img { width: 17px; height: 17px; object-fit: contain; }
.gallery-start .gallery-new { border-color: var(--accent); background: var(--accent); color: var(--white); }
.gallery-start .gallery-new:hover { background: var(--accent-strong); }

/* ---------- modal overlay (dialogs) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 32px; background: var(--scrim);
}
.overlay[hidden] { display: none; }
/* Windows are draggable by their title bar; maximize fills the viewport. */
.devwin-title { cursor: move; user-select: none; touch-action: none; }
.preview.maxed {
  position: fixed !important; inset: 12px !important;
  width: auto !important; height: auto !important;
  max-width: none !important; max-height: none !important;
  margin: 0 !important;
}
.preview.maxed .devwin-body, .preview.maxed .web-body,
.preview.maxed .editor-body, .preview.maxed .traffic-body, .preview.maxed .mib-body,
.preview.maxed .mail-body { max-height: none; }
.preview {
  position: relative; width: 100%; max-width: 900px; max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 20px; box-shadow: 0 12px 32px color-mix(in srgb, var(--black) 20%, transparent);
}
.preview h2 { margin: 0 0 8px; font-size: 14px; word-break: break-all; }

.ip-sec {
  margin: 14px 0 6px; padding-bottom: 3px; font-size: 11px; font-weight: 700;
  color: var(--muted); border-bottom: 1px solid var(--line-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.ip-radio { display: inline-flex; align-items: center; gap: 5px; margin-right: 14px; font-size: 12px; }
.ip-tabs { margin: 4px 0 2px; }
.ipfield select, .ipfield input:disabled { background: var(--surface); color: var(--muted); }
.ipfield select { width: 170px; padding: 5px 8px; font: inherit; border: 1px solid var(--line); border-radius: var(--r-m); }
.ip-split { display: flex; gap: 6px; }
.ip-split input { width: 170px; }

.ip-group { border: 1px solid var(--line-soft); border-radius: var(--r-s); margin: 10px 0; padding: 6px 10px 10px; }
.ip-group legend { padding: 0 5px; font-size: 11px; color: var(--text); }
.ip-modes { display: flex; gap: 22px; margin: 2px 0 8px; }
.ip-slash { color: var(--muted); }
.ip-prefix { width: 60px !important; }
.ipfield input, .ipfield select { width: 320px; }
.ip-split input:first-child { width: 250px !important; }

/* ---------- device window ---------- */
.devwin { max-width: 760px; padding: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--window); }
.devwin-title {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; background: var(--titlebar); border-bottom: 1px solid var(--line-win);
  font-size: 12px; font-weight: 600; color: var(--ink);
}
.devwin-title img { width: 16px; height: 16px; }
.devwin-title .dw-btns { margin-left: auto; display: flex; gap: 3px; }
.devwin-title .dw-btns button {
  width: 24px; height: 22px; font: inherit; font-size: 11px; line-height: 1;
  display: grid; place-items: center; padding: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); cursor: pointer;
}
.devwin-title .dw-btns button:disabled { opacity: 0.5; cursor: default; }
.dw-blurb { margin: 0; padding: 4px 8px; font-size: 11px; color: var(--muted); background: var(--window); }
.devwin-tabs { display: flex; gap: 2px; padding: 4px 6px 0; background: var(--window); }
.devwin-tabs button {
  padding: 3px 14px; font: inherit; font-size: 12px; cursor: pointer;
  background: var(--titlebar); border: 1px solid var(--line-win); border-bottom: none;
  border-radius: var(--r-s) 3px 0 0;
}
.devwin-tabs button.active { background: var(--white); font-weight: 600; }
.devwin-body { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--white); border-top: 1px solid var(--line-win); padding: 0; }
.dw-pane { min-height: 380px; }
.dw-top { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: 11px; color: var(--text-2); border-top: 1px solid var(--line-soft); }

.dw-desktop {
  min-height: 380px; padding: 12px;
  background: var(--accent-bg); display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; align-content: start;
}
.dw-app {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 1px solid transparent; padding: 4px; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--navy); border-radius: 2px;
}
.dw-app:hover { border-color: var(--accent-light); background: color-mix(in srgb, var(--white) 40%, transparent); }
.dw-app img { width: 56px; height: 56px; object-fit: contain; }
.dw-app span { text-align: center; line-height: 1.15; max-width: 96px; }

.dw-physical { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dw-physical img { max-width: 340px; max-height: 260px; }
.dw-physical img.off { filter: grayscale(1) brightness(.6); }
.dw-slots { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 6px; }
.dw-slots .slot {
  border: 1px dashed var(--line-win); border-radius: var(--r-m); padding: 6px 8px;
  font: 12px var(--font-mono); color: var(--ink-2); background: var(--white);
}
.dw-slots .slot.filled {
  border-style: solid; border-color: var(--faint); color: var(--ink);
  cursor: pointer; background: var(--hover);
}
.dw-slots .slot.over { border-color: var(--accent); background: var(--accent-bg); }
.dw-tray { display: flex; gap: 8px; }
.dw-tray .mod {
  border: 1px solid var(--line-win); border-radius: var(--r-m); padding: 4px 8px;
  font: 12px var(--font-mono); background: var(--window); cursor: grab;
}
.dw-config { padding: 14px; }
.dw-services { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dw-services fieldset { margin: 0; }
.dns-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.dns-row { display: flex; align-items: center; gap: 6px; font: 12px var(--font-mono); }
.dns-row span { flex: 1; }
.dns-row input {
  flex: 1; padding: 3px 5px; border: 1px solid var(--line);
  font: 12px var(--font-mono); background: var(--white);
}
.http-page {
  width: 100%; box-sizing: border-box; resize: vertical;
  font: 12px var(--font-mono); padding: 6px 8px;
  border: 1px solid var(--line); background: var(--white);
}
.tftp-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.tftp-form input {
  padding: 3px 5px; border: 1px solid var(--line);
  font: 12px var(--font-mono); background: var(--white);
}
.dw-muted { color: var(--muted); padding: 24px; font-size: 12px; }

.cmdwin { max-width: 640px; background: var(--white); padding: 0; overflow: hidden; }
.cmd-out {
  margin: 0; padding: 10px 12px; min-height: 220px; max-height: 380px; overflow: auto;
  background: var(--black); color: var(--line-soft); font: 12px/1.35 var(--font-mono);
  white-space: pre-wrap;
}
.cmd-line {
  display: flex; align-items: center; gap: 4px; padding: 6px 12px 10px;
  background: var(--black); color: var(--line-soft); font: 12px var(--font-mono);
}
.cmd-line input {
  flex: 1; background: var(--black); color: var(--line-soft); border: none; outline: none;
  font: inherit;
}

/* Simulated HTTP browser: URL bar plus a rendered page surface. */
.webwin { max-width: 720px; padding: 0; }
.web-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--titlebar); border-bottom: 1px solid var(--line-win);
}
.web-bar span { font: 12px var(--font-mono); color: var(--ink-2); }
.web-bar input {
  flex: 1; padding: 4px 6px; border: 1px solid var(--line-win); font: 12px var(--font-mono);
}
.web-body {
  background: var(--white); min-height: 260px; max-height: 52vh; overflow: auto;
  padding: 16px 18px; font: 13px/1.5 system-ui, sans-serif; color: var(--ink);
}
.web-body h2 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.web-body p { margin: 0 0 10px; white-space: pre-wrap; }
.web-body .err { color: var(--danger); font-weight: 600; }

/* PDU detail: PT's In/Out layer stack, one column pair per device. */
.pduwin { max-width: 780px; padding: 0; }
.pdu-meta {
  padding: 8px 12px; font: 12px var(--font-mono); color: var(--ink);
  background: var(--hover); border-bottom: 1px solid var(--line-win);
}
.pdu-scroll { max-height: 60vh; overflow: auto; }
.pdu-table { border-collapse: collapse; width: 100%; font: 12px var(--font-mono); }
.pdu-table th, .pdu-table td {
  border: 1px solid var(--line-soft); padding: 4px 7px; text-align: left; vertical-align: top;
}
.pdu-table th { background: var(--window); font-weight: 600; }
.pdu-table td.in { color: var(--accent); }
.pdu-table td.out { color: var(--warn-ink); }
.pdu-table td.note { color: var(--ink-2); }

/* router/switch console: same black console surface, IOS-style prompt */
.cmdwin.termwin { max-width: 660px; }
.termwin .cmd-out { min-height: 260px; }
.termwin .cmd-line { padding-top: 0; }
.termwin #term-prompt { color: var(--accent-light); white-space: pre; }
.termwin .cmd-line input:read-only { color: var(--faint); }

.editorwin, .trafficwin, .mibwin { max-width: 720px; padding: 0; }
.editor-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--titlebar); border-bottom: 1px solid var(--line-win);
  font-size: 12px;
}
.editor-bar .meta { margin-left: auto; color: var(--ink-2); }
.editor-body { background: var(--white); padding: 10px 12px; }
.editor-area {
  display: block; width: 100%; min-height: 320px; resize: vertical;
  padding: 8px; border: 1px solid var(--line-win); background: var(--white);
  font: 12px/1.45 var(--font-mono); color: var(--ink);
}

/* Email client: account settings, the server inbox and the compose form. */
.mailwin { max-width: 560px; padding: 0; }
.mail-body {
  background: var(--white); padding: 0 12px 12px; max-height: 64vh; overflow: auto;
}
.mail-actions { margin-top: 10px; }
.mail-inbox { display: flex; flex-direction: column; gap: 6px; }
.mail-msg {
  border: 1px solid var(--line-soft); border-radius: var(--r-s); background: var(--chrome);
  font: 12px/1.45 var(--font-mono);
}
.mail-msg summary { padding: 5px 8px; cursor: pointer; }
.mail-msg-subject { font-weight: 600; margin-right: 10px; }
.mail-msg-meta { color: var(--ink-2); font-size: 11px; }
.mail-msg-body {
  margin: 0; padding: 6px 10px 8px; border-top: 1px solid var(--line-soft);
  white-space: pre-wrap; word-break: break-word;
}
.mail-text { min-height: 78px; }
.mail-from { margin: 4px 0 0; color: var(--ink-2); }

.traffic-body { background: var(--white); padding: 12px; }
.traffic-form {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px 10px;
  align-items: center; font-size: 12px;
}
.traffic-form input {
  width: 100%; padding: 4px 6px; border: 1px solid var(--line-win);
  font: 12px var(--font-mono); background: var(--white);
}
.traffic-form input:disabled { background: var(--surface); color: var(--muted); }
.traffic-stats {
  display: flex; gap: 18px; margin: 12px 0 4px;
  font: 12px var(--font-mono);
}
.traffic-note { min-height: 18px; font-size: 11px; color: var(--ink-2); }
.traffic-actions { display: flex; gap: 6px; margin: 8px 0; }
.traffic-log {
  margin: 6px 0 0; padding: 8px 10px; min-height: 90px; max-height: 180px;
  overflow: auto; background: var(--black); color: var(--line-soft);
  font: 11px/1.4 var(--font-mono); white-space: pre-wrap;
}

.mib-body { background: var(--white); padding: 12px; }
.mib-note { margin: 0 0 8px; font-size: 11px; color: var(--ink-2); }
.mib-scroll { max-height: 44vh; overflow: auto; }
.mib-table { border-collapse: collapse; width: 100%; font: 12px var(--font-mono); }
.mib-table th, .mib-table td {
  border: 1px solid var(--line-soft); padding: 4px 7px; text-align: left;
}
.mib-table th { background: var(--window); font-weight: 600; }
.mib-table tbody tr { cursor: pointer; }
.mib-table tbody tr:hover td { background: var(--hover); }
.mib-table tbody tr.selected td { background: var(--accent-bg); }
.mib-detail {
  margin-top: 10px; padding: 8px 10px; min-height: 44px;
  border: 1px solid var(--line-soft); background: var(--chrome);
  font: 11px/1.5 var(--font-mono); color: var(--ink);
}
.mib-detail-head { font-weight: 600; margin-bottom: 4px; }
.mib-port-list { list-style: none; margin: 0; padding: 0; }
.mib-port-list li { padding: 1px 0; }

/* ---------- logical / physical view switch ---------- */
.toolbar button.view-toggle {
  width: auto; padding: 0 9px; display: inline-flex; align-items: center;
  font: inherit; font-size: 11px; color: var(--text);
  border-color: var(--line-soft);
}
.toolbar button.view-toggle.active {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600;
}

/* ---------- syslog and NTP service sections ---------- */
.syslog-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sys-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.syslog-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 150px; overflow: auto; margin: 4px 0;
}
.syslog-row { display: flex; gap: 6px; font: 11px var(--font-mono); }
.syslog-time { min-width: 46px; color: var(--muted); }
.syslog-sev { min-width: 56px; font-weight: 600; text-transform: uppercase; font-size: 10px; }
.syslog-sev.sev-debug { color: var(--muted); }
.syslog-sev.sev-info { color: var(--accent); }
.syslog-sev.sev-notice { color: var(--ok); }
.syslog-sev.sev-warning { color: var(--warn-ink); }
.syslog-sev.sev-error { color: var(--danger); }
.syslog-sev.sev-critical { color: var(--danger-ink); }
.syslog-text { flex: 1; word-break: break-word; }
.meta.ok { color: var(--ok); font-weight: 600; }

/* ---------- wireless, VPN, PPPoE, IP phone, firewall, dialogs ---------- */
.wifiwin, .vpnwin, .pppoewin, .phonewin,
.firewallwin, .dialogswin { max-width: 620px; padding: 0; overflow: hidden; background: var(--window); }
.wifi-body, .vpn-body, .pppoe-body, .phone-body,
.firewall-body, .dialogs-body {
  background: var(--white); border-top: 1px solid var(--line-win); padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 70vh; overflow: auto;
}
.wifi-body fieldset, .vpn-body fieldset, .pppoe-body fieldset,
.phone-body fieldset { margin: 0; }
#wifi-ssid { width: 240px; }
.stat-line {
  margin-top: 8px; padding: 6px 8px; border: 1px solid var(--line-soft);
  border-radius: var(--r-s); background: var(--chrome);
  font: 12px var(--font-mono); color: var(--ink);
}

/* ---------- per-kind windows: gateway, radios, provider link, hotspot ---------- */
.kindwin { width: 400px; max-width: 92vw; padding: 0; overflow: hidden; background: var(--window); }
.kindwin-wide { width: 560px; max-width: 94vw; }
.kindwin-body {
  background: var(--white); border-top: 1px solid var(--line-win); padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 70vh; overflow: auto; font-size: 12px; color: var(--text);
}
.kw-blurb { margin: 0; font-size: 11px; color: var(--muted); }
.kw-pane { display: flex; flex-direction: column; gap: 12px; }
.kw-section { display: flex; flex-direction: column; gap: 4px; }
.kw-heading { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.kw-section-body { display: flex; flex-direction: column; gap: 4px; }
.kw-note { margin: 0; color: var(--text-2); }
.kw-empty, .kw-loading { color: var(--muted); }
.kw-error { color: var(--danger-ink); }
.kw-ok { color: var(--ok); }
.kw-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.kw-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.kw-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--ink-2); }
.kw-input {
  font: inherit; width: 110px; padding: 3px 6px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-s);
}
.kindwin .ui-button {
  font: inherit; padding: 3px 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s);
}
.kindwin .ui-button:hover { background: var(--brand-soft); border-color: var(--brand); }
.kindwin .ui-button:focus-visible, .kw-input:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 1px; }
.kw-outcome { flex-basis: 100%; }
.kw-outcome .kw-note { font-size: 11px; }
.kw-permit { color: var(--ok); }
.kw-deny { color: var(--danger-ink); }
.kw-row .kw-remove { margin-left: 8px; padding: 1px 7px; font-size: 11px; }
.kw-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kw-table th { text-align: left; font-weight: 600; color: var(--ink-2); }
.kw-table th, .kw-table td { padding: 2px 8px 2px 0; border-bottom: 1px solid var(--line-soft); }
.kw-load-ok { color: var(--ok); }
.kw-load-warn { color: var(--warn-ink); }
.kw-load-danger { color: var(--danger-ink); font-weight: 600; }
.kw-status-up { color: var(--ok); }
.kw-status-degraded { color: var(--warn-ink); }
.kw-status-down { color: var(--danger-ink); }
.kw-status-isolated { color: var(--muted); }
.kw-spread { margin-top: 4px; align-self: flex-start; }
.kw-spread[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.kw-mono {
  margin: 0; padding: 6px 8px; max-height: 180px; overflow: auto; white-space: pre-wrap;
  font: 11px/1.5 var(--font-mono); color: var(--screen-text);
  background: var(--screen-bg); border: 1px solid var(--screen-edge); border-radius: var(--r-s);
}
/* ---------- ports: the picker menu and the per-device panel ---------- */
.port-picker button { font-variant-numeric: tabular-nums; }
/* Physical port bank: connector shape, LED and a readable state line. */
.dw-face-head {
  display: flex; width: 100%; max-width: 760px; gap: 12px; align-items: center;
  padding-bottom: 8px; border-bottom: 1px solid var(--line-soft);
}
.dw-face-thumb { width: 96px; height: 72px; object-fit: contain; flex: none; }
.dw-face-thumb.off { filter: grayscale(1) brightness(.6); }
.dw-face-info { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.dw-faceplate-host { width: 100%; max-width: 760px; }
.port-faceplate { width: 100%; }
.port-faceplate-note { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.port-faceplate-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 2px 0 6px; }
.port-legend { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.port-legend-item { display: flex; align-items: center; gap: 4px; }
.port-jack-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 5px; max-height: 300px; overflow: auto; padding-right: 4px;
}
.port-jack {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto;
  column-gap: 6px; align-items: center; min-width: 0;
  padding: 5px 6px; background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--r-m);
}
.port-jack svg { display: block; width: 46px; height: 32px; grid-row: 1 / 3; }
.port-jack-name {
  font-family: var(--font-mono); font-size: 10px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.port-jack-state {
  font-size: 10px; line-height: 1.25; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.port-jack-state.state-up { color: var(--ok); }
.port-jack-state.state-no-link { color: var(--warn-ink); }
.port-jack-state.state-free, .port-jack-state.state-shut { color: var(--muted); }
.port-body { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.port-cavity { fill: var(--bg); stroke: var(--line-soft); stroke-width: 1; }
.port-pin { fill: none; stroke: var(--muted); stroke-width: 1; }
.port-pin-fill { fill: var(--muted); }
.port-led { fill: var(--faint); }
.led-up { fill: var(--ok-bright); }
.led-no-link { fill: var(--warn); }
.led-shut { fill: var(--danger); }
.port-legend .port-led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.port-legend .led-up { background: var(--ok-bright); }
.port-legend .led-no-link { background: var(--warn); }
.port-legend .led-shut { background: var(--danger); }
.port-jack.cable-copper .port-body { stroke: var(--cable-copper); }
.port-jack.cable-fiber .port-body { stroke: var(--cable-fiber); fill: var(--warn-bg); }
.port-jack.cable-serial .port-body { stroke: var(--cable-serial); }
.port-jack.cable-console .port-body { stroke: var(--cable-console); }
.port-jack.cable-phone .port-body { stroke: var(--cable-phone); }
.port-jack.cable-coax .port-body { stroke: var(--cable-coax); }
.port-jack.cable-iot .port-body { stroke: var(--cable-iot); }
.port-jack.cable-fiber svg { outline: 1px dashed var(--cable-fiber); outline-offset: -1px; border-radius: var(--r-s); }

.port-list { padding-left: 0; list-style: none; }
.port-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 4px;
  border-bottom: 1px solid var(--line-soft); font-size: 11px;
}
.port-dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
}
.port-dot.is-up { background: var(--ok); }
.port-dot.is-warn { background: var(--warn); }
.port-dot.is-idle { background: var(--faint); }
.port-dot.is-down { background: var(--danger); }
.port-name { font-family: var(--font-mono); color: var(--text); }
.port-addr { font-family: var(--font-mono); color: var(--ink-2); }
.port-extra { color: var(--muted); }
.port-peer { margin-left: auto; color: var(--text-2); }
.port-peer.is-free { color: var(--muted); }
.port-row .port-toggle { flex: none; padding: 1px 7px; font-size: 11px; }
.dw-ports .ui-button {
  font: inherit; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s);
}
.dw-ports .ui-button:hover { background: var(--brand-soft); border-color: var(--brand); }
.dw-ports .ui-button:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 1px; }

.stat-line.ok { color: var(--ok); font-weight: 600; }
.stat-line.off { color: var(--muted); }
.wifi-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 160px; overflow: auto; margin: 4px 0 8px;
}
.wifi-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 4px;
  border-bottom: 1px solid var(--line-soft);
  font: 12px var(--font-mono);
}
.wifi-row .sec { margin-left: auto; color: var(--muted); }
.wifi-row .wlc { color: var(--muted); font-size: 11px; }
.wifi-row .guest {
  padding: 0 5px; font-size: 10px; color: var(--brand);
  border: 1px solid var(--brand); border-radius: var(--r-s);
}
.wifi-guest { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); }
.dw-wireless { display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.dw-wireless .wifi-add { align-items: flex-end; }
.wifi-controller { border-top: 1px solid var(--line-soft); padding-top: 6px; }
.firewall-out {
  margin: 0; padding: 10px 12px; min-height: 200px; max-height: 50vh; overflow: auto;
  background: var(--black); color: var(--line-soft); white-space: pre-wrap; word-break: break-word;
  font: 12px/1.35 var(--font-mono); border-radius: var(--r-s);
}
.phone-screen {
  padding: 12px; border-radius: var(--r-l); background: var(--screen-bg); color: var(--screen-text);
  border: 2px inset var(--screen-edge); font: 13px var(--font-mono);
}
.phone-label { font-size: 16px; font-weight: 700; letter-spacing: 0.03em; }
.phone-state { margin-top: 4px; font-size: 11px; color: var(--screen-dim); }
.phone-state.ok { color: var(--screen-ok); }
.prefs { max-width: 380px; padding: 0; overflow: hidden; }
.prefs-body { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.prefs-body label { display: flex; gap: 8px; align-items: center; font: inherit; }
.prefs-body p { margin: 0; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center; background: var(--scrim-strong);
}
.modal {
  width: min(420px, calc(100vw - 32px)); padding: 16px; border-radius: var(--r-l);
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 32px color-mix(in srgb, var(--black) 30%, transparent);
}
.modal-message { margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; }
.modal-input { width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 6px 8px; font: inherit; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.modal-buttons button { padding: 5px 14px; font: inherit; cursor: pointer; }
.modal-ok { background: var(--accent); color: var(--white); border: 1px solid var(--accent); border-radius: var(--r-s); }
.modal-cancel { background: var(--chrome); border: 1px solid var(--line); border-radius: var(--r-s); }
.run-log-head { display: flex; gap: 6px; align-items: center; padding: 4px 8px; font-weight: 600; }
.run-log-head input { flex: 1; min-width: 0; font: inherit; padding: 2px 6px; }
.run-log { margin: 0; padding: 0 8px 8px 28px; max-height: 160px; overflow: auto; font: 11px var(--font-mono); }
.run-log li { white-space: pre; cursor: pointer; }
.run-log li:hover { background: var(--hover); }

/* ---------- sidebar: tabs, splitter, hide (PRD-UI section 5) ---------- */
.main {
  grid-template-columns: minmax(0, 1fr) 6px var(--sidebar-width, 330px);
}
.main.sidebar-hidden { grid-template-columns: minmax(0, 1fr) 0 0; }
.main.sidebar-hidden .sim, .main.sidebar-hidden .splitter { display: none; }
.splitter { cursor: col-resize; background: var(--line-soft); touch-action: none; }
.splitter:hover { background: var(--accent); }
.sim { min-width: 0; min-height: 0; overflow: hidden; }
.sidebar-tabs {
  display: flex; gap: 2px; padding: 4px 4px 0; background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
}
.sidebar-tabs button {
  font: inherit; font-size: 11px; padding: 4px 7px; border: 1px solid transparent;
  border-bottom: none; border-radius: var(--r-s) 3px 0 0; background: none; cursor: pointer; color: var(--muted);
}
.sidebar-tabs button.active { background: var(--panel); border-color: var(--line-soft); color: var(--text); font-weight: 600; }
.sidebar-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.sidebar-body > [data-panel][hidden] { display: none; }
.sim .capture-dock { flex: 1 1 auto; min-height: 0; border-top: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.engine-loading {
  position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--text);
}
.engine-loading[hidden] { display: none; }
.engine-loading p { margin: 0; font-size: 14px; }
.engine-bar { width: 260px; height: 6px; border-radius: var(--r-s); background: var(--line-soft); overflow: hidden; }
.engine-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.engine-bar.indeterminate span { width: 35%; animation: engine-slide 1.1s ease-in-out infinite alternate; }
@keyframes engine-slide { from { margin-left: 0; } to { margin-left: 65%; } }

/* ---------- one close button for every dialog ---------- */
.dlg-close {
  width: 24px; height: 22px; padding: 0; display: grid; place-items: center;
  font: inherit; font-size: 15px; line-height: 1; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); cursor: pointer;
}
.dlg-close:hover { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }
.dlg-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dlg-close-float { position: absolute; top: 10px; right: 10px; z-index: 2; }

/* ---------- minimize: one handle, one rule for every bar ---------- */
.bar { display: flex; align-items: stretch; background: var(--chrome); }
.bar > .toolbar { flex: 1; min-width: 0; }
.collapse-handle {
  flex: none; align-self: center; margin: 0 6px; min-width: 22px; height: 20px; padding: 0 6px;
  font: inherit; font-size: 11px; line-height: 1; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-m); cursor: pointer;
}
.collapse-handle:hover { color: var(--text); border-color: var(--line); background: var(--hover); }
.collapse-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[data-collapsible].collapsed > :not(.collapse-handle) { display: none; }
[data-collapsible].collapsed { height: auto !important; min-height: 0; padding-top: 2px; padding-bottom: 2px; justify-content: flex-start; border-bottom: 1px solid var(--line-soft); }
.palette.collapsed { border-top: 1px solid var(--line); }
.sidebar-tabs .sidebar-handle { margin: 0 4px 0 auto; align-self: center; }
.main { position: relative; }
.sidebar-restore {
  position: absolute; top: 8px; right: 0; z-index: 5; padding: 6px 8px;
  font: inherit; font-size: 11px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-right: none; border-radius: var(--r-l) 0 0 6px; cursor: pointer;
}
.sidebar-restore:hover { background: var(--hover); }
.sidebar-restore[hidden] { display: none; }

/* ---------- sidebar layout: each tab fits its width and scrolls inside its own area ---------- */
.sidebar-body { container-type: inline-size; }
.sidebar-body > [data-panel]:not([hidden]) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.sidebar-body > .panel-events:not([hidden]) { overflow: hidden; }
.lesson-empty { margin: 0; padding: 14px 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.lesson-empty[hidden] { display: none; }
@container (max-width: 430px) {
  .capture-table th:nth-child(2), .capture-table td:nth-child(2),
  .capture-table th:nth-child(6), .capture-table td:nth-child(6) { display: none; }
  .capture-table th:nth-child(1) { width: 12%; }
  .capture-table th:nth-child(3), .capture-table th:nth-child(4) { width: 21%; }
  .capture-table th:nth-child(5) { width: 16%; }
  .capture-count { display: none; }
}

/* ---------- print: the workspace only ---------- */
.print-sheet { display: none; margin: 0; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: var(--white) !important; height: auto !important; overflow: visible !important; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; }
  .print-sheet img { display: block; width: 100%; height: auto; max-height: 178mm; object-fit: contain; }
  .print-sheet figcaption { margin-top: 4mm; color: var(--text-2); font: 11px system-ui, sans-serif; }
}

/* ---------- menu bar: keyboard and hover states ---------- */
.menu > button[aria-expanded="true"] { background: var(--accent-bg); }
.menu > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu .drop button.active:not(:disabled), .menu .drop a.active { background: var(--accent-bg); }
.menu .drop button:focus, .menu .drop a:focus { outline: none; }

/* ---------- hover label on icon buttons ---------- */
.tooltip {
  position: fixed; z-index: 400; max-width: 260px; padding: 4px 8px; pointer-events: none;
  background: var(--ink); color: var(--white); border-radius: var(--r-m); font-size: 11px; line-height: 1.35;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--black) 25%, transparent);
}
.tooltip[hidden] { display: none; }
.tooltip-key { margin-left: 8px; padding-left: 8px; border-left: 1px solid color-mix(in srgb, var(--white) 30%, transparent); color: var(--line-soft); font-family: var(--font-mono); font-size: 10px; }

/* ---------- phones: one message, nothing else (keep in step with PHONE_QUERY in js/phone.js) ---------- */
.phone-block { display: none; }
@media (max-width: 599px), (max-height: 500px) and (pointer: coarse) {
  body > *:not(.phone-block) { display: none !important; }
  .phone-block {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    min-height: 100vh; padding: 24px 28px; text-align: center; background: var(--bg); color: var(--text);
  }
  html, body { overflow: auto; height: auto; }
  .phone-block h1 { margin: 6px 0 0; font-size: 20px; line-height: 1.25; }
  .phone-block p { margin: 0; max-width: 34ch; color: var(--muted-2); font-size: 14px; line-height: 1.5; }
  .phone-block a { color: var(--accent); }
}

.dw-cli { display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 260px; }
.dw-cli-out { flex: 1; margin: 0; overflow: auto; background: var(--panel-2, var(--panel)); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px; font-family: var(--font-mono, monospace); font-size: 12px; white-space: pre-wrap; }
.dw-cli-line { display: flex; gap: 6px; align-items: center; }
.dw-cli-prompt { font-family: var(--font-mono, monospace); font-size: 12px; color: var(--ink-2, inherit); }
.dw-cli-in { flex: 1; font-family: var(--font-mono, monospace); font-size: 12px; }

.kindwin .kw-pane { padding: 12px; max-height: 70vh; overflow: auto; }
.cli-help-row { display: flex; gap: 10px; align-items: baseline; justify-content: flex-start; text-align: left; width: 100%; padding: 4px 8px; font: inherit; }
.cli-help-row code { font-family: var(--font-mono); color: var(--accent); white-space: nowrap; }
.cli-help-row span { color: var(--text-2); }
div.cli-help-row { padding: 2px 0; }
.devwin-title .dw-btns button.btn { width: auto; padding: 0 8px; }
.port-row { flex-wrap: wrap; }
.port-choice { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); }
.port-choice .kw-input { width: auto; padding: 1px 4px; }
.port-link { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.port-poe { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.port-errors { color: var(--warn-ink); font-variant-numeric: tabular-nums; }
.ip-warning { margin: 6px 0; color: var(--warn-ink); font-size: 12px; }
.pdu-queue { align-self: center; padding: 1px 6px; border-radius: var(--r-s, 4px); background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; white-space: nowrap; }
.port-fault { color: var(--danger-ink); font-weight: 600; }
.cable-tool .cable-swatch { display: block; width: 40px; height: 6px; margin: 2px auto 0; }
.poe-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text); flex-wrap: wrap; justify-content: center; }
.poe-status { color: var(--ink-2); }
.poe-status.is-bad { color: var(--danger-ink); font-weight: 600; }
