/*
  Lune Modular: modular sofa configurator (Screenery template)
  1. Tokens: oat, birch, wool grey, ink and one pine accent; Be Vietnam Pro in light display and regular text; soft radii.
  2. Layout: header, intro, the configurator (sticky stage plus a long control panel), fabrics book and samples form,
     craft cross-section, delivery boxes, compare table, order summary with outcomes, questions, footer.
  3. Fallbacks: the SVG plan shows by default and the 3D canvas only appears once script.js adds .gl to <html>.
*/

:root {
  /* colour */
  --oat: #efe9df;          /* page ground */
  --oat-deep: #e5ddcf;     /* sunk surfaces */
  --paper: #f8f5ef;        /* raised paper, panels */
  --birch: #d8c3a0;        /* pale wood */
  --birch-deep: #b08e60;   /* wood edge, decorative only */
  --wool: #8f8a81;         /* heather grey, decorative lines */
  --wool-ink: #5f5a52;     /* secondary text, 5.6:1 on oat */
  --ink: #2a2723;          /* text */
  --pine: #2f4a3c;         /* the one accent */
  --pine-deep: #243a2f;
  --pine-wash: #dfe5dc;
  --rust: #9c4424;         /* errors, 5.4:1 on paper */
  --rust-wash: #f3e1d6;
  --ok: #2f5a3f;
  --ok-wash: #e1eadf;
  --line: #d7cebf;         /* hairlines */
  --line-strong: #bfb4a2;

  /* type */
  --font: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif;
  --step--1: .875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: clamp(1.5rem, 1.2rem + 1vw, 1.875rem);
  --step-3: clamp(2rem, 1.4rem + 2.2vw, 3rem);
  --step-4: clamp(2.4rem, 1.5rem + 3.4vw, 4.25rem);

  /* space */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;
  --s-9: clamp(4.5rem, 3rem + 6vw, 8.5rem);
  --gutter: clamp(16px, 4vw, 48px);

  /* shape and depth */
  --r-s: 10px;
  --r-m: 18px;
  --r-l: 28px;
  --r-pill: 999px;
  --shadow-soft: 0 1px 2px rgb(60 45 25 / .06), 0 8px 24px -10px rgb(60 45 25 / .22);
  --shadow-lift: 0 2px 4px rgb(60 45 25 / .08), 0 18px 40px -16px rgb(60 45 25 / .32);
  --ease: cubic-bezier(.16, 1, .3, 1);

  color-scheme: light;
  accent-color: var(--pine);
  scrollbar-color: var(--birch-deep) var(--oat-deep);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--oat);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--font);
  caret-color: var(--pine);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
::selection { background: var(--pine); color: var(--paper); }
h1, h2, h3, h4 { margin: 0; font-weight: 400; line-height: 1.15; text-wrap: balance; letter-spacing: -.02em; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--pine); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 3px; border-radius: 6px; }
img, svg { display: block; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--s-4); top: -60px; z-index: 50; background: var(--pine); color: var(--paper); padding: var(--s-2) var(--s-4); border-radius: var(--r-pill); }
.skip:focus { top: var(--s-3); }
.wrap { width: 100%; max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ */
/* Buttons and fields                                                  */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease), transform .3s var(--ease);
}
.btn--primary { background: var(--pine); color: var(--paper); }
.btn--primary:hover { background: var(--pine-deep); text-decoration: none; }
.btn--quiet { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--quiet:hover { border-color: var(--ink); text-decoration: none; }
.btn--wide { width: 100%; }
.btn:active { transform: translateY(1px); }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .btn[aria-busy="true"]::before { animation: none; border-right-color: currentColor; opacity: .5; } }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.link-btn {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px;
  background: none; border: 0; padding: 0; color: var(--pine); font-weight: 500;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .25em;
}
.link-btn .icon { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field label { font-size: var(--step--1); font-weight: 500; display: flex; gap: var(--s-2); align-items: center; }
.field input, .select select {
  width: 100%; min-height: 48px; padding: 0 var(--s-4);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-s);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.field input::placeholder { color: #6b655d; }
.field input:hover, .select select:hover { border-color: var(--wool-ink); }
.field input:focus-visible, .select select:focus-visible { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px rgb(47 74 60 / .22); }
.field input[aria-invalid="true"] { border-color: var(--rust); background: #fcf3ee; }
.field__err { font-size: var(--step--1); color: var(--rust); min-height: 0; }
.field__err:empty { display: none; }
.opt { font-weight: 400; color: var(--wool-ink); }
.select { position: relative; }
.select select { appearance: none; padding-right: 44px; cursor: pointer; }
.select .icon { position: absolute; right: 14px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--wool-ink); }
.check { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--step--1); padding-top: var(--s-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s-6);
  min-height: 68px; padding-inline: var(--gutter);
  background: var(--oat); border-bottom: 1px solid var(--line);
}
.mark { display: flex; align-items: center; gap: var(--s-2); color: var(--ink); text-decoration: none; }
.mark__glyph { width: 34px; height: 21px; }
.mark__glyph rect:first-child { fill: var(--birch); }
.mark__glyph rect:last-child { fill: var(--pine); }
.mark__word { font-size: 1.375rem; font-weight: 500; letter-spacing: -.03em; }
.nav { display: flex; gap: var(--s-5); margin-left: auto; }
.nav a { color: var(--ink); text-decoration: none; font-size: var(--step--1); padding: var(--s-2) 0; border-bottom: 1px solid transparent; }
.nav a:hover { border-bottom-color: var(--ink); }
.top__price {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4);
  border-radius: var(--r-pill); background: var(--pine); color: var(--paper); text-decoration: none;
  font-weight: 500; font-variant-numeric: tabular-nums;
}
.top__price .icon { width: 18px; height: 18px; }
@media (max-width: 960px) { .nav { display: none; } .top__price { margin-left: auto; } }

