@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../assets/fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../assets/fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../assets/fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../assets/fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(../assets/fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(../assets/fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../assets/fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../assets/fonts/ibm-plex-mono-latin-ext-500-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* Standalone page reset (the preview host normally supplies this) */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
[hidden] { display: none !important; }
/* Layout: logo + language header; two columns on desktop (sticky inputs left, bill of materials and pricing right); one column on phones with a fixed totals bar. */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #17222e;
  --muted: #566677;
  --line: #d3dae3;
  --accent: #1d4a78;
  --accent-ink: #ffffff;
  --accent-soft: #e2ebf5;
  --track: #cfd7e1;
  --bad: #a4262c;
  --logo-l: block;
  --logo-d: none;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111715; --surface: #19211f; --surface-2: #1f2926; --ink: #e6ebe8; --muted: #9aa9a2;
    --line: #2d3834; --accent: #8fb09f; --accent-ink: #0f1714; --accent-soft: #24332d; --track: #38453f; --bad: #f08a8f;
    --logo-l: none; --logo-d: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111715; --surface: #19211f; --surface-2: #1f2926; --ink: #e6ebe8; --muted: #9aa9a2;
  --line: #2d3834; --accent: #8fb09f; --accent-ink: #0f1714; --accent-soft: #24332d; --track: #38453f; --bad: #f08a8f;
  --logo-l: none; --logo-d: block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; padding-inline: 16px; padding-block: 16px 24px; }
.wrap { max-width: 1120px; margin-inline: auto; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 4px 12px; }
.logo { height: clamp(34px, 6vw, 50px); width: auto; max-width: 100%; }
.logo-l { display: var(--logo-l); }
.logo-d { display: var(--logo-d); }
.title { padding-bottom: 18px; }
.back { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-size: 0.85rem; font-weight: 500; text-decoration: none; margin-bottom: 4px; }
.title h1 { font-size: clamp(1.25rem, 1.1rem + 1vw, 1.75rem); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.title p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 3px; gap: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 52px; padding-inline: 14px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 0.9rem; color: var(--muted); user-select: none; text-align: center; }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.inputs { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); gap: 24px; }
  .inputs { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; min-width: 0; }
.panel h2 { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 16px; }

