/* AgentSmith UI — Style C "Modern Workbench" design tokens (chosen 2026-07-19). */
:root {
  --bg: #f7f4f0;
  --panel: #ffffff;
  --panel-border: #e5ded4;
  --wire: #c9bfae;
  --text: #2b241d;
  --text-dim: #8b7f70;
  --accent: #c2622b;
  --accent-soft: #f4e3d5;
  --good: #3f8a5c;
  --warn: #c58a1f;
  --critical: #c0433a;
  --series-1: #3d7ac6;
  --series-2: #dd84a4;
  --series-3: #e3a545;
  --series-4: #46ab7f;
  --series-5: #4a4198;
  --band-shade: rgba(120, 100, 70, 0.1);
  --shadow: 0 1px 2px rgba(43, 36, 29, 0.06), 0 4px 14px rgba(43, 36, 29, 0.05);
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #1b1712;
  --panel: #241f18;
  --panel-border: #3a3226;
  --wire: #5a5040;
  --text: #efe7db;
  --text-dim: #a6998a;
  --accent: #e2a066;
  --accent-soft: #3a2c1c;
  --good: #7fce9c;
  --warn: #e0b84f;
  --critical: #e2837a;
  --series-1: #4c88d5;
  --series-2: #c75e87;
  --series-3: #bc8733;
  --series-4: #419a73;
  --series-5: #6964be;
  --band-shade: rgba(226, 160, 102, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1712;
    --panel: #241f18;
    --panel-border: #3a3226;
    --wire: #5a5040;
    --text: #efe7db;
    --text-dim: #a6998a;
    --accent: #e2a066;
    --accent-soft: #3a2c1c;
    --good: #7fce9c;
    --warn: #e0b84f;
    --critical: #e2837a;
    --series-1: #4c88d5;
    --series-2: #c75e87;
    --series-3: #bc8733;
    --series-4: #419a73;
    --series-5: #6964be;
    --band-shade: rgba(226, 160, 102, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  /* The app fills the viewport exactly (not min-height) so only the
     network list scrolls internally — nothing pushes the page itself
     into scrolling, and the charts panel never needs to scroll. */
  overflow: hidden;
}
#app {
  height: 100%;
}

.app {
  display: grid;
  /* The charts panel's own width is user-controlled (dragged via
     .column-resize-handle — see ui/app.tsx's chartsPanelWidthPx),
     read from the --charts-panel-width custom property it sets inline;
     the 6px in between is the handle's own column. */
  grid-template-columns: 190px 1fr 6px var(--charts-panel-width, 420px);
  grid-template-rows: auto 1fr;
  height: 100%;
  min-height: 0;
}
.column-resize-handle {
  grid-column: 3;
  grid-row: 2;
  cursor: col-resize;
  position: relative;
}
.column-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: var(--panel-border);
}
.column-resize-handle:hover::after {
  background: var(--accent);
}

header.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}
.brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand span {
  color: var(--accent);
}
.brand .version {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: normal;
  color: var(--text-dim);
  vertical-align: middle;
}
.card-display-mode {
  display: flex;
  align-items: center;
  gap: 4px;
}
/* Individually rounded pills (not one shared segmented-control box) — same rounding/font language as .network-meta's own VSWR badge, but interactive: unselected reads like that badge, selected switches to a solid accent fill. */
.card-display-mode-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--accent-soft);
  border: none;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
}
.card-display-mode-btn.active {
  background: var(--accent);
  color: #fff;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.icon-btn:hover {
  color: var(--accent);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}
.icon-btn:disabled:hover {
  color: var(--text);
}
.icon-btn.muted {
  color: var(--text-dim);
  opacity: 0.6;
}
.icon-btn.muted:hover {
  color: var(--accent);
  opacity: 1;
}
.settings-menu {
  position: relative;
}
.settings-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.settings-row select {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 3px 6px;
  color: var(--text);
}
.settings-value-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.settings-value-group input {
  width: 52px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 3px 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.demo-menu {
  position: relative;
}
.demo-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.demo-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.demo-item:hover {
  background: var(--accent-soft);
}
.demo-item-label {
  font-size: 12.5px;
  font-weight: 600;
}
.demo-item-description {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}
.text-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.text-btn:hover {
  color: var(--accent);
}
.text-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

main.layout {
  grid-column: 2;
  grid-row: 2;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  min-height: 0;
}

section.networks {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.network-drop-zone {
  flex: 0 0 auto;
  height: 12px;
  border-radius: 6px;
  margin: 0 1px;
}
.network-drop-zone.drop-active {
  background: var(--panel-border);
}
.network-drop-zone.drop-hover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.network-row {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.network-row.dragging {
  opacity: 0;
  pointer-events: none;
}
.network-row-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
}
.network-row.collapsed .network-row-head {
  border-bottom: none;
}
.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 14px;
  background: none;
  border: none;
  padding: 4px 2px;
}
.drag-handle:hover {
  color: var(--accent);
}
.collapse-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  width: 18px;
}
.network-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.network-color-dot.dimmed {
  opacity: 0.25;
}
.network-name {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  flex: 1;
  font-family: var(--sans);
}
.network-name:focus {
  outline: none;
}
.network-row-head .icon-btn {
  width: 28px;
  height: 28px;
  font-size: 12px;
  box-shadow: none;
}
.network-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 20px;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}