/* ------------------------------------------------------------------ */
/* Intro                                                               */
/* ------------------------------------------------------------------ */
.intro {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s-7);
  align-items: end; padding-block: var(--s-6) var(--s-6);
}
.intro h1 { font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.6rem); font-weight: 300; letter-spacing: -.035em; line-height: 1.04; max-width: 15ch; }
.intro__side { display: grid; gap: var(--s-5); max-width: 62ch; }
.intro__side > p { color: var(--ink); }
.intro__facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.intro__facts li {
  font-size: var(--step--1); padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--paper); border: 1px solid var(--line);
}
@media (max-width: 860px) {
  .intro { grid-template-columns: 1fr; gap: var(--s-5); padding-block: var(--s-6) var(--s-5); }
}

/* ------------------------------------------------------------------ */
/* Configurator                                                        */
/* ------------------------------------------------------------------ */
.config {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--s-6);
  align-items: start; padding-bottom: var(--s-9);
}
.stage {
  position: sticky; top: 84px;
  height: clamp(520px, calc(100vh - 110px), 800px);
  border-radius: var(--r-l); overflow: hidden;
  /* soft daylight from a window up and to the left, falling onto a pale floor */
  background:
    radial-gradient(120% 80% at 12% 0%, rgb(255 251 242 / .95), rgb(255 251 242 / 0) 60%),
    linear-gradient(180deg, #ebe4d8 0%, #e6dfd2 44%, #ddd4c4 100%);
  border: 1px solid var(--line);
  touch-action: pan-y;
  isolation: isolate;
}
.stage__gl, .stage__dims { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.stage__dims { pointer-events: none; overflow: visible; }
.gl .stage[data-view="3d"] .stage__gl, .gl .stage[data-view="3d"] .stage__dims { display: block; }
.gl .stage[data-view="3d"] .stage__plan { display: none; }
.stage__gl { cursor: grab; touch-action: pan-y; }
.stage__gl.is-over { cursor: move; }
.stage__gl.is-dragging { cursor: grabbing; }

/* dimension overlay drawn by script.js */
.dim-line { stroke: var(--ink); stroke-width: 1.2; fill: none; }
.dim-tick { stroke: var(--ink); stroke-width: 1.2; }
.dim-text { font: 500 13px/1 var(--font); fill: var(--ink); paint-order: stroke; stroke: #ebe4d8; stroke-width: 5px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.dim-room { font: 500 12px/1 var(--font); fill: var(--wool-ink); paint-order: stroke; stroke: #ebe4d8; stroke-width: 4px; }

.stage__plan { position: absolute; inset: 64px 16px 70px; display: grid; place-items: center; }
.plan { width: 100%; height: 100%; overflow: visible; touch-action: none; }
.plan__grid { stroke: var(--wool); stroke-opacity: .22; stroke-width: .6; }
.plan__wall { stroke: var(--wool-ink); stroke-width: 4; stroke-linecap: round; }
.plan__roomrect { fill: rgb(255 255 255 / .35); stroke: var(--wool-ink); stroke-width: 1.4; stroke-dasharray: 6 5; }
.plan__roomrect.is-tight { stroke: var(--rust); }
.plan__mod { cursor: grab; }
.plan__mod:active { cursor: grabbing; }
.plan__base { stroke: rgb(42 39 35 / .32); stroke-width: 1; }
.plan__mod.is-sel .plan__base { stroke: var(--pine); stroke-width: 3; }
.plan__tag { font: 600 15px/1 var(--font); fill: var(--ink); paint-order: stroke; stroke: rgb(248 245 239 / .85); stroke-width: 4px; pointer-events: none; }
.plan__mod.is-dark + .plan__tag { fill: var(--paper); stroke: rgb(30 30 28 / .45); stroke-width: 3px; }
.plan__dim path { stroke: var(--ink); stroke-width: 1.2; fill: none; }
.plan__dim text { font: 500 13px/1 var(--font); fill: var(--ink); font-variant-numeric: tabular-nums; }
.plan__roomlabel { font: 500 12px/1 var(--font); fill: var(--wool-ink); }

.stage__bar { position: absolute; left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); z-index: 2; pointer-events: none; }
.stage__bar > * { pointer-events: auto; }
.stage__bar--top { top: 16px; }
.stage__readout {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: 8px 16px; border-radius: var(--r-pill); background: var(--paper);
  font-size: var(--step--1); font-weight: 500; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-soft);
  white-space: nowrap;
}
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--wool); }
.views { display: inline-flex; padding: 4px; background: var(--paper); border-radius: var(--r-pill); box-shadow: var(--shadow-soft); }
.views__btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill); background: transparent; font-size: var(--step--1); font-weight: 500;
}
.views__btn .icon { width: 18px; height: 18px; }
.views__btn[aria-pressed="true"] { background: var(--pine); color: var(--paper); }
.views__btn[disabled] { display: none; }
.stage__keys { position: absolute; inset: 64px 0 64px; z-index: 1; pointer-events: none; border-radius: var(--r-m); }
.stage__keys:focus-visible { outline: 2px solid var(--pine); outline-offset: -6px; }
.stage__hint {
  position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 2;
  font-size: var(--step--1); color: var(--wool-ink); max-width: 60ch;
}
.stage__empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: var(--s-6); font-size: var(--step-1); color: var(--wool-ink); pointer-events: none; z-index: 1;
}

