/* v21 dark theme. Loaded last on every page; screen only, so printing and PDF reports always come out light.
   Applied when <html data-theme="dark"> (set before first paint by the head script: stored choice, else the system setting).
   Palette: soft near-black page, charcoal cards, no pure black. One accent (signal amber) per panel.
   Contrast (WCAG 2.1, checked in tests/v21-theme.test.js). Page #121316: text 15.6:1, secondary 11.2:1, muted 7.1:1, links 9.2:1.
   Card #1A1B1F: text 14.4:1, muted 6.6:1. Panel #202227: muted 6.1:1, status colours 7.7-9.6:1. All AA (4.5:1) or better.
   Drawing panels (IES, plan, render, sims) stay charcoal #232428 with a hairline so they read as instruments, not inverted.
   False-colour scales, photos, renders and the plan sheet are never inverted. */
@media screen{
html[data-theme=dark]{
 --paper:#121316;--surface:#1A1B1F;--surface-2:#202227;--line:rgba(255,255,255,.085);--line-2:rgba(255,255,255,.15);
 --ink:#ECEBE8;--ink-2:#C8C9CE;--muted:#9EA0A8;
 --sig:#F5922B;--amber:#F5922B;--amber-400:#F5922B;--amber-700:#F2A65A;--amber-50:rgba(245,146,43,.12);--amber-ink:#F2A65A;--cool-700:#ECEBE8;--cool:#8FB8F0;--cool-50:rgba(143,184,240,.1);
 --ok:#7FD1A0;--ok-50:rgba(127,209,160,.1);--bad:#F2A08E;--bad-50:rgba(242,160,142,.1);--warn:#E8C574;--warn-50:rgba(232,197,116,.1);
 --night-700:#2A2B31;
 --sh-1:0 1px 2px rgba(0,0,0,.3);--sh-2:0 1px 2px rgba(0,0,0,.25),0 8px 24px -12px rgba(0,0,0,.5);--sh-3:0 2px 6px rgba(0,0,0,.3),0 24px 60px -28px rgba(0,0,0,.6);
 --shadow:var(--sh-2);--shadow-lg:var(--sh-3);
 --sim-bg:#17181B;
 color-scheme:dark}
html[data-theme=dark] body{background:var(--paper);color:var(--ink)}
html[data-theme=dark] ::selection{background:rgba(245,146,43,.35);color:#fff}
}
/* the toggle (both themes) */
.theme-t{order:3;flex:none;display:inline-flex;align-items:center;gap:0;margin-left:8px;padding:3px;border:1px solid var(--line-2);border-radius:999px;background:rgba(255,255,255,.6);box-shadow:var(--sh-1);--compact:0}
.theme-t button{all:unset;box-sizing:border-box;display:inline-grid;place-items:center;width:26px;height:22px;border-radius:999px;color:var(--muted);cursor:pointer;transition:background .15s,color .15s}
.theme-t button svg{width:14px;height:14px;display:block}
.theme-t button:hover{color:var(--ink)}
.theme-t button.on{background:var(--ink);color:var(--paper)}
.theme-t button:focus-visible{outline:2px solid var(--sig,#F5922B);outline-offset:1px}
body:has(.hero,.hx) .theme-t{background:rgba(255,255,255,.05);border-color:rgba(255,255,255,.12)}
body:has(.hero,.hx) .theme-t button{color:#A5A7AF}body:has(.hero,.hx) .theme-t button:hover{color:#fff}
body:has(.hero,.hx) .theme-t button.on{background:#EDEDEF;color:#111113}
/* phones: one icon, tap to cycle Auto -> Light -> Dark */
@media(max-width:820px){.theme-t{--compact:1;padding:2px}.theme-t button:not(.on){display:none}.theme-t button.on{background:transparent;color:var(--ink)}
 body:has(.hero,.hx) .theme-t button.on{background:transparent;color:#EDEDEF}}
@media(max-width:480px){.theme-t{margin-left:4px}.theme-t button{width:26px;height:24px}}
@media print{.theme-t{display:none!important}}

@media screen{
/* ---- header ---- */
html[data-theme=dark] .top{background:rgba(18,19,22,.82);border-bottom-color:rgba(255,255,255,.07)}
html[data-theme=dark] .lbm{color:#ECEBE8}
html[data-theme=dark] .nav a{color:#B9BBC2}
html[data-theme=dark] .nav a:hover{background:rgba(255,255,255,.06);color:#fff}
html[data-theme=dark] .nav a[aria-current]{background:rgba(255,255,255,.08);color:#fff}
html[data-theme=dark] .nav .cta,html[data-theme=dark] .nav .cta:hover{background:#ECEBE8;color:#111113;box-shadow:0 1px 2px rgba(0,0,0,.3)}
html[data-theme=dark] .nav .cta:hover{background:#fff}
html[data-theme=dark] .units-t,html[data-theme=dark] .theme-t{background:rgba(255,255,255,.04);border-color:rgba(255,255,255,.12);box-shadow:none;color:#A5A7AF}
html[data-theme=dark] .units-t span.on{background:#ECEBE8;color:#111113}
html[data-theme=dark] .theme-t button{color:#A5A7AF}html[data-theme=dark] .theme-t button:hover{color:#fff}
html[data-theme=dark] .region-p select{background-color:rgba(255,255,255,.04);border-color:rgba(255,255,255,.12);color:#C9CBD2;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23A5A7AF'/%3E%3C/svg%3E")}
html[data-theme=dark] .region-p select option,html[data-theme=dark] select option{background:#202227;color:#ECEBE8}
html[data-theme=dark] .menu{background:rgba(255,255,255,.05);border-color:rgba(255,255,255,.14);color:#ECEBE8}
@media(max-width:820px){html[data-theme=dark] .nav{background:#121316!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;border-bottom-color:rgba(255,255,255,.07)}html[data-theme=dark] body:has(.hero,.hx) .nav{background:#0E0F12!important}html[data-theme=dark] .theme-t button.on{background:transparent;color:#ECEBE8}}
/* ---- logo mark ---- */
html[data-theme=dark] .lbm i{background:radial-gradient(120% 120% at 70% 20%,#3A3B42 0,#1E1F24 70%);color:#fff;box-shadow:inset 0 0 0 1px rgba(255,255,255,.1)}
/* ---- buttons ---- */
html[data-theme=dark] .btn:not(.amber,.primary,.danger,.ghost,.line){background:var(--surface-2);border-color:var(--line-2);color:var(--ink)}
html[data-theme=dark] .btn:not(.amber,.primary,.danger,.ghost,.line):hover{background:#2A2B31;border-color:rgba(255,255,255,.24)}
html[data-theme=dark] .btn.primary,html[data-theme=dark] .dev.lite .btn.primary{background:#ECEBE8;color:#111113;border-color:#ECEBE8;box-shadow:0 1px 2px rgba(0,0,0,.3)}
html[data-theme=dark] .btn.primary:hover,html[data-theme=dark] .dev.lite .btn.primary:hover{background:#fff;color:#111113}
html[data-theme=dark] .btn.ghost,html[data-theme=dark] .btn.line,html[data-theme=dark] .dev.lite .btn.line{background:transparent;color:var(--ink);border-color:var(--line-2)}
html[data-theme=dark] .btn.ghost:hover,html[data-theme=dark] .btn.line:hover{background:rgba(255,255,255,.06)}
/* ---- inputs ---- */
html[data-theme=dark] input,html[data-theme=dark] select,html[data-theme=dark] textarea{background-color:#1E1F24;border-color:var(--line-2);color:var(--ink)}
html[data-theme=dark] input:hover,html[data-theme=dark] select:hover,html[data-theme=dark] textarea:hover{border-color:rgba(255,255,255,.26)}
html[data-theme=dark] input::placeholder,html[data-theme=dark] textarea::placeholder{color:#7F818A}
html[data-theme=dark] input[type=checkbox],html[data-theme=dark] input[type=radio]{accent-color:#F5922B}
/* ---- cards, tables, folds ---- */
html[data-theme=dark] .card{background:var(--surface);border-color:var(--line)}
html[data-theme=dark] .nf-l a{background:var(--surface);border-color:var(--line)}
html[data-theme=dark] thead th{background:var(--surface-2);color:var(--muted)}
html[data-theme=dark] td,html[data-theme=dark] th{border-color:var(--line)!important}
html[data-theme=dark] code,html[data-theme=dark] kbd{background:rgba(255,255,255,.06);color:#E6E4DF}
html[data-theme=dark] a{color:inherit}
html[data-theme=dark] hr{border-color:var(--line)}
/* ---- footer: a step darker than the page ---- */
html[data-theme=dark] .foot{background:#0E0F12!important;color:#9EA0A8!important;border-top:1px solid rgba(255,255,255,.07)!important}
html[data-theme=dark] .foot h4{color:#ECEBE8!important}
html[data-theme=dark] .foot a{color:#C8C9CE!important}html[data-theme=dark] .foot a:hover{color:#F2A65A!important}
html[data-theme=dark] .foot .lbm,html[data-theme=dark] .foot .lbm:hover{color:#ECEBE8!important}
html[data-theme=dark] .foot .lbm i{background:radial-gradient(120% 120% at 70% 20%,#3A3B42 0,#1E1F24 70%)!important;color:#fff!important}
html[data-theme=dark] .foot .base,html[data-theme=dark] .foot .small{color:#9EA0A8!important;border-top-color:rgba(255,255,255,.08)!important}
html[data-theme=dark] .foot :focus-visible{outline-color:#F2A65A!important}
/* ---- light calculator panels become dark surfaces (same tokens the charcoal panels use, a step lighter than the page) ---- */
html[data-theme=dark] .dev.lite{--dev:#1A1B1F;--dev2:#202227;--dev3:#27282E;--devtxt:#ECEBE8;--devlabel:#CFD1D6;--devmute:#A3A5AD;--devline:rgba(255,255,255,.08);--devline2:rgba(255,255,255,.15);
 --pass:#94D2AA;--fail:#F2A08E;--check:#E8C574;box-shadow:0 0 0 1px rgba(255,255,255,.07),0 24px 48px -36px rgba(0,0,0,.6)!important}
html[data-theme=dark] .dev.lite input[type=number],html[data-theme=dark] .dev.lite input:not([type]),html[data-theme=dark] .dev.lite input[inputmode],html[data-theme=dark] .dev.lite input[type=text],html[data-theme=dark] .dev.lite input[type=email],html[data-theme=dark] .dev.lite select,html[data-theme=dark] .dev.lite textarea,html[data-theme=dark] .dev.lite .rw textarea{background:#202227!important;color:var(--devtxt)!important}
html[data-theme=dark] .dev.lite option{background:#202227;color:#ECEBE8}
html[data-theme=dark] .dev.lite .v19-bar span.neg{background:#4A4C53}
html[data-theme=dark] .dev.lite .v19-disc{background:#202227}
html[data-theme=dark] .dev.lite .mk-pick button[aria-pressed=true],html[data-theme=dark] .mk-pick a[aria-current=page]{background:#ECEBE8;color:#111113;border-color:#ECEBE8}
html[data-theme=dark] .dev.lite .v19-flag.warn{border-color:rgba(232,197,116,.5);color:#E8C574}
html[data-theme=dark] .dev.lite .mk-tag.law{border-color:rgba(232,197,116,.45)}
html[data-theme=dark] .dev.lite .cc-dot.dv{background:#9DB4E0}
html[data-theme=dark] .dev.lite .st,html[data-theme=dark] .dev.lite .cp-st,html[data-theme=dark] .dev.lite .sp-st{background:rgba(255,255,255,.04)!important}
html[data-theme=dark] .dev.lite a:hover{color:#F2A65A}
html[data-theme=dark] .cc-rows input[type=checkbox],html[data-theme=dark] .cc-pick input[type=checkbox]{accent-color:#F5922B}
html[data-theme=dark] .ws-mk{box-shadow:0 0 0 1px rgba(255,255,255,.07)!important}
html[data-theme=dark] section>.mk-n{color:var(--muted)}
/* ---- charcoal drawing panels: stay dark, lifted from the page by a hairline ---- */
html[data-theme=dark] .dev:not(.lite){box-shadow:0 0 0 1px rgba(255,255,255,.07),0 18px 40px -30px rgba(0,0,0,.7)!important}
}
@media screen{
/* ---- home: illustrated app pieces follow the theme; the printed report stays paper ---- */
html[data-theme=dark] .vf{background:var(--surface-2);border-color:var(--line)}
html[data-theme=dark] .vchips i{background:var(--surface-2);border-color:var(--line);color:var(--ink-2)}
html[data-theme=dark] .vchips i.a{background:#ECEBE8;color:#111113;border-color:#ECEBE8}
html[data-theme=dark] .vg-rep .pg,html[data-theme=dark] .hx-report{color:#141414}
html[data-theme=dark] .vg-rep .pg .h,html[data-theme=dark] .vg-rep .pg p{color:#141414}
html[data-theme=dark] .vg-rep .pg .m{color:#6E6A62}
html[data-theme=dark] .vg-rep .pg .h em,html[data-theme=dark] .hx-rh em{color:#9A4A06}
/* ---- pricing ---- */
html[data-theme=dark] .v19-plan{background:var(--surface);border-color:var(--line)}
html[data-theme=dark] .v19-plan.pro{border-color:rgba(245,146,43,.45)}
}
/* ---- both themes: small text that was below 4.5:1 on the charcoal and hero backgrounds (found by the v21 audit) ---- */
.stabs button i{color:#9A9CA4!important}
.ies-tabs .tg{color:#9A9CA4}
.sc .sc-card .hint{color:#A3A5AD}
.hx-std ul li{color:rgba(237,237,239,.66)!important}
.hx-note,.hx-pl,.hx-std>p{color:#9496A0!important}
@media screen{
/* ---- tool pages ---- */
html[data-theme=dark] .th .ic,html[data-theme=dark] .feat .ic{background:#26272D;color:#FFB15C;box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
html[data-theme=dark] details.learn,html[data-theme=dark] .ct-side .learn,html[data-theme=dark] .sp-side .learn,html[data-theme=dark] .cp-learn details.learn{background:var(--surface-2);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] details.learn .why{background:rgba(245,146,43,.1);color:var(--ink)}
html[data-theme=dark] .cp-disc{background:var(--surface);color:var(--ink);border-color:var(--line-2)}
html[data-theme=dark] .ai-card textarea,html[data-theme=dark] .ai-card select,html[data-theme=dark] .ai-card input,html[data-theme=dark] .emb-code,html[data-theme=dark] .cy-in input{background:#1E1F24;color:var(--ink)}
html[data-theme=dark] .wtabs button[aria-selected=true]{background:transparent;color:var(--ink)}
html[data-theme=dark] .v19-plan{background:var(--surface)}
/* ---- accuracy page, 404 ---- */
html[data-theme=dark]{--soft:#A3A5AD}
html[data-theme=dark] .acc-pill.match,html[data-theme=dark] .acc-pill.stable{border-color:#5FAF7E;color:#94D2AA}
html[data-theme=dark] .acc-pill.close{color:#F2A65A}
html[data-theme=dark] .acc-pill.off{border-color:#E07A6A;color:#F2A08E}
html[data-theme=dark] .nf-lede{color:#A3A5AD}html[data-theme=dark] .nf-l span{color:#A3A5AD}
html[data-theme=dark] .nf-l a:hover{border-color:var(--line-2)}
}
@media screen{
/* ---- plan view: dark model space (DXF or empty); a PDF underlay keeps its paper (drawn by plan/ui.js) ---- */
html[data-theme=dark] .pl-cvwrap{background:#18191D}
html[data-theme=dark] .pl-empty{color:#B9BBC2;background:repeating-linear-gradient(0deg,transparent 0 23px,rgba(255,255,255,.04) 23px 24px),repeating-linear-gradient(90deg,transparent 0 23px,rgba(255,255,255,.04) 23px 24px),#18191D}
html[data-theme=dark] .pl-empty h2,html[data-theme=dark] .pl-empty h3,html[data-theme=dark] .pl-empty b,html[data-theme=dark] .pl-empty strong{color:#ECEBE8}
html[data-theme=dark] .pl-empty .tbtn{color:#ECEBE8;border-color:rgba(255,255,255,.16);background:rgba(255,255,255,.04)}
html[data-theme=dark] .pl-empty .tbtn:hover{border-color:rgba(255,255,255,.4)}
}
@media screen{
/* ---- workspace ---- */
html[data-theme=dark] .stages a[aria-current] .sn{background:#ECEBE8;border-color:#ECEBE8;color:#9A4A06}
html[data-theme=dark] .stages a.done .sn{background:#2F7A52;border-color:#2F7A52;color:#fff}
html[data-theme=dark] .stages a.done .mini i{background:#7FD1A0}
html[data-theme=dark] .statusline.ok{color:#94D2AA}html[data-theme=dark] .statusline.bad{color:#F2A08E}html[data-theme=dark] .statusline.warn{color:#E8C574}
html[data-theme=dark] .ws-cs .s-pass{color:#94D2AA}html[data-theme=dark] .ws-cs .s-fail{color:#F2A08E}html[data-theme=dark] .ws-cs .s-check{color:#E8C574}html[data-theme=dark] .ws-cs .s-data{color:#9DB4E0}
html[data-theme=dark] .meter span{background:#7FD1A0}
}
@media screen{
/* tools index: the warm corner glow is quieter on dark, so a grid of cards does not turn brown */
html[data-theme=dark] .cards a.card.feat{background:radial-gradient(90% 80% at 100% 0,rgba(245,146,43,.055),transparent 60%),var(--surface);border-color:var(--line)}
html[data-theme=dark] .cards a.card.feat:hover{border-color:var(--line-2)}
}
@media screen{
/* ---- paper islands: report previews look like the printed page in both themes (never inverted) ---- */
html[data-theme=dark] :is(.oer,.plr,.keep-light){--surface:#FFFFFF;--surface-2:#F1EFEB;--line:rgba(17,17,19,.1);--line-2:rgba(17,17,19,.18);--ink:#111113;--ink-2:#3C3D42;--muted:#5F6168;--amber-ink:#9A4A06;--ok:#167A4B;--bad:#C0362C;--warn:#8A5A00;color-scheme:light}
html[data-theme=dark] :is(.oer,.plr) thead th{background:transparent}
html[data-theme=dark] :is(.oer,.plr) input,html[data-theme=dark] :is(.oer,.plr) select,html[data-theme=dark] :is(.oer,.plr) textarea{background-color:#fff;color:#111113;border-color:rgba(17,17,19,.2)}
html[data-theme=dark] .oer{box-shadow:0 0 0 1px rgba(255,255,255,.06),0 30px 60px -30px rgba(0,0,0,.7)}
}
/* both themes: report previews inside a charcoal panel kept the panel's grey table headers (1.9:1 on paper), and the amber "border" verdict was 4.0:1 */
.dev .oer thead th,.dev .oer th,.dev .plr th{color:var(--soft,#6E6A62)!important}
.oer .w-border,.oer table.oer-t td.w-border{color:#8A5A00}
/* both themes: light-page text that borrowed the charcoal panel's muted grey (2.9:1 on paper) or panel text colour (1.0:1 in the light "learn" boxes) */
.cy details.fold>summary,.sv-nums span,main>.mk-n{color:var(--muted)}
.ct-side .learn a,.sp-side .learn a,.cp-learn details.learn a{color:var(--ink)}
html:not([data-theme=dark]) thead th{color:#63656C}
.hx-rh em{color:#9A4A06}
/* both themes: v19 calculators on phones. A plain 1fr column let the two-up inputs push the panel past the screen edge. */
@media(max-width:820px){.v19-two{grid-template-columns:minmax(0,1fr)!important}.v19-two>*{min-width:0}.v19-two input,.v19-two select{min-width:0;max-width:100%}}
@media(max-width:480px){.region-p select{max-width:96px}.theme-t{margin-left:2px}}
/* both themes: the open phone menu let the page show through (a backdrop filter nested in the header's own one); make it solid */
@media(max-width:820px){.nav{background:var(--paper)!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;box-shadow:0 18px 30px -20px rgba(17,17,19,.35)}
 body:has(.hero,.hx) .nav{background:#0E0F12!important}}
@media(max-width:820px){.top:has(.nav.open){-webkit-backdrop-filter:none!important;backdrop-filter:none!important;background:var(--paper)!important}body:has(.hero,.hx) .top:has(.nav.open){background:#0E0F12!important}}
@media screen{
html[data-theme=dark] .vg:not(.vg-lay,.vg-res){background:linear-gradient(180deg,#1E1F24,#1A1B1F);border-bottom-color:var(--line)}
html[data-theme=dark] .vs i{background:#3A3B41}html[data-theme=dark] .vs i::after{background:#ECEBE8}
html[data-theme=dark] .vs.on i{background:#F28A1E}
}
