/* VoltageWarden. Sixth Day Studios palette (same tokens as sixthdaystudios.com/style.css):
   teal accent on near-black or soft grey, light and dark from one set of tokens. Mobile first. */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --border: #dfe3e8;
  --text: #16191d; --muted: #5d6671; --accent: #0c7a68; --accent-ink: #ffffff; --gold: #b7862f;
  --ok: #187741; --warn: #935905; --down: #b23939;   /* the main site's light tokens: 4.5:1 or better on white and on the chip tints */
  --glow: rgba(12, 122, 104, .08); --chip-tint: 8%;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f38;
    --text: #e8ebef; --muted: #98a2ad; --accent: #2cc4a8; --accent-ink: #06231d; --gold: #d4a24c;
    --ok: #3ccf7f; --warn: #f0a93a; --down: #ff6b6b;
    --glow: rgba(44, 196, 168, .12); --chip-tint: 14%; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f38;
  --text: #e8ebef; --muted: #98a2ad; --accent: #2cc4a8; --accent-ink: #06231d; --gold: #d4a24c;
  --ok: #3ccf7f; --warn: #f0a93a; --down: #ff6b6b;
  --glow: rgba(44, 196, 168, .12); --chip-tint: 14%; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: inline; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline; }

/* ── Header ── */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
       backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 9px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 18px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 12px; }
.std { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--glow);
       padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.theme-switch { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
                color: var(--text); cursor: pointer; font-size: 16px; }

/* ── Tool switch ── */
.tools { max-width: 520px; margin: 0 0 16px; }

/* ── Layout ── */
.layout { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) {
  .layout { grid-template-columns: 380px 1fr; }
  .inputs { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.results { display: grid; gap: 16px; min-width: 0; }
h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -.01em; }
.formhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.formhead h2 { margin: 0; }
.sechead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.sub, .hint { color: var(--muted); font-size: 13px; }
.hint { margin: 6px 0 0; }
.hint:empty { display: none; }

/* ── Form ── */
fieldset { border: 0; border-top: 1px solid var(--border); margin: 14px 0 0; padding: 12px 0 0; min-width: 0; display: grid; gap: 10px; }
legend { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); padding: 0 8px 0 0; }
.two { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.two > .f:only-child { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
input[type=number], input[type=text], select {
  font: 15px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; min-height: 42px; width: 100%; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, .seg input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2);
       border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 7px 8px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
details { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; color: var(--text); }
details[open] > summary { margin-bottom: 10px; }
details > .two, details > .check { margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
#adv.off .two:first-of-type { opacity: .5; }

/* ── Conduit planner: one row per cable line ── */
.items { display: grid; gap: 8px; }
.item { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) 96px 64px 36px; align-items: end;
        padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.item label.f { font-size: 12px; }
.item .od { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -2px; }
.item .x { min-height: 42px; padding: 0; width: 36px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fault-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; }
@media (min-width: 1150px) { .fault-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fault-grid .tile { box-shadow: none; background: var(--surface-2); }
.verdict .btn { margin-top: 8px; }
.split { display: grid; gap: 10px; margin-top: 10px; }
.split-opt { display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; padding: 12px 14px;
             border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.split-opt > div { flex: 1 1 260px; min-width: 0; }
.split-opt strong { font-size: 16px; }
.split-opt .chip { margin-left: 6px; vertical-align: 2px; }
.split-opt p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
       border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
       font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; }

/* ── Results ── */
.verdict { display: flex; gap: 14px; align-items: center; border-width: 2px; }
.verdict .mark { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
                 font-size: 24px; font-weight: 800; }
.verdict h2 { font-size: 20px; }
.verdict p { margin: 2px 0 0; color: var(--muted); }
.verdict.ok { border-color: color-mix(in srgb, var(--ok) 60%, var(--border)); }
.verdict.ok .mark { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.verdict.bad { border-color: color-mix(in srgb, var(--down) 60%, var(--border)); }
.verdict.bad .mark { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); }
.verdict.idle .mark { background: var(--glow); color: var(--accent); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* odd tile out (Earth) spans the row */
@media (min-width: 1150px) {
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tiles .tile:last-child:nth-child(odd) { grid-column: auto; }
}
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: 2px; }
.tile .v small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.tile .d { font-size: 13px; color: var(--muted); }
.tile.bad .v { color: var(--down); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .25s; }
.meter.warn i { background: var(--warn); }
.meter.bad i { background: var(--down); }

.scroll { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
     text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
#sizes tbody tr { cursor: pointer; }
#sizes tbody tr:hover td { background: var(--surface-2); }
tr.sel td { background: var(--glow); }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.run td { font-weight: 700; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) var(--chip-tint), transparent); }
.chip.bad { color: var(--down); background: color-mix(in srgb, var(--down) var(--chip-tint), transparent); }
.chip.rec { color: var(--accent); background: var(--glow); }
.notes ul { margin: 6px 0 0; padding-left: 18px; }
.notes li { margin: 4px 0; }
.notes li.warn { color: var(--warn); }
.notes li.bad { color: var(--down); }

/* ── Donate + footer ── */
.donate { display: flex; gap: 14px 24px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
.donate > div:first-child { flex: 1 1 280px; min-width: 0; }
.donate p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.donate .amts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.donate .amts span { font-size: 12px; color: var(--muted); min-width: 52px; }
footer { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px;
         border-top: 1px solid var(--border); margin: 24px 0 0; padding: 14px 0 32px; }
footer img { flex: none; }

@media (max-width: 520px) {
  .std { display: none; }
  .two { grid-template-columns: 1fr; }
  .item { grid-template-columns: minmax(0, 1fr) 64px 36px; }
  .item > label.f:first-child { grid-column: 1 / -1; }   /* cable name gets its own line on phones */
  .tile .v { font-size: 22px; }
}
@media print {
  .noprint, .top, #adv:not([open]), #fl:not([open]) { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { grid-template-columns: 1fr; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
  .inputs { position: static; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .meter i { transition: none; } }
