/* PowerVoltEdge — palette taken from UK conductor colours and cable sheath */
:root {
  --sheath: #e4e6e2;      /* grey cable sheath: page */
  --panel: #ffffff;
  --ink: #1b2127;
  --muted: #56616b;
  --rule: #c7cbc6;
  --brown: #7a4a2a;       /* L1 */
  --black: #24282c;       /* L2 */
  --grey: #8a8f93;        /* L3 */
  --blue: #2453a4;        /* N */
  --earth-g: #3c8a3f;
  --earth-y: #e2bd1c;
  --lcd: #c8d4ae;
  --lcd-ink: #1e2913;
  --lcd-dim: #7f8e66;
  --pass: #2f7a35;
  --fail: #b3261e;
  --focus: #2453a4;
  --radius-s: 4px;
  --radius-m: 10px;
  --font: "Archivo", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sheath: #14181b;
    --panel: #1d2226;
    --ink: #e8ebed;
    --muted: #a3acb3;
    --rule: #343b41;
    --brown: #c08356;
    --blue: #7ea6ec;
    --earth-g: #6cbf6f;
    --pass: #6cbf6f;
    --fail: #ff8a80;
    --focus: #7ea6ec;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sheath);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variation-settings: "wdth" 100;
}
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
img, svg { display: block; }

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-head { background: var(--panel); border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.01em; font-variation-settings: "wdth" 118; }
.brand-name span { font-weight: 500; }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* Core stripe: the three-core cable mark */
.cores { display: inline-flex; gap: 3px; }
.cores i { width: 6px; height: 22px; border-radius: 3px; display: block; }
.cores .l { background: var(--brown); }
.cores .n { background: var(--blue); }
.cores .e { background: repeating-linear-gradient(-45deg, var(--earth-g) 0 4px, var(--earth-y) 4px 8px); }

main { padding: 32px 0 56px; }

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); font-weight: 800; font-variation-settings: "wdth" 112; }
h2 { font-size: 1.4rem; font-weight: 750; font-variation-settings: "wdth" 108; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; max-width: 68ch; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }

/* Calculator layout */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  overflow: hidden;
  margin: 24px 0 32px;
}
.calc-inputs { padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
.calc-output { padding: 24px; background: color-mix(in srgb, var(--panel) 92%, var(--ink)); border-left: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.field .seg { justify-self: start; }
.input-unit .unit:empty { display: none; }
.field label, .field legend { font-weight: 650; font-size: 0.95rem; }
.field .hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.input-unit { display: flex; align-items: stretch; border: 1.5px solid var(--rule); border-radius: var(--radius-s); background: var(--panel); }
.input-unit:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent); }
.input-unit input, .input-unit select { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.input-unit input:focus, .input-unit select:focus { outline: none; }
.input-unit .unit { padding: 10px 12px; color: var(--muted); border-left: 1px solid var(--rule); font-weight: 600; min-width: 3.2em; text-align: center; }
select.plain { width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; border: 1.5px solid var(--rule); border-radius: var(--radius-s); background: var(--panel); color: var(--ink); font: inherit; padding: 10px 12px; }

fieldset { border: 0; padding: 0; margin: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; }
.seg label { font-weight: 600; font-size: 0.95rem; padding: 8px 14px; cursor: pointer; position: relative; }
.seg label + label { border-left: 1.5px solid var(--rule); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--panel); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 700; padding: 10px 18px; border-radius: var(--radius-s); border: 1.5px solid var(--ink); background: var(--ink); color: var(--panel); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); }

/* The LCD readout: the one bold element */
.lcd {
  background: var(--lcd);
  color: var(--lcd-ink);
  border-radius: 6px;
  padding: 16px 18px 14px;
  box-shadow: inset 0 2px 0 rgba(0,0,0,0.12), inset 0 0 0 1px rgba(0,0,0,0.18);
  border: 6px solid #2b3034;
}
.lcd-label { font-size: 0.85rem; font-weight: 650; color: var(--lcd-dim); margin: 0 0 2px; }
.lcd-value { font-size: clamp(2.2rem, 7vw, 3.1rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; font-variation-settings: "wdth" 125; letter-spacing: -0.01em; }
.lcd-value small { font-size: 0.45em; font-weight: 700; margin-left: 4px; font-variation-settings: "wdth" 100; }
.lcd-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(30,41,19,0.35); }
.lcd-rows div { font-variant-numeric: tabular-nums; }
.lcd-rows .k { font-size: 0.8rem; color: var(--lcd-dim); font-weight: 650; display: block; }
.lcd-rows .v { font-size: 1.2rem; font-weight: 750; font-variation-settings: "wdth" 115; }
.lcd.is-empty .lcd-value { color: var(--lcd-dim); }

.verdict { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-s); border: 1.5px solid currentColor; font-weight: 600; }
.verdict.pass { color: var(--pass); }
.verdict.fail { color: var(--fail); }
.verdict[hidden] { display: none; }
.error { color: var(--fail); font-weight: 600; margin: 0; }
.error:empty { display: none; }

.copy-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.copy-row .btn { padding: 8px 14px; font-size: 0.95rem; }
.copy-status { font-size: 0.9rem; color: var(--muted); }
.check-note { font-size: 0.9rem; color: var(--muted); border-left: 4px solid var(--earth-y); padding: 4px 0 4px 12px; margin: 0; }

