:root {
  color-scheme: light;
  --ink: #1c211e;
  --muted: #68716b;
  --line: rgba(28, 33, 30, 0.13);
  --paper: #f3efe7;
  --paper-strong: #fbf9f4;
  --forest: #2c5b4d;
  --forest-dark: #173b31;
  --mint: #c4ddd2;
  --acid: #d6ea86;
  --coral: #fa7656;
  --shadow: 0 24px 70px rgba(35, 50, 43, 0.13);
  --radius: 26px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 90%, rgba(214, 234, 134, 0.22), transparent 30%),
    radial-gradient(circle at 84% 4%, rgba(196, 221, 210, 0.28), transparent 30%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(250, 118, 86, 0.65);
  outline-offset: 3px;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  transform: rotate(-18deg);
}

.brand-mark span {
  position: absolute;
  width: 15px;
  height: 3px;
  border-radius: 3px;
  background: var(--acid);
}

.brand-mark span:first-child { transform: translateY(-5px); }
.brand-mark span:last-child { transform: translateY(5px); }

.brand-name {
  font-size: 18px;
  font-weight: 780;
  letter-spacing: -0.04em;
}

.brand-badge {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.text-button,
.icon-button,
.exploded-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.text-button:hover { color: var(--ink); }

.text-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: background 180ms ease, transform 180ms ease;
}

.icon-button:hover {
  background: var(--paper-strong);
  transform: translateY(-2px);
}

.icon-button svg,
.step-controls svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.builder-shell {
  display: grid;
  grid-template-columns: 180px minmax(500px, 680px) minmax(380px, 1fr);
  min-height: calc(100vh - 76px);
}

.step-rail {
  position: relative;
  padding: 58px 24px 40px 32px;
  border-right: 1px solid var(--line);
}

.step-progress {
  position: absolute;
  top: 62px;
  bottom: 72px;
  left: 42px;
  width: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(28, 33, 30, 0.1);
}

.step-progress span {
  display: block;
  width: 100%;
  height: 0;
  border-radius: inherit;
  background: var(--forest);
  transition: height 450ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.step-rail ol {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-nav-button {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #909690;
  text-align: left;
  cursor: pointer;
}

.step-nav-button .step-dot {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(28, 33, 30, 0.16);
  border-radius: 50%;
  background: var(--paper);
  font-size: 10px;
  font-weight: 800;
  transition: 200ms ease;
}

.step-nav-button span:last-child {
  font-size: 12px;
  font-weight: 720;
  line-height: 1.25;
}

.step-nav-button.is-current { color: var(--ink); }
.step-nav-button.is-current .step-dot {
  border-color: var(--forest);
  background: var(--forest);
  color: white;
  box-shadow: 0 0 0 5px rgba(44, 91, 77, 0.1);
}

.step-nav-button.is-complete { color: var(--forest); }
.step-nav-button.is-complete .step-dot {
  border-color: var(--forest);
  color: var(--forest);
}

.step-nav-button .step-dot svg {
  display: block;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.builder-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 48px clamp(30px, 4vw, 64px) 34px;
  background: rgba(251, 249, 244, 0.44);
}

.intro-line,
.preview-toolbar,
.fit-meter-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.preview-kicker {
  color: var(--forest);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.configuration-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.step-content {
  flex: 1;
  padding-top: 28px;
  animation: content-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes content-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.step-content h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(35px, 4vw, 58px);
  font-weight: 690;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

.step-lead {
  max-width: 540px;
  margin: 18px 0 32px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.field-group {
  margin: 30px 0 0;
  padding: 0;
  border: 0;
}

.field-group legend,
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.field-label small,
.field-group legend small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-grid.choice-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-grid.choice-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.choice-card {
  position: relative;
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.36);
  text-align: left;
  cursor: pointer;
  transition: border 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.choice-card:hover {
  border-color: rgba(44, 91, 77, 0.38);
  transform: translateY(-2px);
}

.choice-card.is-selected {
  border-color: var(--forest);
  background: var(--paper-strong);
  box-shadow: 0 10px 28px rgba(44, 91, 77, 0.09);
}

.choice-card.is-selected::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: 10px;
}

.choice-card strong,
.choice-card small,
.choice-card em {
  display: block;
}

.choice-card strong {
  padding-right: 18px;
  font-size: 13px;
  font-style: normal;
  line-height: 1.25;
}

.choice-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.choice-card em {
  margin-top: 9px;
  color: var(--forest);
  font-size: 10px;
  font-style: normal;
  font-weight: 750;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(var(--segments, 3), 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(28, 33, 30, 0.04);
}

.segmented-control button {
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  cursor: pointer;
}

.segmented-control button.is-selected {
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(28, 33, 30, 0.08);
}

.range-wrap {
  display: grid;
  grid-template-columns: 1fr 64px;
  align-items: center;
  gap: 15px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--forest);
}

.range-value {
  padding: 10px;
  border-radius: 12px;
  background: var(--paper-strong);
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.couple-weight-grid,
.couple-preference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.couple-field {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.28);
}

.couple-field > strong { font-size: 11px; }
.couple-field .range-wrap { grid-template-columns: 1fr 58px; gap: 9px; }
.couple-field .range-value { padding: 8px 5px; font-size: 10px; }
.couple-field .segmented-control button { min-height: 38px; padding: 6px; font-size: 9px; }
.couple-note { margin-top: 18px; }

.dimensions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-strong);
}

.input-shell input,
.input-shell select {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 740;
}

.input-shell span { color: var(--muted); font-size: 11px; }

.switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
}

.switch-row:last-child { border-bottom: 1px solid var(--line); }

.switch-copy strong,
.switch-copy small { display: block; }
.switch-copy strong { font-size: 13px; }
.switch-copy small { max-width: 410px; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cfd3cf;
  cursor: pointer;
  transition: 180ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 7px rgba(28, 33, 30, 0.18);
  transition: 180ms ease;
}

.switch input:checked + span { background: var(--forest); }
.switch input:checked + span::after { transform: translateX(18px); }

.recommendation-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin-top: 28px;
  padding: 18px;
  border-radius: 18px;
  background: var(--forest-dark);
  color: white;
}

