/* ============================================================
   Look D: "The Switchboard Meter" (DESIGN.md, D-29)
   The home page's stylesheet. The other pages keep styles.css
   until the build reaches them (DEVLOG §0, Step line).
   ============================================================ */

@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/barlow-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Michroma'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/michroma-latin-400-normal.woff2') format('woff2'); }

:root {
  /* Primary: the instrument's materials */
  --bakelite: #1b1e1d;
  --panel-steel: #c8cdc7;
  --panel-seam: #a2a8a1;
  /* Secondary */
  --signal-amber: #f2a92b;
  --link-blue: #1f5a85;
  --link-blue-deep: #123f63;
  /* Tertiary: conductor, pencil, bands, lamps */
  --copper: #c47a45;
  --copper-edge: #8a4f28;
  --copper-glint: #ffd3a8;
  --aluminum: #c3c8cb;
  --aluminum-edge: #7c8489;
  --pencil-red: #c8241b;
  --band-green: #3f7d4e;
  --band-amber: #d99a1e;
  --band-red: #b8352a;
  --band-green-text: #2f6a3d;
  --band-amber-text: #7a4d00;
  --band-red-text: #9e2a20;
  --lamp-green-lit: #6fd17f;
  --lamp-amber-lit: #f5b23a;
  --lamp-red-lit: #f0614f;
  --lamp-green-off: #56685b;
  --lamp-amber-off: #6b5f45;
  --lamp-red-off: #6a504b;
  /* Neutral */
  --ink: #141716;
  --ink-soft: #2b302d;
  --ink-note: #3a403c;
  --plate-ink: #f2f3ef;
  --plate-ink-dim: #b9beb7;
  --bezel: #2c312e;
  --gunmetal: #8d948c;
  --field-edge: #666d66;
  --switch-slot: #b3b9b2;
  --key-grey: #e2e5df;
  --dial-white: #f6f7f4;
  --page-white: #ffffff;
  --bench-grey: #eef0ec;
  --chart-paper: #fbfbf9;
  --pale-steel: #dfe2dc;
  --rule-grey: #c9cec7;
  --over-fill: #f8e6c0;
  /* Type */
  --font-display: 'Michroma', Arial, sans-serif;
  --font-body: 'Barlow', Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--page-white);
  font-variant-numeric: lining-nums;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
h1, h2, h3, h4 { text-wrap: balance; }
p, li, figcaption, dd { text-wrap: pretty; }
img, svg { max-width: 100%; }
a { color: var(--link-blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--link-blue-deep); }
::selection { background: var(--signal-amber); color: var(--ink); }
input, select, textarea, button { font: inherit; color: inherit; caret-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button { cursor: pointer; }
.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; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 40px; }