.chain {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 12px;
  overflow-x: auto;
}
.chain::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 85px;
  height: 2px;
  background: var(--wire);
  z-index: 0;
}
.chain-out-of-range {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.chain-out-of-range::before {
  content: none;
}
.chain-out-of-range p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}
.chain-drop-zone {
  align-self: stretch;
  flex: 0 0 auto;
  width: 14px;
  border-radius: 6px;
  z-index: 1;
  margin: 0 1px;
}
.chain-drop-zone.drop-active {
  background: var(--panel-border);
}
.chain-drop-zone.drop-hover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.element {
  position: relative;
  z-index: 1;
  width: 108px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.element[draggable="true"] {
  cursor: grab;
}
/* Lifts this one card's whole stacking context above its (same-z-index)
   sibling cards while its own FileMenu or WarningBadge popover is open
   (see ElementCard.tsx's menuOpen state) — a popover's own z-index only
   ever wins against elements sharing *its* stacking context, which
   means it can never out-rank a sibling `.element` on its own, however
   high it's set; only raising the card itself actually works. */
.element.menu-open {
  z-index: 20;
}
.element.dragging {
  opacity: 0;
  pointer-events: none;
}
.element-delete-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s ease;
}
.element:hover .element-delete-btn {
  opacity: 1;
}
.element-delete-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.element-delete-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.element-disable-btn {
  position: absolute;
  top: -7px;
  left: -7px;
  z-index: 2;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s ease;
}
.element:hover .element-disable-btn {
  opacity: 1;
}
.element-disable-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.element-disable-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.element-disable-btn svg {
  fill: currentColor;
}
.element.disabled {
  opacity: 0.45;
  filter: grayscale(60%);
}
.element.disabled .element-disable-btn {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}
.element .powerbar {
  width: 100%;
  height: 14px;
  background: var(--accent-soft);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}