/* panel */
.panel { display: grid; }
.panel__noscript { padding: var(--s-4); background: var(--paper); border-radius: var(--r-m); margin-bottom: var(--s-4); }
.group { padding-block: var(--s-5); border-top: 1px solid var(--line); display: grid; gap: var(--s-4); }
.group:first-of-type { border-top: 0; padding-top: 0; }
.group__title { font-size: var(--step-0); font-weight: 600; letter-spacing: -.01em; display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding: 0; }
.group__title .icon { color: var(--pine); }
.group__sel { font-weight: 400; color: var(--wool-ink); }
.group__msg { font-size: var(--step--1); color: var(--wool-ink); min-height: 1.6em; }
.group__msg.is-warn { color: var(--rust); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.preset {
  display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; column-gap: var(--s-3); align-items: center; text-align: left; padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m);
  font-size: .8125rem; font-weight: 500; line-height: 1.25; min-height: 44px;
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.preset svg { width: 56px; height: 28px; grid-row: 1 / 3; }
.preset svg rect, .preset svg path { fill: var(--birch); stroke: var(--birch-deep); stroke-width: 1; }
.preset small { font-size: .75rem; font-weight: 400; color: var(--wool-ink); font-variant-numeric: tabular-nums; }
.preset:hover { border-color: var(--wool-ink); }
.preset[aria-pressed="true"] { border-color: var(--pine); background: var(--pine-wash); }
.preset[aria-pressed="true"] svg rect, .preset[aria-pressed="true"] svg path { fill: var(--pine); stroke: var(--pine); }

.tray { display: grid; grid-template-columns: 1fr; gap: var(--s-2); }
.tray__btn {
  display: grid; grid-template-columns: 40px 1fr auto; grid-template-rows: auto auto; column-gap: var(--s-3);
  align-items: center; text-align: left; padding: 10px 14px 10px 10px; min-height: 60px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m);
  transition: border-color .25s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.tray__btn svg { grid-row: 1 / 3; width: 40px; height: 40px; }
.tray__btn .t-base { fill: #cbbda4; }
.tray__btn .t-back { fill: #b9a98c; }
.tray__btn .t-seat { fill: #ddd1bc; }
.tray__name { font-size: var(--step--1); font-weight: 500; line-height: 1.25; }
.tray__meta { font-size: .75rem; color: var(--wool-ink); grid-column: 2; font-variant-numeric: tabular-nums; }
.tray__price { grid-column: 3; grid-row: 1 / 3; font-size: var(--step--1); font-weight: 500; font-variant-numeric: tabular-nums; }
.tray__btn:hover { border-color: var(--pine); box-shadow: var(--shadow-soft); transform: translateY(-1px); }

.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.act {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-size: var(--step--1); font-weight: 500;
}
.act .icon { width: 18px; height: 18px; }
.act:hover:not(:disabled) { border-color: var(--ink); }
.act--danger { color: var(--rust); }
.act--danger:hover:not(:disabled) { border-color: var(--rust); }
.act:disabled, .nudge__btn:disabled { opacity: .45; cursor: not-allowed; }
.act[data-act="mirror"][hidden] { display: none; }
.nudge { display: grid; grid-template-columns: repeat(3, 44px) 1fr; grid-template-rows: 44px 44px; gap: 4px; align-items: center; }
.nudge__btn {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px;
}
.nudge__btn:hover:not(:disabled) { border-color: var(--ink); }
.nudge__btn[data-move="0,-10"] { grid-column: 2; grid-row: 1; }
.nudge__btn[data-move="-10,0"] { grid-column: 1; grid-row: 2; }
.nudge__btn[data-move="0,10"] { grid-column: 2; grid-row: 2; }
.nudge__btn[data-move="10,0"] { grid-column: 3; grid-row: 2; }
.nudge__label { grid-column: 4; grid-row: 1 / 3; padding-left: var(--s-3); font-size: var(--step--1); color: var(--wool-ink); }

.fabrics__row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.sw { display: grid; justify-items: center; gap: 6px; font-size: .75rem; text-align: center; line-height: 1.25; cursor: pointer; padding: 4px 0; border-radius: var(--r-s); }
.sw input, .leg input, .pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw svg { width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-soft); transition: box-shadow .3s var(--ease), transform .3s var(--ease); }
.sw:hover svg { transform: translateY(-2px); }
.sw:has(input:checked) svg { box-shadow: 0 0 0 2px var(--oat), 0 0 0 4px var(--pine), var(--shadow-soft); }
.sw:has(input:checked) span { font-weight: 600; }
.sw:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 2px; }
.legs { margin-top: var(--s-4); }
.legs__row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.leg {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 16px 0 10px;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-size: var(--step--1); font-weight: 500; cursor: pointer;
}
.leg:has(input:checked) { border-color: var(--pine); background: var(--pine-wash); }
.leg:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 2px; }
.leg__chip { width: 22px; height: 22px; border-radius: 50%; }
.leg__chip--oak { background: radial-gradient(circle at 35% 30%, #d1a874, #8a6338); }
.leg__chip--steel { background: radial-gradient(circle at 35% 30%, #6a6a68, #1d1d1c); }

.pieces { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: none; }
.piece {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: var(--s-3);
  padding: 6px 6px 6px 8px; border-radius: var(--r-s); font-size: var(--step--1); line-height: 1.4;
}
.piece.is-sel { background: var(--pine-wash); }
.piece__tag {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line-strong); font-weight: 600; font-size: .8125rem;
}
.piece.is-sel .piece__tag { background: var(--pine); border-color: var(--pine); color: var(--paper); }
.piece__text strong { font-weight: 600; }
.piece__btns { display: flex; gap: 2px; }
.piece__btn {
  min-height: 44px; min-width: 44px; padding: 0 10px; border: 0; background: transparent; border-radius: 10px;
  font-size: .8125rem; font-weight: 500; color: var(--pine);
}
.piece__btn:hover { background: var(--paper); }
.piece__btn .icon { width: 18px; height: 18px; margin: auto; }
.piece__btn--remove { color: var(--rust); }
.pieces__empty { font-size: var(--step--1); color: var(--wool-ink); }

.lines { display: grid; gap: 6px; margin: 0; font-variant-numeric: tabular-nums; }
.lines > div { display: flex; justify-content: space-between; gap: var(--s-4); font-size: var(--step--1); }
.lines dt { color: var(--wool-ink); }
.lines dd { margin: 0; font-weight: 500; text-align: right; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.total strong { font-size: var(--step-2); font-weight: 400; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.fit { display: grid; gap: var(--s-3); }
.fit__help { font-size: var(--step--1); color: var(--wool-ink); }
.fit__row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: var(--s-2); align-items: end; }
.fit__row .field__err { grid-column: auto; }
.fit__x { line-height: 48px; color: var(--wool-ink); }
.fit__row .btn { min-height: 48px; padding: 0 var(--s-4); }
.fit__row .field { align-self: start; }
.fit__row .btn, .fit__x { align-self: start; margin-top: 27px; }
.fit__result:empty { display: none; }
.fit__result { padding: var(--s-4); border-radius: var(--r-m); font-size: var(--step--1); display: grid; gap: 4px; }
.fit__result strong { font-size: var(--step-0); font-weight: 600; }
.fit__result.is-ok { background: var(--ok-wash); color: var(--ok); }
.fit__result.is-tight { background: #f1ead9; color: #5d4a1f; }
.fit__result.is-no { background: var(--rust-wash); color: var(--rust); }

@media (max-width: 1100px) {
  .config { grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-5); }
}
@media (max-width: 900px) {
  .config { grid-template-columns: 1fr; }
  .stage { position: relative; top: 0; height: clamp(380px, 68vw, 560px); }
}
@media (max-width: 560px) {
  .stage { height: 440px; border-radius: var(--r-m); margin-inline: calc(var(--gutter) * -1 + 8px); }
  .stage__plan { inset: 60px 8px 92px; }
  .stage__readout { padding: 6px 12px; gap: var(--s-2); }
  .views__btn { padding: 0 10px; }
  .stage__hint { font-size: .8125rem; }
  .preset { grid-template-columns: 1fr; justify-items: start; row-gap: 2px; }
  .preset svg { grid-row: auto; width: 48px; height: 24px; margin-bottom: 4px; }
  .views__btn .icon { display: none; }
  .fabrics__row { gap: 4px; }
  .sw svg { width: 46px; height: 46px; }
  .fit__row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fit__x { display: none; }
  .fit__row .btn { grid-column: 1 / -1; margin-top: 0; }
}

/* ------------------------------------------------------------------ */
/* Fabrics book                                                        */
/* ------------------------------------------------------------------ */
.fabric-book { background: var(--paper); border-block: 1px solid var(--line); padding-block: var(--s-9); }
.fabric-book__inner { display: grid; gap: var(--s-8); }
.fabric-book__head { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-7); align-items: end; }
.fabric-book__head h2, .craft h2, .delivery h2, .compare h2, .order h2, .faq h2 { font-size: var(--step-3); font-weight: 300; letter-spacing: -.03em; max-width: 20ch; }
.fabric-book__head p { max-width: 60ch; color: var(--wool-ink); }

.book { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-7); align-items: start; }
.book__tabs { display: flex; gap: 0; padding: var(--s-5) 0 var(--s-6) var(--s-4); }
.book__tab {
  flex: 1 1 0; min-width: 0; display: grid; gap: var(--s-3); justify-items: start;
  margin-left: -6%; padding: 0; border: 0; background: none; text-align: left;
  font-size: var(--step--1); font-weight: 500;
  transition: transform .6s var(--ease);
}
.book__tab:first-child { margin-left: 0; }
.book__tab svg {
  width: 100%; height: auto; aspect-ratio: 3 / 4; border-radius: 10px;
  box-shadow: -6px 10px 24px -14px rgb(60 45 25 / .55), 0 0 0 1px rgb(60 45 25 / .1);
  transform: rotate(var(--tilt, 0deg)); transition: transform .6s var(--ease);
}
.book__tab:nth-child(1) { --tilt: -4deg; }
.book__tab:nth-child(2) { --tilt: -1.5deg; }
.book__tab:nth-child(3) { --tilt: 1deg; }
.book__tab:nth-child(4) { --tilt: 3deg; }
.book__tab:nth-child(5) { --tilt: 5deg; }
.book__tab span { padding-left: 10%; }
.book__tab:hover { transform: translateY(-6px); }
.book__tab[aria-selected="true"] { transform: translateY(-18px); z-index: 1; }
.book__tab[aria-selected="true"] svg { transform: rotate(0deg); box-shadow: -6px 18px 34px -14px rgb(60 45 25 / .6), 0 0 0 2px var(--pine); }
.book__tab[aria-selected="true"] span { font-weight: 600; }
.cloth { display: grid; gap: var(--s-4); padding-top: var(--s-4); }
.cloth:focus-visible { outline-offset: 8px; }
.cloth__name { font-size: var(--step-2); font-weight: 400; }
.cloth__line { max-width: 52ch; }
.cloth__facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-5); margin: 0; padding-block: var(--s-4); border-block: 1px solid var(--line); }
.cloth__facts dt { font-size: var(--step--1); color: var(--wool-ink); }
.cloth__facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.cloth__care-title { font-size: var(--step-0); font-weight: 600; }
.care { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); font-size: var(--step--1); }
.care li { display: flex; gap: var(--s-3); align-items: center; }
.care .icon { width: 26px; height: 26px; color: var(--pine); }
.cloth .btn { justify-self: start; margin-top: var(--s-2); }

