/* Spot the Violation - sandbox.css
 * Wiring sandbox page (sandbox.html). Loads after css/app.css and reuses its tokens and components.
 * Sandbox-only tokens: framing, wall cavity, tape, the inspector's clipboard. Dark mode mirrors app.css.
 */

:root {
  --sbx-cavity: #e9dfc9;          /* OSB / sheathing seen between the studs */
  --sbx-fleck: rgba(120, 90, 40, 0.18);
  --sbx-wood: #dcb57e;
  --sbx-wood-edge: #a77d43;
  --sbx-grain: rgba(120, 78, 24, 0.28);
  --sbx-plate: #d2a76b;
  --sbx-joist: #c99a5b;
  --sbx-attic: #f1ece2;
  --sbx-label-halo: rgba(255, 255, 255, 0.92);
  --sbx-tape: #f4c430;
  --sbx-tape-ink: #2b2410;
  --sbx-hole: #3b2a14;
  --sbx-hole-rim: #f3d9b0;
  --sbx-paper: #fffdf6;
  --sbx-paper-line: rgba(47, 79, 127, 0.10);
  --sbx-clip: #8b939b;
  --sbx-stage: #e9ecef;
  --sbx-stage-dot: rgba(0, 0, 0, 0.06);
  --sbx-live: rgba(255, 166, 0, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sbx-cavity: #3a3428;
    --sbx-fleck: rgba(255, 230, 180, 0.08);
    --sbx-wood: #9a7547;
    --sbx-wood-edge: #6b4e2a;
    --sbx-grain: rgba(40, 24, 6, 0.4);
    --sbx-plate: #8c6a3f;
    --sbx-joist: #82623a;
    --sbx-attic: #2a2722;
    --sbx-label-halo: rgba(20, 22, 25, 0.9);
    --sbx-tape: #d8ab22;
    --sbx-hole: #120c05;
    --sbx-hole-rim: #c7a978;
    --sbx-paper: #20232a;
    --sbx-paper-line: rgba(169, 196, 240, 0.07);
    --sbx-clip: #6b737b;
    --sbx-stage: #171a1e;
    --sbx-stage-dot: rgba(255, 255, 255, 0.05);
    --sbx-live: rgba(255, 176, 30, 0.6);
  }
}
:root[data-theme="dark"] {
  --sbx-cavity: #3a3428;
  --sbx-fleck: rgba(255, 230, 180, 0.08);
  --sbx-wood: #9a7547;
  --sbx-wood-edge: #6b4e2a;
  --sbx-grain: rgba(40, 24, 6, 0.4);
  --sbx-plate: #8c6a3f;
  --sbx-joist: #82623a;
  --sbx-attic: #2a2722;
  --sbx-label-halo: rgba(20, 22, 25, 0.9);
  --sbx-tape: #d8ab22;
  --sbx-hole: #120c05;
  --sbx-hole-rim: #c7a978;
  --sbx-paper: #20232a;
  --sbx-paper-line: rgba(169, 196, 240, 0.07);
  --sbx-clip: #6b737b;
  --sbx-stage: #171a1e;
  --sbx-stage-dot: rgba(255, 255, 255, 0.05);
  --sbx-live: rgba(255, 176, 30, 0.6);
}

/* ---------- page ---------- */
.sbx-view { --maxw: 1440px; max-width: var(--maxw); padding-top: 16px; }
.sbx-view, .bx-dialog { -webkit-tap-highlight-color: transparent; }
body.has-dialog { overflow: hidden; }

/* ---------- job header ---------- */
.sbx-job { display: grid; gap: 8px; margin-bottom: 14px; padding: 14px 16px; }
.sbx-job-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sbx-eyebrow { margin: 0; }
.sbx-eyebrow .icon { width: 16px; height: 16px; }
.sbx-jobs-toggle { gap: 8px; }
.sbx-jobs-toggle .chev { width: 18px; height: 18px; transition: transform 0.15s; }
.sbx-jobs-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sbx-jobs-count { font-weight: 600; color: var(--muted); font-size: 0.8rem; }
.sbx-job-title { margin: 2px 0 0; font-size: 1.45rem; }
.sbx-job-title:focus { outline: none; }
.sbx-job-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sbx-job-meta .pill .icon { width: 1em; height: 1em; }
.sbx-job-body { display: grid; gap: 12px; margin-top: 4px; }
.sbx-job-text { min-width: 0; }
.sbx-job-intro { margin: 0 0 6px; max-width: 64em; }
.sbx-task { margin: 0; padding-left: 1.2rem; display: grid; gap: 2px; font-size: 0.95rem; }
.sbx-hints { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); align-self: start; min-width: 0; }
.sbx-hints .section-title { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sbx-hints .section-title .icon { width: 16px; height: 16px; color: var(--warn-text); }
.sbx-hint-list { margin: 0 0 8px; padding-left: 1.2rem; display: grid; gap: 4px; font-size: 0.92rem; }
@media (min-width: 900px) {
  .sbx-job-body { grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; }
}

.sbx-jobs { border-top: 1px solid var(--border); padding-top: 10px; }
.sbx-joblist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.sbx-jobbtn {
  width: 100%; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; text-align: left;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer;
}
.sbx-jobbtn:hover { border-color: var(--accent); }
.sbx-jobbtn.is-current { border-color: var(--accent); background: var(--accent-soft); }
.sbx-jobnum { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-3); font-weight: 800; font-size: 0.85rem; }
.sbx-jobbtn.is-done .sbx-jobnum { background: var(--ok); color: #fff; }
.sbx-jobnum .icon { width: 16px; height: 16px; }
.sbx-jobtext { display: grid; min-width: 0; flex: 1; }
.sbx-jobname { font-weight: 700; line-height: 1.25; }
.sbx-jobsub { font-size: 0.78rem; color: var(--muted); }

/* ---------- three panels ---------- */
.sbx-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "tools" "wall" "test" "lists"; align-items: start; }
.sbx-tools { grid-area: tools; display: grid; gap: 10px; padding: 12px; min-width: 0; }
.sbx-wall { grid-area: wall; padding: 10px; min-width: 0; }
.sbx-lists { grid-area: lists; padding: 12px; min-width: 0; display: grid; gap: 8px; }
.sbx-test { grid-area: test; min-width: 0; position: relative; }
.sbx-tools .section-title, .sbx-lists .section-title { margin: 0; }
@media (min-width: 1100px) {
  .sbx-layout {
    grid-template-columns: 228px minmax(0, 1fr) 330px;
    grid-template-areas: "tools wall test" "lists wall test";
    grid-template-rows: auto 1fr;
  }
  .sbx-test { position: sticky; top: 12px; }
  .sbx-test-paper { max-height: calc(100vh - 40px); overflow: auto; overscroll-behavior: contain; }
}

