/* Layout: sticky strip, then page content. Tool pages: dark instrument panel (live readout + one-cycle current trace),
   bench with inputs beside the analysis sheet, then explanatory prose. One column on phones. */
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/chakra-petch-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #ECEEEA;
  --panel: #FAFAF8;
  --field: #FFFFFF;
  --ink: #16191C;
  --muted: #5A6067;
  --rule: #D2D5CE;
  --accent: #E3AE00;
  --accent-ink: #8C6600;
  --link: #1F5BC4;
  --focus: #2E6BD6;
  --c-tx: #E3AE00;
  --c-act: #2E6BD6;
  --c-sleep: #178A77;
  --c-base: #C9472F;
  --c-sd: #8576B3;
  --note-bg: #F6EBCB;
  --note-ink: #5E4100;
  --err-bg: #F7DDD6;
  --err-ink: #8A2414;
  --scope-bg: #16191C;
  --scope-edge: #16191C;
  --scope-ink: #ECEEE8;
  --scope-dim: #8E969E;
  --scope-grid: #2A3036;
  --scope-trace: #F4C21E;
  --font-display: "Chakra Petch", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215; --panel: #171A1E; --field: #1D2126; --ink: #E5E7EA; --muted: #99A0A8; --rule: #2A2F35;
    --accent: #F4C21E; --accent-ink: #F4C21E; --link: #8DB2F7; --focus: #6E9BF2;
    --c-tx: #F4C21E; --c-act: #5C8FEF; --c-sleep: #2DB8A0; --c-base: #E86E58; --c-sd: #A898D8;
    --note-bg: #33290F; --note-ink: #F1D27E; --err-bg: #3A1A14; --err-ink: #F2A898;
    --scope-bg: #0A0C0E; --scope-edge: #262B31; --scope-grid: #23292F;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 2px; }
.gut { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: var(--r); z-index: 50; }
.skip:focus { top: 8px; }
a:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* strip */
.bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--rule); }
.bar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .01em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.cell { width: 24px; height: 13px; border: 2px solid var(--ink); border-radius: 3px; position: relative; padding: 1px; flex: none; }
.cell::before { content: ""; display: block; height: 100%; width: 60%; background: var(--accent); border-radius: 1px; }
.cell::after { content: ""; position: absolute; right: -5px; top: 2.5px; width: 3px; height: 4px; background: var(--ink); border-radius: 0 1px 1px 0; }
.bar-readout { margin-left: auto; font-family: var(--font-mono); font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-variant-numeric: tabular-nums; }
.bar-readout.on { opacity: 1; }
.bar-readout b { color: var(--ink); font-weight: 500; }
.lang { display: flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; flex: none; margin-left: auto; }
.bar-readout + .lang { margin-left: 0; }
.lang a, .lang span { font: 500 12px/1 var(--font-mono); letter-spacing: .06em; padding: 8px 10px; color: var(--muted); text-decoration: none; }
.lang span[aria-current] { background: var(--ink); color: var(--bg); }
.lang a:hover { color: var(--ink); }

main { max-width: 1180px; margin: 0 auto; padding-block: 0 56px; display: block; }

/* intro */
.intro { padding-block: 28px 20px; max-width: 780px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 4.4vw, 42px); line-height: 1.08; letter-spacing: -.005em; margin: 0 0 10px; text-wrap: balance; }
.lede { margin: 0; color: var(--muted); font-size: 16px; max-width: 64ch; }

