/* How Many Boards — shared styles for all pages */
@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin-wdth.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3f6f9;
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #55646f;
  --line: #d2dae1;
  --chalk: #1b5fc1;
  --chalk-deep: #134a99;
  --chalk-wash: #e6eefb;
  --tape: #ffd21f;
  --cedar: #cf9560;
  --cedar-deep: #a9703d;
  --treated: #6f8259;
  --radius: 10px;
  --font: "Archivo", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}
img, svg { max-width: 100%; }
a { color: var(--chalk-deep); text-underline-offset: 3px; }
a:hover { color: var(--chalk); }
:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-head { background: var(--ink); color: #fff; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-stretch: 78%; font-size: 1.35rem; letter-spacing: 0.01em; }
.brand:hover { color: var(--tape); }
.brand-mark { width: 54px; height: 48px; flex: none; filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff); transform: rotate(-4deg); transition: transform .2s; }
.brand:hover .brand-mark { transform: rotate(4deg) scale(1.06); }
.brand span { display: inline-flex; align-items: baseline; gap: 6px; font-size: 1.3rem; }
.brand b { color: var(--tape); font-weight: 900; font-size: 1.45rem; }
@media (prefers-reduced-motion: reduce) { .brand-mark, .brand:hover .brand-mark { transition: none; transform: rotate(-4deg); } }
.site-head nav a { color: #dfe7ee; text-decoration: none; font-size: 0.95rem; }
.site-head nav a:hover { color: var(--tape); text-decoration: underline; }

/* Tape-measure rule under the header: the one loud element */
.tape {
  height: 22px;
  background-color: var(--tape);
  background-image:
    repeating-linear-gradient(to right, var(--ink) 0 2px, transparent 2px 96px),
    repeating-linear-gradient(to right, var(--ink) 0 1px, transparent 1px 12px);
  background-size: auto 100%, auto 45%;
  background-repeat: repeat-x;
  border-bottom: 2px solid var(--ink);
}

/* Page intro */
.intro { padding-top: 34px; padding-bottom: 22px; }
h1 {
  margin: 0 0 10px;
  font-size: clamp(2.3rem, 6.2vw, 4.1rem);
  line-height: 0.98;
  font-weight: 800;
  font-stretch: 70%;
  letter-spacing: -0.005em;
}
.lede { margin: 0; max-width: 62ch; font-size: 1.12rem; color: var(--muted); }

h2 { font-size: 1.7rem; line-height: 1.15; font-weight: 750; font-stretch: 80%; margin: 0 0 12px; }
h3 { font-size: 1.1rem; line-height: 1.25; font-weight: 700; margin: 0 0 6px; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 24px; align-items: start; padding-bottom: 48px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.inputs { padding: 6px 20px 20px; }
.inputs fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 16px 0 6px; min-width: 0; }
.inputs fieldset:first-of-type { border-top: 0; }
.inputs legend { padding: 0; float: left; width: 100%; font-weight: 750; font-stretch: 85%; font-size: 1.08rem; margin-bottom: 10px; }
.inputs fieldset > *:not(legend) { clear: both; }

.field { margin-bottom: 12px; }
.field > label, .field > .label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.hint { display: block; font-size: 0.82rem; color: var(--muted); font-weight: 400; margin-top: 3px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }

.num { display: flex; align-items: stretch; border: 1.5px solid #9fabb5; border-radius: 8px; background: #fff; overflow: hidden; }
.num:focus-within { border-color: var(--chalk); box-shadow: 0 0 0 3px var(--chalk-wash); }
.num input { flex: 1; min-width: 0; width: 100%; border: 0; padding: 10px 10px; font: inherit; font-variant-numeric: tabular-nums; color: var(--ink); background: transparent; }
.num input:focus { outline: none; }
.num span { display: flex; align-items: center; padding: 0 10px; background: var(--paper); color: var(--muted); font-size: 0.88rem; border-left: 1px solid var(--line); }
.pair { display: grid; grid-template-columns: 1.2fr 1fr; gap: 6px; }

select {
  width: 100%; font: inherit; color: var(--ink); padding: 10px 34px 10px 10px;
  border: 1.5px solid #9fabb5; border-radius: 8px; background-color: #fff;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2314212b' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:focus { outline: none; border-color: var(--chalk); box-shadow: 0 0 0 3px var(--chalk-wash); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg label { position: relative; text-align: center; padding: 9px 8px; font-size: 0.92rem; font-weight: 600; cursor: pointer; background: #fff; }
.seg label + label { border-left: 1.5px solid var(--ink); }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--chalk); outline-offset: -3px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1.5px solid #9fabb5; border-radius: 999px; font-size: 0.9rem; cursor: pointer; background: #fff; }
.check:has(input:checked) { border-color: var(--ink); background: var(--chalk-wash); }
.check input { width: 16px; height: 16px; accent-color: var(--chalk); margin: 0; }
.toggle { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 0.95rem; cursor: pointer; margin-bottom: 10px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--chalk); margin: 0; }

details.more { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
details.more > summary { cursor: pointer; font-weight: 700; font-size: 0.98rem; padding: 4px 0 10px; }

/* Results */
.results { display: grid; gap: 20px; min-width: 0; }
.plan { padding: 16px 16px 10px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.plan-head h2 { margin: 0; font-size: 1.25rem; }
.plan-head p { margin: 0; font-size: 0.85rem; color: var(--muted); }
#plan { display: block; width: 100%; height: auto; max-height: 520px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82rem; color: var(--muted); padding: 6px 0 4px; }
.legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }

.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 2px solid var(--ink); border-radius: var(--radius); background: var(--tape); overflow: hidden; }
.totals div { padding: 12px 14px; }
.totals div + div { border-left: 2px solid var(--ink); }
.totals b { display: block; font-size: 1.9rem; line-height: 1.05; font-weight: 800; font-stretch: 78%; font-variant-numeric: tabular-nums; }
.totals span { font-size: 0.85rem; font-weight: 600; }

.list { padding: 18px 18px 14px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.list-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 650; font-size: 0.92rem; padding: 9px 14px; border-radius: 8px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--chalk-wash); }
.btn.primary { background: var(--chalk); border-color: var(--chalk); color: #fff; }
.btn.primary:hover { background: var(--chalk-deep); }
.list-note { margin: 0 0 8px; font-size: 0.88rem; color: var(--muted); max-width: 70ch; }

table.shop { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.shop th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 8px 8px 6px; border-bottom: 2px solid var(--ink); }
.shop th.r, .shop td.r { text-align: right; }
.shop td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.shop tr.group td { padding: 16px 8px 5px; font-weight: 750; font-stretch: 85%; font-size: 1rem; border-bottom: 1.5px solid var(--ink); }
.shop .item b { font-weight: 650; }
.shop .spec { display: block; color: var(--muted); font-size: 0.86rem; }
.shop .qty { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop .qty small { font-weight: 500; font-size: 0.78rem; color: var(--muted); display: block; }
.shop details { margin-top: 4px; font-size: 0.84rem; color: var(--muted); }
.shop summary { cursor: pointer; color: var(--chalk-deep); width: fit-content; }
.shop details p { margin: 4px 0 0; max-width: 56ch; }
.shop input.price { width: 84px; font: inherit; font-variant-numeric: tabular-nums; text-align: right; padding: 6px 8px; border: 1.5px solid #9fabb5; border-radius: 6px; }
.shop input.price:focus { outline: none; border-color: var(--chalk); box-shadow: 0 0 0 3px var(--chalk-wash); }
.shop .line { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 70px; }
.shop tfoot td { border-bottom: 0; padding-top: 14px; font-weight: 800; font-size: 1.1rem; }
.notes { margin: 12px 0 0; padding: 0; list-style: none; font-size: 0.88rem; }
.notes li { padding: 8px 12px; border-left: 4px solid var(--tape); background: #fffbe6; margin-top: 6px; border-radius: 0 6px 6px 0; }
.toast { font-size: 0.85rem; color: var(--treated); font-weight: 600; margin: 0; }
.toast:empty { display: none; }

/* Article content */
.article { background: var(--surface); border-top: 1px solid var(--line); padding: 44px 0 56px; }
.article .wrap { max-width: 820px; }
.article section + section { margin-top: 36px; }
.article p, .article li { max-width: 70ch; }
.article ol, .article ul { padding-left: 22px; }
.article li { margin-bottom: 6px; }
.formula { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--chalk); border-radius: 0 8px 8px 0; padding: 12px 16px; margin: 12px 0; font-variant-numeric: tabular-nums; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 650; font-size: 1.05rem; }
.faq details p { margin: 8px 0 2px; color: #2c3a45; }
.spans { border-collapse: collapse; margin: 10px 0; font-size: 0.94rem; font-variant-numeric: tabular-nums; }
.spans th, .spans td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.spans th { background: var(--paper); }

/* Home */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 8px 0 56px; }
.tool { display: block; padding: 18px 18px 16px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--radius); border-bottom-width: 5px; }
a.tool:hover { background: var(--chalk-wash); color: var(--ink); }
.tool h2 { font-size: 1.3rem; margin-bottom: 4px; }
.tool p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.tool.soon { border-style: dashed; border-color: #9fabb5; border-bottom-width: 1.5px; background: transparent; }
.tool.soon h2 { color: var(--muted); }

.site-foot { background: var(--ink); color: #c9d3db; font-size: 0.88rem; padding: 22px 0; }
.site-foot p { margin: 0 0 4px; max-width: 80ch; }
.site-foot a { color: #fff; }

@media (max-width: 900px) {
  .calc { grid-template-columns: 1fr; }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals div:nth-child(3) { border-left: 0; }
  .totals div:nth-child(n+3) { border-top: 2px solid var(--ink); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .intro { padding-top: 24px; padding-bottom: 16px; }
  .list { padding: 16px 12px 12px; }
  .shop th.line-h, .shop td.line { display: none; }
  .shop input.price { width: 70px; }
  .site-head nav { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

@media print {
  body { background: #fff; }
  .site-head, .tape, .inputs, .actions, .article, .site-foot, .lede, .shop details, .toast { display: none !important; }
  .calc { display: block; padding: 0; }
  .panel { border: 0; }
  .plan { break-inside: avoid; }
  #plan { max-height: 300px; }
  .totals { margin: 10px 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shop input.price { border: 0; padding: 0; width: 60px; }
  .shop tr { break-inside: avoid; }
  h1 { font-size: 1.8rem; }
}

/* Related calculators */
.related ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.related li { margin: 0; }
.related a { display: inline-block; padding: 9px 14px; border: 1.5px solid var(--ink); border-radius: 8px; text-decoration: none; font-weight: 650; color: var(--ink); background: #fff; }
.related a:hover { background: var(--chalk-wash); }
.seg label { display: flex; align-items: center; justify-content: center; }
@media print { .related { display: none !important; } }
.foot-links a { margin-right: 18px; }

/* Ad slots: only below the shopping list and inside the article, never near inputs or buttons */
.ad-slot { display: block; margin: 0; padding: 10px 0 0; border-top: 1px dashed var(--line); min-height: 120px; }
.ad-slot[hidden] { display: none; }
.article .ad-slot { margin: 36px 0; }
.ad-label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }

/* Report and contact forms */
.report { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.report > summary { cursor: pointer; font-weight: 650; color: var(--chalk-deep); width: fit-content; }
#reportForm { display: grid; gap: 6px; margin-top: 10px; max-width: 560px; }
#reportForm label { font-size: 0.9rem; font-weight: 600; margin-top: 6px; }
#reportForm textarea, #reportForm input[type=email] { font: inherit; padding: 10px; border: 1.5px solid #9fabb5; border-radius: 8px; width: 100%; }
#reportForm textarea:focus, #reportForm input:focus { outline: none; border-color: var(--chalk); box-shadow: 0 0 0 3px var(--chalk-wash); }
#reportForm .btn { justify-self: start; margin-top: 6px; }
#reportForm .hint { margin: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.report-status { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--treated); min-height: 1.3em; }
@media print { .report, .ad-slot { display: none !important; } }
#reportForm label .hint { display: inline; margin: 0; }

/* ===== Calculator layout v2: list | live preview with size | options ===== */
.wrap { max-width: 1400px; }
.sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.calc {
  display: grid;
  grid-template-columns: minmax(250px, 290px) minmax(0, 1fr) minmax(300px, 350px);
  grid-template-areas: "opts stage list";
  gap: 18px; align-items: start;
}
.calc-form { display: contents; }
.stage { grid-area: stage; padding: 14px 16px 10px; position: sticky; top: 12px; }
.opts { grid-area: opts; }
.results { grid-area: list; display: grid; gap: 14px; }

/* size fields sit on top of the live drawing */
.size-bar { border: 0; margin: 0 0 6px; padding: 12px; min-width: 0; background: var(--paper); border-radius: 8px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px 12px; align-items: end; }
.size-bar [data-sys], .size-bar [data-show], .size-bar .row { display: contents; }
.size-bar [data-sys][hidden], .size-bar [data-show][hidden] { display: none; }
.size-bar .field { margin: 0; }
.size-bar .hint { grid-column: 1 / -1; margin: 0; }
.size-bar .seg label { padding: 8px 6px; font-size: 0.88rem; }
.stage .plan-head { margin-bottom: 8px; }
.stage #plan { max-height: min(560px, calc(100vh - 290px)); min-height: 220px; }

/* options column */
.opts { padding: 4px 16px 16px; }
.opts .row { grid-template-columns: 1fr; gap: 0; }
.opts fieldset:first-child { border-top: 0; }

/* totals as a compact 2 × 2 block */
.results .totals { grid-template-columns: 1fr 1fr; }
.results .totals div { padding: 10px 12px; border-left: 0; border-top: 0; }
.results .totals div:nth-child(even) { border-left: 2px solid var(--ink); }
.results .totals div:nth-child(n+3) { border-top: 2px solid var(--ink); }
.results .totals b { font-size: 1.55rem; }
.results .totals span { font-size: 0.8rem; }

/* compact shopping list */
.list { padding: 14px 14px 12px; }
.list-head { margin-bottom: 6px; }
.list-head h2 { font-size: 1.35rem; }
.actions { margin-bottom: 4px; }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; border-radius: 7px; }
.list .list-note { display: none; font-size: 0.8rem; margin: 2px 0 6px; }
.list.prices .list-note { display: block; }
.shop .grp { margin-top: 8px; }
.shop .grp h3 { font-size: 0.82rem; font-weight: 750; color: var(--muted); margin: 0; padding: 6px 0 4px; border-bottom: 1.5px solid var(--ink); }
.shop .it { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: start; }
.list.prices .shop .it { grid-template-columns: 52px minmax(0, 1fr) 76px; }
.shop .q { font-weight: 800; font-stretch: 80%; font-size: 1.3rem; line-height: 1.05; font-variant-numeric: tabular-nums; text-align: right; }
.shop .q small { display: block; font-size: 0.7rem; font-weight: 500; color: var(--muted); font-stretch: 100%; }
.shop .nm { min-width: 0; font-size: 0.9rem; line-height: 1.3; }
.shop .nm b { font-weight: 650; }
.shop .spec { display: block; color: var(--muted); font-size: 0.8rem; }
.shop .how { margin-top: 2px; font-size: 0.78rem; color: var(--muted); }
.shop .how summary { cursor: pointer; color: var(--chalk-deep); width: fit-content; }
.shop .how p { margin: 4px 0 0; }
.shop .pr { display: none; text-align: right; }
.list.prices .shop .pr { display: block; }
.shop input.price { width: 76px; font: inherit; font-size: 0.85rem; font-variant-numeric: tabular-nums; text-align: right; padding: 5px 6px; border: 1.5px solid #9fabb5; border-radius: 6px; }
.shop input.price:focus { outline: none; border-color: var(--chalk); box-shadow: 0 0 0 3px var(--chalk-wash); }
.shop .line { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.list .grand { display: none; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 0 2px; font-weight: 800; }
.list.prices .grand { display: flex; }
.list .grand b { font-variant-numeric: tabular-nums; }
.list .notes { font-size: 0.8rem; }
.list .notes li { padding: 6px 10px; }

@media (max-width: 1180px) {
  .calc { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); grid-template-areas: "stage stage" "opts list"; }
  .stage { position: static; }
}
@media (max-width: 760px) {
  .calc { grid-template-columns: 1fr; grid-template-areas: "stage" "opts" "list"; }
  .size-bar { grid-template-columns: 1fr 1fr; padding: 10px; }
  .size-bar .seg, .size-bar .field:has(.seg), .size-bar .field:has(.pair) { grid-column: 1 / -1; }
}
@media print {
  .calc { display: block; }
  .opts, .size-bar, .list .actions, #btnPrices, .report, .ad-slot { display: none !important; }
  .stage { position: static; }
  .shop .how { display: none; }
}

/* Options always within reach: the options column stays on screen and scrolls on its own */
@media (min-width: 1181px) {
  .opts { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}
@media (min-width: 761px) and (max-width: 1180px) {
  .opts { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}
.opts fieldset { padding: 12px 0 2px; }
.opts .inputs legend, .opts legend { margin-bottom: 6px; font-size: 1rem; }
.opts .field { margin-bottom: 9px; }
.opts .field > label, .opts .field > .label { font-size: 0.85rem; margin-bottom: 3px; }
.opts select, .opts .num input { padding-top: 8px; padding-bottom: 8px; }
.opts .hint { font-size: 0.78rem; }
.opts details.more > summary { padding: 4px 0 8px; }
@media print { .opts { position: static; max-height: none; overflow: visible; } }

/* Calculator switcher rail */
.calc-rail { display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.calc-rail::-webkit-scrollbar { display: none; }
.calc-rail a { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.calc-rail a:hover { background: var(--chalk-wash); border-color: var(--chalk); color: var(--ink); }
.calc-rail a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.calc-rail svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 1181px) {
  .calc-rail { position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 20; flex-direction: column; gap: 4px; width: 76px; padding: 8px 6px; overflow: visible; border: 1.5px solid var(--ink); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 0 6px 18px rgba(20,33,43,.10); }
  .calc-rail a { flex-direction: column; gap: 3px; padding: 8px 2px; border: 0; border-radius: 8px; font-size: 0.72rem; font-weight: 600; }
  .calc-rail svg { width: 24px; height: 24px; }
  .calc-rail ~ main { padding-left: 76px; }
}
@media print { .calc-rail { display: none !important; } }
@media (max-width: 480px) { .calc-rail { padding: 8px 10px; gap: 4px; } .calc-rail a { padding: 6px 9px; gap: 5px; font-size: 0.85rem; } }

/* =====================================================================
   Calculator pages: one modular system.
   Module m = 8px. Every size is a multiple of it:
     control height 48 (6m) · compact control 32 (4m)
     gaps 8 / 16 / 24 · panel padding 24 · radius 8 (controls) / 16 (panels)
   Columns are 1 : 2 : 1 (options · drawing · list); totals are 2 × 2 equal tiles.
   ===================================================================== */
body:has(.calc) {
  --m: 8px; --ctl: 48px; --ctl-s: 32px; --gap: 24px; --pad: 24px; --r-ctl: 8px; --r-panel: 16px;
  --fs-s: 0.875rem; --fs: 1rem; --fs-h: 1.25rem; --fs-xl: 2rem;
}
body:has(.calc) .wrap { max-width: 1920px; padding-left: var(--gap); padding-right: var(--gap); }

/* title row */
body:has(.calc) .intro { padding-top: var(--gap); padding-bottom: var(--gap); }
@media (min-width: 761px) {
  body:has(.calc) .intro { display: flex; align-items: baseline; gap: var(--m) var(--gap); flex-wrap: wrap; }
  body:has(.calc) .intro h1 { font-size: var(--fs-xl); line-height: 1; margin: 0; }
  body:has(.calc) .intro .lede { margin: 0; max-width: 840px; font-size: var(--fs); }
}

/* grid: units sit at the top of the right column, above the yellow totals */
.calc { gap: var(--gap); padding-bottom: calc(var(--gap) * 2);
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "opts stage units" "opts stage list"; }
.units-bar { grid-area: units; }
.opts, .stage { grid-row: 1 / span 2; }
.opts { grid-area: opts; } .stage { grid-area: stage; } .results { grid-area: list; }
@media (min-width: 1181px) { .calc { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr) minmax(280px, 1fr); } }
@media (max-width: 1180px) {
  .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: none;
    grid-template-areas: "units ." "stage stage" "opts list"; }
  .opts, .stage { grid-row: auto; }
}
@media (max-width: 760px) {
  .calc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "units" "stage" "opts" "list"; }
}

/* panels */
.calc .panel { border-radius: var(--r-panel); }
.calc .stage, .calc .opts, .calc .list { padding: var(--pad); }
.calc .opts { padding-top: calc(var(--pad) - var(--m)); }
.results { gap: var(--gap); }

/* units bar: one control high */
.calc .units-bar .units-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--m) calc(var(--m) * 2); margin: 0; }
.calc .units-bar .units-field > .label { margin: 0; font-size: var(--fs-s); font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* every control is the same height */
.calc .num, .calc select, .calc .seg { height: var(--ctl); border-radius: var(--r-ctl); }
.calc .num input { height: 100%; padding: 0 12px; font-size: var(--fs); }
.calc .num span { padding: 0 12px; font-size: var(--fs-s); }
.calc select { padding: 0 40px 0 12px; font-size: var(--fs); }
.calc .seg label { height: 100%; padding: 0 8px; font-size: var(--fs-s); line-height: 1.15; }
.calc .pair { gap: var(--m); grid-template-columns: 1fr 1fr; }
.calc .row { gap: calc(var(--m) * 2); }
.calc .field { margin: 0 0 calc(var(--m) * 2); }
.calc .field > label, .calc .field > .label { font-size: var(--fs-s); margin-bottom: var(--m); line-height: 1.2; }
.calc .hint { font-size: var(--fs-s); margin-top: var(--m); }
.calc .check { height: var(--ctl-s); padding: 0 12px; font-size: var(--fs-s); }
.calc .checks { gap: var(--m); margin-bottom: calc(var(--m) * 2); }
.calc .toggle { min-height: var(--ctl-s); margin: 0 0 var(--m); font-size: var(--fs-s); }
.calc .btn { height: var(--ctl-s); padding: 0 12px; font-size: var(--fs-s); border-radius: var(--r-ctl); display: inline-flex; align-items: center; }
.calc .actions { gap: var(--m); margin-bottom: calc(var(--m) * 2); }

/* options column */
.opts fieldset { padding: calc(var(--m) * 2) 0 0; }
.opts legend, .opts .inputs legend { font-size: var(--fs-h); line-height: 1.2; margin-bottom: calc(var(--m) * 2); }
.opts details.more > summary { padding: var(--m) 0 calc(var(--m) * 2); font-size: var(--fs); }

/* drawing panel: size fields in an equal-column grid */
.stage { container-type: inline-size; }
.stage .plan-head { margin-bottom: calc(var(--m) * 2); }
.stage .plan-head h2 { font-size: var(--fs-h); }
.stage .plan-head p { font-size: var(--fs-s); }
.size-bar { padding: calc(var(--m) * 2); gap: calc(var(--m) * 2); margin-bottom: calc(var(--m) * 2); border-radius: var(--r-ctl);
  grid-template-columns: repeat(2, minmax(0, 1fr)); }
.size-bar .field { margin: 0; }
.size-bar .field:has(.seg) { grid-column: span 2; }
@container (min-width: 720px) { .size-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.size-bar .hint { margin: 0; }

/* totals: four equal tiles, each two controls high */
.results .totals { grid-template-columns: 1fr 1fr; grid-auto-rows: calc(var(--ctl) * 2); border-radius: var(--r-panel); }
.results .totals div { padding: calc(var(--m) * 2); display: flex; flex-direction: column; justify-content: center; gap: var(--m); }
.results .totals b { font-size: var(--fs-xl); line-height: 1; }
.results .totals span { font-size: var(--fs-s); line-height: 1.2; }

/* shopping list rows on the same rhythm */
.list .list-head { margin-bottom: calc(var(--m) * 2); }
.list .list-head h2 { font-size: var(--fs-h); }
.shop .grp { margin-top: calc(var(--m) * 2); }
.shop .grp:first-child { margin-top: 0; }
.shop .grp h3 { font-size: var(--fs-s); padding: 0 0 var(--m); }
.shop .it, .list.prices .shop .it { grid-template-columns: var(--ctl) minmax(0, 1fr); gap: 0 calc(var(--m) * 2); padding: var(--m) 0; min-height: var(--ctl); }
.list.prices .shop .it { grid-template-columns: var(--ctl) minmax(0, 1fr) calc(var(--ctl) * 2); }
.shop .q { font-size: var(--fs-h); }
.shop .nm { font-size: var(--fs-s); }
.shop .spec, .shop .how { font-size: 0.75rem; }
.shop input.price { width: 100%; height: var(--ctl-s); padding: 0 var(--m); border-radius: var(--r-ctl); }

@media print { .units-bar { display: none !important; } }
.calc .row { row-gap: calc(var(--m) * 2); margin-bottom: calc(var(--m) * 2); }
.calc .row > .field { margin: 0; }
.size-bar .row { margin: 0; }
.calc .field:has(+ .hint), .calc .field:has(> .hint) { margin-bottom: var(--m); }
.opts > .hint, .opts fieldset > .hint { margin: 0 0 calc(var(--m) * 2); }