/* ---------- Header ---------- */
.header { background: var(--bakelite); color: var(--plate-ink); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--plate-ink); text-decoration: none; font-family: var(--font-display); font-size: 0.875rem; line-height: 1.3; letter-spacing: 0.02em; }
.logo:hover { color: #ffffff; }
.logo-icon { flex: none; width: 22px; height: 22px; color: var(--signal-amber); }
.nav-desktop { display: flex; gap: 28px; }
.nav-desktop a { display: block; padding: 20px 0 18px; border-bottom: 2px solid transparent; color: var(--pale-steel); text-decoration: none; font-weight: 600; font-size: 0.9375rem; white-space: nowrap; }
.nav-desktop a:hover { color: #ffffff; }
.nav-desktop a.active { color: #ffffff; border-bottom-color: var(--signal-amber); }
.nav-toggle { display: none; min-height: 44px; padding: 0 14px; border: 1px solid var(--field-edge); border-radius: 4px; background: transparent; color: var(--plate-ink); font-weight: 600; font-size: 0.9375rem; }
.nav-mobile { display: none; }
.header :focus-visible { outline-color: var(--signal-amber); }

/* ---------- The panel: form and meter ---------- */
.panel { background: var(--panel-steel); border-bottom: 1px solid var(--panel-seam); }
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 480px;
  grid-template-areas: "head meter" "form meter";
  grid-template-rows: auto 1fr;
  column-gap: 64px;
  padding-top: 40px;
  padding-bottom: 48px;
}
.panel-head { grid-area: head; }
.calc-page-title { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.25rem, 6.4vw, 2.125rem); line-height: 1.25; letter-spacing: 0.01em; overflow-wrap: anywhere; }
.byline { margin-top: 10px; font-size: 0.9375rem; color: var(--ink-soft); }
.byline a { color: var(--link-blue-deep); }
.intro-text { margin-top: 14px; max-width: 60ch; }

.calculator-card { grid-area: form; margin-top: 28px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.calc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; align-items: start; }
.calc-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.calc-field { min-width: 0; }
fieldset.calc-field { margin: 0; padding: 0; border: 0; }
.calc-field-label { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9375rem; line-height: 1.35; color: var(--ink); }
.calc-field-hint { font-weight: 400; color: var(--ink-soft); }
.calc-field-sub { margin-top: 14px; }
.calc-field-message { margin-top: 6px; font-size: 0.875rem; line-height: 1.4; color: var(--ink-soft); }
.calc-field-message:empty { display: none; }
.ac-only { display: none; }
.ac-only.visible { display: block; }

/* A window: the number field dressed as a meter window. */
.window { position: relative; display: flex; align-items: center; min-height: 50px; background: var(--dial-white); border: 1px solid var(--field-edge); border-radius: 4px; box-shadow: inset 0 2px 0 rgba(20, 23, 22, 0.10); }
.window:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.window input, .window select { flex: 1; min-width: 0; width: 100%; height: 48px; padding: 0 14px; border: 0; background: transparent; outline: none; appearance: none; -webkit-appearance: none; -moz-appearance: textfield; font-weight: 600; font-size: 1.3125rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.window input::-webkit-outer-spin-button, .window input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.window input::placeholder { color: var(--ink-note); font-weight: 400; }
.window select { padding-right: 40px; font-size: 1.125rem; cursor: pointer; text-overflow: ellipsis; }
.window-select::after { content: ''; position: absolute; right: 17px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.calc-field-unit { flex: none; padding-right: 14px; font-weight: 600; font-size: 1.0625rem; color: var(--ink-soft); }
.window:has(input[aria-invalid="true"]) { border: 2px solid var(--band-red); }
.calc-field:has(input[aria-invalid="true"]) .calc-field-message { color: var(--band-red-text); font-weight: 600; }

/* Switch keys: radio groups and pressed buttons in a recessed slot. */
.keys { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--switch-slot); border: 1px solid var(--field-edge); border-radius: 5px; }
label.key { position: relative; flex: 1 1 auto; display: flex; margin: 0; }
label.key input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
label.key span, button.key { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 14px; border: 0; border-radius: 3px; background: var(--key-grey); color: var(--ink); font-weight: 600; font-size: 0.9375rem; line-height: 1.2; text-align: center; white-space: nowrap; }
label.key:hover span, button.key:hover { background: var(--page-white); }
label.key input:checked + span, button.key[aria-pressed="true"] { background: var(--bakelite); color: #ffffff; }
label.key input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Advanced and the math: disclosures under a seam. */
.calc-advanced { border-top: 1px solid var(--panel-seam); }
.collapsible-trigger { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 0.9375rem; text-align: left; }
.collapsible-trigger svg { flex: none; width: 18px; height: 18px; transition: transform 0.2s ease; }
.collapsible-trigger.open svg { transform: rotate(180deg); }
.collapsible-content { display: none; }
.collapsible-content.open { display: block; padding: 6px 0 4px; }

.calculate-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 0 16px; border: 0; border-radius: 5px; background: var(--bakelite); color: #ffffff; font-weight: 700; font-size: 1.125rem; }
.calculate-btn svg { flex: none; width: 20px; height: 20px; color: var(--signal-amber); }

/* The meter */
.meter-box { grid-area: meter; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.meter-fig { width: 100%; max-width: 480px; }
.meter { display: block; width: 100%; height: auto; overflow: visible; }
.meter-case { fill: var(--bakelite); }
.meter-face { fill: var(--dial-white); }
.meter-glass { fill: none; stroke: #ffffff; stroke-opacity: 0.55; stroke-width: 2; }
.meter-mirror { fill: none; stroke: var(--pale-steel); stroke-width: 6; }
.meter-band { fill: none; stroke-width: 12; }
.meter-band-low { stroke: var(--band-green); }
.meter-band-mid { stroke: var(--band-amber); }
.meter-band-high { stroke: var(--band-red); }
.meter-ticks { fill: none; stroke: var(--bakelite); stroke-width: 2; stroke-linecap: round; }
.meter-num { font-family: var(--font-body); font-weight: 600; font-size: 17px; fill: var(--bakelite); text-anchor: middle; }
.meter-bandtxt { font-family: var(--font-body); font-weight: 600; font-size: 13px; text-anchor: middle; }
.meter-bandtxt-low { fill: var(--band-green-text); }
.meter-bandtxt-mid { fill: var(--band-amber-text); }
.meter-bandtxt-high { fill: var(--band-red-text); }
.meter-facetxt { font-family: var(--font-body); font-weight: 600; font-size: 18px; fill: var(--ink-soft); text-anchor: middle; }
.meter-pivot { fill: var(--bakelite); }
.meter-pivot-dot { fill: var(--gunmetal); }
/* The needle: --needle-to is the reading (-48deg at 0%, 9.6deg a percent, +48deg at 10% and above). */
.needle { fill: var(--bakelite); transform-origin: 240px 312px; transform: rotate(var(--needle-to, -48deg)); }
.needle.sweep { animation: needle-sweep var(--needle-dur, 2.6s) cubic-bezier(0.25, 0.6, 0.3, 1) var(--needle-delay, 0.4s) both; }
.needle-quiver { transform-origin: 240px 312px; animation: needle-quiver 2.6s ease-in-out 3s infinite; }
@keyframes needle-sweep {
  0% { transform: rotate(var(--needle-from, -48deg)); }
  52% { transform: rotate(calc(var(--needle-to, -48deg) + var(--needle-o1, 0deg))); }
  70% { transform: rotate(calc(var(--needle-to, -48deg) - var(--needle-o2, 0deg))); }
  85% { transform: rotate(calc(var(--needle-to, -48deg) + var(--needle-o3, 0deg))); }
  100% { transform: rotate(var(--needle-to, -48deg)); }
}
@keyframes needle-quiver {
  0%, 100% { transform: rotate(0deg); }
  22% { transform: rotate(0.4deg); }
  41% { transform: rotate(-0.5deg); }
  63% { transform: rotate(0.3deg); }
  82% { transform: rotate(-0.8deg); }
}
/* The pencilled correction: the one hand on the page. */
.pencil { fill: var(--pencil-red); }
.pencil-mark { fill: none; stroke: var(--pencil-red); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pencil.write { animation: pencil-write 1s steps(12, end) var(--pencil-delay, 3.1s) both; }
@keyframes pencil-write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.plate { margin-top: 18px; padding: 8px 16px; border-radius: 3px; background: var(--bakelite); color: var(--plate-ink); font-weight: 600; font-size: 0.9375rem; line-height: 1.4; letter-spacing: 0.04em; text-align: center; }
.plate:empty { display: none; }
.result-primary { margin-top: 14px; text-align: center; }
.result-label { font-weight: 600; font-size: 0.9375rem; color: var(--ink-soft); }
.reading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; column-gap: 14px; font-variant-numeric: tabular-nums; }
.result-value { font-weight: 700; font-size: clamp(2.75rem, 18.5vw, 6rem); line-height: 1; letter-spacing: -0.01em; }
.result-percentage { font-weight: 600; font-size: clamp(1.5rem, 7.2vw, 2.125rem); line-height: 1.2; }
.result-status { margin: 10px auto 0; max-width: 56ch; font-size: 1rem; line-height: 1.5; text-wrap: balance; }
.lamps { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 28px; }
.lamp { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: 0.875rem; line-height: 1.3; color: var(--ink-soft); }
.bulb { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--bakelite); }
.lamp[data-band="low"] .bulb { background: var(--lamp-green-off); }
.lamp[data-band="mid"] .bulb { background: var(--lamp-amber-off); }
.lamp[data-band="high"] .bulb { background: var(--lamp-red-off); }
.lamp.on { color: var(--ink); }
.lamp.on[data-band="low"] .bulb { background: var(--lamp-green-lit); box-shadow: 0 0 0 4px rgba(111, 209, 127, 0.28), 0 0 22px 6px rgba(111, 209, 127, 0.5); }
.lamp.on[data-band="mid"] .bulb { background: var(--lamp-amber-lit); box-shadow: 0 0 0 4px rgba(245, 178, 58, 0.28), 0 0 22px 6px rgba(245, 178, 58, 0.55); }
.lamp.on[data-band="high"] .bulb { background: var(--lamp-red-lit); box-shadow: 0 0 0 4px rgba(240, 97, 79, 0.28), 0 0 22px 6px rgba(240, 97, 79, 0.5); }
.nec-gauge-note { margin: 12px auto 0; max-width: 46ch; font-size: 0.875rem; line-height: 1.45; color: var(--ink-soft); text-align: center; }

/* The landscape lighting calculator: the run on an instrument face, in the meter's place.
   The voltage line draws itself in once; the glints move along each stretch at a speed in
   proportion to its current (assets/js/landscape-engine.js, runSvg). */
.ll-draw { width: 100%; }
.ll-run { display: block; width: 100%; height: auto; overflow: visible; }
.ll-run text { font-family: var(--font-body); }
.ll-case { fill: var(--bakelite); }
.ll-face { fill: var(--dial-white); }
.ll-facetxt { font-weight: 600; font-size: 19px; fill: var(--ink-soft); }
.ll-grid { fill: none; stroke: var(--pale-steel); stroke-width: 1.5; }
.ll-guide { fill: none; stroke: var(--gunmetal); stroke-width: 1.5; stroke-dasharray: 4 4; }
.ll-tick { font-weight: 600; font-size: 17px; fill: var(--ink-note); }
.ll-profile { fill: none; stroke: var(--bakelite); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.ll-profile.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ll-draw 1.8s cubic-bezier(0.25, 0.6, 0.3, 1) 0.3s forwards; }
@keyframes ll-draw { to { stroke-dashoffset: 0; } }
.ll-point { fill: var(--bakelite); stroke: var(--dial-white); stroke-width: 2; }
.ll-value { font-weight: 700; font-size: 19px; fill: var(--ink); paint-order: stroke; stroke: var(--dial-white); stroke-width: 6px; stroke-linejoin: round; }
.ll-value-off { fill: var(--band-red-text); }
.ll-wire { fill: none; stroke: var(--copper); stroke-width: 6; stroke-linecap: round; }
.ll-wire-back { stroke: var(--copper-edge); }
.ll-flow { fill: none; stroke: var(--copper-glint); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0.01 16; animation: diagram-flow 1.6s linear infinite; }
.ll-supply { fill: var(--bakelite); }
.ll-supply-txt { font-weight: 700; font-size: 17px; fill: var(--plate-ink); }
.ll-drop { stroke: var(--ink-soft); stroke-width: 2; }
.ll-glow { fill: var(--lamp-amber-lit); fill-opacity: 0.3; }
.ll-lamp { fill: var(--lamp-amber-lit); stroke: var(--bakelite); stroke-width: 2; }
.ll-lamp.off { fill: var(--pale-steel); }
.ll-note { font-weight: 600; font-size: 17px; fill: var(--ink-soft); }
.ll-nec { margin-top: 16px; max-width: 72ch; font-size: 0.9375rem; line-height: 1.5; color: var(--ink-soft); }
.data-table tr.row-current > * { font-weight: 700; }
.data-table tr.row-current > th { white-space: nowrap; }

/* ---------- The bench: results ---------- */
.bench { background: var(--bench-grey); border-bottom: 1px solid var(--rule-grey); padding: 40px 0 44px; }
.results-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.results-title { font-family: var(--font-display); font-weight: 400; font-size: 1.3125rem; line-height: 1.3; }
.results-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--bakelite); border-radius: 4px; background: var(--page-white); color: var(--ink); font-weight: 600; font-size: 0.9375rem; }
.action-btn:hover { background: var(--bench-grey); }
.results-method-link { margin-left: 8px; font-weight: 600; font-size: 0.9375rem; }
.copy-field-box { margin-top: 16px; }
.copy-field-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9375rem; }
.copy-field { width: 100%; padding: 10px 12px; border: 1px solid var(--field-edge); border-radius: 4px; background: var(--page-white); font-size: 0.9375rem; line-height: 1.5; resize: vertical; }

.readouts { margin-top: 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.readout { padding: 14px 18px; border-radius: 6px; background: var(--bakelite); box-shadow: inset 0 0 0 3px var(--bezel); min-width: 0; }
.readout-label { font-weight: 600; font-size: 0.875rem; color: var(--plate-ink-dim); }
.readout-value { margin-top: 2px; font-weight: 700; font-size: clamp(1.75rem, 3.45vw, 2.75rem); line-height: 1.05; letter-spacing: -0.01em; color: #ffffff; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.readout-note { margin-top: 2px; font-size: 0.875rem; color: var(--plate-ink-dim); }

/* The run chart: the voltage along the run on recorder paper. */
.run-chart { margin-top: 28px; padding: 18px 20px 16px; border: 1px solid var(--gunmetal); border-radius: 6px; background: var(--chart-paper); }
.run-chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.run-chart-title { font-weight: 700; font-size: 1.125rem; line-height: 1.3; }
.run-chart-sub { font-size: 0.9375rem; color: var(--ink-note); }
.run-svg { display: block; width: 100%; max-width: 1120px; height: auto; margin: 10px auto 0; overflow: visible; }
.run-svg-m { display: none; }
.run-chart-caption { margin-top: 10px; max-width: 90ch; font-size: 0.875rem; line-height: 1.5; color: var(--ink-note); }
.run-grid { fill: none; stroke: var(--pale-steel); stroke-width: 1; }
.run-wedge { fill: var(--copper); fill-opacity: 0.14; }
.run-lim3 { fill: none; stroke: var(--band-amber); stroke-width: 1.8; stroke-dasharray: 8 6; }
.run-lim5 { fill: none; stroke: var(--band-red); stroke-width: 1.8; stroke-dasharray: 8 6; }
.run-guide { fill: none; stroke: var(--gunmetal); stroke-width: 1.2; stroke-dasharray: 2 5; }
.run-guide-a { fill: none; stroke: var(--band-amber); stroke-width: 1.4; stroke-dasharray: 2 5; }
.run-profile { fill: none; stroke: var(--bakelite); stroke-width: 3.5; stroke-linecap: round; }
.run-off { fill: var(--bakelite); }
.run-cross { fill: #ffffff; stroke: var(--band-amber-text); stroke-width: 3; }
.run-dot { fill: var(--bakelite); }
.run-term { fill: var(--ink-soft); stroke: var(--bakelite); stroke-width: 1.5; }
.run-ins { fill: none; stroke: var(--ink-note); stroke-width: 15; stroke-linecap: round; }
.run-cu { fill: none; stroke: var(--copper); stroke-width: 6; stroke-linecap: round; }
.run-cu.al { stroke: var(--aluminum); }
.run-pulse { fill: none; stroke: var(--copper-glint); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 8 40; animation: run-flow 1.1s linear infinite; }
.run-pulse.ac { animation: run-sway 1.1s ease-in-out infinite alternate; }
.run-svg-m .run-ins { stroke-width: 11; }
.run-svg-m .run-cu { stroke-width: 4; }
.run-svg-m .run-pulse { stroke-width: 3; }
@keyframes run-flow { to { stroke-dashoffset: -48; } }
@keyframes run-sway { to { stroke-dashoffset: -24; } }
.run-t { font-family: var(--font-body); fill: var(--ink-soft); }
.run-t-l { font-size: 21px; font-weight: 700; fill: var(--ink); }
.run-t-m { font-size: 16px; font-weight: 700; fill: var(--ink); }
.run-t-s { font-size: 15px; font-weight: 600; }
.run-t-xs { font-size: 13px; font-weight: 600; }
.run-t-amber { fill: var(--band-amber-text); font-weight: 700; }
.run-t-red { fill: var(--band-red-text); font-weight: 700; }
.run-end { text-anchor: end; }
.run-mid { text-anchor: middle; }
/* Paper-coloured edge so a grid or dashed line under a label stops short of its letters. */
.run-halo { paint-order: stroke; stroke: var(--chart-paper); stroke-width: 5px; stroke-linejoin: round; }

/* Ampacity and the recommendation, with the cross-sections. */
.res-cols { margin-top: 30px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px; }
.res-block { min-width: 0; }
.res-block h3 { font-weight: 700; font-size: 1.125rem; line-height: 1.3; }
.interpretation-text, .interpretation-action, .result-recommendation { margin-top: 6px; max-width: 60ch; font-size: 1rem; line-height: 1.55; }
.interpretation-action:empty, .interpretation-text:empty { display: none; }
.wire-comparison { margin-top: 14px; }
.xsecs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 32px; }
.xsec { display: flex; flex-direction: column; align-items: center; min-width: 120px; }
.xsec-draw svg { display: block; width: 140px; height: 120px; }
.xsec-strand { fill: var(--copper); stroke: var(--copper-edge); stroke-width: 1; }
.xsec-strand.al { fill: var(--aluminum); stroke: var(--aluminum-edge); }
.wire-comparison-label { display: block; margin-top: 4px; font-weight: 700; font-size: 0.9375rem; line-height: 1.3; text-align: center; }
.xsec-drop { display: block; font-weight: 700; font-size: 0.9375rem; text-align: center; font-variant-numeric: tabular-nums; }
.xsec-drop.band-low { color: var(--band-green-text); }
.xsec-drop.band-mid { color: var(--band-amber-text); }
.xsec-drop.band-high { color: var(--band-red-text); }
.xsec-caption { margin-top: 10px; max-width: 60ch; font-size: 0.875rem; line-height: 1.5; color: var(--ink-note); }

.math { margin-top: 28px; border-top: 1px solid var(--rule-grey); }
.math .collapsible-trigger { font-size: 1rem; font-weight: 700; }
.formula-display { padding: 12px 14px; border: 1px solid var(--rule-grey); background: var(--page-white); }
.formula-display-title { font-weight: 600; font-size: 0.9375rem; color: var(--ink-soft); }
.formula-display-content { margin-top: 4px; font-weight: 600; font-size: 1.0625rem; line-height: 1.5; overflow-wrap: anywhere; }
.formula-display-breakdown { margin-top: 8px; font-size: 0.9375rem; line-height: 1.6; overflow-wrap: anywhere; }
.meta-info { margin-top: 16px; font-size: 0.875rem; color: var(--ink-note); }

/* ---------- The paper: the guide ---------- */
.paper { background: var(--page-white); padding: 48px 0 56px; }
.paper-grid { display: grid; grid-template-columns: minmax(0, 720px) 300px; grid-template-areas: "article side"; justify-content: space-between; column-gap: 64px; align-items: start; }
.article-col { grid-area: article; min-width: 0; }
.paper-side { grid-area: side; position: sticky; top: 24px; }
.toc-page { padding-top: 10px; border-top: 2px solid var(--bakelite); }
.toc-title { margin-bottom: 8px; font-weight: 700; font-size: 0.9375rem; }
.toc-page ol { margin: 0; padding-left: 1.25rem; }
.toc-page li { margin: 5px 0; font-size: 0.9375rem; line-height: 1.4; }

.content-section + .content-section { margin-top: 48px; }
.content-section h2 { margin-bottom: 14px; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.25rem, 3.6vw, 1.5625rem); line-height: 1.3; overflow-wrap: anywhere; }
.content-section h2 .h-num { font-family: var(--font-body); font-weight: 700; font-size: 1.12em; letter-spacing: 0; }
.content-section h3 { margin: 28px 0 8px; font-weight: 700; font-size: 1.3125rem; line-height: 1.3; }
.content-section h4 { margin: 24px 0 6px; font-weight: 700; font-size: 1.0625rem; line-height: 1.35; }
.content-section p, .content-section > ul, .content-section > ol, .content-section dl { max-width: 68ch; }
.content-section > * + * { margin-top: 14px; }
.step > * + *, .faq-answer > * + * { margin-top: 10px; }
.content-section > ul, .content-section > ol { padding-left: 1.25rem; }
.content-section li + li { margin-top: 4px; }
.content-section :is(p, li, dd) a, .figure figcaption a { text-decoration: underline; }
.content-section code, .formula-inline { white-space: nowrap; }
/* Large text (a 200% default font, VDC-037): a long word breaks at the line's end; a link in text or in
   a table cell, and the value cell of a label-and-value table, break anywhere; inline formulas wrap while
   fewer than 20 of the reader's characters fit across the screen (a media query's em is the browser's
   default font size: below 320 px at 16 px, below 640 px at 32 px). */
body { overflow-wrap: break-word; }
.content-section :is(p, li, td, dd) a, .row-table td { overflow-wrap: anywhere; }
@media (max-width: 19.99em) { .content-section code, .formula-inline { white-space: normal; } }
.good { color: var(--band-green-text); font-weight: 600; }
.caution { color: var(--band-amber-text); font-weight: 600; }
.poor { color: var(--band-red-text); font-weight: 600; }
.text-center { text-align: center; }

.definition-list { margin-top: 14px; }
.definition-list dt { margin-top: 14px; font-weight: 700; }
.definition-list dt:first-child { margin-top: 0; }
.definition-list dd { margin-top: 2px; }

/* Figures drawn by scripts/render-tables.mjs: marks take fills, SVG text the text colours (D-13). */
.figure { margin: 24px 0; max-width: 22rem; }
.figure svg { display: block; width: 100%; height: auto; }
.figure figcaption { margin-top: 10px; font-size: 0.875rem; line-height: 1.5; color: var(--ink-note); }
.diagram-svg text, .chart-svg text { font-family: var(--font-body); }
.diagram-label { font-size: 13px; fill: var(--ink-soft); }
.diagram-name { font-size: 13px; font-weight: 600; fill: var(--ink); }
.diagram-drop { font-size: 15px; font-weight: 700; fill: var(--ink); }
.diagram-note { font-size: 13px; fill: var(--ink-note); }
.diagram-box { fill: var(--dial-white); stroke: var(--bakelite); stroke-width: 1.5; }
.diagram-wire { stroke: var(--copper); stroke-width: 2.5; stroke-linecap: round; }
.diagram-arrow { fill: none; stroke: var(--bakelite); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.diagram-dim { stroke: var(--gunmetal); stroke-width: 1; }
.diagram-lead { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.diagram-joint { fill: var(--ink-soft); }
.chart-label { font-size: 13px; fill: var(--ink-soft); }
.chart-value { font-size: 12px; fill: var(--ink-soft); }
.chart-tick { font-size: 12px; fill: var(--ink-note); }
.chart-grid { stroke: var(--pale-steel); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-bar-a { fill: var(--copper); }
.chart-bar-b { fill: var(--bakelite); }
.chart-line { fill: none; stroke: var(--bakelite); stroke-width: 2.5; }
.chart-point { fill: var(--bakelite); stroke: #ffffff; stroke-width: 2; }
.chart-line-alt { fill: none; stroke: var(--copper); stroke-width: 2.5; stroke-dasharray: 7 5; }
.chart-point-alt { fill: var(--copper); stroke: #ffffff; stroke-width: 2; }
.chart-guide { fill: none; stroke: var(--gunmetal); stroke-width: 1; stroke-dasharray: 3 3; }
/* A resistor's span on a chart of volts round a loop (the series guide, VDC-032). */
.chart-band { fill: var(--pale-steel); opacity: 0.6; }
/* Current in a circuit diagram: glints along the copper, as on the home page's run chart. A path's
   inline animation-duration sets its speed in proportion to its current (the parallel guide). */
.diagram-flow { fill: none; stroke: var(--copper-glint); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 0.01 16; animation: diagram-flow 1.6s linear infinite; }
@keyframes diagram-flow { to { stroke-dashoffset: -16; } }

/* Bar rows of the distance chart: band fills, labels in ink. */
.vd-distance-chart { margin: 24px 0; padding: 18px 20px 16px; border: 1px solid var(--gunmetal); border-radius: 6px; background: var(--chart-paper); }
.vd-distance-chart h4 { margin: 0 0 12px; font-size: 1rem; }
.vd-distance-row { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; }
.vd-distance-row + .vd-distance-row { margin-top: 8px; }
.vd-distance-label { flex: none; width: 64px; text-align: right; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.vd-distance-bar { flex: 1; height: 24px; background: var(--page-white); border: 1px solid var(--rule-grey); border-radius: 3px; overflow: hidden; }
.vd-distance-fill { height: 100%; display: flex; align-items: center; padding-left: 8px; }
.vd-distance-fill span { font-size: 0.8125rem; font-weight: 700; color: var(--ink); white-space: nowrap; }
.vd-distance-fill.good { background: var(--band-green); }
.vd-distance-fill.caution { background: var(--band-amber); }
.vd-distance-fill.poor { background: var(--band-red); }
.vd-distance-fill.good span, .vd-distance-fill.poor span { color: #ffffff; }
.vd-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 0.8125rem; color: var(--ink-soft); }
.vd-legend span { display: inline-flex; align-items: center; gap: 6px; }
.vd-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.vd-legend .dot.good { background: var(--band-green); }
.vd-legend .dot.caution { background: var(--band-amber); }
.vd-legend .dot.poor { background: var(--band-red); }

/* Formulas and steps */
.formula-box { margin: 20px 0; padding: 16px 18px; border-radius: 6px; background: var(--bakelite); box-shadow: inset 0 0 0 3px var(--bezel); overflow-x: auto; }
.formula { color: var(--plate-ink); font-weight: 600; font-size: 1.125rem; line-height: 1.5; text-align: center; font-variant-numeric: tabular-nums; }
.formula + .formula { margin-top: 6px; }
.formula-work .formula { font-size: 1rem; text-align: left; padding-left: 2ch; text-indent: -2ch; }
.formula-sheet { display: grid; grid-template-columns: max-content max-content; justify-content: center; align-items: baseline; gap: 10px 24px; }
.formula-sheet dt { text-align: right; font-size: 0.875rem; color: var(--plate-ink-dim); }
.formula-sheet dd { color: var(--plate-ink); font-weight: 600; font-size: 1.125rem; }
.step-by-step { counter-reset: step; margin-top: 16px; }
.step { position: relative; padding: 0 0 22px 44px; margin-left: 14px; border-left: 2px solid var(--rule-grey); }
.step:last-child { padding-bottom: 0; border-left-color: transparent; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: -15px; top: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--bakelite); color: #ffffff; font-weight: 700; font-size: 0.875rem; }
.step h4 { margin-top: 0; }
.step-formula { display: block; width: fit-content; max-width: 100%; margin-top: 8px; padding: 6px 12px; border-radius: 3px; background: var(--bench-grey); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.step-formula + .step-formula { margin-top: 6px; }

/* Tables */
.table-responsive { margin: 16px 0; overflow-x: auto; border: 1px solid var(--rule-grey); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9375rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--pale-steel); }
.data-table thead th { background: var(--bakelite); color: var(--plate-ink); font-weight: 600; white-space: nowrap; border-bottom: 2px solid var(--bakelite); }
.data-table tbody th, .data-table td:first-child { font-weight: 600; }
.data-table tbody th[scope="row"] { background: var(--bench-grey); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table.num :is(th, td):not(:first-child) { text-align: right; }
.data-table td[colspan] { background: var(--bench-grey); font-weight: 600; }
.data-table:has(thead th:nth-child(5)) :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--page-white); box-shadow: inset -1px 0 0 var(--pale-steel); }
.data-table:has(thead th:nth-child(5)) thead th:first-child { background: var(--bakelite); }
.data-table-stack th { white-space: normal; }

/* Questions */
.faq-list { margin-top: 8px; border-top: 1px solid var(--rule-grey); }
.faq-item { border-bottom: 1px solid var(--rule-grey); }
.faq-question { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 52px; padding: 12px 0; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 1.0625rem; line-height: 1.4; text-align: left; }
.faq-question svg { flex: none; width: 20px; height: 20px; transition: transform 0.2s ease; }
.faq-item.open .faq-question svg { transform: rotate(180deg); }
.faq-answer { display: none; padding: 0 0 16px; }
.faq-item.open .faq-answer { display: block; }

/* Guides: a list, not cards */
.content-section > .guide-list { list-style: none; margin: 18px 0 0; padding: 0; max-width: 68ch; border-top: 1px solid var(--rule-grey); }
.guide-item { padding: 14px 0; border-bottom: 1px solid var(--rule-grey); }
.content-section .guide-item + .guide-item { margin-top: 0; }
.guide-item h3 { margin: 0; font-size: 1.125rem; }
.guide-item p { margin-top: 4px; font-size: 1rem; }
.guides-all { margin-top: 16px; font-weight: 600; }

/* ---------- Article pages: the guides, the guides list, about, contact, methodology, legal, 404 ---------- */
/* The head of the page (breadcrumb, H1, byline, opening) sits on the steel panel at full width, as
   the calculator's does; the text sits on paper in the 720px column, On This Page in the 300px
   sidebar. The steel runs past the container with a border-image outset (no scroll, no markup). */
.content-narrow { padding-bottom: 64px; }
:is(.breadcrumb, .article-header, .article-header + .intro-text, main > .container > h1:first-child, main > .container > h1:first-child + p) {
  border-image: conic-gradient(var(--panel-steel) 0 0) fill 0 / / 0 100vmax;
}
/* The last piece of the head draws the panel's seam under it. */
:is(.article-header:not(:has(+ .intro-text)), .article-header + .intro-text, main > .container > h1:first-child:not(:has(+ p)), main > .container > h1:first-child + p) {
  border-image: linear-gradient(var(--panel-steel) calc(100% - 1px), var(--panel-seam) 0) fill 0 / / 0 100vmax;
  padding-bottom: 36px;
}
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding-top: 22px; font-size: 0.875rem; color: var(--ink-soft); }
.breadcrumb a { color: var(--link-blue-deep); text-decoration: underline; }
.breadcrumb svg { flex: none; width: 14px; height: 14px; color: var(--ink-note); }
.article-header { padding-top: 14px; }
main > .container > h1:first-child { padding-top: 40px; }
:is(.article-header h1, main > .container > h1:first-child) { max-width: 30ch; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.25rem, 6.4vw, 2.125rem); line-height: 1.25; letter-spacing: 0.01em; overflow-wrap: anywhere; }
:is(h1, h2) .h-num { font-family: var(--font-body); font-weight: 700; font-size: 1.12em; letter-spacing: 0; }
.article-header + .intro-text, main > .container > h1:first-child + p { margin: 0; padding-top: 14px; max-width: 68ch; }
main > .container > h1:first-child + p { padding-top: 12px; }
/* The paper under the head. */
:is(.article-header + .intro-text, .article-header:not(:has(+ .intro-text)), main > .container > h1:first-child:not(:has(+ p)), main > .container > h1:first-child + p) + * { margin-top: 40px; }
article > .formula-box { max-width: 720px; }
/* A short page keeps its footer at the bottom of the window. */
body.look-d { min-height: 100vh; display: flex; flex-direction: column; }
body.look-d > main { flex: 1 0 auto; }
/* A button-styled link in the text (contact's email) sizes to its words. */
.content-section > a.calculate-btn { width: auto; max-width: 100%; padding: 8px 20px; overflow-wrap: anywhere; text-align: left; }
a.calculate-btn:hover, a.calculate-btn:visited { color: #ffffff; }
@media (min-width: 53.8125em) {
  article:has(> :is(.toc-page, .toc)) { display: grid; grid-template-columns: minmax(0, 720px) 300px; justify-content: space-between; column-gap: 64px; align-items: start; }
  article:has(> :is(.toc-page, .toc)) > * { grid-column: 1; min-width: 0; }
  article:has(> :is(.toc-page, .toc)) > :is(.article-header, .article-header + .intro-text) { grid-column: 1 / -1; }
  article > :is(.toc-page, .toc) { grid-column: 2; grid-row: span 80; position: sticky; top: 24px; margin-top: 40px; }
  article > :is(.toc-page, .toc) + .content-section { margin-top: 40px; }
  main > .content-narrow > :not(.breadcrumb, h1:first-child, h1:first-child + p, article) { max-width: 720px; }
  article:not(:has(> :is(.toc-page, .toc))) > :not(.article-header, .article-header + .intro-text) { max-width: 720px; }
}
.toc { padding-top: 10px; border-top: 2px solid var(--bakelite); }
.toc h2 { margin: 0 0 8px; font-family: var(--font-body); font-weight: 700; font-size: 0.9375rem; }
.toc ol { margin: 0; padding-left: 1.25rem; }
.toc li { margin: 5px 0; font-size: 0.9375rem; line-height: 1.4; }
.toc-page .toc-title { margin-top: 0; }
/* A panel that sends the reader to the calculator. */
.cta-box { margin: 48px 0; padding: 24px 28px; max-width: 720px; border: 1px solid var(--panel-seam); border-radius: 6px; background: var(--panel-steel); }
.cta-box :is(h2, h3) { margin: 0 0 6px; font-family: var(--font-body); font-weight: 700; font-size: 1.3125rem; line-height: 1.3; }
.cta-box p { max-width: 60ch; margin: 0 0 18px; }
.cta-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px; border-radius: 6px; background: var(--bakelite); color: #ffffff; font-weight: 700; font-size: 1.0625rem; text-decoration: none; }
.cta-btn::before { content: ""; flex: none; width: 18px; height: 18px; background: var(--signal-amber); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat; }
.cta-btn:hover { background: #000000; color: #ffffff; }
.cta-btn svg { display: none; }
.cta-box :focus-visible { outline-color: var(--ink); }
/* Notes in the text: bench grey, the heading in its band's colour; no side stripe. */
.callout-box { margin: 20px 0; padding: 16px 18px; max-width: 720px; border: 1px solid var(--rule-grey); border-radius: 6px; background: var(--bench-grey); }
.callout-box h3, .callout-box h4 { margin: 0 0 8px; font-size: 1.0625rem; }
.callout-box.primary h3, .callout-box.primary h4 { color: var(--link-blue-deep); }
.callout-box.success h3, .callout-box.success h4 { color: var(--band-green-text); }
.callout-box.warning h3, .callout-box.warning h4 { color: var(--band-amber-text); }
.callout-box.error h3, .callout-box.error h4 { color: var(--band-red-text); }
.callout-box ul { margin: 0; padding-left: 1.25rem; }
.callout-box li + li { margin-top: 6px; }
/* A link to a tool: the bolt on bakelite, the title underlined; no arrow after it. */
.interlink-box { display: flex; align-items: center; gap: 14px; margin: 24px 0; padding: 14px 16px; max-width: 720px; border: 1px solid var(--rule-grey); border-radius: 6px; background: var(--bench-grey); color: var(--ink); text-decoration: none; }
.interlink-icon { flex: none; display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--bakelite); }
.interlink-icon svg { width: 18px; height: 18px; color: var(--signal-amber); }
.interlink-content { flex: 1; min-width: 0; }
.interlink-label { display: block; font-size: 0.875rem; color: var(--ink-soft); }
.interlink-title { display: block; font-weight: 700; color: var(--link-blue); text-decoration: underline; text-underline-offset: 3px; }
.interlink-box:hover .interlink-title { color: var(--link-blue-deep); }
.interlink-arrow { display: none; }
/* Related guides: a list, as on the home page. */
.related-articles-grid { max-width: 68ch; border-top: 1px solid var(--rule-grey); }
.related-article-card { display: flex; flex-direction: column; padding: 14px 0; border-bottom: 1px solid var(--rule-grey); color: var(--ink); text-decoration: none; }
.related-article-card .related-title { order: 1; font-weight: 700; font-size: 1.125rem; line-height: 1.35; color: var(--link-blue); text-decoration: underline; text-underline-offset: 3px; }
.related-article-card:hover .related-title { color: var(--link-blue-deep); }
.related-article-card .related-desc { order: 2; margin-top: 4px; color: var(--ink-soft); }
.related-article-card .related-label { order: 3; margin-top: 4px; font-size: 0.875rem; color: var(--ink-note); }
/* Sources. */
.sources-list { list-style: none; padding: 0; max-width: 68ch; }
.content-section > .sources-list { padding-left: 0; }
.sources-list li { padding: 8px 0; border-bottom: 1px solid var(--pale-steel); font-size: 0.9375rem; }
.content-section .sources-list li + li { margin-top: 0; }
.sources-list li:last-child { border-bottom: 0; }
.sources-list a { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: underline; }
.sources-list svg { flex: none; width: 14px; height: 14px; color: var(--ink-note); transform: translateY(2px); }
.sources-list li:not(:has(a)) { padding-left: 22px; }
/* Readout tiles for a few headline figures (the guides list). */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 20px 0; }
.stat-card, .featured-article-stat { padding: 12px 14px; border-radius: 6px; background: var(--bakelite); box-shadow: inset 0 0 0 3px var(--bezel); color: var(--plate-ink); }
.stat-card .stat-value, .featured-article-stat .stat-num { display: block; font-size: 1.625rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; color: #ffffff; }
.stat-card .stat-label, .featured-article-stat .stat-desc { display: block; margin-top: 2px; font-size: 0.8125rem; color: var(--plate-ink-dim); }
/* Contact and legal: links that act as keys. */
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.quick-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--field-edge); border-radius: 6px; background: var(--key-grey); color: var(--ink); font-weight: 600; text-decoration: none; }
.quick-link:hover { background: var(--page-white); color: var(--ink); }
.quick-link svg { flex: none; width: 18px; height: 18px; color: var(--ink-soft); }
.quick-link span { font-size: 0.9375rem; }
/* Tables of words, answers, values over a limit. */
.data-table.text-table td { color: var(--ink-soft); }
.data-table.text-table th[scope="row"] { white-space: normal; }
.data-table td.answer { font-weight: 700; color: var(--ink); }
.data-table.wrap-heads thead th { white-space: normal; vertical-align: bottom; }
.data-table td.over { position: relative; background: var(--over-fill); }
.over-mark { position: absolute; right: 3px; font-size: 0.75em; color: var(--band-amber-text); }
.formula-variables { margin-top: 20px; padding: 14px 16px; border-radius: 6px; background: var(--bench-grey); }
.formula-variables dt { font-weight: 600; }
.formula-variables dd { margin: 0 0 8px 1.25rem; color: var(--ink-soft); }
.figure.figure-image { max-width: 24rem; }
.figure-image img { display: block; width: 100%; height: auto; border: 1px solid var(--rule-grey); border-radius: 4px; }
.lever-list strong { color: var(--ink); }
@media (min-width: 53.8125em) {
  article .figure { max-width: 28rem; }
}
/* The NEC guide's limits chart: hatched bars for the notes that advise. */
.chart-bar-hatch { fill: url(#limits-hatch); stroke: var(--bakelite); stroke-width: 1; }
.chart-hatch-ground { fill: var(--page-white); }
.chart-hatch-line { stroke: var(--bakelite); stroke-width: 2; }
/* The guides list (/blog/): the featured guide on steel, the rest as a list. */
.featured-article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; margin-top: 40px; padding: 24px 28px; max-width: 1084px; border: 1px solid var(--panel-seam); border-radius: 6px; background: var(--panel-steel); }
.featured-article-badge { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 600; color: var(--ink-soft); }
.featured-article h2 { font-size: 1.3125rem; line-height: 1.3; }
.featured-article h2 a { color: var(--ink); }
.featured-article p { margin-top: 8px; max-width: 60ch; }
.featured-article .blog-card-link { display: inline-block; margin-top: 12px; font-weight: 600; }
.featured-article-stats { display: grid; grid-template-columns: repeat(3, minmax(110px, auto)); gap: 10px; }
.blog-grid { max-width: 720px; margin-top: 24px; border-top: 1px solid var(--rule-grey); }
.blog-card { padding: 16px 0; border-bottom: 1px solid var(--rule-grey); }
.blog-card-content h2 { font-size: 1.125rem; line-height: 1.35; }
.blog-card-content { display: flex; flex-direction: column; }
.blog-card-content h2 { order: 1; }
.blog-card-content > p:not(.blog-card-meta) { order: 2; }
.blog-card-meta { order: 3; margin-top: 4px; font-size: 0.875rem; color: var(--ink-note); }
.blog-card-content .blog-card-link { order: 4; margin-top: 6px; }
.blog-card-content p { margin-top: 4px; }
.blog-card-link { font-weight: 600; text-decoration: underline; }
@media (max-width: 53.75em) {
  .breadcrumb { padding-top: 16px; }
  main > .container > h1:first-child { padding-top: 28px; }
  :is(.article-header:not(:has(+ .intro-text)), .article-header + .intro-text, main > .container > h1:first-child:not(:has(+ p)), main > .container > h1:first-child + p) { padding-bottom: 28px; }
  article > :is(.toc-page, .toc) { margin-top: 32px; }
  .cta-box { padding: 20px 18px; }
  .cta-btn { display: flex; width: 100%; }
  .featured-article { grid-template-columns: minmax(0, 1fr); padding: 20px 18px; }
  .featured-article-stats { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  /* Tables of words stack: each row a block, each cell under its column's name. */
  .data-table.text-table, .data-table.text-table > :is(thead, tbody) { display: block; }
  .data-table.text-table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .data-table.text-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--pale-steel); }
  .data-table.text-table :is(th, td) { padding: 2px 0; border-bottom: 0; }
  .data-table.text-table tbody th[scope="row"]:first-child { grid-column: 1 / -1; position: static; box-shadow: none; background: none; }
  .data-table.text-table td::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 600; color: var(--ink-note); }
}

/* ---------- The resistor calculator: the home page's panel, keys and windows; results on the bench ---------- */
main > .container > :is(.calc-page-title, .byline, .intro-text, .calculator-card) {
  border-image: conic-gradient(var(--panel-steel) 0 0) fill 0 / / 0 100vmax;
}
main > .container > .calc-page-title { padding-top: 14px; }
main > .container > .byline { margin: 0; padding-top: 10px; }
main > .container > .intro-text { margin: 0; padding-top: 14px; max-width: 68ch; }
main > .container > .calculator-card { grid-area: auto; margin: 0; padding: 28px 0 40px; max-width: 720px; border-image: linear-gradient(var(--panel-steel) calc(100% - 1px), var(--panel-seam) 0) fill 0 / / 0 100vmax; }
main > .container > .results-section { margin: 0; padding: 36px 0 40px; border-image: linear-gradient(var(--bench-grey) calc(100% - 1px), var(--rule-grey) 0) fill 0 / / 0 100vmax; }
main > .container > .results-section + * { margin-top: 48px; }
@media (min-width: 53.8125em) {
  main > .container:has(> .calculator-card) { display: grid; grid-template-columns: minmax(0, 720px) 300px; justify-content: space-between; column-gap: 64px; align-items: start; }
  main > .container:has(> .calculator-card) > * { grid-column: 1; min-width: 0; }
  main > .container:has(> .calculator-card) > :is(.breadcrumb, .calc-page-title, .byline, .intro-text, .calculator-card, .results-section) { grid-column: 1 / -1; }
  main > .container:has(> .calculator-card) > .toc-page { grid-column: 2; grid-row: span 80; position: sticky; top: 24px; margin-top: 48px; }
}
.calc-settings-bar, .resistor-field, .choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.calc-setting-label { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9375rem; color: var(--ink); }
.calc-setting-label svg { flex: none; color: var(--ink-soft); }
.choice-group { display: grid; gap: 3px; padding: 3px; background: var(--switch-slot); border: 1px solid var(--field-edge); border-radius: 5px; }
.choice-group-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-group-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-group-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { position: relative; display: flex; margin: 0; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice span { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 4px 12px; border-radius: 3px; background: var(--key-grey); color: var(--ink); font-weight: 600; font-size: 0.9375rem; line-height: 1.25; text-align: center; }
.choice:hover span { background: var(--page-white); }
.choice input:checked + span { background: var(--bakelite); color: #ffffff; }
.choice input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.calc-panel { display: flex; flex-direction: column; gap: 18px; }
.calc-panel[hidden], .calc-field[hidden] { display: none; }
.calculator-card .calc-field-header { display: flex; flex-direction: column; align-items: stretch; }
.calc-field-value { display: flex; align-items: center; min-height: 50px; background: var(--dial-white); border: 1px solid var(--field-edge); border-radius: 4px; box-shadow: inset 0 2px 0 rgba(20, 23, 22, 0.10); }
.calc-field-value:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.calc-number-input { flex: 1; min-width: 0; width: 100%; height: 48px; padding: 0 14px; border: 0; background: transparent; outline: none; -moz-appearance: textfield; appearance: textfield; font-weight: 600; font-size: 1.3125rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.calc-number-input::-webkit-outer-spin-button, .calc-number-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-number-input::placeholder { color: var(--ink-note); font-weight: 400; }
.calc-unit-select { flex: none; height: 48px; padding: 0 30px 0 12px; border: 0; border-left: 1px solid var(--rule-grey); border-radius: 0 3px 3px 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23141716' stroke-width='1.6'/%3E%3C/svg%3E") right 11px center / 10px 6px no-repeat; -webkit-appearance: none; appearance: none; font-weight: 600; font-size: 1rem; color: var(--ink-soft); cursor: pointer; }
.calc-field-value:has(.calc-number-input[aria-invalid="true"]) { border: 2px solid var(--band-red); }
.resistor-row:has(.calc-number-input[aria-invalid="true"]) .calc-field-message { color: var(--band-red-text); font-weight: 600; }
.resistor-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.resistor-row { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto auto; align-items: center; gap: 4px 8px; }
.resistor-row-label { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.resistor-row .calc-number-input { height: 46px; border: 1px solid var(--field-edge); border-radius: 4px; background: var(--dial-white); box-shadow: inset 0 2px 0 rgba(20, 23, 22, 0.10); }
.resistor-row .calc-number-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.resistor-row .calc-number-input[aria-invalid="true"] { border: 2px solid var(--band-red); }
.resistor-row .calc-unit-select { height: 46px; border: 1px solid var(--field-edge); border-radius: 4px; background-color: var(--key-grey); }
.resistor-row .calc-field-message { grid-column: 2 / -1; margin-top: 0; }
.row-remove-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--ink-soft); }
.row-remove-btn:hover { background: var(--page-white); color: var(--band-red-text); }
.row-remove-btn:disabled { visibility: hidden; }
.row-remove-btn svg { width: 18px; height: 18px; }
.add-row-btn { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; margin-top: 12px; min-height: 44px; padding: 0 14px; border: 1px solid var(--field-edge); border-radius: 4px; background: var(--key-grey); color: var(--ink); font-weight: 600; font-size: 0.9375rem; }
.add-row-btn:hover { background: var(--page-white); }
.add-row-btn:disabled { color: var(--ink-note); cursor: not-allowed; }
.add-row-btn svg { width: 16px; height: 16px; }
.results-card { padding: 0; border: 0; background: none; box-shadow: none; }
.results-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.results-actions .print-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--bakelite); border-radius: 4px; background: var(--page-white); color: var(--ink); font-weight: 600; font-size: 0.9375rem; }
.results-actions .print-btn:hover { background: var(--bench-grey); }
#result-body { margin-top: 20px; }
.result-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr)); gap: 12px; }
.result-figure { min-width: 0; padding: 12px 16px; border-radius: 6px; background: var(--bakelite); box-shadow: inset 0 0 0 3px var(--bezel); }
.result-figure-label { display: block; font-weight: 600; font-size: 0.875rem; color: var(--plate-ink-dim); }
.result-figure-value { display: block; margin-top: 2px; font-weight: 700; font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.1; color: #ffffff; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-note { max-width: 68ch; margin: 12px 0 0; font-size: 0.9375rem; color: var(--ink-soft); }
.result-summary { max-width: 72ch; margin: 0 0 18px; font-size: 1.0625rem; line-height: 1.5; color: var(--ink); }
.results-empty { margin: 0; padding: 20px; border: 1px dashed var(--field-edge); border-radius: 6px; color: var(--ink-soft); text-align: center; }
:is(.results-subsection, .result-figures, .result-note) + .results-subsection { margin-top: 28px; }
.results-subsection-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 700; font-size: 1.0625rem; }
.results-subsection-title svg { width: 18px; height: 18px; color: var(--ink-soft); }
.results-section .table-responsive { width: fit-content; max-width: 100%; background: var(--page-white); }
.results-card .data-table { width: auto; min-width: min(100%, 26rem); }
.results-card .data-table th { white-space: normal; }
.results-card .data-table td:nth-child(3):nth-last-child(4), .results-card .data-table td:nth-child(4):nth-last-child(2), .results-card .data-table td:nth-child(2):nth-last-child(2), .results-card .data-table td:nth-child(2):last-child { font-weight: 700; color: var(--ink); }

/* ---------- The chart page: charts as tables, their notes, the downloads ---------- */
.chart-table { margin-top: 32px; }
.chart-table h3 { margin: 0 0 8px; font-size: 1.125rem; }
.chart-table .table-responsive { margin: 0 0 8px; }
.chart-table .data-table :is(th, td) { padding-inline: 10px; }
.chart-table .data-table :is(th, td):first-child { white-space: nowrap; position: sticky; left: 0; z-index: 1; background: var(--page-white); box-shadow: inset -1px 0 0 var(--pale-steel); }
.chart-table .data-table thead th:first-child { background: var(--bakelite); }
.chart-table .data-table tbody tr:hover > :first-child { background: var(--bench-grey); }
.chart-table.long-heads th { white-space: normal; vertical-align: bottom; text-wrap: balance; }
.chart-table.long-heads th:not(:first-child) { min-width: 6.75rem; }
.chart-table .data-table :is(th, td):not(.over) + td.over { box-shadow: inset 2px 0 0 var(--band-amber-text); }
.chart-note { max-width: 68ch; margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--ink-note); }
.chart-note > span { display: block; }
.chart-basis { max-width: 68ch; }
.download-list { list-style: none; padding: 0; max-width: 68ch; }
.download-list li { padding: 10px 0; border-bottom: 1px solid var(--pale-steel); }
.content-section .download-list li + li { margin-top: 0; }
.download-list li:last-child { border-bottom: 0; }
.download-list a { display: inline-flex; align-items: flex-start; gap: 8px; font-weight: 600; text-decoration: underline; }
.download-list svg { flex: none; width: 18px; height: 18px; margin-top: 0.2em; color: var(--ink-soft); }
.download-desc { display: block; padding-left: 26px; font-size: 0.875rem; color: var(--ink-note); }
.content-section > .print-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--bakelite); border-radius: 4px; background: var(--page-white); color: var(--ink); font-weight: 600; font-size: 0.9375rem; }
.content-section > .print-btn:hover { background: var(--bench-grey); }
@media (max-width: 53.75em) {
  main > .container > .calculator-card { padding: 24px 0 32px; }
  main > .container > .results-section { padding: 28px 0 32px; }
  .choice-group-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Footer (build-meta writes its markup) ---------- */
.footer { background: var(--bakelite); color: var(--pale-steel); font-size: 0.9375rem; }
.footer a { color: var(--plate-ink); }
.footer a:hover { color: #ffffff; }
.footer :focus-visible { outline-color: var(--signal-amber); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 40px; padding-top: 40px; padding-bottom: 28px; }
.footer-brand .logo { margin-bottom: 10px; }
.footer-brand p { max-width: 40ch; }
/* The footer's headings are h2s: an h4 after a page's h2 skipped two levels (VDC-031). */
.footer-nav h2 { font-weight: 700; font-size: 0.9375rem; color: #ffffff; }
.footer-nav ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 16px; padding-bottom: 28px; border-top: 1px solid var(--ink-note); font-size: 0.875rem; color: var(--plate-ink-dim); }
.footer-disclaimer { max-width: 60ch; }

/* ---------- One breakpoint ---------- */
/* One breakpoint, in em so it moves with the reader's default font size: 860px at 16px. */
@media (max-width: 53.75em) {
  .container { padding: 0 18px; }
  .nav-desktop { display: none; }
  /* With a large default font the logo can need the whole row: Menu then goes under it, at the right. */
  .header-inner { flex-wrap: wrap; row-gap: 8px; padding-block: 10px; }
  .nav-toggle { display: inline-flex; align-items: center; margin-left: auto; }
  .nav-mobile.active { display: flex; flex-direction: column; padding: 4px 0 14px; border-top: 1px solid var(--bezel); }
  .nav-mobile a { padding: 12px 0; color: var(--pale-steel); text-decoration: none; font-weight: 600; }
  .nav-mobile a[aria-current="page"] { color: #ffffff; }

  .panel-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "meter" "form"; grid-template-rows: auto; row-gap: 28px; padding-top: 28px; padding-bottom: 32px; }
  .calculator-card { margin-top: 0; }
  .meter-fig { max-width: 340px; }
  .result-primary { order: -1; margin: 0 0 18px; }
  .plate { font-size: 0.875rem; letter-spacing: 0.02em; }
  .meter-bandtxts { display: none; }
  .calc-grid, .calc-grid-3 { grid-template-columns: minmax(0, 1fr); }

  .bench { padding: 28px 0 32px; }
  .readouts { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .readout-value { font-size: 2.375rem; }
  .run-chart { padding: 14px 12px 12px; }
  .run-svg { display: none; }
  .run-svg-m { display: block; width: 100%; max-width: 380px; height: auto; margin: 8px auto 0; overflow: visible; }
  .res-cols { grid-template-columns: minmax(0, 1fr); gap: 24px; }

  .paper { padding: 36px 0 44px; }
  .paper-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "article"; }
  .paper-side { position: static; margin-bottom: 32px; }
  .figure { max-width: 100%; }
  .formula { font-size: 0.9375rem; text-align: left; padding-left: 1.5em; text-indent: -1.5em; }
  .formula-sheet { grid-template-columns: minmax(0, 1fr); justify-content: stretch; row-gap: 0; }
  .formula-sheet dt { text-align: left; }
  .formula-sheet dd + dt { margin-top: 10px; }
  .data-table:has(thead th:nth-child(5)) td { white-space: nowrap; }
  .data-table-stack, .data-table-stack :is(thead, tbody) { display: block; }
  .data-table-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 9rem); }
  .data-table-stack :is(th, td):nth-child(3) { grid-column: 1 / -1; padding-top: 0; }
  .data-table-stack :is(th, td):not(:last-child) { border-bottom: 0; }

  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

/* ---------- Reduced motion: the needle already on the reading, the pencil whole, no pulses ---------- */
@media (prefers-reduced-motion: reduce) {
  .needle.sweep, .needle-quiver { animation: none; }
  .pencil.write { animation: none; clip-path: none; }
  .run-pulse, .diagram-flow, .ll-flow { display: none; }
  .ll-profile.draw { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
  .collapsible-trigger svg, .faq-question svg { transition: none; }
}

/* ---------- Print: dark plates print as outlined text ---------- */
@media print {
  .header, .footer, .calculate-btn, .action-btn, .nav-toggle, .print-btn, .results-method-link, .paper-side, .run-pulse, .diagram-flow, .ll-flow { display: none !important; }
  .panel, .bench { background: none; border: 0; }
  .readout, .plate, .formula-box { background: none; box-shadow: none; border: 1px solid #000; color: #000; }
  .readout-label, .readout-note, .readout-value, .formula, .formula-sheet dt, .formula-sheet dd { color: #000; }
  .data-table thead th { background: none; color: #000; }
  .faq-answer { display: block; }
  .faq-question svg { display: none; }
  .data-table tr, .figure, .faq-item, .readout, .run-chart { break-inside: avoid; }
  :is(h2, h3, h4) { break-after: avoid; }
  .paper-grid { display: block; }
  article, main > .container { display: block !important; }
  .breadcrumb, .article-header, .article-header + .intro-text, main > .container > *, .calculator-card { border-image: none !important; }
  .toc-page, .toc, .cta-box, .download-list, .figure-image, .add-row-btn, .row-remove-btn { display: none !important; }
  .content-section:has(> :is(.related-articles-grid, .download-list)) { display: none !important; }
  .result-figure { background: none; box-shadow: none; border: 1px solid #000; }
  .result-figure-label, .result-figure-value { color: #000; }
  .sources-list a { display: block; }
  .sources-list svg { display: none; }
  .sources-list a::after { content: " " attr(href); overflow-wrap: anywhere; font-size: 0.85em; color: #333; }
  .data-table td.over { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .data-table tr, .chart-note, .figure, .faq-item { break-inside: avoid; }
  .chart-table { margin-top: 18px; break-inside: avoid; }
  .chart-table .data-table :is(th, td) { padding: 1px 6px; font-size: 8.5pt; line-height: 1.35; }
  .chart-note { max-width: none; font-size: 7.5pt; }
  /* The chart PDF (scripts/build-chart-assets.mjs adds .print-charts): the opening, the basis, every chart and the sources. */
  .print-charts :is(.breadcrumb, .cta-box, main .content-section:not(.chart-print)) { display: none !important; }
  .print-charts .chart-print > :not(h2, .chart-basis, .chart-table, .sources-list) { display: none; }
  .print-charts .chart-print:has(.chart-table) > h2 { display: none; }
  .print-charts .chart-print:has(> .long-heads) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; align-items: start; }
  .print-charts .long-heads th:not(:first-child) { min-width: 0; }
  .print-charts :is(.intro-text, .chart-basis) { font-size: 9pt; margin-bottom: 6px; }
  .print-charts .article-header { padding-top: 0; }
  .print-charts .content-section + .content-section { margin-top: 14px; }
  .print-charts .article-header h1 { font-size: 18pt; }
  .print-charts .content-section h2 { font-size: 13pt; }
  .print-charts .content-section:has(> .sources-list) { break-inside: avoid; }
  .print-charts .sources-list li { padding: 1px 0; font-size: 8pt; }
}
