:root {
  color-scheme: dark;
  --bg: #12150d;
  --panel: #1b1f16;
  --panel-raised: #252a1f;
  --line: rgba(242, 239, 229, 0.18);
  --line-strong: rgba(242, 239, 229, 0.34);
  --text: #f2efe5;
  --muted: #bdb9aa;
  --accent: #e4cd63;
  --accent-light: #e4cd63;
  --wood-dark: #9e6e3d;
  --wood-base: #b9854d;
  --wood-light: #c89b62;
  --osb-texture: url("assets/osb-texture.png");
  --osb-texture-size: cover;
  --success: #b7c5a6;
  --danger: #efafa4;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.lab-header {
  min-height: 4.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(18, 21, 13, 0.98);
}

.lab-header > div {
  display: grid;
  gap: 0.1rem;
}

.brand {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.lab-label,
.eyebrow {
  color: var(--accent-light);
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.quiet-button,
.primary-button {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  cursor: pointer;
}

.quiet-button {
  padding: 0.6rem 0.75rem;
  background: transparent;
  color: var(--muted);
}

.quiet-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.primary-button {
  padding: 0.8rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 750;
}

.planner-shell {
  width: min(100%, 1240px);
  margin-inline: auto;
  padding: 2.5rem clamp(1rem, 4vw, 2rem) 5rem;
}

.intro {
  max-width: 58rem;
  margin-bottom: 3.5rem;
}

.intro h1 {
  max-width: 14ch;
  margin: 0.65rem 0 1rem;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 10vw, 5.5rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.intro > p:last-child {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
}

.model-section,
.input-panel,
.preview-panel,
.result-panel,
.recommendation-panel,
.discovery-cta {
  border-top: 1px solid var(--line);
  padding-block: 2rem;
}

.model-section {
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid rgba(18, 21, 13, 0.46);
  background-color: var(--wood-base);
  background-image: var(--osb-texture);
  background-size: var(--osb-texture-size);
  background-position: center;
  background-repeat: no-repeat;
}

.model-section > .section-heading {
  width: fit-content;
  max-width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  background: rgba(18, 21, 13, 0.96);
}

.workspace-grid {
  gap: 1rem;
  margin-top: 2rem;
}

.input-panel,
.preview-panel,
.result-panel {
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  background: var(--panel);
}

.section-heading {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.section-heading > span {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.section-heading h2,
.surface-block h3,
.finish-block h3,
.exclusions h3,
.recommendation-panel h2,
.discovery-cta h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
}

.section-heading h2 {
  font-size: clamp(1.45rem, 6vw, 2.1rem);
}

.section-heading p,
.finish-block p,
.transfer-status,
.preview-caption {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.model-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.25rem 0 1.25rem;
}

.model-card {
  min-width: 0;
  min-height: 13rem;
  display: grid;
  grid-template-rows: 6.5rem minmax(0, auto);
  align-content: start;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(27, 31, 22, 0.98);
  color: var(--text);
  text-align: left;
  overflow: visible;
}

.model-card[data-selected="true"] {
  border-color: var(--accent);
  background: var(--panel-raised);
}

@media (hover: hover) {
  .model-card:hover,
  .surface-card:hover,
  .finish-button:hover {
    border-color: var(--line-strong);
    background-color: var(--panel-raised);
  }
}

.model-card[data-pricing-enabled="false"] {
  color: var(--muted);
  cursor: pointer;
}

.model-card-copy {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
  overflow-wrap: anywhere;
}

.model-card strong {
  font-size: 1rem;
  line-height: 1.35;
}

.model-card small,
.model-code {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.model-code {
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  letter-spacing: 0.08em;
}

.mini-preview {
  display: flex;
  gap: 3px;
  align-items: stretch;
  justify-content: center;
  width: 7.5rem;
  height: 6.5rem;
  margin-inline: auto;
  padding: 0.45rem;
  border: 1px solid var(--line-strong);
  background: #e2d2b8;
}

.mini-door {
  flex: 1;
  border: 1px solid rgba(16, 19, 22, 0.25);
  background: rgba(255, 255, 255, 0.16);
}

.mini-preview[data-door-type="sliding"] .mini-door {
  border-color: rgba(16, 19, 22, 0.4);
}

.workspace-grid {
  display: grid;
}

.measure-form {
  display: grid;
  gap: 1rem;
}

.measure-form label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.measure-form label > span:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.measure-form small {
  font-weight: 400;
}

.input-wrap {
  min-height: 3.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
}

.input-wrap:focus-within {
  border-color: var(--accent-light);
}

.input-wrap input {
  min-width: 0;
  min-height: 3.4rem;
  border: 0;
  padding: 0.65rem 0.85rem;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 750;
}

.input-wrap b {
  padding-right: 0.85rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.transfer-button {
  width: 100%;
  min-height: 3.5rem;
  border: 1px solid var(--accent-light);
  border-radius: 2px;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 800;
  cursor: pointer;
}

.transfer-status {
  min-height: 1.4rem;
}

.surface-block,
.finish-block {
  margin-top: 2rem;
}

.surface-block h3,
.finish-block h3 {
  font-size: 1.25rem;
}

.surface-grid {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.surface-card {
  position: relative;
  min-height: 4.5rem;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel-raised);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.surface-card[aria-checked="true"] {
  border-color: var(--accent);
  background: #2b3024;
}

.surface-card[aria-checked="true"]::after {
  content: "✓";
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
}

.surface-sample,
.finish-sample {
  display: block;
  border: 1px solid rgba(241, 238, 232, 0.25);
  background-color: var(--sample-color);
}

.surface-sample {
  width: 2.25rem;
  height: 2.25rem;
}

.surface-card strong,
.surface-card small {
  display: block;
  overflow-wrap: anywhere;
}

.surface-card small {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.72rem;
}

.surface-price {
  grid-column: 2;
  justify-self: start;
  color: var(--accent-light);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.finish-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.finish-heading span {
  color: var(--muted);
  font-size: 0.75rem;
}

.finish-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.finish-button {
  min-width: 4.7rem;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  cursor: pointer;
}

.finish-button[aria-checked="true"] {
  border-color: var(--accent);
  color: var(--text);
}

.finish-sample {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
}

.drawing-board {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(0.5rem, 2vw, 1rem);
  border: 1px solid #323628;
  background-color: #f2efe5;
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(45, 51, 35, 0.055) 28px), repeating-linear-gradient(90deg, transparent 0 27px, rgba(45, 51, 35, 0.055) 28px);
}

.wardrobe-svg {
  display: block;
  width: min(100%, 42rem);
  height: auto;
  min-height: 0;
  max-height: 40rem;
  aspect-ratio: 520 / 560;
  margin: auto;
}

.svg-ground {
  stroke: rgba(37, 45, 28, 0.36);
  stroke-width: 1;
}

.svg-body {
  fill: var(--wardrobe-color);
  stroke: #39402e;
  stroke-width: 1.3;
}

.svg-door {
  fill: var(--wardrobe-color);
  stroke: rgba(37, 45, 28, 0.62);
  stroke-width: 0.9;
}

.svg-joint {
  stroke: rgba(37, 45, 28, 0.62);
  stroke-width: 0.75;
}

.svg-handle {
  stroke: #333a29;
  stroke-width: 1.2;
  stroke-linecap: round;
}

.svg-dimension,
.svg-label {
  fill: #303727;
  font-family: var(--sans);
  font-size: 11px;
}

.svg-label {
  letter-spacing: 0.08em;
}

.preview-caption {
  min-height: 2.8rem;
}

.result-panel {
  margin-top: 1rem;
}

.result-content {
  border: 1px solid var(--line);
  background: var(--panel-raised);
}

.result-status {
  min-height: 0;
  padding: 0;
  color: var(--danger);
}

.result-status:not(:empty) {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.result-status.is-valid {
  color: var(--success);
}

.price-breakdown {
  margin: 0;
  padding: 0.25rem 1rem;
}

.price-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.price-breakdown dt {
  color: var(--muted);
}

.price-breakdown dd {
  margin: 0;
  text-align: right;
}

[data-result-unit-price] {
  color: var(--accent);
  font-weight: 800;
}

.total-row {
  display: grid;
  gap: 0.3rem;
  padding: 1.15rem 1rem;
  border-top: 2px solid var(--accent);
}

.total-row span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.total-row strong {
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(2rem, 10vw, 3.4rem);
  font-weight: 400;
  line-height: 1;
}

.exclusions {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(18, 21, 13, 0.38);
  border-left: 4px solid var(--accent);
  background-color: var(--wood-base);
  background-image: var(--osb-texture);
  background-size: var(--osb-texture-size);
  background-position: center;
  background-repeat: no-repeat;
  color: var(--bg);
}

.exclusions h3 {
  font-size: 1.15rem;
}

.exclusions ul {
  margin: 0.65rem 0 0;
  padding-left: 1.1rem;
  color: rgba(18, 21, 13, 0.88);
  font-size: 0.85rem;
}

.legal-note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.recommendation-panel {
  margin-top: 1rem;
}

.recommendation-panel h2 {
  margin-top: 0.5rem;
  font-size: clamp(1.5rem, 6vw, 2.35rem);
}

.recommendation-panel > p:last-child {
  max-width: 48rem;
  color: var(--muted);
}

.discovery-cta {
  display: grid;
  gap: 1.2rem;
  margin-top: 2rem;
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid rgba(18, 21, 13, 0.46);
  background-color: var(--wood-base);
  background-image: var(--osb-texture);
  background-size: var(--osb-texture-size);
  background-position: center;
  background-repeat: no-repeat;
}

.discovery-cta > div {
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(18, 21, 13, 0.96);
}

.discovery-cta h2 {
  max-width: 22ch;
  margin-top: 0.5rem;
  font-size: clamp(1.8rem, 8vw, 3.25rem);
  line-height: 1.05;
}

.discovery-cta > div > p:last-child,
.cta-message {
  max-width: 44rem;
  color: var(--muted);
}

.cta-message {
  min-height: 1.5rem;
  margin: 0;
  font-size: 0.82rem;
  padding-inline: 0.25rem;
  color: var(--bg);
  font-weight: 700;
}

.lab-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--panel);
}

[hidden] {
  display: none !important;
}

@media (min-width: 44rem) {
  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .measure-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .transfer-button,
  .transfer-status {
    grid-column: 1 / -1;
  }

  .surface-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .discovery-cta {
    grid-template-columns: minmax(0, 42rem) auto;
    justify-content: start;
    align-items: center;
    column-gap: 1.25rem;
  }

  .cta-message {
    grid-column: 1 / -1;
  }
}

@media (min-width: 62rem) {
  .model-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
    gap: 2rem;
  }

  .input-panel .surface-grid {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .preview-panel {
    min-width: 0;
  }

  .result-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 2rem;
  }

  .result-panel > .section-heading {
    grid-column: 1 / -1;
  }

  .exclusions,
  .legal-note {
    grid-column: 1;
  }

  .result-content {
    grid-column: 2;
    grid-row: 2 / span 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