/* instrument panel */
.scope { background: var(--scope-bg); color: var(--scope-ink); border: 1px solid var(--scope-edge); border-radius: 12px; padding: 22px clamp(16px, 2.5vw, 28px) 16px; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.6fr); gap: 22px 34px; }
@media (max-width: 860px) { .scope { grid-template-columns: minmax(0, 1fr); } }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.scope .eyebrow { color: var(--scope-dim); }
.readout { min-width: 0; display: flex; flex-direction: column; }
.big { font-family: var(--font-display); font-weight: 700; font-size: clamp(54px, 8vw, 82px); line-height: .95; margin: 12px 0 8px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--scope-trace); }
.big .u { font-size: .4em; color: var(--scope-ink); margin-left: .2em; letter-spacing: 0; }
.sub { font-family: var(--font-mono); font-size: 13px; color: var(--scope-dim); min-height: 1.5em; }
.readout .sub { margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--scope-grid); }
.stats > div { display: flex; flex-direction: column; min-width: 0; }
.stats dt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--scope-dim); line-height: 1.3; }
.stats dd { margin: auto 0 0; padding-top: 5px; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.trace { margin: 0; min-width: 0; }
.svgbox { width: 100%; margin-top: 6px; min-height: 200px; }
.svgbox svg { display: block; width: 100%; overflow: visible; }

/* bench */
.bench { display: grid; grid-template-columns: minmax(0, 390px) minmax(0, 1fr); gap: 28px 36px; margin-top: 30px; align-items: start; }
@media (max-width: 900px) { .bench { grid-template-columns: minmax(0, 1fr); } }
fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0 0 26px; padding: 0; min-width: 0; }
legend { font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding: 0 10px 0 0; }
.fs { display: grid; gap: 15px; padding-top: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.lbl { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sw { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.tx { background: var(--c-tx); } .act { background: var(--c-act); } .sleep { background: var(--c-sleep); } .base { background: var(--c-base); } .sd { background: var(--c-sd); }
.inp { display: flex; align-items: stretch; background: var(--field); border: 1px solid var(--rule); border-radius: var(--r); min-width: 0; }
.inp:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.inp input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); font: 400 15px/1.2 var(--font-mono); padding: 10px; font-variant-numeric: tabular-nums; outline: none; }
.inp .unit { font: 400 12.5px/1 var(--font-mono); color: var(--muted); padding: 0 10px 0 4px; display: flex; align-items: center; white-space: nowrap; }
.inp select { border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--ink); font: 400 13px var(--font-mono); padding: 0 8px; outline: none; cursor: pointer; }
select.sel { width: 100%; max-width: 100%; background: var(--field); border: 1px solid var(--rule); border-radius: var(--r); color: var(--ink); font: 400 14px/1.3 var(--font-body); padding: 9px 10px; cursor: pointer; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.mini { font: 400 11px/1.2 var(--font-mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* analysis sheet */
.sheet { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 4px clamp(16px, 2.4vw, 26px); min-width: 0; }
.sheet > section { padding-block: 20px; border-top: 1px solid var(--rule); }
.sheet > section:first-child { border-top: 0; }
.sheet h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.2; margin: 0 0 14px; text-wrap: balance; }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 3px; overflow: hidden; }
.stack span { display: block; height: 100%; min-width: 2px; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; }
.legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 3.4em; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--rule); font-size: 14px; }
.legend li:last-child { border-bottom: 0; }
.legend .v, .legend .p { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.legend .v { color: var(--muted); }
.legend .p { font-weight: 500; }
.notes { display: grid; gap: 10px; }
.notes:not(:empty) { margin-bottom: 16px; }
.note { background: var(--note-bg); color: var(--note-ink); padding: 10px 12px; border-radius: var(--r); font-size: 14px; }
.note.err { background: var(--err-bg); color: var(--err-ink); }
.tips { display: grid; gap: 16px; }
.tip h3 { margin: 0 0 5px; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.tip p { margin: 0; max-width: 68ch; }
.cap { margin: 10px 0 0; font-size: 13px; color: var(--muted); max-width: 70ch; }
.dbl { margin: 12px 0 0; font-size: 14.5px; max-width: 70ch; }
.dbl b { font-weight: 600; }
.copyrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.btn { font: 500 14px/1 var(--font-body); background: var(--ink); color: var(--panel); border: 0; border-radius: var(--r); padding: 11px 15px; cursor: pointer; }
.btn:hover { opacity: .9; }
.status { font-size: 13px; color: var(--muted); }
#fallback { display: block; width: 100%; margin-top: 12px; font: 12.5px/1.45 var(--font-mono); background: var(--field); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px; min-height: 150px; resize: vertical; }
.method { font-size: 13px; color: var(--muted); margin: 14px 0 0; max-width: 72ch; }

/* svg */
.g-grid { stroke: var(--scope-grid); stroke-width: 1; }
.g-axis { stroke: var(--scope-dim); stroke-width: 1; opacity: .5; }
.g-lab { fill: var(--scope-dim); font: 400 10.5px var(--font-mono); }
.g-val { fill: var(--scope-ink); font: 500 11.5px var(--font-mono); }
.g-trace { fill: none; stroke: var(--scope-trace); stroke-width: 2; stroke-linejoin: round; }
.g-area { fill: var(--scope-trace); fill-opacity: .13; }
.g-gap { fill: var(--scope-bg); }
.g-break { stroke: var(--scope-dim); stroke-width: 1.5; fill: none; }
.ph-sleep { fill: var(--c-sleep); } .ph-act { fill: var(--c-act); } .ph-tx { fill: var(--c-tx); }
.c-grid { stroke: var(--rule); stroke-width: 1; }
.c-lab { fill: var(--muted); font: 400 10.5px var(--font-mono); }
.c-line { fill: none; stroke: var(--accent-ink); stroke-width: 2.25; stroke-linejoin: round; }
.c-area { fill: var(--accent); fill-opacity: .12; }
.c-asym { stroke: var(--muted); stroke-width: 1.25; stroke-dasharray: 5 4; }
.c-drop { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; opacity: .5; }
.c-dot { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }
.c-now { fill: var(--ink); font: 500 12px var(--font-mono); }
.c-ann { fill: var(--muted); font: 400 11px var(--font-mono); }

/* prose under the tool, privacy page */
.prose { max-width: 760px; margin-top: 48px; }
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3vw, 27px); line-height: 1.15; margin: 40px 0 12px; text-wrap: balance; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 17px; font-weight: 600; margin: 24px 0 6px; line-height: 1.3; }
.prose p, .prose li { font-size: 16px; line-height: 1.65; max-width: 68ch; }
.prose p { margin: 0 0 14px; }
.prose code { font-family: var(--font-mono); font-size: .92em; }
.formula { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 16px; overflow-x: auto; white-space: pre; margin: 0 0 16px; }
.tbl { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); }
.tbl table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font: 500 11px/1.3 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.tbl td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tblcap { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.faq h3 { margin-top: 26px; }
.updated { font-size: 13px; color: var(--muted); }

/* home */
.home-hero { padding-block: 44px 28px; max-width: 820px; }
.home-hero h1 { font-size: clamp(32px, 5.4vw, 54px); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.card { display: grid; grid-template-rows: auto 1fr; background: var(--scope-bg); color: var(--scope-ink); border: 1px solid var(--scope-edge); border-radius: 12px; text-decoration: none; overflow: hidden; }
.card:hover .card-cta { text-decoration: underline; }
.card svg { display: block; width: 100%; height: 96px; }
.card-body { padding: 4px 20px 20px; display: grid; gap: 6px; align-content: start; }
.card .eyebrow { color: var(--scope-dim); }
.card h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--scope-trace); }
.card p { margin: 0; color: var(--scope-ink); }
.card-cta { margin-top: 8px; font-weight: 500; color: var(--scope-ink); }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 22px 30px; margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--rule); }
.why h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.why p { margin: 0; color: var(--muted); }