.samples {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s-5) var(--s-7);
  padding: var(--s-7); border-radius: var(--r-l); background: var(--oat); border: 1px solid var(--line);
}
.samples__intro { display: grid; gap: var(--s-3); align-content: start; }
.samples__intro h3 { font-size: var(--step-2); font-weight: 400; }
.samples__intro p { color: var(--wool-ink); max-width: 46ch; }
.samples__pick { grid-column: 1; display: flex; flex-wrap: wrap; gap: var(--s-2); align-content: start; }
.samples__pick legend { font-size: var(--step--1); font-weight: 500; margin-bottom: var(--s-3); }
.samples__pick .field__err { flex-basis: 100%; }
.pick {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 16px 0 8px;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-size: var(--step--1); font-weight: 500; cursor: pointer;
}
.pick__sw { width: 26px; height: 26px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); display: grid; place-items: center; }
.pick:has(input:checked) { border-color: var(--pine); background: var(--pine-wash); }
.pick:has(input:checked) .pick__sw::after {
  content: ""; width: 10px; height: 6px; border: solid var(--paper); border-width: 0 0 2px 2px; rotate: -45deg; translate: 0 -1px;
  filter: drop-shadow(0 0 1px rgb(0 0 0 / .6));
}
.pick:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 2px; }
.pick:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.samples__fields { grid-column: 2; grid-row: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); align-content: start; }
.field--wide { grid-column: 1 / -1; }
.samples__send { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; padding-top: var(--s-2); }
.samples__status { font-size: var(--step--1); }
.samples__status.is-ok { color: var(--ok); font-weight: 500; }
.samples__status.is-err { color: var(--rust); }