.recommendation-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--acid);
  color: var(--forest-dark);
  font-size: 18px;
}

.recommendation-card strong,
.recommendation-card p { margin: 0; }
.recommendation-card strong { font-size: 12px; }
.recommendation-card p { margin-top: 5px; color: rgba(255, 255, 255, 0.7); font-size: 11px; line-height: 1.5; }

.result-card {
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-strong);
}

.result-card-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  background: var(--forest-dark);
  color: white;
}

.result-card-header small,
.result-card-header strong { display: block; }
.result-card-header small { color: rgba(255, 255, 255, 0.62); font-size: 10px; }
.result-card-header strong { margin-top: 4px; font-size: 25px; letter-spacing: -0.04em; }

.result-list { margin: 0; padding: 4px 20px; }
.result-list div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.result-list div:last-child { border-bottom: 0; }
.result-list dt { color: var(--muted); }
.result-list dd { margin: 0; font-weight: 730; text-align: right; }

.price-breakdown {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.36);
}

.price-breakdown h2 {
  margin: 0;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  letter-spacing: -0.02em;
}

.price-breakdown dl { margin: 0; padding: 4px 20px; }
.price-breakdown dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 22px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.price-breakdown dl div:last-child { border-bottom: 0; }
.price-breakdown dt { color: var(--muted); }
.price-breakdown dd { margin: 0; font-weight: 760; text-align: right; }
.price-breakdown .price-section {
  margin: 0 -20px;
  padding: 12px 20px;
  background: rgba(44, 91, 77, 0.045);
}
.price-breakdown .price-section dt,
.price-breakdown .price-section dd { color: var(--ink); font-weight: 790; }
.price-breakdown .price-component { padding: 8px 0 8px 12px; font-size: 10px; }
.price-breakdown .price-component dt::before { content: "↳ "; color: rgba(44, 91, 77, 0.55); }
.price-breakdown .price-total {
  padding: 15px 20px;
  background: rgba(44, 91, 77, 0.07);
}
.price-breakdown .price-total dt,
.price-breakdown .price-total dd { color: var(--ink); font-size: 14px; font-weight: 820; }

