/* ==========================================================================
   Калькулятор расчёта кровли — конфигуратор
   Единая гамма: терракота (кирпично-винный RAL 3005/8017) + графит (RAL 7024)
   на чертёжной бумаге. Один акцент — брендовый терракотовый; графит держит
   тёмные кнопки и линии чертежей. Слева — живой дом (сцена), справа —
   настройки; ниже раскладка листов и смета.
   ========================================================================== */

:root {
  --paper: #f4f6f4;
  --paper-raised: #ffffff;
  --paper-sunk: #f0f2ef;
  --grid-line: #dde2e0;
  --ink: #1c2126;
  --ink-soft: #4d5760;
  --graphite: #3d4750;
  --graphite-dark: #262b30;
  --brick: #a23b2e;
  --brick-dark: #832f24;
  --brick-soft: #fbeeec;
  --accent: var(--brick);
  --accent-dark: var(--brick-dark);
  --accent-soft: var(--brick-soft);
  --border: #d7dbd8;
  --border-strong: #c2c8c3;
  --shadow: 0 1px 2px rgba(28, 33, 38, 0.06), 0 8px 24px rgba(28, 33, 38, 0.06);

  /* Сцена: светлая студия, как у макета (клетка убрана) */
  --stage-bg: #f6f6f4;
  --stage-grid: transparent;

  --draw-line: #a23b2e;
  --draw-f3: #e5cbc4;
  --draw-shadow: #efe0dd;

  --font-display: 'Unbounded', 'Segoe UI', sans-serif;
  --font-body: 'Golos Text', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

.app { max-width: 1380px; margin: 0 auto; padding: 20px 24px 64px; }
@media (max-width: 640px) { .app { padding: 12px 12px 110px; } }

a { color: var(--brick); }
button { font-family: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2.5px solid var(--brick); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ----- configurator: stage | settings ------------------------------------ */

.configurator {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1099px) { .configurator { grid-template-columns: 1fr; } }

/* ----- stage: the live house ------------------------------------------- */

.stage {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  min-height: 600px;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(var(--stage-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
  overflow: hidden;
}
@media (max-width: 1099px) {
  .stage { position: static; height: auto; min-height: 0; max-height: none; }
}

.stage__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 26px 0;
  container-type: inline-size;
}
.stage__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.1vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.stage__spec { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.92rem; max-width: 46ch; }
.stage__tools { display: flex; gap: 6px; flex: none; }
.tool {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.tool:hover { border-color: var(--graphite); color: var(--ink); }
.tool--play { border-color: var(--brick); color: var(--brick-dark); background: var(--paper-raised); font-weight: 600; }
.tool--play:hover { background: var(--brick-soft); color: var(--brick-dark); border-color: var(--brick); }
.tool--play.is-on { background: var(--brick); border-color: var(--brick); color: #fff; }
.tool--icon svg { display: none; }
/* a narrow stage (a phone, or a 1100–1300 px screen, where the title pushed
   «Начать заново» off the card): «Показать укладку» and two round icon
   buttons, one row — the icon padded all round by the pill's own top
   padding: a circle its height */
@container (max-width: 640px) {
  .stage__tools { align-items: center; }
  .tool { white-space: nowrap; }
  .tool--icon { display: grid; place-items: center; padding: 6px; }
  .tool--icon svg { display: block; }
  .tool--icon span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

.stage__view { position: relative; flex: 1; min-height: 0; display: flex; }
@media (max-width: 1099px) { .stage__view { flex: none; display: block; } }

.stage__canvas {
  flex: 1;
  min-height: 0;
  position: relative;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}
.stage__canvas.is-dragging { cursor: grabbing; }
.stage__canvas:focus-visible { outline-offset: -6px; border-radius: var(--radius-m); }
@media (max-width: 1099px) { .stage__canvas { flex: none; aspect-ratio: 4 / 3; max-height: 60vh; } }

/* zoom: a plus over a minus on the house's lower right, quiet like the tools */
.zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  box-shadow: 0 1px 2px rgba(28, 33, 38, 0.06), 0 6px 16px rgba(28, 33, 38, 0.08);
  overflow: hidden;
}
.zoom__btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--graphite);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.zoom__btn + .zoom__btn { border-top: 1px solid var(--border); }
.zoom__btn:hover:not(:disabled) { background: var(--brick-soft); color: var(--brick-dark); }
.zoom__btn:active:not(:disabled) { color: var(--brick); }
.zoom__btn:disabled { color: var(--border-strong); cursor: default; }
.zoom__btn:focus-visible { outline-offset: -4px; border-radius: var(--radius-s); }
.stage.is-drawn .zoom { display: none; } /* «Свой чертёж»: flat slopes, nothing to come closer to */
@media (pointer: coarse) { .zoom__btn { width: 42px; height: 42px; } }
@media print { .zoom { display: none; } }

.house-svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* the dimension marks drawn over the 3D house */
.house-dims { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }

.stage__hint {
  margin: -6px 0 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  transition: opacity 0.4s ease;
}
.stage__hint.is-gone { opacity: 0; }

.stage__warn { list-style: none; margin: 8px 26px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stage__warn:empty { display: none; }
.stage__warn li {
  padding: 8px 12px;
  border-left: 3px solid var(--brick);
  background: var(--brick-soft);
  color: var(--brick-dark);
  font-size: 0.82rem;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}

.stage__foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'facts price' 'cta cta';
  gap: 14px 20px;
  align-items: end;
  margin-top: 12px;
  padding: 18px 26px 22px;
  background: var(--paper-raised);
  border-top: 1px solid var(--border);
}
.facts { grid-area: facts; display: flex; flex-wrap: wrap; gap: 8px 26px; margin: 0; }
.facts div { display: flex; flex-direction: column; gap: 2px; }
.facts dt { font-size: 0.8125rem; color: var(--ink-soft); }
.facts dd { margin: 0; font-family: var(--font-mono); font-size: 1rem; font-weight: 500; }

.price { grid-area: price; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.price__label { font-size: 0.8125rem; color: var(--ink-soft); }
.price__row { position: relative; display: flex; align-items: baseline; }
.price__total {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
/* Mechanical counter (odometer.js): each digit a strip rolling to its place. */
.odo { display: inline-flex; align-items: flex-start; height: 1.1em; line-height: 1.1em; vertical-align: bottom; }
.odo__col { display: block; height: 1.1em; overflow: hidden; }
.odo__strip {
  display: block;
  transform: translateY(calc(var(--i) * -1.1em));
  transition: transform var(--dur, 0.7s) cubic-bezier(0.22, 0.8, 0.26, 1);
}
.odo__strip > span { display: block; height: 1.1em; }
.odo__strip.is-still { transition: none; }
.odo__sep { display: block; white-space: pre; }
.odo__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.price__delta {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  margin-top: -11px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.price__delta.is-up { background: var(--brick-soft); color: var(--brick-dark); }
.price__delta.is-down { background: var(--paper-sunk); color: var(--graphite); }
.price__delta.is-on { opacity: 1; transform: none; }

.stage__cta { grid-area: cta; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) {
  .stage__head { padding: 16px 16px 0; flex-direction: column; }
  .stage__warn { margin: 8px 16px 0; }
  .stage__foot { grid-template-columns: 1fr; grid-template-areas: 'price' 'facts' 'cta'; padding: 16px; }
  .price { align-items: flex-start; }
  .price__delta { right: auto; left: calc(100% + 10px); }
  .stage__cta .btn { padding: 11px 12px; }
}

/* ----- estimate ↔ house (houseView.js): the parts glow on the 3D house;
   only the long screws are drawn over it, a row of dots ----------------- */

.h-hl--line { fill: none; stroke: var(--brick); stroke-width: 6; stroke-linecap: round; animation: hl-pulse 1.2s ease-in-out infinite; }
.h-hl--line.h-hl--hidden { stroke-width: 3.5; stroke-dasharray: 8 6; stroke-opacity: 0.6; } /* round the far side */
/* fasteners: a row of small round dots along the line */
.h-hl--line.h-hl--stitch { stroke-width: 4.5; stroke-dasharray: 0 9; }
.h-hl--line.h-hl--stitch.h-hl--hidden { stroke-width: 3; stroke-opacity: 0.5; }
@keyframes hl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* the dimension marks over the house */
.h-dim__line, .h-dim__tick, .h-dim__ext { fill: none; stroke: var(--brick); }
.h-dim__line { stroke-width: 1.4; }
.h-dim__tick { stroke-width: 1.8; }
.h-dim__ext { stroke-width: 0.9; opacity: 0.7; }
.h-dim__pill { fill: var(--paper-raised); stroke: var(--brick); stroke-width: 1; }
.h-dim__badge { fill: var(--brick); }
.h-dim__letter { fill: #fff; font: italic 700 13px var(--font-body); }
.h-dim__value { fill: var(--ink); font: 500 12px var(--font-mono); }
.h-dim.is-hidden { opacity: 0.38; }
.h-dim.is-hidden .h-dim__line { stroke-dasharray: 4 4; }
.h-dim.is-hot .h-dim__line { stroke-width: 3; }
.h-dim.is-hot .h-dim__pill { fill: var(--brick); }
.h-dim.is-hot .h-dim__value { fill: #fff; }
.h-dim.is-hot .h-dim__badge {
  transform-box: fill-box;
  transform-origin: center;
  animation: dim-pulse 1.1s ease-in-out infinite;
}
@keyframes dim-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ----- settings column --------------------------------------------------- */

.config {
  background: var(--paper-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 26px 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}
@media (max-width: 640px) { .config { padding: 20px 16px 24px; gap: 24px; } }

.cfg { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cfg + .cfg { padding-top: 24px; border-top: 1px dashed var(--border-strong); }
.cfg__title { margin: 0; font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; }
.cfg__caption { margin: 0; color: var(--ink-soft); font-size: 0.84rem; }

.delta { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink-soft); }
.delta:empty { display: none; }

/* roof type */
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; container-type: inline-size; }
/* two tiles a row in a narrow column (screens 1100–1290 and 460–540 px wide)
   leave ~90 px beside the icon — «Односкатная» didn't fit: the icon goes above */
@container (max-width: 490px) {
  .type-grid:not(.type-grid--wide) > .type-tile:not(.type-tile--span) { grid-template-columns: minmax(0, 1fr); }
  .type-grid:not(.type-grid--wide) > .type-tile:not(.type-tile--span) .type-tile__icon { grid-row: auto; }
}
.type-tile {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--paper);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.type-tile:hover { border-color: var(--graphite); }
.type-tile[aria-pressed='true'] { border-color: var(--brick); background: var(--brick-soft); }
.type-tile__icon { grid-row: 1 / 3; display: flex; }
.type-tile__name { font-family: var(--font-display); font-weight: 600; font-size: 0.9rem; align-self: end; }
.type-tile__hint { color: var(--ink-soft); font-size: 0.8125rem; line-height: 1.3; align-self: start; }
/* material: the same tiles one per row, the names are too long for two; each
   shows a pack of its sheets (stand/pack.html renders them), the same whatever
   the colour or profile */
.type-grid--wide { grid-template-columns: minmax(0, 1fr); }
.type-grid--wide .type-tile { grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: auto auto auto; }
.type-tile__icon--photo { width: 104px; height: 70px; overflow: hidden; border-radius: var(--radius-s); }
.type-tile__photo { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; }
.type-grid--wide .type-tile__icon { grid-row: 1 / -1; }
.type-tile .delta { align-self: start; }
@media (max-width: 460px) {
  .type-tile { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 10px 8px; }
  .type-tile__icon { grid-row: auto; }
  .type-tile__hint { display: none; }
  .type-grid--wide .type-tile { grid-template-columns: 104px minmax(0, 1fr); text-align: left; justify-items: stretch; padding: 10px 12px; }
  .type-grid--wide .type-tile__hint { display: block; }
}
/* a phone: «Металлочерепица» didn't fit beside the 104 px pack — a smaller pack */
@container (max-width: 320px) {
  .type-grid--wide > .type-tile { grid-template-columns: 76px minmax(0, 1fr); }
  .type-grid--wide .type-tile__icon--photo { width: 76px; height: 52px; }
}

.mini { width: 76px; height: auto; overflow: visible; display: block; }
.mini-shadow { fill: var(--draw-shadow); }
.mini-body { fill: var(--paper-raised); stroke: var(--draw-line); stroke-width: 2.4; stroke-linejoin: round; }
.mini-dot-bg { fill: var(--paper-raised); }
.mini-dot { fill: var(--draw-f3); }
.mini-seam { stroke-width: 1.3; }

.seg__price { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; }

/* colour */
.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.color-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(28, 33, 38, 0.14);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.color-dot:hover { transform: translateY(-2px); }
.color-dot[aria-pressed='true'] {
  box-shadow: inset 0 0 0 1px rgba(28, 33, 38, 0.14), 0 0 0 2px var(--paper-raised), 0 0 0 4px var(--brick);
}

/* profile cards: the sheet's photo in the roof colour, its name and price */
.chip-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 10px; }
@media (max-width: 460px) { .chip-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chip-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.chip {
  width: 100%;
  flex: 1; /* the chosen one, without a price, as tall as the rest */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chip:hover { border-color: var(--graphite); }
.chip[aria-pressed='true'] { border-color: var(--brick); background: var(--brick-soft); }
.chip__pic { width: 100%; aspect-ratio: 16 / 10; overflow: hidden; }
/* multiply: the photo's white backdrop takes the card's own tone */
.chip__photo { width: 100%; height: 100%; object-fit: cover; object-position: 50% 78%; scale: 1.18; mix-blend-mode: multiply; transition: opacity 0.2s ease; }
.chip__photo.is-tinting { opacity: 0; }
.chip__name { font-weight: 600; }
.chip-link {
  border: none;
  background: none;
  padding: 2px;
  font-size: 0.8125rem;
  color: var(--brick);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chip-link:hover { color: var(--brick-dark); }

/* profile popover */
.profile-pop-slot { position: relative; z-index: 30; }
.profile-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  transform-origin: top center;
  animation: profile-pop-in 0.16s ease-out both;
}
.profile-pop::before {
  content: '';
  position: absolute;
  top: -8px;
  left: var(--caret-x, 60px);
  width: 15px;
  height: 15px;
  background: var(--paper-raised);
  border-left: 1.5px solid var(--border);
  border-top: 1.5px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
}
.profile-pop.is-leaving { animation: profile-pop-out 0.12s ease-in both; }
@keyframes profile-pop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes profile-pop-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-6px); }
}
.profile-pop__top {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.profile-pop__top--text { grid-template-columns: 1fr; }
@media (max-width: 620px) { .profile-pop__top { grid-template-columns: 1fr; } }
.profile-pop__figure {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #fff;
}
.profile-pop__figure--diagram { background: var(--stage-bg); aspect-ratio: auto; min-height: 130px; }
.profile-pop__img { width: 100%; height: 100%; object-fit: contain; display: block; }
.profile-pop__scheme {
  margin: 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-pop__scheme img { width: 100%; height: auto; max-height: 220px; object-fit: contain; display: block; }
.profile-pop__scheme figcaption { font-size: 0.8125rem; color: var(--ink-soft); }
/* a small outline image: shown at its own size, never blown up */
.profile-pop__scheme--outline img { width: auto; max-width: 100%; margin: 6px auto; }
.profile-pop__scheme--outline figcaption { font-size: 0.8rem; color: var(--ink); }
.profile-diagram { width: 100%; height: auto; display: block; padding: 8px; }
.pd-base { stroke: var(--border-strong); stroke-width: 1; }
.pd-sheet { fill: none; stroke: var(--graphite); stroke-width: 2.2; stroke-linejoin: round; }
.pd-dim { stroke: var(--brick); stroke-width: 1.4; fill: none; }
.pd-text { fill: var(--ink-soft); font: 500 11px var(--font-mono); }
.profile-pop__body { display: flex; flex-direction: column; gap: 8px; }
.profile-pop__name { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }
.profile-pop__desc { margin: 0; font-size: 0.86rem; line-height: 1.5; color: var(--ink-soft); }
.profile-pop__fact { margin: 0; font-size: 0.82rem; font-weight: 500; }
.profile-pop__more { align-self: flex-start; text-decoration: none; }

/* thickness */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg__btn {
  flex: 1 1 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper);
}
.seg__btn:hover { border-color: var(--graphite); }
.seg__btn[aria-pressed='true'] { border-color: var(--brick); background: var(--brick-soft); }
.seg__val { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 500; }
.seg__btn .seg__price { white-space: nowrap; }

/* ----- dimensions ------------------------------------------------------- */

.dims-house {
  display: none;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(var(--stage-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: pan-y;
  cursor: grab;
}
/* On a phone the house rides along while the sizes are typed in. */
@media (max-width: 1099px) {
  .dims-house {
    display: block;
    position: sticky;
    top: 8px;
    z-index: 5;
    aspect-ratio: 16 / 10;
    max-height: 36vh;
    box-shadow: 0 6px 18px rgba(28, 33, 38, 0.12);
  }
}

.dims-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
@media (max-width: 460px) { .dims-fields { grid-template-columns: 1fr; } }

.dims-area {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-s);
  background: var(--paper-sunk);
}
.dims-area span { font-size: 0.84rem; color: var(--ink-soft); }
.dims-area strong { font-family: var(--font-mono); font-size: 1.05rem; color: var(--brick-dark); }
.dims-area code { margin-left: auto; font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); }
.dims-note { margin: 0; color: var(--ink-soft); font-size: 0.82rem; line-height: 1.45; }
.dims-derived { grid-column: 1 / -1; margin: 0; font-size: 0.84rem; font-family: var(--font-mono); color: var(--ink); }
/* the lead form's bot trap: out of sight and out of the tab order */
.lead-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 0.82rem; color: var(--ink-soft); }
.field .req { color: var(--brick); }
.field-input {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--paper);
  transition: border-color 0.15s ease;
}
.field-input:focus-within { border-color: var(--brick); }
.field--warn .field-input { border-color: var(--brick); background: var(--brick-soft); }
.field-warn { margin: 0; font-size: 0.8125rem; line-height: 1.35; color: var(--brick-dark); }
.field-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 0 8px;
  background: var(--paper-sunk);
  border-right: 1px solid var(--border);
  font-family: var(--font-mono);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.field-input input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  color: var(--ink);
}
.field-input input:focus { outline: none; }
.field-input .unit {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  border-left: 1px solid var(--border);
}

/* ----- toggle ------------------------------------------------------------ */

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}
.toggle-row { display: flex; align-items: center; gap: 8px; }
/* an extra with its product photo, in the colour it comes in */
.toggle__pic { width: 52px; height: 40px; flex: none; overflow: hidden; }
.toggle__photo { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; transition: opacity 0.2s ease; }
.toggle__photo.is-tinting { opacity: 0; }
.toggle .delta { margin-left: auto; }
/* the gutter's wall height and colours, under its toggle */
.extras__gutter { display: flex; flex-direction: column; gap: 12px; padding-left: 50px; }
@media (max-width: 600px) { .extras__gutter { padding-left: 0; } }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  flex: none;
  transition: background 0.15s ease;
}
.toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.toggle input:checked + .toggle__track { background: var(--brick); }
.toggle input:checked + .toggle__track .toggle__knob { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { outline: 2.5px solid var(--brick); outline-offset: 2px; }

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--brick);
  border-radius: 50%;
  font-size: 0.66rem;
  color: var(--brick);
  cursor: help;
}

/* ----- panels below the configurator ------------------------------------ */

.panel {
  margin-top: 20px;
  background: var(--paper-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 26px 30px 30px;
  scroll-margin-top: 16px;
}
@media (max-width: 640px) { .panel { padding: 20px 16px 24px; } }
.panel__head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.panel__title { margin: 0; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.panel__lede { margin: 0; color: var(--ink-soft); font-size: 0.88rem; max-width: 70ch; }
.panel__head--tool { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 16px; }
.panel__head--tool .panel__lede { grid-column: 1 / -1; }
.panel__tool { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
@media (max-width: 560px) {
  .panel__head--tool { grid-template-columns: minmax(0, 1fr); }
  .panel__tool { justify-self: start; order: 1; margin-top: 6px; } /* under the lede: the title keeps the width */
}

/* sheet layout */
.slope-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.slope-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  border: 1.5px solid var(--border);
  background: var(--paper);
  padding: 7px 14px;
  border-radius: var(--radius-s);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
}
.slope-tab small { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 400; color: var(--ink-soft); }
.slope-tab:hover { border-color: var(--graphite); }
.slope-tab[aria-selected='true'] { border-color: var(--brick); background: var(--brick-soft); }

.slope-tab__mark { font-style: normal; font-size: 0.6rem; color: var(--brick); vertical-align: 2px; }
.slope-tab__shape {
  width: 20px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  fill: var(--brick-soft);
  stroke: var(--brick);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

/* per-slope layout editor next to the plan */
.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 330px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch; /* the editor and the plan end on one line */
}
@media (max-width: 900px) {
  .layout-grid { grid-template-columns: 1fr; }
  .sheet-plan { order: -1; } /* the drawing first: every tap below shows on it */
}
.slope-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--paper-sunk);
}
.slope-edit__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.slope-edit__stats div { display: flex; flex-direction: column; gap: 2px; }
.slope-edit__stats dt { font-size: 0.8125rem; color: var(--ink-soft); white-space: nowrap; }
.slope-edit__stats dd { margin: 0; font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; }
.slope-edit__std, .slope-edit__cmp { font-size: 0.8125rem; color: var(--ink-soft); margin-top: -6px; }
.slope-edit__cmp.is-better { color: var(--graphite); font-weight: 600; }
.slope-edit__cmp.is-worse { color: var(--brick-dark); font-weight: 600; }
.slope-edit__field { display: flex; flex-direction: column; gap: 6px; }
.slope-edit__label { font-size: 0.8rem; font-weight: 600; }
.slope-edit__stepper { align-self: flex-start; }
.slope-edit__stepper span { min-width: 96px; }
.slope-edit__stepper button:disabled { opacity: 0.35; cursor: default; }
.slope-edit__hint { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.4; }
.slope-edit__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.slope-edit__actions .btn { padding: 9px 14px; font-size: 0.84rem; }
.seg--compact { gap: 6px; }
.seg--compact .seg__btn { flex: 1 1 0; padding: 7px 6px; font-size: 0.8125rem; line-height: 1.2; }

.sheet-plan {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--paper);
  padding: 12px 12px 14px;
}
/* the sheets drag along the eave; a finger still scrolls the page up and down */
.sheet-plan__svg { width: 100%; height: auto; display: block; cursor: grab; touch-action: pan-y; }
.is-dragging-plan { user-select: none; }
.is-dragging-plan .sheet-plan__svg { cursor: grabbing; }
.cut-list { margin: 10px 4px 0; }
.cut-list__title { margin: 0 0 6px; font-size: 0.82rem; font-weight: 600; }
.cut-list__title span { margin-left: 6px; font-weight: 400; color: var(--ink-soft); }
.cut-list__items { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cut-list__items li {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper-raised);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
/* the sheets as light panels: where two lap over each other it shows darker */
.sp-sheet { fill: #c7d0ee; fill-opacity: 0.62; stroke: #46557f; stroke-width: 1; }
.sp-offcut .sp-sheet { fill: #dfe4f3; fill-opacity: 0.5; stroke: #a3abc4; }
/* a column cut from another sheet's offcut: nothing ordered for it */
.sp-sheets .sp-sheet--offcut, .sp-spare { fill: #d9ead7; fill-opacity: 0.85; stroke: #5d7f58; stroke-dasharray: 5 3; }
/* the same number where an offcut is cut and where it goes */
.sp-pair circle { fill: #5d7f58; stroke: #fff; stroke-width: 1.5; }
.sp-pair text { fill: #fff; font: 700 10px var(--font-mono); text-anchor: middle; dominant-baseline: central; }
/* the fitter's sheet: every sheet's number */
.sp-num rect { fill: #fff; stroke: var(--graphite); stroke-width: 1; }
.sp-num text { fill: var(--ink); font: 700 10px var(--font-mono); text-anchor: middle; dominant-baseline: central; }
.sp-outline { fill: none; stroke: var(--brick); stroke-width: 2.2; stroke-linejoin: round; }
/* each sheet's length in mm, in its lower corner */
.sp-labels text {
  font: 500 11px var(--font-mono);
  fill: #26336b;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}
.sp-ruler { fill: none; stroke: var(--graphite); stroke-width: 1; }
.sp-ruler__x, .sp-ruler__y { font: 500 10px var(--font-mono); fill: var(--ink-soft); }
.sp-ruler__x { text-anchor: middle; }
.sp-ruler__y { text-anchor: end; dominant-baseline: central; }
/* the sheet the plan is drawn in, over the plan */
.sheet-plan__sheet { margin: 2px 4px 10px; font-size: 0.84rem; color: var(--ink-soft); }
.sheet-plan__sheet b { color: var(--ink); font-weight: 600; }

/* ----- specification ----------------------------------------------------- */

.spec-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 26px;
  align-items: start;
}
@media (max-width: 900px) { .spec-layout { grid-template-columns: 1fr; } }

.spec-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.spec-group { display: flex; flex-direction: column; gap: 10px; }
.spec-group__title { margin: 4px 0 0; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }

/* estimate cards, like the catalogue's: the photo (in the roof colour) on the
   left, name / colour / price, then a row per line — the profile has one
   row per sheet length */
.spec-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper-raised);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.spec-card.is-hot { border-color: var(--brick); box-shadow: 0 0 0 3px var(--brick-soft); }
.spec-card__pic {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-right: 1px solid var(--border);
  background: #fff;
}
.spec-card__photo { width: 100%; max-width: 160px; aspect-ratio: 1; object-fit: contain; transition: opacity 0.2s ease; }
.spec-card__photo.is-tinting { opacity: 0; }
.spec-card__body { display: flex; flex-direction: column; min-width: 0; }
.spec-card__head { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px 0; }
.spec-card__text { min-width: 0; }
.spec-card__name { margin: 0; font-size: 0.86rem; font-weight: 600; line-height: 1.35; text-transform: uppercase; letter-spacing: 0.01em; }
.spec-card__color { margin: 4px 0 0; font-size: 0.82rem; line-height: 1.4; }
.spec-card__note { margin: 2px 0 0; font-size: 0.8125rem; line-height: 1.4; color: var(--ink-soft); }
.spec-card__price { margin: 6px 14px 10px; text-align: right; font-size: 0.86rem; font-weight: 600; }
.spec-card__rows { margin-top: auto; }
.spec-row { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); }
.spec-row.is-hot { background: var(--brick-soft); }
.spec-row > div {
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.spec-row > div:last-child { border-right: none; }
.spec-row span:first-child { font-size: 0.8125rem; color: var(--ink-soft); }
.spec-row > div > span:not(:first-child) { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500; }
.spec-row strong { font-family: var(--font-mono); font-size: 0.9rem; }
.stepper--qty input {
  width: 52px;
  padding: 4px 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper--qty input::-webkit-inner-spin-button,
.stepper--qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
@media (max-width: 600px) {
  .spec-card { grid-template-columns: 1fr; }
  .spec-card__pic { border-right: none; border-bottom: 1px solid var(--border); padding: 6px; }
  .spec-card__photo { max-width: 120px; }
  .spec-row { grid-template-columns: repeat(2, 1fr); }
  .spec-row > div:nth-child(2) { border-right: none; }
  .spec-row > div:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
}

/* the estimate's own house */
.spec-house { display: flex; flex-direction: column; gap: 4px; }
.spec-house__canvas {
  aspect-ratio: 16 / 11;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(var(--stage-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.spec-house__cap { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); text-align: center; }
.spec-house--mobile { display: none; }
@media (max-width: 900px) {
  .summary { max-height: none; overflow: visible; }
  .summary .spec-house { display: none; }
  .spec-house--mobile {
    display: flex;
    position: sticky;
    top: 8px;
    z-index: 5;
    background: var(--paper-raised);
    padding-bottom: 6px;
  }
  .spec-house--mobile .spec-house__canvas { max-height: 30vh; width: 100%; box-shadow: 0 6px 18px rgba(28, 33, 38, 0.12); }
}
.spec-card__check {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brick);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
}
.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--paper-sunk);
  border-radius: 5px;
  overflow: hidden;
}
.stepper button {
  width: 30px;
  padding: 6px 0;
  border: none;
  background: none;
  font-size: 1rem;
  line-height: 1;
}
.stepper button:hover { background: var(--border); }
.stepper span { min-width: 40px; text-align: center; font-family: var(--font-mono); font-size: 0.86rem; }

/* touch screens: small controls grow to a fingertip (~40 px); the mouse layout stays compact */
@media (pointer: coarse) {
  .tool { padding: 10px 14px; }
  .stepper button { width: 40px; padding: 11px 0; }
  .stepper--qty input { padding: 9px 2px; }
  .seg--compact .seg__btn { padding: 11px 6px; }
  .chip-link { padding: 11px 4px; margin: -9px -4px; } /* bigger hit area, same place on screen */
  .legal__contacts a { padding: 11px 0; } /* inline: the tap area grows, the line doesn't move */
}
/* a phone's round icon buttons on a touch screen: the pill's height */
@media (pointer: coarse) and (max-width: 520px) {
  .tool--icon { padding: 10px; }
}

.summary {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--paper-sunk);
  border-radius: var(--radius-m);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.summary__block { display: flex; flex-direction: column; gap: 8px; }
.summary__block + .summary__block { padding-top: 12px; border-top: 1px solid var(--border); }
.summary__row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; }
.summary__row span:first-child { color: var(--ink-soft); }
.summary__row span:last-child { font-family: var(--font-mono); font-weight: 500; }
/* what the total is made of: one bar, the list under it — over the estimate's
   lines (in the summary it pushed the total and its buttons off a laptop screen) */
.cost { padding: 14px 16px; background: var(--paper-sunk); border-radius: var(--radius-m); display: flex; flex-direction: column; gap: 10px; }
.cost__title { margin: 0; font-size: 0.82rem; color: var(--ink-soft); }
.cost__bar { display: flex; gap: 2px; height: 12px; }
.cost__seg { flex-basis: 0; min-width: 4px; transition: opacity 0.15s ease; }
.cost__seg:first-child { border-radius: 4px 0 0 4px; }
.cost__seg:last-child { border-radius: 0 4px 4px 0; }
.cost__list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 28px; }
.cost__row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 6px; font-size: 0.82rem; transition: opacity 0.15s ease; }
.cost__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cost__key { width: 10px; height: 10px; border-radius: 3px; }
.cost__share { font-family: var(--font-mono); color: var(--ink-soft); }
.cost__sum { font-family: var(--font-mono); font-weight: 500; min-width: 7.5ch; text-align: right; }
.cost .is-dim { opacity: 0.3; }
.cost__seg, .cost__key { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.summary__total { padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.summary__total span { font-size: 0.82rem; color: var(--ink-soft); }
.summary__total strong { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.summary__actions { display: flex; flex-direction: column; gap: 8px; }
.summary__actions .btn { padding: 10px 12px; font-size: 0.875rem; }
.summary__fine { margin: 0; font-size: 0.75rem; line-height: 1.4; color: var(--ink-soft); }
/* the whole column on a laptop screen: its house gives way when the window is low */
@media (min-width: 901px) {
  .summary .spec-house__canvas { aspect-ratio: auto; height: clamp(76px, calc(100vh - 590px), 190px); }
}

/* ----- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-s);
  padding: 12px 20px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-wide { width: 100%; }
.btn-accent { background: var(--brick); color: #fff; }
.btn-accent:hover { background: var(--brick-dark); }
.btn-ghost { background: var(--paper-raised); border-color: var(--border-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--graphite); background: var(--paper-sunk); }

/* ----- lead modal -------------------------------------------------------- */

.lead-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 28, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.lead-modal[data-open='true'] { display: flex; }
.lead-modal__box {
  position: relative;
  width: min(420px, 100%);
  background: var(--paper-raised);
  border-radius: var(--radius-m);
  padding: 26px;
  box-shadow: var(--shadow);
}
.lead-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: none;
  font-size: 0.95rem;
  padding: 6px;
  color: var(--ink-soft);
}
.lead-modal h3 { font-family: var(--font-display); font-size: 1.02rem; margin: 0 0 4px; }
.lead-modal .lede { color: var(--ink-soft); font-size: 0.86rem; margin: 0 0 16px; }
.lead-modal form { display: flex; flex-direction: column; gap: 10px; }
.lead-modal .field-input input { padding: 11px 12px; font-family: var(--font-body); font-size: 0.92rem; width: 100%; }
.field-error { color: var(--brick); font-size: 0.8125rem; display: none; }
.field-error.visible { display: block; }
.lead-result { margin-top: 12px; font-size: 0.86rem; border-radius: var(--radius-s); }
.lead-result:empty { display: none; }
.lead-result.is-ok { background: var(--paper-sunk); color: var(--ink); padding: 12px 14px; border-left: 3px solid var(--graphite); }
.lead-result.is-error { background: var(--brick-soft); color: var(--brick-dark); padding: 12px 14px; border-left: 3px solid var(--brick); }
.lead-sum {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius-s);
  background: var(--paper-sunk);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.lead-sum__what b { display: block; color: var(--ink); font-weight: 600; font-size: 0.9rem; }
.lead-sum__total { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--ink); white-space: nowrap; }

/* ----- mobile price bar + toast ----------------------------------------- */

.pricebar { display: none; }
@media (max-width: 1099px) {
  .pricebar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 10px 18px;
    border-radius: var(--radius-m);
    background: var(--graphite-dark);
    color: var(--paper);
    box-shadow: 0 10px 30px rgba(28, 33, 38, 0.25);
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .pricebar.is-hidden { transform: translateY(140%); opacity: 0; }
  .pricebar__sum { display: flex; flex-direction: column; line-height: 1.2; }
  /* only the «Итого» caption: the odometer's own spans live inside <strong> */
  .pricebar__sum > span { font-size: 0.8125rem; opacity: 0.75; }
  .pricebar__sum strong { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .pricebar__acts { display: flex; gap: 8px; flex: none; }
  .pricebar .btn { padding: 12px 14px; }
  .pricebar .pricebar__call { padding: 12px; }
  /* the total and three buttons on a 360 px phone */
  @media (max-width: 419px) {
    .pricebar { gap: 8px; padding: 8px 8px 8px 14px; }
    .pricebar__acts { gap: 6px; }
    .pricebar .btn, .pricebar .pricebar__call { padding: 11px 10px; }
    .pricebar__sum strong { font-size: 1.05rem; }
  }
  /* the estimate link sits quiet on the dark bar; the lead button carries the colour */
  .pricebar .btn-ghost { background: transparent; border-color: rgba(244, 246, 244, 0.35); color: var(--paper); }
  .pricebar .btn-ghost:hover { background: rgba(244, 246, 244, 0.1); border-color: var(--paper); }
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--graphite-dark);
  color: var(--paper);
  font-size: 0.86rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-on { opacity: 1; transform: none; }
@media (max-width: 1099px) {
  .toast { right: auto; left: 50%; bottom: 92px; transform: translate(-50%, 20px); }
  .toast.is-on { transform: translate(-50%, 0); }
}

/* ----- footer + print --------------------------------------------------- */

footer.legal { color: var(--ink-soft); font-size: 0.8125rem; margin-top: 28px; text-align: center; }
footer.legal p { margin: 0 0 6px; }
.logo { display: block; width: auto; }
footer.legal .logo { height: 48px; margin: 0 auto 14px; }
.legal__contacts { color: var(--ink); font-size: 0.9rem; }
/* a narrow screen wraps between the contacts, not inside «Почта: адрес» */
.legal__contacts span, .print-head__contacts span { white-space: nowrap; }
.legal__contacts a, .print-head__contacts a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.legal__contacts a:hover { color: var(--accent); }

.print-head, .print-layout, .print-fitter { display: none; }

@media print {
  html { scroll-behavior: auto; }
  .configurator, #layout, .pricebar, .toast, .lead-modal, footer.legal,
  .summary__actions, .stepper button, #spec .panel__lede, .spec-house { display: none !important; }
  .summary { max-height: none; overflow: visible; }
  .app { padding: 0; max-width: none; }
  .panel { border: none; box-shadow: none; padding: 0; margin: 0; }
  .print-head { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 18px; }
  .print-head .logo { height: 44px; margin-bottom: 14px; }
  .print-qr { margin: 0; display: grid; justify-items: center; gap: 4px; flex: 0 0 auto; }
  .print-qr figcaption { max-width: 170px; font-size: 0.68rem; line-height: 1.25; text-align: center; color: var(--ink-soft); }
  .print-head h1 { font-family: var(--font-display); font-size: 1.3rem; margin: 0 0 6px; }
  .print-head p { margin: 0 0 2px; color: var(--ink-soft); font-size: 0.86rem; }
  .print-house { width: 280px; flex: none; }
  .print-house .house-shot { position: relative; }
  .print-house .house-shot img { width: 100%; height: auto; display: block; }
  .print-house .house-shot .house-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .spec-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .spec-card { break-inside: avoid; grid-template-columns: 130px minmax(0, 1fr); }
  .stepper--qty input { border: none; background: none; width: auto; }
  .stepper { background: none; }
  .spec-card__photo.is-tinting { opacity: 1; } /* not painted yet: print the plain photo, not a gap */
  .spec-card.is-hot { border-color: var(--border); box-shadow: none; }
  .spec-row.is-hot { background: none; }
  /* the sheet layout of every slope, after the estimate */
  .print-layout { display: block; break-before: page; }
  .print-layout__title { font-family: var(--font-display); font-size: 1.1rem; margin: 0 0 12px; }
  .print-slope { break-inside: avoid; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .print-slope .cut-list { margin: 0 0 6px; }
  .print-slope__plan .sheet-plan__svg { width: auto; max-width: 100%; } /* its own size: 11 px lengths, more slopes a page */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* a note over the estimate (sheets longer than 6 m) */
.spec-note { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-s); background: var(--brick-soft); color: var(--brick-dark); font-size: 14px; }
.layout-reuse { margin: 0 0 14px; }

/* ----- «Свой чертёж» ------------------------------------------------------ */

/* the side marks' colours: the editor, the stage, the legend and the buttons */
.dp-edge--eave, .edge-type--eave, .edge-key--eave { --edge: #2563a8; }
.dp-edge--ridge, .edge-type--ridge, .edge-key--ridge { --edge: #a23b2e; }
.dp-edge--hip, .edge-type--hip, .edge-key--hip { --edge: #c06a10; }
.dp-edge--gable, .edge-type--gable, .edge-key--gable { --edge: #3d7a37; }
.dp-edge--none, .edge-type--none, .edge-key--none { --edge: #87919a; }

.type-tile--span { grid-column: 1 / -1; }
.mini-handle { fill: var(--paper-raised); stroke: var(--draw-line); stroke-width: 3; }
.mini-pen__lead { fill: var(--draw-line); }

.drawn-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.drawn-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
}
.drawn-item span:last-child { font-family: var(--font-mono); font-weight: 400; font-size: 0.8125rem; color: var(--ink-soft); }
.drawn-item:hover { border-color: var(--graphite); }

.slope-tab--add { border-style: dashed; color: var(--brick-dark); }
.draw-mode { max-width: 440px; margin: -4px 0 14px; }

.draw-tpls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.draw-tpl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper-raised);
  font-size: 0.68rem;
  line-height: 1.15;
  color: var(--ink-soft);
}
.draw-tpl svg { width: 36px; height: 24px; overflow: visible; }
.draw-tpl polygon { fill: var(--brick-soft); stroke: var(--brick); stroke-width: 0.09; stroke-linejoin: round; }
.draw-tpl:hover { border-color: var(--graphite); }
.draw-tpl[aria-pressed='true'] { border-color: var(--brick); background: var(--brick-soft); color: var(--ink); }
.draw-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin-top: 4px; }
.draw-fields .field-input input { padding: 8px; }

.edge-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 6px; }
.edge-type {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--paper-raised);
  font-size: 0.8125rem;
  text-align: left;
}
.edge-type::before { content: ''; flex: none; width: 16px; height: 4px; border-radius: 2px; background: var(--edge); }
.edge-type:hover { border-color: var(--edge); }
.edge-type[aria-pressed='true'] { border-color: var(--edge); box-shadow: inset 0 0 0 1px var(--edge); font-weight: 600; }
.draw-sel__btn { align-self: flex-start; padding: 8px 12px; font-size: 0.8125rem; }

/* the editor, KladEra-like: white paper, sizes in little frames, red points */
.draw-plan { background: #fff; }
.draw-canvas { min-height: 200px; }
.dp-svg { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.dp-paper { fill: #fff; }
.dp-paper--draft { cursor: crosshair; }
.dp-svg--draft { cursor: crosshair; }
.dp-grid { fill: none; stroke: #eceeed; stroke-width: 1; }
.dp-ruler { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.dp-ruler__x, .dp-ruler__y { font: 500 10px var(--font-mono); fill: var(--ink-soft); }
.dp-ruler__x { text-anchor: middle; }
.dp-ruler__y { text-anchor: end; dominant-baseline: central; }
.dp-fill { fill: rgba(162, 59, 46, 0.05); }
.dp-edge { stroke: var(--edge); stroke-width: 2.5; stroke-linecap: round; }
.dp-edge--none { stroke-dasharray: 7 6; stroke-width: 2; }
.dp-edge.is-sel { stroke-width: 5; }
.dp-hit { stroke: transparent; stroke-width: 20; stroke-linecap: round; cursor: pointer; }
.dp-hit:focus { outline: none; }
.dp-hit:focus-visible { stroke: rgba(28, 33, 38, 0.12); }
.dp-box { pointer-events: none; }
.dp-box rect { fill: #fff; stroke: var(--ink); stroke-width: 1; }
.dp-box text { font: 500 11px var(--font-mono); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.dp-box.is-sel rect { fill: var(--brick-soft); stroke: var(--brick); }
.dp-box.is-typed rect { fill: var(--brick); stroke: var(--brick); }
.dp-box.is-typed text { fill: #fff; }
.dp-svg--draft .dp-box.is-sel rect { stroke-width: 2; }
.dp-box.is-typed.is-sel rect { stroke: var(--ink); }
.dp-dim__line { stroke: #6b747c; stroke-width: 1; }
.dp-dim__arrow { fill: #6b747c; }
.dp-ext { fill: none; stroke: #a7aeb4; stroke-width: 1; stroke-dasharray: 4 4; }
.dp-draft { fill: none; stroke: #e0302a; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.dp-draft--next { stroke-dasharray: 8 5; }
.dp-draft__pt { fill: #e0302a; }
.dp-draft__pt.is-close { fill: #fff; stroke: #e0302a; stroke-width: 2.5; }
.dp-draft__aim { fill: none; stroke: #e0302a; stroke-width: 1.5; }
.dp-draft--next.is-close { stroke-dasharray: none; }
.dp-draft__pt.is-aim { fill: #e0302a; stroke: #fff; stroke-width: 3; }
.dp-pt { cursor: grab; }
.dp-pt:focus { outline: none; }
.dp-pt__hit { fill: transparent; }
.dp-pt__dot { fill: #e0302a; stroke: #fff; stroke-width: 1.5; }
.dp-pt:hover .dp-pt__dot, .dp-pt:focus-visible .dp-pt__dot { stroke: var(--ink); }
.dp-pt.is-sel .dp-pt__dot { stroke: var(--ink); stroke-width: 2; }
/* the point a typed side length moves */
.dp-pt.is-moving .dp-pt__dot { fill: #2563a8; }
.draw-tpl--pen polyline { fill: none; stroke: #e0302a; stroke-width: 0.12; stroke-linejoin: round; }
.draw-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 4px 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--ink-soft); }
.edge-key { display: flex; align-items: center; gap: 6px; }
.edge-key::before { content: ''; width: 16px; height: 4px; border-radius: 2px; background: var(--edge); }
.edge-key--none::before { background: repeating-linear-gradient(90deg, var(--edge) 0 5px, transparent 5px 8px); }

/* the stage: every slope in the roof's colour with its sheets, on the studio floor */
.stage.is-drawn .tool--play, .stage.is-drawn [data-act='home'] { display: none; }
.stage.is-drawn .stage__canvas { cursor: default; touch-action: auto; }
.stage.is-drawn .stage__hint { opacity: 1; }
.st-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.st-hit { fill: transparent; }
.st-shadow { fill: rgba(28, 33, 38, 0.24); }
.st-seam { fill: none; stroke-width: 1.4; }
.st-outline { fill: none; stroke: var(--graphite); stroke-width: 1.3; stroke-linejoin: round; transition: stroke 0.15s ease; }
.st-halo { fill: none; stroke: #fff; stroke-width: 0; stroke-linejoin: round; } /* keeps the brick outline clear of a dark red roof */
.st-slope { cursor: pointer; outline: none; }
.st-slope:hover .st-outline { stroke: var(--brick); stroke-width: 2; }
.st-slope.is-active .st-outline, .st-slope:focus-visible .st-outline { stroke: var(--brick); stroke-width: 2.6; }
.st-slope.is-active .st-halo, .st-slope:hover .st-halo, .st-slope:focus-visible .st-halo { stroke-width: 5.5; }
.st-slope--compact { cursor: default; }
.st-hot { fill: rgba(162, 59, 46, 0.3); animation: hl-pulse 1.2s ease-in-out infinite; }
.st-svg .dp-edge.is-hot { stroke-width: 6; animation: hl-pulse 1.2s ease-in-out infinite; }
.st-ext { fill: none; stroke: var(--brick); stroke-width: 0.9; opacity: 0.7; }
.st-dim__line { fill: none; stroke: var(--brick); stroke-width: 1.4; }
.st-dim__tick { fill: none; stroke: var(--brick); stroke-width: 1.8; }
.st-dim__pill { fill: var(--paper-raised); stroke: var(--brick); stroke-width: 1; }
.st-dim__text { fill: var(--ink); font: 500 12px var(--font-mono); text-anchor: middle; dominant-baseline: central; }
.st-badge__pill { fill: var(--paper-raised); stroke: var(--border-strong); stroke-width: 1; }
.st-badge__num { fill: var(--graphite); }
.st-badge__n { fill: #fff; font: 700 12px var(--font-body); text-anchor: middle; dominant-baseline: central; }
.st-badge__area { fill: var(--ink); font: 500 12px var(--font-mono); dominant-baseline: central; }
.st-slope.is-active .st-badge__num { fill: var(--brick); }
.st-slope.is-active .st-badge__pill { stroke: var(--brick); }
.st-name { fill: var(--ink-soft); font: 600 11px var(--font-body); text-anchor: middle; }

@media print {
  .print-house .st-svg { width: 100%; height: auto; }
}
/* «Лист для монтажника»: only the fitter's sheet goes to paper — no prices */
@media print {
  body.is-fitter #calc-root > :not(#print-fitter) { display: none !important; }
  body.is-fitter .print-fitter { display: block; }
  .fitter { font-size: 0.86rem; }
  .fitter__head { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 12px; }
  .fitter__head .logo { height: 40px; width: auto; margin-bottom: 10px; }
  .fitter__head h1 { font-family: var(--font-display); font-size: 1.3rem; margin: 0 0 6px; }
  .fitter__head p { margin: 0 0 2px; color: var(--ink-soft); }
  .fitter__head .print-qr figcaption { font-size: 0.68rem; color: var(--ink-soft); text-align: center; }
  .fitter__facts { margin: 0 0 14px; padding-left: 18px; }
  .fitter__facts li { margin-bottom: 2px; }
  .fitter__slope { break-inside: avoid; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .fitter__slope h2, .fitter__kit h2 { font-family: var(--font-display); font-size: 1rem; margin: 0 0 8px; }
  .fitter__slope h2 span { margin-left: 8px; font-family: var(--font-body); font-weight: 400; font-size: 0.86rem; color: var(--ink-soft); }
  .fitter__plan .sheet-plan__svg { width: auto; max-width: 100%; }
  .fitter__lens { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 6px 0 0; padding: 0; list-style: none; }
  .fitter__lens span { margin-left: 8px; color: var(--ink-soft); }
  .fitter__kit { break-before: auto; }
  .fitter__kit table { width: 100%; border-collapse: collapse; }
  .fitter__kit td { padding: 4px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
  .fitter__kit td:last-child { text-align: right; white-space: nowrap; font-family: var(--font-mono); padding-left: 16px; }
  .fitter__kit td small { display: block; color: var(--ink-soft); font-size: 0.78rem; }
  .fitter__group th { text-align: left; padding: 10px 0 4px; font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
  .fitter__foot { margin-top: 14px; color: var(--ink-soft); font-size: 0.8rem; }
}