@media (max-width: 900px) {
  .fabric-book__head, .book { grid-template-columns: 1fr; gap: var(--s-5); }
  .samples { grid-template-columns: 1fr; padding: var(--s-5); }
  .samples__pick, .samples__fields { grid-column: 1; grid-row: auto; }
}
@media (max-width: 560px) {
  .book__tabs { padding-left: 0; }
  /* only the lifted swatch keeps a visible name on phones; the others stay named for screen readers */
  .book__tab span { font-size: .75rem; padding-left: 4%; white-space: nowrap; }
  .book__tab[aria-selected="false"] span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .samples__fields { grid-template-columns: 1fr; }
  .cloth__facts { grid-template-columns: 1fr 1fr; }
}

/* ------------------------------------------------------------------ */
/* Craft                                                               */
/* ------------------------------------------------------------------ */
.craft { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: var(--s-7); align-items: center; padding-block: var(--s-9); }
.craft__text { display: grid; gap: var(--s-5); }
.craft__text > p { max-width: 58ch; color: var(--wool-ink); }
.layers { display: grid; gap: 2px; }
.layer {
  display: grid; grid-template-columns: 28px 1fr; gap: var(--s-3); align-items: start; text-align: left;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-3); border: 1px solid transparent; border-radius: var(--r-m);
  background: transparent; font-size: var(--step--1); line-height: 1.5; color: var(--wool-ink);
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.layer strong { display: block; color: var(--ink); font-size: var(--step-0); font-weight: 600; margin-bottom: 2px; }
.layer__sw { width: 22px; height: 22px; margin-top: 3px; border-radius: 6px; background: var(--sw); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .14); }
.layer:hover { background: var(--paper); }
.layer[aria-pressed="true"] { background: var(--paper); border-color: var(--pine); }
.section-drawing { margin: 0; padding: var(--s-6); background: var(--paper); border-radius: var(--r-l); border: 1px solid var(--line); display: grid; gap: var(--s-4); }
.section-drawing svg { width: 100%; height: auto; }
.section-drawing figcaption { font-size: var(--step--1); color: var(--wool-ink); }
.xs-floor { stroke: var(--wool); stroke-width: 1.5; }
.xs-wood { fill: #d4b07c; stroke: #9a7442; stroke-width: 1.2; }
.xs-grain { stroke: #a98153; stroke-opacity: .45; stroke-width: 1; fill: none; }
.xs-spring { fill: none; stroke: #5d5a55; stroke-width: 2.4; stroke-linejoin: round; }
.xs-deck { stroke: #b9ab90; stroke-width: 3; }
.xs-foam { fill: #ecdcaa; stroke: #c2ad6c; stroke-width: 1.2; }
.xs-cells circle { fill: #d6c27f; }
.xs-wrap { fill: #f6f1e6; stroke: #cfc5b2; stroke-width: 1.2; }
.xs-stitch { stroke: #b4a88f; stroke-width: 1.2; stroke-dasharray: 2 3; }
.xs-cover { fill: none; stroke: #8f7f62; stroke-width: 3; }
.xs-zip { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.xs-dim path { stroke: var(--ink); stroke-width: 1.1; fill: none; }
.xs-dim text { font: 500 13px var(--font); fill: var(--ink); }
.xs-part { transition: opacity .4s var(--ease), filter .4s var(--ease); }
.section-drawing[data-layer-active]:not([data-layer-active=""]) .xs-part { opacity: .22; }
.section-drawing[data-layer-active="cover"] [data-part="cover"],
.section-drawing[data-layer-active="wrap"] [data-part="wrap"],
.section-drawing[data-layer-active="foam"] [data-part="foam"],
.section-drawing[data-layer-active="springs"] [data-part="springs"],
.section-drawing[data-layer-active="frame"] [data-part="frame"] { opacity: 1; filter: drop-shadow(0 4px 8px rgb(60 45 25 / .25)); }
@media (max-width: 900px) { .craft { grid-template-columns: 1fr; gap: var(--s-6); } .section-drawing { padding: var(--s-4); } }

/* ------------------------------------------------------------------ */
/* Delivery                                                            */
/* ------------------------------------------------------------------ */
.delivery { background: var(--oat-deep); padding-block: var(--s-9); }
.delivery__inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-6) var(--s-7); align-items: center; }
.delivery__text { display: grid; gap: var(--s-4); }
.delivery__text > p { max-width: 60ch; }
.door { display: grid; gap: var(--s-3); margin-top: var(--s-2); }
.door .field label .icon { color: var(--pine); }
.door__row { display: flex; gap: var(--s-2); }
.door__row input { max-width: 140px; background: var(--paper); }
.door__result:empty { display: none; }
.door__result { font-size: var(--step--1); padding: var(--s-3) var(--s-4); border-radius: var(--r-m); background: var(--paper); }
.door__result.is-no { color: var(--rust); background: var(--rust-wash); }
.door__result.is-ok { color: var(--ok); background: var(--ok-wash); }
.boxes { margin: 0; }
.boxes svg { width: 100%; height: auto; }
.bx-floor { stroke: var(--wool-ink); stroke-width: 1.5; }
.bx-door { fill: none; stroke: #8a6a42; stroke-width: 6; stroke-linejoin: round; }
.bx-door-in { fill: #f3eee5; stroke: none; }
.bx-side { fill: #c9a578; stroke: #8f6c40; stroke-width: 1.5; stroke-linejoin: round; }
.bx-edge { fill: none; stroke: #8f6c40; stroke-width: 1.5; }
.bx-tape { stroke: #efe4cf; stroke-width: 6; stroke-linecap: round; }
.bx-label { font: 600 16px var(--font); fill: #5a4122; letter-spacing: .1em; }
.bx-dim path { stroke: var(--ink); stroke-width: 1.2; fill: none; }
.bx-dim text, .bx-note { font: 500 13px var(--font); fill: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .bx-box { animation: slide-in linear both; animation-timeline: view(); animation-range: entry 10% cover 45%; }
    @keyframes slide-in { from { transform: translateX(-60px); } to { transform: translateX(80px); } }
  }
}
.delivery__table { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--paper); }
.table-wrap:focus-visible { outline-offset: 2px; }
.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.data caption { text-align: left; padding: var(--s-4) var(--s-5) 0; font-weight: 600; caption-side: top; }
.data th, .data td { padding: 14px var(--s-5); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data thead th { font-weight: 500; color: var(--wool-ink); white-space: nowrap; }
.data tbody th { font-weight: 600; white-space: nowrap; }
.data tbody tr:last-child > * { border-bottom: 0; }
@media (max-width: 900px) { .delivery__inner { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* Compare                                                             */
/* ------------------------------------------------------------------ */
.compare { padding-block: var(--s-9); display: grid; gap: var(--s-4); }
.compare__lede { color: var(--wool-ink); max-width: 62ch; margin-bottom: var(--s-4); }
.data--compare { min-width: 1000px; }
.data--compare td:nth-child(3), .data--compare td:nth-child(4), .data--compare td:nth-child(6), .data--compare td:nth-child(8) { white-space: nowrap; }
.cmp-sw { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--sw); vertical-align: -3px; margin-right: 10px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .14); }
.data--compare tr.is-current > * { background: var(--pine-wash); }
.data--compare tr.is-current th::after { content: "on your sofa"; display: block; font-size: .75rem; font-weight: 500; color: var(--pine); margin: 2px 0 0 26px; }

/* ------------------------------------------------------------------ */
/* Order                                                               */
/* ------------------------------------------------------------------ */
.order { background: var(--pine); color: var(--paper); padding-block: var(--s-9); }
.order a, .order .link-btn { color: #e6efe4; }
.order__inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-7); align-items: start; }
.order__recap { display: grid; gap: var(--s-5); }
.order__lede { color: #d9e3d6; max-width: 54ch; }
.recap { display: grid; gap: var(--s-4); padding-top: var(--s-4); }
.recap__plan { width: 100%; height: auto; max-height: 240px; padding: var(--s-4); border-radius: var(--r-m); background: rgb(248 245 239 / .07); border: 1px solid rgb(248 245 239 / .16); }
.recap__plan .plan__dim path { stroke: #e6efe4; }
.recap__plan .plan__dim text { fill: #e6efe4; }
.recap__plan .plan__base { stroke: rgb(0 0 0 / .3); }
.recap__plan .plan__tag { fill: var(--ink); }
.order .lines dt { color: #cfdccb; }
.order .lines dd { color: var(--paper); }
.lines--totals { padding-top: var(--s-3); border-top: 1px solid rgb(248 245 239 / .2); }
.lines__total dt, .lines__total dd { color: var(--paper) !important; font-size: var(--step-1); font-weight: 500; }
.order__form-wrap { background: var(--paper); color: var(--ink); border-radius: var(--r-l); padding: var(--s-6); box-shadow: 0 2px 4px rgb(0 0 0 / .12), 0 22px 44px -22px rgb(0 0 0 / .45); }
.order__form-wrap a { color: var(--pine); }
.order-form { display: grid; gap: var(--s-5); }
.order-form h3 { font-size: var(--step-2); font-weight: 400; }
.order-form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.order-form__note:empty { display: none; }
.order-form__note { font-size: var(--step--1); color: var(--wool-ink); }
.order-form__note.is-err { color: var(--rust); }
.outcome { display: grid; gap: var(--s-4); justify-items: start; }
.outcome:focus { outline: none; }
.outcome__icon { width: 48px; height: 48px; padding: 10px; border-radius: 50%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.outcome--success .outcome__icon { background: var(--ok-wash); color: var(--ok); }
.outcome--error .outcome__icon { background: var(--rust-wash); color: var(--rust); }
.outcome h3 { font-size: var(--step-2); font-weight: 400; }
.outcome p { max-width: 52ch; }
.outcome__row { display: flex; flex-wrap: wrap; gap: var(--s-3); }
@media (max-width: 900px) { .order__inner { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .order-form__grid { grid-template-columns: 1fr; } .order__form-wrap { padding: var(--s-5); } }

/* ------------------------------------------------------------------ */
/* Questions and footer                                                */
/* ------------------------------------------------------------------ */
.faq { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: var(--s-7); padding-block: var(--s-9); align-items: start; }
.faq__list { display: grid; border-top: 1px solid var(--line); }
.q { border-bottom: 1px solid var(--line); }
.q summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: var(--s-4);
  min-height: 64px; padding-block: var(--s-3); font-size: var(--step-1); cursor: pointer;
}
.q summary::-webkit-details-marker { display: none; }
.q summary .icon { transition: rotate .4s var(--ease); color: var(--wool-ink); }
.q[open] summary .icon { rotate: 180deg; }
.q p { padding-bottom: var(--s-5); max-width: 62ch; color: var(--wool-ink); }
@media (max-width: 860px) { .faq { grid-template-columns: 1fr; gap: var(--s-5); } }

.foot { background: var(--ink); color: #e9e3d8; padding-block: var(--s-8) var(--s-6); }
.foot a { color: #e9e3d8; }
.foot__inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--s-6); font-size: var(--step--1); }
.foot__word { font-size: var(--step-2); font-weight: 300; letter-spacing: -.03em; margin-bottom: var(--s-2); color: var(--paper); }
.foot__addr { font-style: normal; line-height: 1.8; }
.foot__hours { display: grid; gap: var(--s-2); align-content: start; }
.foot__nav { display: grid; gap: var(--s-1); align-content: start; }
.foot__nav a { min-height: 32px; display: inline-flex; align-items: center; text-decoration: none; }
.foot__nav a:hover { text-decoration: underline; }
.foot__note { margin-top: var(--s-7); font-size: .8125rem; color: #b9b2a6; }
@media (max-width: 860px) { .foot__inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .foot__inner { grid-template-columns: 1fr; } }