.nested-options {
  margin: 8px 0 16px;
  padding: 16px;
  border: 1px solid rgba(44, 91, 77, 0.14);
  border-radius: 16px;
  background: rgba(44, 91, 77, 0.035);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.step-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 28px;
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 790;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.button:hover { transform: translateY(-2px); }
.button:disabled { opacity: 0.35; pointer-events: none; }
.button-primary { background: var(--forest); color: white; box-shadow: 0 13px 30px rgba(44, 91, 77, 0.2); }
.button-primary:hover { background: var(--forest-dark); }
.button-secondary { border-color: var(--line); background: transparent; color: var(--muted); }
.button-accent { background: var(--coral); color: var(--ink); }

.preview-panel {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 34px clamp(28px, 3vw, 54px) 32px;
  overflow: hidden;
  background: var(--mint);
}

.preview-panel::after {
  content: "";
  position: absolute;
  right: -15%;
  bottom: -24%;
  width: 380px;
  height: 380px;
  border: 1px solid rgba(44, 91, 77, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(44, 91, 77, 0.035), 0 0 0 100px rgba(44, 91, 77, 0.025);
  pointer-events: none;
}

.preview-toolbar { position: relative; z-index: 2; }
.preview-toolbar > div span,
.preview-toolbar > div strong { display: block; }
.preview-toolbar > div strong { margin-top: 3px; font-size: 15px; letter-spacing: -0.03em; }

.exploded-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid rgba(44, 91, 77, 0.17);
  border-radius: 999px;
  color: var(--forest);
  font-size: 10px;
  font-weight: 790;
}

.toggle-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--forest);
  box-shadow: 0 0 0 3px rgba(44, 91, 77, 0.13);
}

.exploded-toggle[aria-pressed="false"] .toggle-dot { background: transparent; }

.mattress-stage {
  --rotate-x: 58deg;
  --rotate-z: -28deg;
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 360px;
  flex: 1;
  place-items: center;
  touch-action: none;
  cursor: grab;
}

.mattress-stage:active { cursor: grabbing; }

.stage-glow {
  position: absolute;
  width: min(440px, 85%);
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.72), transparent 66%);
  filter: blur(12px);
}

.mattress-canvas {
  position: relative;
  z-index: 2;
  display: block;
  width: min(480px, 96%);
  height: 330px;
  outline: none;
  filter: saturate(0.98) contrast(1.01);
  touch-action: none;
}

.mattress-canvas:focus-visible {
  border-radius: 22px;
  box-shadow: 0 0 0 3px rgba(44, 91, 77, 0.2);
}

.mattress-stage.is-dragging .mattress-canvas { cursor: grabbing !important; }

.mattress-stack {
  position: relative;
  width: min(390px, 84%);
  aspect-ratio: 1.75;
  transform-style: preserve-3d;
  transform: perspective(980px) rotateX(var(--rotate-x)) rotateZ(var(--rotate-z));
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mattress-stage.is-dragging .mattress-stack { transition: none; }

.mattress-layer {
  --layer-y: var(--exploded-y);
  position: absolute;
  inset: 0;
  z-index: var(--index);
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: rgba(28, 33, 30, 0.68);
  transform: translate3d(0, var(--layer-y), calc(var(--index) * 4px));
  transform-style: preserve-3d;
  transition: transform 620ms cubic-bezier(0.16, 1, 0.3, 1), filter 220ms ease;
  cursor: pointer;
}

.mattress-stack.is-compact .mattress-layer { --layer-y: var(--compact-y); }
.mattress-layer:hover,
.mattress-layer.is-active {
  z-index: 20;
  filter: brightness(1.035) saturate(1.08) drop-shadow(0 12px 11px rgba(24, 45, 37, 0.12));
}

.layer-top,
.layer-front,
.layer-side {
  position: absolute;
  display: block;
  pointer-events: none;
}

.layer-top {
  inset: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--layer-color), #1f332b 14%);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), transparent 34%, rgba(23, 53, 42, 0.07)),
    var(--layer-pattern, none),
    var(--layer-color, white);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -12px 22px rgba(38, 54, 47, 0.06),
    0 10px 22px rgba(28, 33, 30, 0.1);
}

.layer-top::before {
  content: "";
  position: absolute;
  inset: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(34, 61, 51, 0.045);
}

.layer-top::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, transparent 10%, rgba(255, 255, 255, 0.25) 38%, transparent 61%);
  opacity: 0.72;
  transform: translateX(-60%);
  transition: transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mattress-layer:hover .layer-top::after,
.mattress-layer.is-active .layer-top::after { transform: translateX(64%); }

.layer-front {
  right: 7%;
  bottom: calc(var(--layer-depth) * -1 + 1px);
  left: 7%;
  height: var(--layer-depth);
  border-right: 1px solid rgba(25, 47, 39, 0.16);
  border-bottom: 1px solid rgba(25, 47, 39, 0.18);
  border-left: 1px solid rgba(25, 47, 39, 0.13);
  border-radius: 0 0 13px 13px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 22%, rgba(25, 47, 39, 0.11)),
    color-mix(in srgb, var(--layer-color), #23362f 10%);
  box-shadow: 0 10px 16px rgba(24, 41, 35, 0.1);
  transform: skewX(-34deg);
  transform-origin: top;
}