.field { display: grid; gap: 6px; padding-bottom: 18px; }
.field + .field, .fields + .field { padding-top: 18px; border-top: 1px solid var(--line); }
.field:last-child { padding-bottom: 0; }
.fields > .field:last-child { padding-bottom: 18px; }
.fields.end > .field:last-child { padding-bottom: 0; }
.field .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field label.lbl { font-weight: 500; font-size: 0.95rem; }
.num { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); height: 44px; width: 132px; flex: none; }
.num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.num input { width: 100%; min-width: 0; border: 0; background: transparent; text-align: right; padding: 0 6px 0 10px; font-family: var(--mono); font-weight: 500; font-size: 1.05rem; height: 100%; outline: none; }
.num span { padding-right: 10px; color: var(--muted); font-size: 0.85rem; }
.num.invalid, .pin.invalid { border-color: var(--bad); }
.lw { display: grid; gap: 1px; min-width: 0; }
.sub { color: var(--muted); font-size: 0.78rem; }
.sub:empty { display: none; }
.sub.warn { color: var(--bad); }
.btn.ghost { background: transparent; color: var(--accent); }
.num.w { width: 172px; }
.link { justify-self: start; display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-size: 0.82rem; font-weight: 500; }
.opts { display: grid; gap: 6px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.opt .ot { flex: 1; min-width: 0; font-size: 0.92rem; }
.opt .ov { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.alusum { margin-top: 18px; padding-top: 12px; border-top: 2px solid var(--ink); }
.arow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-block: 3px; }
.arow b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.gnote { margin: 8px 0 0; color: var(--muted); font-size: 0.8rem; }
.pin input.auto { color: var(--muted); }
.lims { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; font-family: var(--mono); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; margin: 0; background: transparent; cursor: pointer; --pct: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--pct), var(--track) var(--pct)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 500; font-size: 0.95rem; margin-bottom: 8px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide label { flex: 1; min-width: 0; padding-inline: 6px; font-family: var(--mono); font-size: 0.82rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }

/* Results panel is a size container so the bill of materials adapts to the panel width, not the screen width. */
.res { container-type: inline-size; }
.summary { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.est { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 0.82rem; color: var(--muted); align-self: start; }
.est b { display: block; color: var(--ink); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
@container (min-width: 620px) { .summary { grid-template-columns: minmax(0, 1fr) minmax(0, 17rem); gap: 24px; } }
.total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; }
.total .big { font-family: var(--mono); font-weight: 500; font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); line-height: 1; letter-spacing: -0.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.total .unit { font-size: 1.1rem; color: var(--muted); }
.total .cap { flex-basis: 100%; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 14px; margin: 14px 0 0; border-top: 1px solid var(--line); }
.stat dt { font-size: 0.75rem; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-family: var(--mono); font-weight: 500; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.group { margin-top: 22px; }
.group h3 { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
ul.lines { list-style: none; margin: 0; padding: 0; }
ul.lines > li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 12px; padding-block: 14px; border-bottom: 1px solid var(--line); align-items: baseline; }
.code { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.name { font-weight: 500; overflow-wrap: anywhere; }
.basis { grid-column: 2; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.basis .b2 { display: block; color: var(--ink); opacity: .85; }
.basis .b3 { display: block; }
.chip { justify-self: start; margin-top: 4px; min-height: 30px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vals { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.qty { flex: none; font-family: var(--mono); font-weight: 500; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty small, .ltot small { font-family: var(--font); font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 4px; }
.pin { flex: 1 1 0; min-width: 0; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); height: 42px; }
.pin:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.pin input { width: 100%; min-width: 0; border: 0; background: transparent; text-align: right; padding: 0 6px 0 8px; font-family: var(--mono); font-weight: 500; font-size: 1rem; height: 100%; outline: none; }
.pin input::placeholder { color: var(--muted); opacity: .6; }
.pin span.pu { padding-right: 8px; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.ltot { flex: none; min-width: 6.5rem; text-align: right; font-family: var(--mono); font-weight: 500; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ltot.empty { color: var(--muted); }
li.sum { background: var(--accent-soft); padding-inline: 10px; border-radius: 6px; margin-top: 8px; border-bottom: 0; }
li.sum .name, li.sum .qty, li.sum .ltot { font-weight: 600; }
li.sum .spacer { flex: 1 1 0; }
@container (min-width: 640px) {
  ul.lines > li { grid-template-columns: 48px minmax(0, 1fr) 7.5rem 9.5rem 7.5rem; column-gap: 12px; }
  .vals { display: contents; }
  .name { grid-column: 2; grid-row: 1; }
  .basis { grid-row: 2; }
  .code { grid-row: 1; }
  .qty, .pin, .ltot, .spacer { grid-row: 1 / span 2; align-self: center; margin: 0; }
  .qty { grid-column: 3; text-align: right; }
  .pin { grid-column: 4; flex: none; }
  .ltot { grid-column: 5; }
  li.sum .spacer { grid-column: 4; }
}

.totals { margin-top: 22px; border-top: 2px solid var(--ink); }
.trow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.trow .tl { color: var(--muted); }
.trow .tv { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trow.grand { background: var(--accent); color: var(--accent-ink); border: 0; padding: 14px 12px; border-radius: 8px; margin-top: 10px; }
.trow.grand .tl { color: inherit; font-weight: 600; }
.trow.grand .tv { font-size: 1.35rem; }
.trow.small .tl, .trow.small .tv { font-size: 0.85rem; border: 0; }
.trow.small { border-bottom: 0; }

.schematic { margin: 22px 0 0; }
.schematic svg { display: block; width: 100%; height: auto; max-width: 560px; margin-inline: auto; }
.schematic figcaption { color: var(--muted); font-size: 0.8rem; margin-top: 6px; text-align: center; }
.s-post { fill: var(--ink); }
.s-bar { fill: var(--accent); fill-opacity: .85; stroke: var(--surface); stroke-width: 0.8; }
.s-frame { fill: none; stroke: var(--line); }
.s-dim { stroke: var(--muted); stroke-width: 1; fill: none; }
.s-txt { fill: var(--muted); font: 500 12px var(--mono); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.btn { min-height: 44px; padding-inline: 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.status { color: var(--muted); font-size: 0.85rem; }
.note { margin-top: 16px; color: var(--muted); font-size: 0.8rem; max-width: 70ch; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--ink); color: var(--bg); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
.bar b { font-family: var(--mono); font-weight: 500; font-size: 1.25rem; }
.bar small { opacity: .75; display: block; font-size: 0.75rem; }
.bar button { min-height: 44px; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 8px; padding-inline: 16px; font-weight: 600; cursor: pointer; }
body { padding-bottom: 88px; }
@media (min-width: 900px) { .bar { display: none; } body { padding-bottom: 24px; } }
@media (max-width: 420px) { .num { width: 120px; } .num.w { width: 150px; } .ltot { min-width: 5.5rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