/* footer */
.foot { border-top: 1px solid var(--rule); }
.foot-in { max-width: 1180px; margin: 0 auto; padding-block: 22px 32px; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: baseline; font-size: 13px; color: var(--muted); }
.foot-in p { margin: 0; flex: 1 1 320px; max-width: 72ch; }
.foot-in nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot-in a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .bar-readout { transition: none; } }

/* ---------- shared bits for the newer tools ---------- */
.boardbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 18px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--field); max-width: 100%; }
.seg button { font: 500 13px/1.2 var(--font-body); color: var(--muted); background: transparent; border: 0; padding: 9px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg-static { font: 500 13px/1.2 var(--font-mono); color: var(--muted); }
.xlink { font-weight: 500; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent-ink); flex: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn.sm { padding: 9px 12px; font-size: 13px; }
.inp input[type="text"] { font-family: var(--font-body); }
.fallback { display: block; width: 100%; margin-top: 12px; font: 12.5px/1.45 var(--font-mono); background: var(--field); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px; min-height: 150px; resize: vertical; }

/* ---------- pinout ---------- */
.pinscope { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .pinscope { grid-template-columns: minmax(0, 1fr); } }
.pm-wrap { min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { font: 500 12px/1 var(--font-mono); letter-spacing: .04em; color: var(--scope-dim); background: transparent; border: 1px solid var(--scope-grid); border-radius: 999px; padding: 7px 11px; cursor: pointer; }
.chip:hover { color: var(--scope-ink); border-color: var(--scope-dim); }
.chip[aria-pressed="true"] { background: var(--scope-trace); border-color: var(--scope-trace); color: #16191C; }
.chip:focus-visible, .pin:focus-visible { outline: 2px solid var(--scope-trace); outline-offset: 2px; }
.pm-fnote { font-size: 12.5px; color: var(--scope-dim); margin: -6px 0 14px; max-width: 60ch; }
.s-ok { --pin-c: #2DB8A0; } .s-warn { --pin-c: #F4C21E; } .s-in { --pin-c: #5C8FEF; } .s-bad { --pin-c: #E86E58; } .s-pwr { --pin-c: #6B737B; }
.pinmap { display: grid; grid-template-columns: minmax(0, 1fr) clamp(70px, 13vw, 124px) minmax(0, 1fr); grid-template-rows: repeat(var(--rows), 30px); }
.pm-board { grid-column: 2; position: relative; border: 1.5px solid #3A4149; border-radius: 9px; background: rgba(255, 255, 255, .035); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 10px 0; }
.pm-chip { writing-mode: vertical-rl; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; color: var(--scope-dim); border: 1px solid #3A4149; border-radius: 4px; padding: 14px 8px; background: rgba(255, 255, 255, .03); }
.esp32 .pm-chip { margin-top: 4px; }
.pm-end { display: block; }
.pm-end.antenna { width: 62%; height: 18px; background: repeating-linear-gradient(90deg, #4A525B 0 2px, transparent 2px 9px); border-bottom: 2px solid #4A525B; opacity: .8; }
.pm-end.usb { width: 34%; min-width: 24px; height: 14px; border: 1.5px solid #6B737B; border-radius: 3px; }
.pm-end.bottom.usb { margin-bottom: -16px; }
.pm-end.usb:not(.bottom) { margin-top: -16px; }
.pm-end.debug { width: 30%; height: 6px; background: radial-gradient(circle, #6B737B 2px, transparent 2.5px) 0 0 / 33.3% 100% repeat-x; }
.pin { grid-column: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; height: 30px; background: none; border: 0; padding: 0 2px 0 4px; margin: 0; color: var(--scope-ink); font: 500 12.5px/1 var(--font-mono); cursor: pointer; transition: opacity .15s; }
.pin.R { grid-column: 3; justify-content: flex-start; padding: 0 4px 0 2px; }
.pin .pad { width: 14px; height: 14px; border-radius: 3px; flex: none; background: var(--pin-c); }
.pin.L .pt { order: 1; text-align: right; } .pin.L .pn { order: 2; } .pin.L .pad { order: 3; margin-right: -9px; }
.pin.R .pad { order: 1; margin-left: -9px; } .pin.R .pn { order: 2; } .pin.R .pt { order: 3; }
.pin .pn { white-space: nowrap; }
.pin .pt { font: 400 10.5px/1 var(--font-mono); color: var(--scope-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pin.s-pwr .pn { color: var(--scope-dim); }
.pin:hover .pn { color: var(--scope-trace); }
.pin[aria-pressed="true"] .pn { color: var(--scope-trace); }
.pin[aria-pressed="true"] .pad { box-shadow: 0 0 0 2px var(--scope-bg), 0 0 0 4px var(--scope-trace); }
.pin.hit .pt { color: var(--scope-ink); }
.pin.dim { opacity: .26; }
.pin.inplan .pn { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: #2DB8A0; }
.pin.plan-warn .pn { text-decoration-color: #F4C21E; }
.pin.plan-err .pn { text-decoration-color: #E86E58; }
.pm-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0; margin: 18px 0 0; font-size: 12.5px; color: var(--scope-dim); }
.pm-legend li { display: flex; align-items: center; gap: 7px; }
.pm-legend .pad { width: 11px; height: 11px; border-radius: 2px; background: var(--pin-c); display: inline-block; }
.pm-detail { min-width: 0; border-left: 1px solid var(--scope-grid); padding-left: clamp(16px, 2.4vw, 28px); align-self: stretch; }
.pm-hint { color: var(--scope-dim); font-size: 14px; margin: 0; }
.pd-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.pd-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(34px, 5vw, 50px); line-height: 1; color: var(--scope-trace); letter-spacing: -.01em; }
.pd-badge { font: 500 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--pin-c); color: var(--pin-c); }
.pd-sub { font: 400 13px/1.4 var(--font-mono); color: var(--scope-dim); margin: 8px 0 4px; }
.pm-detail .eyebrow { margin: 16px 0 8px; }
.pd-fns { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pd-fns li { font: 500 12px/1 var(--font-mono); padding: 6px 8px; border: 1px solid var(--scope-grid); border-radius: 4px; color: var(--scope-ink); }
.pd-desc { color: var(--scope-ink); font-size: 14px; margin: 12px 0 0; max-width: 52ch; }
.pd-notes { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.pd-notes li { font-size: 13.5px; line-height: 1.45; padding-left: 12px; border-left: 3px solid var(--scope-dim); color: var(--scope-ink); }
.pd-notes .lvl-err { border-left-color: #E86E58; } .pd-notes .lvl-warn { border-left-color: #F4C21E; } .pd-notes .lvl-info { color: var(--scope-dim); }
.pd-add { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--scope-grid); display: grid; gap: 8px; }
.pd-add .mini { color: var(--scope-dim); }
.pd-addrow { display: flex; gap: 8px; }
.pd-addrow .sel { flex: 1; min-width: 0; background: #1D2126; color: #E5E7EA; border-color: #2F353C; }
.pinscope .btn { background: var(--scope-trace); color: #16191C; }
@media (max-width: 860px) {
  .pm-detail { border-left: 0; position: sticky; bottom: 0; z-index: 5; background: var(--scope-bg); border-top: 1px solid var(--scope-grid); margin: 0 calc(-1 * clamp(16px, 2.5vw, 28px)) -16px; padding: 14px clamp(16px, 2.5vw, 28px) 16px; max-height: 46vh; overflow: auto; box-shadow: 0 -12px 24px rgba(0, 0, 0, .35); border-radius: 0 0 12px 12px; }
  .pd-name { font-size: 32px; }
  .pm-detail .eyebrow { margin-top: 12px; }
}
@media (max-width: 520px) {
  .pinmap { grid-template-rows: repeat(var(--rows), 32px); }
  .pin { font-size: 11.5px; gap: 6px; height: 32px; }
  .pin .pt { display: none; }
  .pin.hit .pt { display: inline; font-size: 9.5px; }
}
.plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plan-sum { font: 500 13px/1.4 var(--font-mono); margin: -4px 0 14px; color: var(--muted); }
.plan-sum.lvl-err { color: var(--err-ink); } .plan-sum.lvl-warn { color: var(--note-ink); } .plan-sum.lvl-ok { color: var(--c-sleep); }
.pl-item { border: 1px solid var(--rule); border-left: 4px solid var(--c-sleep); border-radius: var(--r); background: var(--field); padding: 10px; }
.pl-item.pl-err { border-left-color: var(--c-base); } .pl-item.pl-warn { border-left-color: var(--accent); }
.pl-row { display: grid; grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pl-pin { font: 600 13px/1 var(--font-mono); background: none; border: 0; color: var(--ink); padding: 6px 2px; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.pl-role.sel { padding: 7px 8px; font-size: 13.5px; }
.pl-label { border: 1px solid var(--rule); border-radius: var(--r); background: var(--field); color: var(--ink); font: 400 13.5px/1.2 var(--font-body); padding: 8px; min-width: 0; width: 100%; }
.pl-x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; }
.pl-x:hover { color: var(--err-ink); }
.pl-issues { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.pl-issues li { font-size: 13.5px; line-height: 1.45; padding: 7px 10px; border-radius: 4px; }
.pl-issues .lvl-err { background: var(--err-bg); color: var(--err-ink); }
.pl-issues .lvl-warn { background: var(--note-bg); color: var(--note-ink); }
.pl-issues .lvl-info { color: var(--muted); border-left: 2px solid var(--rule); border-radius: 0; padding: 2px 10px; }
@media (max-width: 520px) { .pl-row { grid-template-columns: auto minmax(0, 1fr) auto; } .pl-label { grid-column: 1 / -1; grid-row: 2; } }
@media (prefers-reduced-motion: reduce) { .pin { transition: none; } }

/* card art for the newer tools */
.g-board { fill: rgba(255, 255, 255, .04); stroke: var(--scope-grid); stroke-width: 1.5; }
.g-pad { fill: #2DB8A0; } .g-pad.w { fill: var(--scope-trace); } .g-pad.b { fill: #5C8FEF; } .g-pad.r { fill: #E86E58; } .g-pad.h { fill: var(--scope-ink); }
.g-limit { stroke: var(--scope-dim); stroke-width: 1.25; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.g-trace.dim { stroke: #E86E58; opacity: .7; stroke-width: 1.5; }
.g-trace.soc { stroke: #2DB8A0; stroke-width: 1.75; }
.g-code { fill: var(--scope-grid); } .g-code.k { fill: #5C8FEF; opacity: .85; } .g-code.v { fill: var(--scope-trace); opacity: .9; }
.pd-close { display: none; margin-left: auto; background: none; border: 1px solid var(--scope-grid); color: var(--scope-ink); border-radius: 999px; width: 34px; height: 34px; font-size: 20px; line-height: 1; cursor: pointer; }
@media (max-width: 860px) { .pd-close { display: inline-block; } .pm-detail .pm-hint { font-size: 13px; } }

/* ---------- wire size ---------- */
.b-ok { fill: #2DB8A0; fill-opacity: .55; } .b-rec { fill: var(--scope-trace); } .b-bad { fill: #E86E58; fill-opacity: .55; }
.b-amp { fill: none; stroke: #E86E58; stroke-width: 1.5; stroke-dasharray: 3 3; }
.g-lim { stroke: var(--scope-ink); stroke-width: 1.25; stroke-dasharray: 6 4; opacity: .75; }
.seg + .seg, .inp + .seg, .sel + .inp { margin-top: 6px; }
.field > .seg { justify-self: start; }
.wtbl { margin: 0; }
.wtbl table { font-size: 13.5px; }
.wtbl th, .wtbl td { padding: 7px 10px; white-space: nowrap; }
.wtbl tr.rec td { background: var(--note-bg); color: var(--note-ink); font-weight: 600; }
.wtbl tr.bad td { color: var(--muted); }
.tag { font: 500 11px/1 var(--font-mono); letter-spacing: .04em; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--rule); white-space: nowrap; }
.tag.rec { background: var(--accent); border-color: var(--accent); color: #16191C; }
.tag.bad { color: var(--err-ink); border-color: currentColor; }
.tag.ok { color: var(--c-sleep); border-color: currentColor; }

/* ---------- off-grid ---------- */
.og-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; margin-bottom: 20px; }
.og-res { min-width: 0; }
.og-big { font-family: var(--font-display); font-weight: 700; font-size: clamp(36px, 4.6vw, 50px); line-height: 1; margin: 8px 0 6px; color: var(--scope-trace); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.og-big .u { font-size: .46em; color: var(--scope-ink); margin-left: .18em; letter-spacing: 0; }
.og-res .sub { font-size: 12px; line-height: 1.4; }
.og-night { fill: #5C8FEF; fill-opacity: .1; }
.g-val.sun { fill: var(--scope-trace); }
.loads { display: grid; gap: 8px; }
.ld-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "name name x" "w h meta"; gap: 6px 8px; padding: 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); align-items: center; }
.ld-name { grid-area: name; border: 1px solid var(--rule); border-radius: var(--r); background: var(--field); color: var(--ink); font: 500 14px/1.2 var(--font-body); padding: 8px 9px; min-width: 0; }
.ld-name:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.ld-x { grid-area: x; }
.ld-row > .inp:nth-of-type(1) { grid-area: w; }
.ld-row > .inp:nth-of-type(2) { grid-area: h; }
.ld-row .inp input { padding: 8px; font-size: 14px; }
.ld-meta { grid-area: meta; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ld-ac { display: flex; align-items: center; gap: 5px; font: 500 12px/1 var(--font-mono); color: var(--muted); cursor: pointer; }
.ld-ac input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent-ink); }
.ld-wh { font: 400 12px/1 var(--font-mono); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.k0 { background: var(--c-tx); } .k1 { background: var(--c-act); } .k2 { background: var(--c-sleep); } .k3 { background: var(--c-base); } .k4 { background: var(--c-sd); } .k5 { background: var(--muted); }
.hint a { color: var(--link); }
.pair { align-items: end; }

/* ---------- ESPHome generator ---------- */
.gen { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 28px 36px; margin-top: 6px; align-items: start; }
@media (max-width: 960px) { .gen { grid-template-columns: minmax(0, 1fr); } }
.codepanel { position: sticky; top: 64px; background: var(--scope-bg); color: var(--scope-ink); border: 1px solid var(--scope-edge); border-radius: 12px; padding: 14px clamp(14px, 2vw, 20px) 16px; min-width: 0; max-height: calc(100vh - 80px); display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 960px) { .codepanel { position: static; max-height: none; } }
.cp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.cp-bar h2 { margin: 0; color: var(--scope-ink); font-size: 12px; }
.cp-actions { display: flex; gap: 8px; }
.codepanel .btn { background: var(--scope-trace); color: #16191C; }
.codepanel .btn.ghost { background: transparent; color: var(--scope-ink); border-color: var(--scope-grid); }
.code { margin: 0; font: 400 12.5px/1.55 var(--font-mono); white-space: pre; overflow: auto; background: rgba(255, 255, 255, .03); border: 1px solid var(--scope-grid); border-radius: var(--r); padding: 12px 14px; color: var(--scope-ink); tab-size: 2; }
.codepanel > .code { flex: 1 1 auto; min-height: 220px; }
.code:focus-visible { outline: 2px solid var(--scope-trace); outline-offset: 2px; }
.y-k { color: #8DB2F7; } .y-s { color: #F4C21E; } .y-v { color: #7FD8C4; } .y-t { color: #E86E58; } .y-c { color: #8E969E; font-style: italic; } .y-d { color: #8E969E; }
.cp-warn ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; max-height: 160px; overflow: auto; }
.cp-warn li { font-size: 13px; line-height: 1.45; padding-left: 10px; border-left: 3px solid var(--scope-dim); }
.cp-warn .lvl-err { border-left-color: #E86E58; } .cp-warn .lvl-warn { border-left-color: #F4C21E; }
.cp-ok { margin: 0; font: 500 12.5px/1.4 var(--font-mono); color: #2DB8A0; }
.cp-secrets summary { cursor: pointer; font: 500 12px/1 var(--font-mono); letter-spacing: .06em; color: var(--scope-dim); padding: 4px 0; }
.cp-secrets .code { margin-top: 8px; }
.cp-secrets .hint { color: var(--scope-dim); margin-top: 8px; }
.codepanel .status { color: var(--scope-dim); min-height: 1em; }
.comps { display: grid; gap: 10px; }
.cc { border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); padding: 10px 12px 12px; display: grid; gap: 10px; }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-type { font: 600 13px/1.3 var(--font-body); }
.cc-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.cc .inp input { padding: 8px; font-size: 14px; }
.cc .sel { padding: 8px; font-size: 13.5px; }
.check.sm { font-size: 13px; font-weight: 400; }
.ipgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.ipgrid .inp input { font-family: var(--font-mono); font-size: 13.5px; }
.keysrow { display: grid; gap: 6px; justify-items: start; }

.cp-bar h2 { text-transform: none; letter-spacing: .02em; font-size: 13px; }
.jump { display: none; margin-top: 14px; font-weight: 500; font-size: 14px; }
@media (max-width: 960px) { .jump { display: inline-block; } }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkbtn:hover { color: var(--ink); }