.layer-side {
  top: 9%;
  right: calc(var(--layer-depth) * -0.72);
  bottom: 9%;
  width: calc(var(--layer-depth) * 0.76);
  clip-path: polygon(0 0, 100% 10%, 100% 90%, 0 100%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 28%, rgba(22, 43, 35, 0.14)),
    color-mix(in srgb, var(--layer-color), #21352e 15%);
  opacity: 0.9;
}

.layer-kind-springs .layer-front {
  background:
    repeating-radial-gradient(ellipse at 10px 50%, transparent 0 3px, rgba(30, 68, 54, 0.31) 4px 5px, transparent 6px 12px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(36, 68, 57, 0.12)),
    var(--layer-color);
  background-size: 22px 100%, auto, auto;
}

.layer-kind-foam-core .layer-front,
.layer-kind-comfort .layer-front {
  background:
    radial-gradient(circle at 8px 7px, rgba(255, 255, 255, 0.38) 0 1.4px, transparent 1.8px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(38, 54, 47, 0.1)),
    var(--layer-color);
  background-size: 17px 14px, auto, auto;
}

.layer-kind-fiber .layer-front,
.layer-kind-second-side .layer-front {
  background:
    repeating-linear-gradient(16deg, transparent 0 4px, rgba(67, 43, 24, 0.18) 5px 6px),
    color-mix(in srgb, var(--layer-color), #32251c 8%);
}

.layer-kind-cover .layer-front {
  background:
    repeating-linear-gradient(110deg, rgba(255, 255, 255, 0.16) 0 5px, rgba(51, 78, 68, 0.09) 6px 7px),
    var(--layer-color);
}

.layer-tag {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 72%;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(28, 48, 41, 0.12);
  color: var(--forest-dark);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.08em;
  opacity: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  transform: translate(-50%, -50%) scale(0.94);
  transition: opacity 180ms ease, transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.layer-tag i {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--layer-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--layer-color), transparent 64%);
}

.mattress-layer:hover .layer-tag,
.mattress-layer.is-active .layer-tag {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.mattress-stack.is-compact .mattress-layer:not(.is-active) .layer-tag {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .mattress-layer,
  .layer-top::after,
  .layer-tag {
    transition-duration: 1ms;
  }
}

.layer-caption {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid rgba(44, 91, 77, 0.12);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.34);
  color: var(--forest-dark);
  font-size: 10px;
  line-height: 1.45;
}

.caption-swatch {
  width: 11px;
  height: 11px;
  margin-top: 2px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(37, 72, 60, 0.15);
}

.layer-caption strong,
.layer-caption small { display: block; }
.layer-caption strong { margin-bottom: 2px; font-size: 10px; }
.layer-caption small { color: rgba(33, 67, 56, 0.72); font-size: 9px; }

/* Kept separate from the interactive layer labels for readable screen copy. */
.layer-caption > span:last-child {
  min-width: 0;
}

.layer-caption > span:last-child small {
  text-transform: none;
  letter-spacing: normal;
}

.layer-caption > span:last-child strong {
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.drag-hint {
  position: absolute;
  right: 2px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(44, 91, 77, 0.62);
  font-size: 9px;
  font-weight: 700;
}

.drag-hint svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.quick-stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 13px 0 0;
  padding: 13px 0;
  border-top: 1px solid rgba(44, 91, 77, 0.13);
  border-bottom: 1px solid rgba(44, 91, 77, 0.13);
}

.quick-stats div + div { border-left: 1px solid rgba(44, 91, 77, 0.13); }
.quick-stats dt,
.quick-stats dd { margin: 0; text-align: center; }
.quick-stats dt { color: rgba(44, 91, 77, 0.67); font-size: 8px; font-weight: 750; text-transform: uppercase; }
.quick-stats dd { margin-top: 4px; color: var(--forest-dark); font-size: 12px; font-weight: 820; }

.price-block {
  position: relative;
  z-index: 2;
  padding-top: 14px;
}

.price-block span,
.price-block strong,
.price-block small { display: block; }
.price-block span { color: rgba(44, 91, 77, 0.7); font-size: 9px; }
.price-block strong { margin-top: 2px; font-size: clamp(28px, 3vw, 42px); letter-spacing: -0.055em; }
.price-block small { margin-top: 2px; color: var(--forest); font-size: 10px; }
.price-block #priceComposition { color: rgba(44, 91, 77, 0.68); }

.preview-price-details {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  border-top: 1px solid rgba(44, 91, 77, 0.14);
  border-bottom: 1px solid rgba(44, 91, 77, 0.14);
}
.preview-price-details summary {
  padding: 10px 0;
  color: var(--forest-dark);
  font-size: 10px;
  font-weight: 760;
  cursor: pointer;
}
.preview-price-details dl { margin: 0; padding: 0 0 8px; }
.preview-price-details dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  color: rgba(44, 91, 77, 0.78);
  font-size: 9px;
}
.preview-price-details dd { margin: 0; font-weight: 720; text-align: right; }
.preview-price-details .price-factor { color: rgba(44, 91, 77, 0.58); }