/* tools */
.sbx-toolseg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sbx-tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 6px 4px;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 700; font-size: 0.78rem; position: relative;
}
.sbx-tool:hover { border-color: var(--muted); }
.sbx-tool .icon { width: 20px; height: 20px; }
.sbx-tool[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.sbx-tool-key { position: absolute; top: 3px; right: 3px; font-size: 0.62rem; min-width: 1.3em; padding: 0 3px; display: none; }
@media (hover: hover) and (pointer: fine) { .sbx-tool-key { display: inline-block; } }
@media (min-width: 1100px) {
  .sbx-toolseg { grid-template-columns: 1fr 1fr; }
}
.sbx-cabletypes { display: flex; flex-wrap: wrap; gap: 6px; }
.sbx-cable-chip { min-height: 40px; }
.sbx-history { gap: 6px; }
.sbx-history .btn { padding-left: 10px; padding-right: 10px; }
.sbx-history .icon { width: 16px; height: 16px; }
.sbx-reset { margin-left: auto; }
.sbx-reset-confirm { padding: 10px 12px; }

/* swatches used in legends and chips */
.sbx-sw { display: inline-block; width: 22px; height: 9px; border-radius: 5px; flex: none; vertical-align: middle; border: 1.5px solid; position: relative; }
.sbx-sw.is-nm14 { background: #f2efe6; border-color: #7f796c; }
.sbx-sw.is-nm12 { background: #f4c63d; border-color: #8d6c0d; }
.sbx-sw.is-three, .sbx-sw.has-stripe { background-image: linear-gradient(transparent 3px, #c92a2a 3px, #c92a2a 4.5px, transparent 4.5px); }
.sbx-sw.is-three { background-color: #f2efe6; border-color: #7f796c; }
.sbx-sw.is-hole { width: 12px; height: 12px; border-radius: 50%; background: var(--sbx-hole); border: 2px solid var(--sbx-hole-rim); }
.sbx-sw.is-staple { width: 14px; height: 9px; border: 2.5px solid #6b7280; border-bottom: 0; border-radius: 7px 7px 0 0; background: none; }

/* lists */
.sbx-boxlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sbx-boxbtn {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer;
}
.sbx-boxbtn:hover { border-color: var(--accent); }
.sbx-boxbtn > .icon { color: var(--muted); }
.sbx-boxbtn-text { display: grid; min-width: 0; line-height: 1.25; }
.sbx-boxbtn-text span { font-size: 0.8rem; color: var(--muted); }
.sbx-cablelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sbx-cableitem { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface-2); display: grid; gap: 6px; min-width: 0; }
.sbx-cableitem-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sbx-cableitem-title { flex: 1; min-width: 0; font-size: 0.88rem; }
.sbx-rm { min-height: 36px; padding: 4px 8px; }
.sbx-rm .icon { width: 16px; height: 16px; }
.sbx-runs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sbx-run { display: grid; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 0.85rem; }
.sbx-run-title { font-weight: 700; }
.sbx-staples { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sbx-staple-chip { min-height: 30px; padding: 3px 8px; font-size: 0.8rem; gap: 4px; }
.sbx-staple-chip .icon { width: 12px; height: 12px; }
.sbx-run-add { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sbx-pos { width: 76px; min-height: 36px; }
.sbx-run-none { margin: 0; }
@media (min-width: 720px) and (max-width: 1099px) {
  .sbx-lists { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); column-gap: 16px; }
  .sbx-lists > .section-title:nth-of-type(1) { grid-column: 1; grid-row: 1; }
  .sbx-lists > .sbx-boxlist { grid-column: 1; grid-row: 2; align-self: start; }
  .sbx-lists > .section-title:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .sbx-lists > .sbx-cablelist { grid-column: 2; grid-row: 2; }
}

/* ---------- wall view ---------- */
.sbx-wall-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 2px 4px 0; }
.sbx-wall-head .section-title { margin: 0; }
.sbx-wall-scale { font-size: 0.78rem; color: var(--muted); }
.sbx-wall-status { margin: 4px 4px 8px; min-height: 1.5em; font-size: 0.9rem; font-weight: 600; color: var(--text); }
.sbx-wall-wrap { position: relative; border-radius: 8px; overflow: hidden; background: var(--sbx-attic); border: 1px solid var(--border); }
.sbx-wall-svg { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sbx-wall-wrap[data-tool="run"] .sbx-wall-svg, .sbx-wall-wrap[data-tool="staple"] .sbx-wall-svg { cursor: crosshair; }
.sbx-wall-wrap[data-tool="remove"] .sbx-wall-svg { cursor: not-allowed; }
.sbx-wall-wrap[data-tool="remove"] .sbx-cable-hit, .sbx-wall-wrap[data-tool="remove"] .sbx-staple { cursor: pointer; }
.sbx-wall-svg text { font-family: var(--font); }
.sbx-cavity { fill: var(--sbx-cavity); }
.sbx-cavity-fleck { stroke: var(--sbx-fleck); stroke-width: 1.2; fill: none; stroke-linecap: round; }
.sbx-attic { fill: var(--sbx-attic); }
.sbx-stud, .sbx-plate { fill: var(--sbx-wood); stroke: var(--sbx-wood-edge); stroke-width: 0.8; }
.sbx-plate { fill: var(--sbx-plate); }
.sbx-joist { fill: var(--sbx-joist); stroke: var(--sbx-wood-edge); stroke-width: 0.8; }
.sbx-grain { stroke: var(--sbx-grain); stroke-width: 0.7; fill: none; }
.sbx-band-label { font-size: 10px; font-weight: 700; fill: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.sbx-tape { fill: var(--sbx-tape); stroke: #8d6c0d; stroke-width: 1; }
.sbx-tape-tick { stroke: var(--sbx-tape-ink); stroke-width: 0.8; fill: none; }
.sbx-tape-stud { fill: #c92a2a; }
.sbx-tape-num { font-size: 9.5px; font-weight: 800; fill: var(--sbx-tape-ink); font-family: var(--mono); }
.sbx-hole { fill: var(--sbx-hole); }
.sbx-hole-rim { fill: var(--sbx-hole-rim); opacity: 0.9; }

.sbx-hit { fill: transparent; }
.sbx-box { cursor: pointer; outline: none; }
.sbx-box-ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.sbx-box:hover .sbx-box-ring { stroke: var(--accent); stroke-dasharray: 4 3; }
.sbx-box:focus-visible .sbx-box-ring { stroke: var(--accent); stroke-width: 3; }
.sbx-box.is-from .sbx-box-ring { stroke: var(--accent); stroke-width: 3; stroke-dasharray: none; }
.sbx-boxshape.is-plastic { fill: #2f6fbd; stroke: #173f73; stroke-width: 1; }
.sbx-boxshape.is-metal { fill: #9aa1a9; stroke: #4d545b; stroke-width: 1; }
.sbx-mudring { fill: #c3c8cd; stroke: #6c737a; stroke-width: 0.8; }
.sbx-nailtab { fill: none; stroke: #173f73; stroke-width: 1.2; }
.sbx-panel-can { fill: #858c94; stroke: #3f454b; stroke-width: 1.2; }
.sbx-panel-dead { fill: #b8bec4; stroke: #6c737a; stroke-width: 0.8; }
.sbx-panel-slot { fill: #3a3f45; }
.sbx-panel-slot.is-used { fill: #e8590c; }
.sbx-panel-text { font-size: 10px; font-weight: 800; fill: #1c1e21; letter-spacing: 0.04em; text-transform: uppercase; }
.sbx-box-label { font-size: 10.5px; font-weight: 700; fill: var(--text); paint-order: stroke; stroke: var(--sbx-label-halo); stroke-width: 3.2px; stroke-linejoin: round; }
.sbx-icon-plate { fill: #f6f3ea; stroke: #8a8475; stroke-width: 0.6; }
.sbx-icon-face { fill: none; stroke: #5a554b; stroke-width: 0.9; }
.sbx-icon-btn { fill: #343a40; }
.sbx-icon-toggle { fill: #5a554b; }
.sbx-icon-num { font-size: 5px; font-weight: 800; fill: #2b2b2b; }
.sbx-icon-bulb { fill: #f8f9fa; stroke: #adb5bd; stroke-width: 1; }
.sbx-icon-bulb.is-on { fill: #ffd43b; stroke: #e8590c; }
.sbx-glow { fill: #ffd43b; opacity: 0.35; }

/* the drawn cable lets the pointer through: its hit stroke, in a layer under the boxes, takes the clicks */
.sbx-cable { outline: none; pointer-events: none; }
.sbx-cable-hit { fill: none; stroke: transparent; stroke-width: 14; stroke-linejoin: round; cursor: pointer; }
/* drawn feedback only: markers, badges, highlights and previews never catch a click meant for what is under them */
.sbx-marks, .sbx-preview { pointer-events: none; }
.sbx-cable-focus { fill: none; stroke: transparent; stroke-width: 9; stroke-linejoin: round; stroke-linecap: round; }
.sbx-cable:focus-visible .sbx-cable-focus { stroke: var(--accent); }
.sbx-staple { outline: none; }
.sbx-staple-hit { fill: transparent; }
.sbx-staple-focus { fill: none; stroke: transparent; stroke-width: 2.5; }
.sbx-staple:focus-visible .sbx-staple-focus { stroke: var(--accent); }
.sbx-staple-crown { fill: none; stroke: #4b5563; stroke-width: 2.2; stroke-linecap: round; }
.sbx-staple-legs { stroke: #374151; stroke-width: 1.6; stroke-linecap: round; }
.sbx-staple-crown.is-ghost, .sbx-staple-legs.is-ghost { stroke: var(--accent); }
.sbx-preview-path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 7 5; stroke-linejoin: round; stroke-linecap: round; animation: sbx-march 0.8s linear infinite; }
.sbx-preview-path.is-free { stroke-width: 2; opacity: 0.8; }
.sbx-preview-text { font-size: 11px; font-weight: 800; fill: var(--accent-text); paint-order: stroke; stroke: var(--sbx-label-halo); stroke-width: 3.5px; }
.sbx-remove-ring { fill: rgba(224, 49, 49, 0.18); stroke: var(--bad); stroke-width: 2.4; }
.sbx-remove-path { fill: none; stroke: var(--bad); stroke-width: 7; stroke-opacity: 0.55; stroke-linejoin: round; stroke-linecap: round; }
@keyframes sbx-march { to { stroke-dashoffset: -24; } }

.sbx-mark { stroke: #fff; stroke-width: 1.6; }
.sbx-mark.is-bad { fill: var(--bad); }
.sbx-mark.is-warn { fill: var(--warn); }
.sbx-mark-pulse { fill: none; stroke-width: 2; animation: sbx-pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.sbx-mark-pulse.is-bad { stroke: var(--bad); }
.sbx-mark-pulse.is-warn { stroke: var(--warn); }
.sbx-mark-glyph { font-size: 9px; font-weight: 900; fill: #fff; pointer-events: none; }
.sbx-badge { stroke: #fff; stroke-width: 1.4; }
.sbx-badge.is-ok { fill: var(--ok); }
.sbx-badge.is-bad { fill: var(--bad); }
.sbx-badge-glyph { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.is-stale { opacity: 0.45; }
.sbx-flash-ring { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: 6 4; animation: sbx-march 0.6s linear infinite; }
.sbx-flash-path { fill: none; stroke: var(--accent); stroke-width: 9; stroke-opacity: 0.55; stroke-linejoin: round; stroke-linecap: round; animation: sbx-blink 0.9s ease-in-out infinite alternate; }
@keyframes sbx-pulse { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
@keyframes sbx-blink { from { stroke-opacity: 0.2; } to { stroke-opacity: 0.7; } }

.sbx-tip {
  position: absolute; z-index: 3; pointer-events: none; max-width: 260px; padding: 5px 9px; border-radius: 6px;
  background: rgba(20, 22, 25, 0.88); color: #fff; font-size: 0.78rem; font-weight: 600; line-height: 1.3; white-space: normal;
}
.sbx-legend { list-style: none; margin: 8px 4px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--muted); }
.sbx-legend li { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- test panel: the inspector's clipboard ---------- */
.sbx-test { padding-top: 14px; }
.sbx-clip {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 110px; height: 24px; z-index: 2;
  border-radius: 7px 7px 4px 4px; background: linear-gradient(var(--sbx-clip), #5d646b); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.sbx-clip::after { content: ""; position: absolute; left: 50%; top: 5px; width: 34px; height: 8px; transform: translateX(-50%); border-radius: 4px; background: var(--bg); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4); }
.sbx-test-paper {
  border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 14px 14px;
  background-color: var(--sbx-paper);
  background-image: repeating-linear-gradient(transparent 0 27px, var(--sbx-paper-line) 27px 28px);
  display: grid; gap: 10px;
}
.sbx-test-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--text); padding-bottom: 4px; }
.sbx-test-title { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; text-transform: uppercase; }
.sbx-test-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.sbx-test-body { display: grid; gap: 8px; }
.sbx-test-row, .sbx-devrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.sbx-test-label { display: grid; min-width: 0; line-height: 1.25; }
.sbx-test-label .small { font-size: 0.78rem; }
.sbx-devlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sbx-devrow { padding: 8px 0; border-top: 1px dashed var(--border-strong); flex-wrap: wrap; }
.sbx-devrow.is-tester { align-items: flex-start; }
.sbx-tester-wrap { display: grid; justify-items: end; gap: 4px; }
.sbx-tester { width: 128px; height: auto; display: block; }
.sbx-tester-name .icon { width: 1em; height: 1em; }
.sbx-bulb-wrap { display: inline-flex; align-items: center; gap: 8px; }
.sbx-bulb { width: 30px; height: 36px; color: var(--muted); }
.sbx-switch {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; min-width: 92px; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface-3); color: var(--text); cursor: pointer; font-weight: 800; font-size: 0.8rem; font-family: var(--mono);
}
.sbx-switch-knob { width: 30px; height: 30px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; flex: none; }
.sbx-switch.is-on { background: var(--ok); border-color: var(--ok); color: #fff; }
.sbx-switch.is-on .sbx-switch-knob { transform: translateX(2px); }
.sbx-switch.is-ab.is-on { background: #3b82c4; border-color: #3b82c4; }
.sbx-fault { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--bad); color: #fff; }
.sbx-fault .icon { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.sbx-fault p { margin: 2px 0 0; font-size: 0.88rem; }
/* a GFCI tripped on purpose with its TEST button: a notice, not a fault */
.sbx-fault.is-test { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.sbx-fault.is-test .icon { color: var(--bad); }
.sbx-devrow > .sbx-gfci-btn { margin-left: auto; align-self: center; min-width: 74px; font-weight: 800; letter-spacing: 0.04em; }
.sbx-devrow > .pill + .sbx-gfci-btn { margin-left: 8px; }
.sbx-gfci-btn.is-tripped { border-color: var(--bad); color: var(--bad); }
.sbx-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--info-soft); color: var(--text); font-size: 0.85rem; }
.sbx-note .icon { color: var(--info-text); width: 18px; height: 18px; flex: none; }
.sbx-check { width: 100%; }
.sbx-results { display: grid; gap: 8px; }
.sbx-results-empty { margin: 0; }
.sbx-score { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 2px solid; }
.sbx-score:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.sbx-score.is-complete, .sbx-score.is-clean { border-color: var(--ok); background: var(--ok-soft); }
.sbx-score.is-open { border-color: var(--bad); background: var(--bad-soft); }
.sbx-score.is-stale { opacity: 0.6; }
.sbx-score-icon { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; flex: none; }
.sbx-score.is-complete .sbx-score-icon, .sbx-score.is-clean .sbx-score-icon { background: var(--ok); }
.sbx-score.is-open .sbx-score-icon { background: var(--bad); }
.sbx-score-icon .icon { width: 20px; height: 20px; }
.sbx-score-text { display: grid; min-width: 0; }
.sbx-score-title { font-size: 1.15rem; }
.sbx-score.is-complete .sbx-score-title { color: var(--ok-text); }
.sbx-score.is-open .sbx-score-title { color: var(--bad-text); }
.sbx-score-sub { font-size: 0.8rem; color: var(--muted); font-family: var(--mono); }
.sbx-stale-note { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--warn-text); font-weight: 600; }
.sbx-stale-note .icon { width: 16px; height: 16px; }
.sbx-res-h { margin: 6px 0 0; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sbx-res-h.is-violation { color: var(--bad-text); }
.sbx-res-h.is-warning { color: var(--warn-text); }
.sbx-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sbx-goals li { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; }
.sbx-goal-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; margin-top: 1px; }
.sbx-goals .is-pass .sbx-goal-mark { background: var(--ok); }
.sbx-goals .is-fail .sbx-goal-mark { background: var(--bad); }
.sbx-goal-mark .icon { width: 14px; height: 14px; }
.sbx-goal-detail { display: block; font-size: 0.8rem; color: var(--muted); }
.sbx-findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sbx-finding { display: grid; gap: 2px; }
.sbx-finding-btn {
  display: grid; gap: 4px; justify-items: start; width: 100%; text-align: left; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.88rem;
}
.sbx-finding-btn:hover { border-color: var(--accent); }
.sbx-finding-btn[aria-disabled="true"] { cursor: default; }
.sbx-finding.is-violation .sbx-finding-btn { border-left-color: var(--bad); }
.sbx-finding.is-warning .sbx-finding-btn { border-left-color: var(--warn); }
.sbx-finding.is-tip .sbx-finding-btn { border-left-color: var(--info-text); }
.sbx-finding-top { display: flex; gap: 6px; align-items: flex-start; }
.sbx-sev .icon { width: 16px; height: 16px; margin-top: 2px; }
.sbx-finding.is-violation .sbx-sev { color: var(--bad-text); }
.sbx-finding.is-warning .sbx-sev { color: var(--warn-text); }
.sbx-finding.is-tip .sbx-sev { color: var(--info-text); }
.sbx-finding-title { line-height: 1.3; }
.sbx-nec { display: inline-block; padding: 2px 7px; border-radius: 4px; background: var(--text); color: var(--surface); font-family: var(--mono); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; }
.sbx-finding-detail { color: var(--text); line-height: 1.4; }
.sbx-finding-ref { font-size: 0.75rem; color: var(--muted); }
.sbx-openbox { justify-self: start; min-height: 32px; padding: 3px 8px; font-size: 0.8rem; }
.sbx-openbox .icon { width: 15px; height: 15px; }
.sbx-solution, .sbx-solution-note { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); display: grid; gap: 8px; justify-items: start; margin: 0; font-size: 0.88rem; }
.sbx-solution-note { display: flex; gap: 8px; align-items: flex-start; }
.sbx-solution-note .icon, .sbx-solution-btn .icon { width: 18px; height: 18px; flex: none; }
.sbx-solution p { margin: 0; }

/* ---------- box view dialog ---------- */
.bx-dialog {
  width: min(1120px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.bx-dialog:not([open]) { display: none; }
.bx-dialog::backdrop { background: rgba(10, 12, 14, 0.62); }
.bx-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.bx-head-text { flex: 1; min-width: 0; }
.bx-title { margin: 0; font-size: 1.15rem; }
.bx-sub { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.bx-close { flex: none; }
.bx-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.bx-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bx-group-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.bx-chip { min-height: 36px; }
.bx-device-name { font-size: 0.92rem; }
.bx-seg button { min-height: 34px; padding: 5px 12px; }
.bx-status { padding: 6px 14px; min-height: 46px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.bx-hint { margin: 0; font-size: 0.85rem; color: var(--muted); }
.bx-hint strong { color: var(--text); }
.bx-kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .bx-kbd-hint { display: inline; } }
.bx-selrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; width: 100%; }
.bx-seltext { margin: 0; font-size: 0.88rem; flex: 1 1 260px; min-width: 0; }
.bx-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.45); flex: none; vertical-align: -3px; }
.bx-acts { gap: 6px; }
.bx-acts .btn { min-height: 36px; }
.bx-pig-btn { gap: 6px; }
.bx-stage {
  flex: 1 1 auto; min-height: 0; position: relative; padding: 6px;
  background-color: var(--sbx-stage);
  background-image: radial-gradient(var(--sbx-stage-dot) 1px, transparent 1.2px);
  background-size: 16px 16px;
}
.bx-svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.bx-svg text { font-family: var(--font); pointer-events: none; }
.bx-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 8px 14px 10px; border-top: 1px solid var(--border); }
.bx-fill { flex: 1 1 300px; min-width: 0; display: grid; gap: 4px; }
.bx-fill-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bx-fill-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.bx-fill-num { font-family: var(--mono); font-weight: 800; font-size: 0.9rem; }
.bx-fill-bar { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--border); }
.bx-fill-bar > span { display: block; height: 100%; background: var(--ok); transition: width 0.2s; }
.bx-fill.is-over .bx-fill-bar > span { background: var(--bad); }
.bx-fill.is-over .bx-fill-num { color: var(--bad-text); }
.bx-fill-items { font-size: 0.8rem; }
.bx-fill-items summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.bx-fill-items ul { margin: 4px 0 0; padding-left: 1.1rem; }
.bx-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; color: var(--muted); }
.bx-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.bx-screw-swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1.5px solid rgba(0, 0, 0, 0.5); }
.bx-screw-swatch.is-brass { background: radial-gradient(circle at 35% 35%, #f6d37a, #b07f1c); }
.bx-screw-swatch.is-silver { background: radial-gradient(circle at 35% 35%, #fbfcfd, #9aa1a9); }
.bx-screw-swatch.is-green { background: radial-gradient(circle at 35% 35%, #6fdc87, #1f7a36); }
.bx-screw-swatch.is-black { background: radial-gradient(circle at 35% 35%, #777, #151515); }
.bx-live-swatch { width: 18px; height: 8px; border-radius: 4px; background: #26272b; box-shadow: 0 0 0 3px var(--sbx-live); display: inline-block; }

/* drawing: box shell */
.bx-shell.is-plastic { fill: #2b66b1; stroke: #143a6b; stroke-width: 2.5; }
.bx-back.is-plastic { fill: #3d7cc6; }
.bx-shell.is-metal { fill: #8f969e; stroke: #474e55; stroke-width: 2.5; }
.bx-back.is-metal { fill: #b4bac0; }
.bx-shell.is-panel { fill: #7a8189; stroke: #3b4147; stroke-width: 2.5; }
.bx-back.is-panel { fill: #a3a9b0; }
.bx-rib { stroke: rgba(10, 30, 60, 0.35); stroke-width: 2; fill: none; }
.bx-ko { fill: none; stroke: rgba(40, 45, 50, 0.35); stroke-width: 2; }
.bx-mark-text { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; fill: rgba(255, 255, 255, 0.55); }
.bx-back.is-metal ~ .bx-mark-text, .bx-shell.is-metal ~ .bx-mark-text { fill: rgba(30, 35, 40, 0.5); }
.bx-sheath { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.bx-clamp { fill: #c3c8cd; stroke: #5d646b; stroke-width: 1.5; }
.bx-clamp-screw { fill: #8d959c; stroke: #3f454b; }
.bx-ko-tab { fill: rgba(10, 30, 60, 0.35); stroke: rgba(10, 30, 60, 0.6); stroke-width: 1.5; }
.bx-label { font-size: 12px; font-weight: 800; fill: var(--text); paint-order: stroke; stroke: var(--sbx-stage); stroke-width: 4px; stroke-linejoin: round; letter-spacing: 0.02em; }
.bx-label-sm { font-size: 10.5px; fill: #e9f7ec; stroke: rgba(0, 0, 0, 0.55); }
.bx-entry-label { font-size: 12.5px; }
.bx-term-label { font-size: 11px; fill: var(--text); }
.bx-dev-text { font-size: 11.5px; font-weight: 800; fill: #3a3632; stroke: none; letter-spacing: 0.04em; }
.bx-dev-text.is-tiny { font-size: 9.5px; }
.bx-dev-text.is-light { fill: #f1f3f5; }
.bx-dev-text.is-warn { fill: #c62828; font-size: 12px; }
.bx-dev-text.is-on { fill: #b35c00; }
.bx-labels .bx-dev-text { paint-order: normal; }
.bx-empty-text { font-size: 15px; font-weight: 800; fill: rgba(255, 255, 255, 0.9); }
.bx-empty-text.is-sub { font-size: 12.5px; font-weight: 600; fill: rgba(255, 255, 255, 0.78); }
.bx-nodev { fill: none; stroke: var(--border-strong); stroke-width: 2; stroke-dasharray: 8 6; }
.bx-nodev ~ .bx-empty-text { fill: var(--muted); }
.bx-washer { fill: rgba(0, 0, 0, 0.18); }
.bx-yoke { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.bx-contact { stroke: #c92a2a; stroke-width: 3; stroke-linecap: round; fill: none; }
.bx-contact-dot { fill: #c92a2a; }
.bx-lead-tip { fill: #c97a3b; stroke: #6e3a12; stroke-width: 1.5; }
.bx-bar-hole { fill: #2b2f33; stroke: #111; }
.bx-tape-text { font-size: 13px; font-weight: 900; fill: #5c4300; letter-spacing: 0.08em; }
.bx-tape-text.is-sub { font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; }
.bx-nut-count { font-size: 12px; font-weight: 900; fill: rgba(0, 0, 0, 0.7); }
.bx-nut-warn { font-size: 13px; font-weight: 900; fill: #fff; }

/* drawing: interaction states */
.bx-hit, .bx-term-hit, .bx-tab-hit { fill: transparent; }
.bx-end { cursor: grab; outline: none; }
.bx-svg.is-dragging, .bx-svg.is-dragging .bx-end { cursor: grabbing; }
.bx-end-shadow { fill: rgba(0, 0, 0, 0.28); }
.bx-end-letter { font-weight: 900; font-family: var(--font); }
.bx-sel-ring { fill: none; stroke: transparent; stroke-width: 3.5; }
.bx-end:hover .bx-sel-ring, .bx-nut:hover .bx-sel-ring { stroke: rgba(232, 89, 12, 0.55); }
.bx-end:focus-visible .bx-sel-ring, .bx-nut:focus-visible .bx-sel-ring { stroke: var(--accent); stroke-dasharray: 4 3; }
.bx-end.is-selected .bx-sel-ring, .bx-nut.is-selected .bx-sel-ring { stroke: var(--accent); stroke-width: 4.5; stroke-dasharray: 6 4; animation: sbx-march 0.7s linear infinite; }
.bx-end.is-dragged .bx-end-body { stroke: var(--accent); stroke-width: 3; }
.bx-target-ring { fill: none; stroke: transparent; stroke-width: 3; pointer-events: none; }
.has-sel .is-target .bx-target-ring { stroke: #2fbf55; stroke-dasharray: 5 4; animation: sbx-march 0.9s linear infinite; }
.has-sel .bx-end.is-target .bx-sel-ring { stroke: #2fbf55; stroke-dasharray: 5 4; animation: sbx-march 0.9s linear infinite; }
.is-target:focus-visible .bx-target-ring, .bx-end.is-target:focus-visible .bx-sel-ring { stroke: var(--accent); stroke-width: 4.5; stroke-dasharray: none; }
.is-hot .bx-target-ring, .bx-end.is-hot .bx-sel-ring { stroke: #2fbf55 !important; stroke-width: 6 !important; fill: rgba(47, 191, 85, 0.22) !important; stroke-dasharray: none !important; }
.is-hot-bad .bx-target-ring, .bx-end.is-hot-bad .bx-sel-ring { stroke: var(--bad) !important; stroke-width: 5 !important; fill: rgba(224, 49, 49, 0.18) !important; stroke-dasharray: none !important; }
.bx-term { cursor: pointer; outline: none; }
.bx-term:focus-visible .bx-target-ring { stroke: var(--accent); stroke-width: 4; }
.has-sel .bx-term.is-blocked { opacity: 0.55; }
.bx-nut { cursor: pointer; outline: none; }
.bx-tab { cursor: pointer; outline: none; }
.bx-gfci-btn { cursor: pointer; }
.bx-gfci-btn:active .bx-gfci-face { transform: translateY(1.5px); }
.bx-tab-focus { fill: none; stroke: transparent; stroke-width: 2.5; }
.bx-tab:hover .bx-tab-focus { stroke: rgba(232, 89, 12, 0.6); }
.bx-tab:focus-visible .bx-tab-focus { stroke: var(--accent); stroke-width: 3; }
.bx-wire { pointer-events: none; }
.bx-wire-glow { fill: none; stroke: var(--sbx-live); stroke-linecap: round; stroke-linejoin: round; }
.bx-wire.is-fault .bx-wire-glow { stroke: rgba(224, 49, 49, 0.6); animation: sbx-blink 0.6s ease-in-out infinite alternate; }

/* phones: the box view is full screen */
@media (max-width: 719px) {
  .bx-dialog { width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; max-height: 100vh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .bx-head { padding: 8px 10px 6px; }
  .bx-title { font-size: 1.02rem; }
  .bx-sub { font-size: 0.78rem; }
  .bx-bar { padding: 6px 10px; gap: 6px 12px; }
  .bx-status { padding: 4px 10px; min-height: 40px; }
  .bx-hint { font-size: 0.8rem; }
  .bx-stage { padding: 2px; }
  .bx-foot { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .bx-legend { display: none; }
  .sbx-job-title { font-size: 1.25rem; }
  .sbx-tool { min-height: 50px; font-size: 0.74rem; }
}
@media (max-width: 380px) {
  .bx-chip { padding-left: 9px; padding-right: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .sbx-preview-path, .sbx-mark-pulse, .sbx-flash-ring, .sbx-flash-path, .bx-end.is-selected .bx-sel-ring, .has-sel .is-target .bx-target-ring { animation: none; }
}

@media print {
  .sbx-tools, .sbx-lists, .bx-dialog { display: none !important; }
}

/* ---------- refinements ---------- */
.sbx-panel-bus { fill: #c9a227; opacity: 0.7; }
.sbx-brief > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 36px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sbx-brief > summary::-webkit-details-marker { display: none; }
.sbx-brief > summary .chev { width: 16px; height: 16px; transition: transform 0.15s; }
.sbx-brief[open] > summary .chev { transform: rotate(180deg); }
.sbx-brief .sbx-job-intro { font-size: 0.95rem; line-height: 1.45; }
.sbx-brief .sbx-task { font-size: 0.9rem; line-height: 1.4; }
.sbx-run-add { flex-wrap: nowrap; }
.sbx-pos { width: 64px; flex: none; padding-left: 6px; padding-right: 4px; }
.sbx-cableitem-title { font-size: 0.84rem; line-height: 1.3; }
.sbx-in { white-space: nowrap; }
.sbx-run-add .btn { flex: none; }
.sbx-joist { stroke: var(--sbx-wood-edge); stroke-width: 0.8; }
.sbx-joist-fill { fill: var(--sbx-joist); }
.sbx-joist-hatch { stroke: var(--sbx-wood-edge); stroke-width: 1.4; opacity: 0.55; }
.sbx-ceiling-line { fill: #9aa1a9; }
.bx-mark-text { font-size: 11px; }
.bx-head, .bx-bar, .bx-status, .bx-foot { flex: none; }
:root[data-theme="dark"] .sbx-staple-crown { stroke: #c4cad1; }
:root[data-theme="dark"] .sbx-staple-legs { stroke: #9aa1a9; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sbx-staple-crown { stroke: #c4cad1; }
  :root:not([data-theme="light"]) .sbx-staple-legs { stroke: #9aa1a9; }
}
@media (max-width: 719px) {
  .bx-bar .btn-sm, .bx-chip { min-height: 34px; padding: 4px 10px; font-size: 0.82rem; }
  .bx-group-label { font-size: 0.66rem; }
}
.sbx-box-label { font-size: var(--sbx-lbl, 10.5px); stroke-width: calc(var(--sbx-lbl, 10.5px) * 0.32); }
.sbx-wall-wrap.is-zoomed { overflow-x: auto; overscroll-behavior-x: contain; }
.sbx-wall-wrap.is-zoomed .sbx-wall-svg { max-width: none; }
.sbx-wall-head .sbx-wall-scale { margin-right: auto; }
.sbx-zoom { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
@media (max-width: 479px) { .sbx-wall-scale { display: none; } .sbx-wall-head .section-title { margin-right: auto; } }
.sbx-switch-knob { background: #ffffff; }
.bx-tip-edge { stroke: #6e3a12; stroke-width: 5.2; stroke-linecap: round; fill: none; }
.bx-tip { stroke: #e0995a; stroke-width: 3.2; stroke-linecap: round; fill: none; }
.sbx-switch.is-tripped { background: var(--bad); border-color: var(--bad); color: #fff; }
.sbx-halves { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.sbx-half { font-size: 0.72rem; font-weight: 700; }
.sbx-devnote { flex-basis: 100%; text-align: right; font-size: 0.78rem; }
.sbx-devrow > .pill { margin-left: auto; }
.sbx-devrow > .sbx-tester-wrap, .sbx-devrow > .sbx-halves, .sbx-devrow > .sbx-bulb-wrap, .sbx-devrow > .sbx-switch { margin-left: auto; }

/* ---------- review pass: weights that follow the drawn size of the wall (--sbx-k is set by the wall view) ---------- */
.sbx-preview-path { stroke-width: calc(3px * var(--sbx-k, 1)); }
.sbx-preview-path.is-free { stroke-width: calc(2px * var(--sbx-k, 1)); }
.sbx-remove-path { stroke-width: calc(7px * var(--sbx-k, 1)); }
.sbx-flash-path { stroke-width: calc(9px * var(--sbx-k, 1)); }
.sbx-flash-ring { stroke-width: calc(3.5px * var(--sbx-k, 1)); }
.sbx-mark { stroke-width: calc(1.6px * var(--sbx-k, 1)); }
.sbx-box:focus-visible .sbx-box-ring, .sbx-box.is-from .sbx-box-ring { stroke-width: calc(3px * var(--sbx-k, 1)); }
.sbx-preview-text { stroke-width: calc(3.5px * var(--sbx-k, 1)); }
/* empty-box text on a light metal or panel back needs dark ink */
.bx-back.is-metal ~ .bx-empty-text, .bx-back.is-panel ~ .bx-empty-text { fill: #1f2328; }
.bx-back.is-metal ~ .bx-empty-text.is-sub, .bx-back.is-panel ~ .bx-empty-text.is-sub { fill: #3d434a; }
/* hover feedback for everything clickable in the drawings (keyboard focus already has its own ring) */
@media (hover: hover) {
  .sbx-cable.is-hover .sbx-cable-focus { stroke: color-mix(in srgb, var(--accent) 40%, transparent); }
  .sbx-staple:hover .sbx-staple-focus { stroke: color-mix(in srgb, var(--accent) 60%, transparent); }
  .bx-term:hover .bx-target-ring { stroke: rgba(232, 89, 12, 0.55); }
  .sbx-switch:not(:disabled):hover { border-color: var(--accent); }
  .sbx-finding-btn[aria-disabled="true"]:hover { border-color: var(--border); }
}
.sbx-switch:focus-visible { outline-offset: 3px; }
/* the breaker handle before a breaker is chosen: nothing to switch */
.sbx-switch:disabled { cursor: not-allowed; opacity: 0.6; border-style: dashed; }
/* the knob slides to the right when a toggle is on (it used to sit on the left in both states) */
.sbx-switch { justify-content: space-between; }
.sbx-switch.is-on { flex-direction: row-reverse; padding: 4px 4px 4px 12px; }
.sbx-switch.is-on .sbx-switch-knob { transform: none; }

/* ---------- getting started: running the first cable (the start prompt lives in the tool bar, .sbx-status-bar.is-start) ---------- */
/* while Run cable is active every box gets an outlined target the size of its tap area, so small boxes are easy to find */
.sbx-run-target { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); stroke-width: calc(2.5px * var(--sbx-k, 1)); stroke-dasharray: 6 4; pointer-events: none; }
.sbx-run-target.is-from { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke-dasharray: none; stroke-width: calc(3.5px * var(--sbx-k, 1)); }
@media (prefers-reduced-motion: no-preference) {
  .sbx-run-target:not(.is-from) { animation: sbx-run-pulse 1.4s ease-in-out infinite; }
  @keyframes sbx-run-pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.35; } }
}
/* box view: Run cable to ... */
.bx-run-group { padding-right: 6px; }
.bx-run-to { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.bx-run-group.is-empty { padding: 6px 8px; border-radius: 8px; background: var(--accent-soft); }

/* ---------- novice pass: the tool bar above the wall ---------- */
/* The current hint and invisible copies of every other hint share one grid cell, so the bar is always as tall as the
   longest hint and switching tools never moves the wall. The button (Run cable / Cancel / Done) keeps its column even
   when it is hidden, and a min-width that fits its longest label, for the same reason. */
.sbx-status-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; margin: 4px 0 8px; padding: 8px 10px; background: var(--surface); border-radius: 8px; }
.sbx-status-bar > .sbx-wall-status, .sbx-status-sizers { grid-area: 1 / 1; }
.sbx-status-bar > .sbx-wall-status { margin: 0; min-height: 0; line-height: 1.4; }
.sbx-status-sizers { display: grid; visibility: hidden; pointer-events: none; }
.sbx-status-sizers > p { grid-area: 1 / 1; margin: 0; font-size: 0.9rem; font-weight: 600; line-height: 1.4; }
.sbx-status-act { grid-area: 1 / 2; min-width: 8em; justify-content: center; white-space: nowrap; }
.sbx-status-act .icon { width: 16px; height: 16px; }
.sbx-status-act.is-idle { visibility: hidden; }
.sbx-status-probe { height: 0; }
/* an empty wall: the bar is the "Start here" prompt (an inset ring, not a border, so its size never changes) */
.sbx-status-bar.is-start { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
/* wide screens: the bar sticks to the top of the window while the wall scrolls under it */
@media (min-width: 720px) {
  .sbx-status-bar { position: sticky; top: 0; z-index: 5; }
  .sbx-status-bar.is-stuck { border-radius: 0 0 8px 8px; box-shadow: 0 8px 12px -10px rgba(0, 0, 0, 0.5); }
  .sbx-status-bar.is-start.is-stuck { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 12px -10px rgba(0, 0, 0, 0.5); }
}
@media (max-width: 719px) {
  .sbx-status-bar > .sbx-wall-status, .sbx-status-sizers > p { font-size: 0.84rem; line-height: 1.35; }
  .sbx-status-act { min-width: 7.4em; padding-left: 8px; padding-right: 8px; }
}

/* Cables and staples: the distance field says which box it is measured from */
.sbx-run-add { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.sbx-run-add .sbx-in { white-space: normal; overflow-wrap: normal; line-height: 1.2; }
@media (min-width: 1100px) {
  /* the narrow sidebar: "in. from" over the box name, never a word broken in two */
  .sbx-run-add { grid-template-columns: auto minmax(min-content, 1fr) auto; gap: 4px; }
  .sbx-run-add .sbx-pos { width: 46px; }
  .sbx-run-add .sbx-in { font-size: 0.75rem; }
  .sbx-run-add .btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }
}

/* ---------- novice pass: box view ---------- */
/* The status line has a fixed height in every state (hint, selected wire, wire nut menu): selecting a wire never
   shrinks the stage, so the drawing does not move or rescale between a tap on a wire end and the tap on its target.
   The description gets two lines; the actions scroll sideways when they do not fit (a fade says there is more); Cancel
   sits outside them and is always in sight. */
.bx-status { height: 58px; min-height: 0; overflow: hidden; }
.bx-hint { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.bx-selrow { flex-wrap: nowrap; }
.bx-seltext { flex: 1 1 0; min-width: 140px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; line-height: 1.35; }
.bx-acts { flex: 0 1 auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding: 1px; }
.bx-acts:empty { display: none; }
.bx-acts .btn { flex: none; }
.bx-acts.is-scroll { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); padding-right: 24px; }
.bx-sel-cancel { flex: none; }
.bx-next { color: var(--muted); }
.bx-next.is-miss { color: var(--bad-text); font-weight: 700; }
@media (max-width: 719px) {
  .bx-status { height: 88px; align-items: center; }
  .bx-hint { -webkit-line-clamp: 4; }
  .bx-selrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "sw text text" "acts acts cancel"; gap: 4px 8px; align-items: center; }
  .bx-selrow > .bx-swatch { grid-area: sw; }
  .bx-selrow > .bx-seltext { grid-area: text; min-width: 0; font-size: 0.82rem; }
  .bx-selrow > .bx-acts { grid-area: acts; max-width: 100%; }
  .bx-selrow > .bx-sel-cancel { grid-area: cancel; min-height: 32px; }
  .bx-selrow > .bx-acts:empty + .bx-sel-cancel { grid-column: 1 / -1; justify-self: start; }
  .bx-acts .btn { min-height: 32px; padding-top: 3px; padding-bottom: 3px; }
}
/* the breaker handle: the Test panel's switch, a little smaller in the bar */
.bx-handle { min-height: 36px; min-width: 84px; }
.bx-handle .sbx-switch-knob { width: 26px; height: 26px; }
/* messages inside the box view: one compact toast near the bottom, so it hides as little of the drawing as it can */
.bx-dialog .toast-region { bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%; right: auto; transform: translateX(-50%); justify-items: center; max-width: min(560px, calc(100vw - 32px)); }
.bx-dialog .toast { padding: 7px 12px; font-size: 0.82rem; }