/* Explainer below each calculator */
.explain { max-width: 70ch; }
.explain h2 { margin-top: 1.6em; }
.formula { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 12px 16px; display: inline-block; margin: 0 0 1em; font-variation-settings: "wdth" 110; }

/* Home: tool list as cable runs, not cards */
.tool-list { list-style: none; padding: 0; margin: 16px 0 40px; border-top: 1px solid var(--rule); }
.tool-list li { border-bottom: 1px solid var(--rule); }
.tool-list a, .tool-list .soon { display: grid; grid-template-columns: 8px 1fr auto; gap: 16px; align-items: center; padding: 18px 4px; color: var(--ink); text-decoration: none; }
.tool-list a:hover { background: var(--panel); }
.tool-list .core { width: 8px; height: 100%; min-height: 44px; border-radius: 4px; }
.tool-list .t { font-weight: 750; font-size: 1.1rem; font-variation-settings: "wdth" 110; }
.tool-list .d { display: block; color: var(--muted); font-size: 0.95rem; font-weight: 400; font-variation-settings: "wdth" 100; }
.tool-list .go { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.tool-list .soon { color: var(--muted); }
.tool-list .soon .t { color: var(--muted); }

.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-bottom: 40px; }
.hero h1 { margin-top: 32px; }
.quick { font-weight: 600; }
.install-note { font-size: 0.95rem; color: var(--muted); border-left: 4px solid var(--blue); padding: 4px 0 4px 12px; }
.hero .calc { margin: 0; grid-template-columns: minmax(0, 1fr); }
.hero .calc-output { border-left: 0; border-top: 1px solid var(--rule); }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); background: var(--panel); padding: 24px 0 32px; font-size: 0.9rem; color: var(--muted); }
.site-foot .wrap { display: grid; gap: 10px; }
.site-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }

/* Learning hub */
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); }
.lesson { max-width: 70ch; }
.lesson h2 { margin-top: 1.6em; }
.lesson ul, .lesson ol { padding-left: 1.3em; }
.lesson li { margin-bottom: 0.4em; }
.topic-count { font-weight: 650; color: var(--brown); margin-bottom: 6px; }
.tip { background: var(--panel); border-left: 4px solid var(--earth-y); padding: 12px 16px; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.diagram { width: 100%; max-width: 440px; height: auto; margin: 8px 0 20px; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 12px; }
.diagram.small { max-width: 240px; }
table.data { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; background: var(--panel); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-weight: 700; }
.calc-link { font-weight: 600; }
.quiz { margin-top: 2em; padding-top: 1em; border-top: 2px solid var(--ink); }
.quiz .q { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 16px; margin: 0 0 14px; }
.quiz legend { font-weight: 700; float: left; width: 100%; margin-bottom: 10px; }
.quiz .opts { clear: both; display: grid; gap: 8px; }
.opt { font: inherit; text-align: left; padding: 11px 14px; min-height: 44px; border: 1.5px solid var(--rule); border-radius: var(--radius-s); background: var(--panel); color: var(--ink); cursor: pointer; }
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:disabled { cursor: default; opacity: 0.75; }
.opt.is-right { border-color: var(--pass); color: var(--pass); font-weight: 700; opacity: 1; }
.opt.is-wrong { border-color: var(--fail); color: var(--fail); opacity: 1; text-decoration: line-through; }
.fb { margin: 10px 0 0; font-weight: 600; }
.fb:empty { display: none; }
.fb.pass { color: var(--pass); }
.fb.fail { color: var(--fail); }
.quiz-score { font-weight: 700; font-size: 1.1rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 32px 0; max-width: 70ch; }
.pager a { display: block; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 12px 16px; text-decoration: none; color: var(--ink); font-weight: 700; }
.pager a span { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.pager .next { text-align: right; }
.pack-cta { max-width: 70ch; background: var(--panel); border: 2px solid var(--ink); border-radius: var(--radius-m); padding: 20px; margin: 24px 0; }
.pack-cta h2 { margin-top: 0; }
.btn.is-disabled { display: inline-block; opacity: 0.55; cursor: not-allowed; }
a.btn { display: inline-block; text-decoration: none; }
.topic-list { list-style: none; counter-reset: t; padding: 0; margin: 16px 0 24px; max-width: 70ch; }
.topic-list li { counter-increment: t; border-bottom: 1px solid var(--rule); }
.topic-list a { display: grid; grid-template-columns: 2.2em 1fr; column-gap: 8px; padding: 16px 4px; color: var(--ink); text-decoration: none; }
.topic-list a::before { content: counter(t); grid-row: span 3; font-weight: 800; font-size: 1.4rem; color: var(--brown); font-variation-settings: "wdth" 120; }
.topic-list a:hover { background: var(--panel); }
.topic-list .t { font-weight: 750; font-size: 1.1rem; }
.topic-list .d { color: var(--muted); font-size: 0.95rem; }
.topic-list .q { font-size: 0.85rem; font-weight: 650; color: var(--blue); }
.hint-text { font-size: 0.9rem; color: var(--muted); }

.prose { max-width: 70ch; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.4em; }

@media (max-width: 760px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .calc-output { border-left: 0; border-top: 1px solid var(--rule); }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .calc-inputs, .calc-output { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