.element .powerbar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
}
.element .powerbar span {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 9px;
  display: block;
  text-align: center;
  line-height: 14px;
  color: var(--text);
}
.element .primary-readout {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  /* A long value plus the trailing arrow can be wider than the card —
     let it overlap the card's edge rather than wrap, which used to strand
     the arrow alone on its own line. */
  white-space: nowrap;
}
/* The arrow glyph sits visibly lower than the surrounding digits at this font size — nudged up to read as part of the same line instead of a subscript. */
.z-arrow {
  display: inline-block;
  vertical-align: 1px;
}
/* Overlaid on the powerbar's own left edge rather than a separate row below it — the bar already has 14px of height to spare and this keeps the "plot power" control right next to the value it plots. */
.powerbar-plot-toggle {
  position: absolute;
  z-index: 2;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  cursor: pointer;
}
.powerbar-plot-toggle input {
  width: 10px;
  height: 10px;
  margin: 0;
  cursor: pointer;
}
.element .icon-slot {
  height: 38px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.cycle-btn {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text-dim);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cycle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.cycle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
/* A card's own "something here is silently untrustworthy right now"
   badge (see ElementCard.tsx's props.warning) — an Auto L Match whose
   current selection can't reach the target (no `action`, just a native
   `title` tooltip — Cycle already lives right next to it), or an S2P
   element missing a measured direction (has an `action`: this becomes a
   real <button>, opening .warning-menu-list below). Same round-badge
   sizing as .cycle-btn, in --critical. Explicit `cursor: default` rather
   than leaving it to inherit — the card itself is draggable
   (cursor: grab), which would otherwise bleed through here too. */
.element-warning {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--critical);
  background: var(--bg);
  color: var(--critical);
  /* .cycle-btn (also sometimes a <button>) already has this — a plain
     browser default button carries non-zero padding of its own, and
     with the app-wide `* { box-sizing: border-box }` reset that padding
     eats directly into this 15px box instead of adding to it, squeezing
     the icon into a much smaller effective area. A <span> (the non-
     interactive Auto L Match case) has no such default, which is
     exactly why only the clickable S2P badge was ever affected. */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
button.element-warning {
  cursor: pointer;
}
/* The "fix it" popover a warning badge with an `action` opens — same
   small-dropdown language as .file-menu/.file-menu-list, just under its
   own name (a warning fix isn't a file action, even though the visual
   affordance is identical). */
.warning-menu {
  position: relative;
  flex-shrink: 0;
}
.warning-menu-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  min-width: 140px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.warning-menu-list li {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.warning-menu-list li:hover {
  background: var(--accent-soft);
}
/* A tank's resonant-frequency lock — same round-button language as
   .cycle-btn, just inline in its own param row (see ElementCard.tsx's
   ParamInput) instead of the icon-slot, since it's that one field's own
   coupling being toggled, not a whole-card action. */
.param-lock-btn {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text-dim);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.param-lock-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.param-lock-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.element .icon-svg {
  width: 38px;
  height: 24px;
  color: var(--text);
}
.icon-svg.rotated {
  transform: rotate(90deg);
}
.element .name {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-align: center;
}
.cable-select {
  position: relative;
  width: 100%;
}
.cable-select-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--sans);
  font-size: 9.5px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3px 8px;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cable-select-input:hover {
  color: var(--accent);
}
.cable-select-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cable-select-input.stale {
  color: var(--accent);
}
.loss-kind-toggle {
  display: flex;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  overflow: hidden;
}
.loss-kind-toggle button {
  flex: 1;
  border: none;
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
  padding: 3px 0;
  cursor: pointer;
}
.loss-kind-toggle button:first-child {
  border-right: 1px solid var(--panel-border);
}
.loss-kind-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* Same look as .loss-kind-toggle, but :not(:last-child) rather than :first-child so it stays correct with any number of buttons (the transformer model selector currently has 2, growing to 3). */
.model-kind-toggle {
  display: flex;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  overflow: hidden;
}
.model-kind-toggle button {
  flex: 1;
  border: none;
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
  padding: 3px 0;
  cursor: pointer;
}
.model-kind-toggle button:not(:last-child) {
  border-right: 1px solid var(--panel-border);
}
.model-kind-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.file-menu {
  position: relative;
  width: 100%;
}
.file-selector-btn {
  width: 100%;
  background: var(--bg);
  border: 1px dashed var(--panel-border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}
.file-selector-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.file-menu-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  min-width: 140px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.file-menu-list li {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.file-menu-list li:hover {
  background: var(--accent-soft);
}
.element .params {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.element .param-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.element .param-error {
  flex-basis: 100%;
  font-size: 9px;
  color: var(--critical);
}
.element .param-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 16px;
  text-align: right;
}
.element .param-input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3px 8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: text; /* not inherited "grab" from the now-draggable card */
}
.element .param-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.element .param-input[readonly] {
  background: none;
  border-style: dashed;
  color: var(--text-dim);
  cursor: default;
}
.element .param-details {
  width: 100%;
}
.element .param-details summary {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
}
.element .param-details summary:hover {
  color: var(--accent);
}
.element .param-details .params {
  margin-top: 6px;
}
.element.source,
.element.load {
  box-shadow: 0 0 0 1.5px var(--accent), var(--shadow);
}

.add-network {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.add-network:hover {
  color: var(--accent);
}

section.sweep-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}
.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 20px;
  padding: 3px;
}
.tab {
  background: none;
  color: var(--text-dim);
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: 16px;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}
.field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.field input {
  width: 84px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

aside.charts-panel {
  grid-column: 4;
  grid-row: 2;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Charts should never scroll — they're sized to fit this column. */
  overflow: hidden;
  min-height: 0;
}
.chart {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  /* Both charts share the column's full height (rather than sitting at
     a fixed/intrinsic size with empty flex space left over below — see
     SweepChart.tsx's own height, measured from this container rather
     than hardcoded); the Smith chart gets a bit more of it than the
     SWR/dB chart — see the :first-child/:last-child overrides below,
     scoped to the compact side-by-side layout only, not the enlarge
     overlay (which shows one chart at a time, full height). */
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.charts-panel > .chart:first-child {
  flex-grow: 1.35;
}
.charts-panel > .chart:last-child {
  flex-grow: 1;
}
/* Collapsed: header only, same idea as .network-row.collapsed — doesn't
   grow to share the column's height with the other (still expanded)
   chart, just sits at its own header height. */
.charts-panel > .chart.collapsed {
  flex: 0 0 auto;
}
.chart-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.smith-canvas-wrap {
  /* Fills whatever vertical space .chart-header and the caption <p>
     below don't need. Doesn't need to itself be square — the SVG's own
     default preserveAspectRatio ("xMidYMid meet") centers its square
     viewBox inside whatever box it's given, letterboxing the long axis
     rather than stretching, so a plain 100%/100% svg here already ends
     up as the largest centered square that fits, no JS measurement
     needed. Positioned (not static) so the tooltip below can be
     absolutely placed relative to it. */
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.smith-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
/* Shared by the Smith chart's and SWR/dB chart's own mouseover readouts. */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  z-index: 5;
}
.chart-segment {
  transition: stroke-width 0.4s ease, r 0.4s ease;
}
.chart h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chart-header h3 {
  margin: 0;
}
.chart-header .tabs {
  padding: 2px;
}
.chart-header .tab {
  padding: 4px 10px;
  font-size: 11px;
}
.chart-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-export-btn {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
}
.chart-export-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.chart-export-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.power-plot-header-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.chart-export-menu {
  position: relative;
}
.chart-export-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  right: 0;
  min-width: 120px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.chart-export-list li {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.chart-export-list li:hover {
  background: var(--accent-soft);
}
.sweep-chart-wrap {
  position: relative;
  margin-top: 4px;
  flex: 1 1 auto;
  min-height: 0;
}
.sweep-chart {
  width: 100%;
  height: 100%;
}
.sweep-chart .u-over {
  cursor: grab;
}

aside.palette {
  grid-column: 1;
  grid-row: 2;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.palette-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 2px 6px 8px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: grab;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.palette-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.palette-item .icon-svg {
  width: 26px;
  height: 16px;
  flex-shrink: 0;
  color: inherit;
}
.palette-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.variables-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 14px;
  margin-left: 4px;
  border-left: 1px solid var(--panel-border);
}
.variable-chip-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.variable-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3px 4px 3px 10px;
}
.variable-chip-name {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}
.variable-chip-value {
  width: 64px;
  font-family: var(--mono);
  font-size: 11.5px;
  background: none;
  border: none;
  color: var(--text-dim);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.variable-chip-value:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 6px;
}
.variable-chip-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
}
.variable-chip-delete:hover {
  color: var(--critical);
  background: var(--accent-soft);
}
.variable-add-btn {
  background: none;
  border: 1px dashed var(--panel-border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
}
.variable-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.variable-add-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.variable-add-name,
.variable-add-value {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 5px 10px;
  color: var(--text);
}
.variable-add-name {
  width: 90px;
}
.variable-add-value {
  width: 70px;
  text-align: center;
}
.variable-add-name:focus-visible,
.variable-add-value:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.variable-error {
  font-size: 11px;
  color: var(--critical);
}

/* Chart enlarge overlay (see ui/app.tsx's ChartsOverlay/chartsExpanded). */
.chart-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.chart-overlay-panel {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 1400px;
  height: 100%;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow: hidden;
}
.chart-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.chart-overlay-header h2 {
  margin: 0;
  font-size: 15px;
}
/* The overlay shows exactly one chart at a time (see ui/app.tsx's
   expandedChart) — this row holds that one chart plus, only for the
   SWR/dB chart, a settings sidebar next to it (not a block below,
   which would waste the overlay's abundant width for a narrow panel). */
.chart-overlay-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 12px;
}
.chart-overlay-body .chart {
  flex: 1 1 auto;
  min-width: 0;
}
/* CableLibraryBrowser — reuses .chart-overlay-backdrop/-panel/-header/-body
   (see above) for the same modal shell as the chart enlarge overlay; only
   the list/chart panes and the footer below are specific to it. */
.cable-library-panel {
  max-width: 1100px;
  max-height: 720px;
}
.cable-library-list-pane {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.cable-library-search {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 10px;
}
.cable-library-search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cable-library-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
.cable-library-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.cable-library-row:hover {
  background: var(--accent-soft);
}
.cable-library-row.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.cable-library-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.cable-library-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cable-library-empty {
  padding: 5px 7px;
  font-size: 11px;
  color: var(--text-dim);
}
.cable-library-chart-pane {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}
.cable-library-chart-placeholder {
  margin: auto;
  color: var(--text-dim);
  font-size: 12px;
  max-width: 220px;
  text-align: center;
}
.cable-attenuation-chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}
.cable-attenuation-chart {
  width: 100%;
  height: 100%;
}
.chart-overlay-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}
.chart-overlay-footer-primary {
  display: flex;
  gap: 8px;
}
.text-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.text-btn.primary:hover {
  color: var(--bg);
  filter: brightness(1.08);
}
.text-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.text-btn:disabled:hover {
  color: var(--text);
  filter: none;
}
.chart-settings {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
.chart-settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chart-settings-group h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.chart-settings-group select {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 3px 6px;
  color: var(--text);
  width: 100%;
}
.band-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.band-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.axis-range-fields {
  display: flex;
  gap: 10px;
}
.axis-range-fields label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-dim);
}
.axis-range-fields input {
  width: 76px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