.fit-meter {
  position: relative;
  z-index: 2;
  margin-top: 15px;
}

.fit-meter-copy { color: var(--forest-dark); font-size: 9px; }
.fit-meter-copy strong { font-size: 11px; }
.fit-track {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(44, 91, 77, 0.13);
}
.fit-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--forest);
  transition: width 320ms ease, background 180ms ease;
}
.fit-meter[data-level="good"] .fit-track span { background: #779162; }
.fit-meter[data-level="compromise"] .fit-track span { background: #b97839; }

.mobile-summary { display: none; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 340px;
  padding: 13px 17px;
  border-radius: 14px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 220ms ease;
}

.toast.is-visible { opacity: 1; transform: none; }

.layer-dialog {
  width: min(450px, calc(100% - 32px));
  padding: 28px;
  border: 0;
  border-radius: 24px;
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.layer-dialog::backdrop { background: rgba(22, 33, 29, 0.55); backdrop-filter: blur(6px); }
.layer-dialog h2 { margin: 12px 0 8px; font-size: 30px; letter-spacing: -0.05em; }
.layer-dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.layer-dialog dl { margin: 18px 0 0; }
.layer-dialog dl div { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 11px; }
.layer-dialog dt { color: var(--muted); }
.layer-dialog dd { margin: 0; font-weight: 730; }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(28, 33, 30, 0.06); font-size: 20px; cursor: pointer; }

@media (max-width: 1180px) {
  .builder-shell { grid-template-columns: 140px minmax(460px, 1fr) minmax(330px, 42%); }
  .step-rail { padding-left: 24px; }
  .step-progress { left: 34px; }
  .step-nav-button { grid-template-columns: 22px 1fr; gap: 9px; }
  .choice-grid.choice-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 920px) {
  body { padding-bottom: 78px; }
  .site-header { min-height: 64px; padding: 0 18px; }
  .brand-name { font-size: 16px; }
  .text-button { display: none; }
  .builder-shell { display: flex; min-height: 0; flex-direction: column; }
  .step-rail { position: sticky; top: 0; z-index: 12; padding: 10px 18px; overflow-x: auto; border: 0; border-bottom: 1px solid var(--line); background: rgba(243, 239, 231, 0.92); backdrop-filter: blur(14px); }
  .step-progress { display: none; }
  .step-rail ol { display: flex; width: max-content; gap: 8px; }
  .step-nav-button { display: flex; width: auto; gap: 7px; padding: 6px 9px 6px 6px; border: 1px solid transparent; border-radius: 999px; }
  .step-nav-button span:last-child { font-size: 10px; }
  .step-nav-button.is-current { border-color: var(--line); background: var(--paper-strong); }
  .builder-content { padding: 28px 18px 18px; }
  .step-content { padding-top: 20px; }
  .step-content h1 { font-size: clamp(34px, 10vw, 50px); }
  .step-controls { display: none; }
  .preview-panel { order: -1; min-height: 590px; padding: 25px 22px 26px; }
  .mattress-stage { min-height: 310px; }
  .mobile-summary {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 18px;
    border-top: 1px solid var(--line);
    background: rgba(251, 249, 244, 0.95);
    box-shadow: 0 -10px 35px rgba(28, 33, 30, 0.11);
    backdrop-filter: blur(16px);
  }
  .mobile-summary small,
  .mobile-summary strong { display: block; }
  .mobile-summary small { color: var(--muted); font-size: 9px; }
  .mobile-summary strong { margin-top: 2px; font-size: 18px; }
  .mobile-summary .button { min-height: 46px; }
}

@media (max-width: 600px) {
  .brand-badge { display: none; }
  .preview-panel { min-height: 540px; }
  .mattress-stage { min-height: 270px; }
  .mattress-stack { width: 82%; }
  .choice-grid,
  .choice-grid.choice-grid-3,
  .choice-grid.choice-grid-4 { grid-template-columns: 1fr 1fr; }
  .choice-card { min-height: 72px; padding: 13px; }
  .dimensions-grid { grid-template-columns: 1fr; }
  .couple-weight-grid,
  .couple-preference-grid { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr; }
  .configuration-code { display: none; }
  .toast { right: 16px; bottom: 90px; left: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
