:root {
  color-scheme: light;
  --paper: #f7f4ef;
  --surface: #fffdfa;
  --ink: #24201d;
  --muted: #68615b;
  --line: #e5ddd3;
  --accent: #892f38;
  --accent-soft: #f7edec;
  --focus: #702330;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button, input {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible + label {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.masthead-inner, .workspace {
  width: min(100% - 5rem, 90rem);
  margin-inline: auto;
}

.masthead-inner {
  min-height: 5.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.identity {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.875rem, 3vw, 2.475rem);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: 1.12;
}

.utility-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 2.65rem;
  padding: .625rem .875rem;
  border: 1px solid #ded4c9;
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}

.utility-button:hover:not([aria-disabled="true"]):not(:disabled) {
  border-color: #ae9d90;
  background: #fbf8f3;
}

.utility-button[aria-disabled="true"], .utility-button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: .6;
}

.catalog-export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem .85rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--line);
}

.catalog-export p {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.4;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 23rem);
  align-items: start;
  gap: clamp(1.125rem, 2.75vw, 2.6rem);
  margin-block: clamp(1.5rem, 4vw, 3rem);
}

.viewer {
  position: sticky;
  top: .75rem;
  z-index: 2;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .875rem;
  background: var(--surface);
  box-shadow: 0 1rem 2rem -1.95rem #39271e5a;
}

.scene {
  position: relative;
  isolation: isolate;
  display: grid;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  background: #e9e0d4;
}

.scene img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.scene[aria-busy="true"] img {
  opacity: .76;
}

.scene-message {
  position: absolute;
  inset-inline: 1rem;
  bottom: 1rem;
  justify-self: center;
  max-width: 36rem;
  margin: 0;
  padding: .65rem .9rem;
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  text-align: center;
  box-shadow: 0 .25rem 1.1rem #30231e29;
}

.zoom-button {
  position: absolute;
  right: .75rem;
  top: .75rem;
  display: grid;
  width: 2.625rem;
  height: 2.625rem;
  place-items: center;
  padding: 0;
  border: 1px solid #d8cdbf;
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  cursor: zoom-in;
}

.zoom-button:hover {
  background-color: #f4ede4;
}

.zoom-button:disabled {
  visibility: hidden;
}

.utility-icon {
  position: relative;
  flex: none;
  display: block;
  width: 1rem;
  height: 1rem;
}

.download-icon {
  background: linear-gradient(currentColor 0 0) center .0625rem / .09rem .55rem no-repeat;
}

.download-icon::before {
  content: "";
  position: absolute;
  top: .25rem;
  left: .29rem;
  width: .42rem;
  height: .42rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.download-icon::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: .125rem;
  width: .75rem;
  height: .25rem;
  border: 1.5px solid currentColor;
  border-top: 0;
  border-radius: 0 0 .1rem .1rem;
}

.expand-icon {
  width: .9rem;
  height: .9rem;
  border: 1.5px solid currentColor;
  border-radius: .12rem;
}

.expand-icon::before, .expand-icon::after {
  content: "";
  position: absolute;
  background: var(--surface);
}

.expand-icon::before {
  inset: -.12rem .22rem;
}

.expand-icon::after {
  inset: .22rem -.12rem;
}

.zoom-button:hover .expand-icon::before, .zoom-button:hover .expand-icon::after {
  background: #f4ede4;
}

figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  padding: .85rem 1rem;
  font-size: .9rem;
  font-weight: 650;
}

.caption-detail {
  color: var(--muted);
  font-weight: 400;
}

.controls {
  display: grid;
  gap: 1.4rem;
  min-width: 0;
  padding: clamp(1.05rem, 2vw, 1.45rem);
  border: 1px solid var(--line);
  border-radius: .875rem;
  background: var(--surface);
}

.controls fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.controls fieldset + fieldset {
  position: relative;
}

.controls fieldset + fieldset::before {
  content: "";
  position: absolute;
  top: -.7rem;
  inset-inline: 0;
  height: 1px;
  background: var(--line);
}

.controls legend {
  margin-bottom: .625rem;
  padding: 0;
  font-size: .9375rem;
  font-weight: 700;
}

.choice-grid {
  display: grid;
  gap: .5rem;
}

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

.view-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.swatch-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
}

.element-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .8rem;
}

.element-field {
  display: grid;
  align-content: end;
  gap: .35rem;
  color: var(--muted);
  font-size: .875rem;
}

.element-field[hidden] {
  display: none;
}

.element-select {
  position: relative;
}

.size-fieldset .element-select {
  display: block;
  font-size: .875rem;
}

.element-select::after {
  position: absolute;
  top: calc(50% - .25rem);
  right: .8rem;
  width: .45rem;
  height: .45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: rotate(45deg);
  pointer-events: none;
}

.element-select select {
  width: 100%;
  min-height: 2.65rem;
  padding: .38rem 1.9rem .38rem .7rem;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}

.choice {
  position: relative;
  min-width: 0;
}

.choice input, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.choice-label {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 2.75rem;
  flex-direction: column;
  justify-content: center;
  gap: .21rem;
  padding: .65rem .6rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.28;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}

.choice-label:hover {
  border-color: #baa297;
}

.choice input:checked + .choice-label {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: #631f29;
}

.model-label, .mattress-label {
  align-items: center;
  text-align: center;
  padding-inline: .2rem;
}

.model-label {
  justify-content: flex-start;
  gap: .45rem;
}

.headboard-illustration {
  display: block;
  width: 2.5rem;
  height: 1.375rem;
  border: 1px solid currentColor;
  border-radius: .22rem .22rem .08rem .08rem;
  color: #91616a;
}

.headboard-illustration[data-model="canale"] {
  background: repeating-linear-gradient(to right, transparent 0 calc(100% / 8 - 1px), currentColor calc(100% / 8 - 1px) calc(100% / 8));
}

.headboard-illustration[data-model="panouri"] {
  background: repeating-linear-gradient(to right, transparent 0 calc(25% - 1px), currentColor calc(25% - 1px) 25%);
}

.headboard-illustration[data-model="matlasata"] {
  background:
    repeating-linear-gradient(to right, transparent 0 calc(12.5% - 1px), currentColor calc(12.5% - 1px) 12.5%),
    repeating-linear-gradient(to bottom, transparent 0 calc(100% / 3 - 1px), currentColor calc(100% / 3 - 1px) calc(100% / 3));
}

.choice-detail {
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 400;
}

.swatch-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  justify-content: stretch;
  gap: .24rem;
  padding: .35rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.fabric-color {
  display: block;
  width: 100%;
  height: 1.6rem;
  border: 1px solid #261b1d35;
  border-radius: .28rem;
  background-color: var(--fabric-color);
  background-image: var(--fabric-swatches);
  background-repeat: no-repeat;
  background-size: 400% var(--fabric-atlas-height);
}

.fabric-family-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: .85rem;
}

.fabric-family-label {
  align-items: center;
}

.fabric-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}

.fabric-group:has(.choice:nth-child(3)) {
  grid-column: 1 / -1;
}

.fabric-group:has(.choice:nth-child(3)) .swatch-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fabric-group:has(.choice:nth-child(4)) .swatch-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.fabric-group h2 {
  margin: 0 0 .4rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
}

.fabric-code {
  white-space: nowrap;
}

.fabric-name {
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 400;
}

.fabric-note {
  margin: .7rem 0 0;
  color: var(--muted);
  font-size: .8125rem;
}

.preview-dialog {
  width: min(95vw, 105rem);
  max-width: none;
  max-height: 94vh;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--surface);
  color: var(--ink);
}

.preview-dialog::backdrop, .catalog-dialog::backdrop {
  background: #241b1bd6;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}

.preview-header p {
  margin: 0;
  font-size: .9375rem;
  font-weight: 600;
}

.preview-dialog img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(94vh - 5.5rem);
  border-radius: .375rem;
  object-fit: contain;
  background: #ebe2d5;
}

.catalog-dialog {
  width: min(58rem, calc(100% - 1.5rem));
  max-width: none;
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--surface);
  color: var(--ink);
}

#catalog-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 1.75rem);
}

.catalog-header, .catalog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  padding: .875rem 1rem;
}

.catalog-header { border-bottom: 1px solid var(--line); }
.catalog-footer { border-top: 1px solid var(--line); }

.catalog-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.15;
}

.catalog-header p, .catalog-feedback p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.35;
}

.catalog-options, .catalog-format, .catalog-variants {
  min-inline-size: 0;
  margin: 0;
  border: 0;
}

.catalog-options {
  padding: 1rem;
  overflow-y: auto;
}

.catalog-format + .catalog-format {
  margin-top: 1rem;
}

.catalog-format {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem 1.4rem;
  padding: 0;
}

.catalog-format legend, .catalog-variants legend {
  padding: 0;
  font-size: .875rem;
  font-weight: 600;
}

.catalog-format legend { margin-bottom: .4rem; }

.catalog-format label, .catalog-model label {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .875rem;
  line-height: 1.35;
}

.catalog-dialog input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.catalog-dialog input:focus-visible, .catalog-model summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.catalog-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-block: 1rem .7rem;
}

.catalog-models {
  display: grid;
  gap: .5rem;
}

.catalog-model {
  border: 1px solid var(--line);
  border-radius: .55rem;
}

.catalog-model summary {
  padding: .7rem .8rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
}

.catalog-model[open] summary { border-bottom: 1px solid var(--line); }

.catalog-model-count {
  margin-left: .45rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
}

.catalog-model-content { padding: .65rem .8rem .8rem; }
.catalog-model-all { font-weight: 600; }

.catalog-variant-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  align-items: start;
  gap: .75rem;
  margin-top: .7rem;
}

.catalog-variants {
  display: grid;
  gap: .35rem;
  padding: 0;
}

.catalog-variants legend {
  margin-bottom: .3rem;
  color: var(--muted);
}

.catalog-model label { padding: .12rem 0; }

.catalog-feedback {
  flex: 1 1 13rem;
  min-width: 0;
}

.catalog-feedback p:first-child { font-weight: 600; }

.catalog-feedback progress {
  display: block;
  width: 100%;
  height: .45rem;
  margin-top: .4rem;
  accent-color: var(--accent);
}

.catalog-submit:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.catalog-submit:hover:not(:disabled) {
  border-color: var(--focus);
  background: var(--focus);
}

.no-script {
  width: min(100% - 2rem, 38rem);
  margin: auto;
  text-align: center;
}

@media (max-width: 65rem) {
  .masthead-inner, .workspace {
    width: calc(100% - 2.5rem);
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 20rem);
    gap: 1rem;
  }
}

@media (max-width: 51rem) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.1rem;
  }

  .controls fieldset + fieldset::before {
    display: none;
  }

  .room-fieldset, .size-fieldset, .mattress-fieldset, .storage-floor-fieldset, .fabric-fieldset {
    grid-column: 1 / -1;
  }

}

@media (max-width: 36rem) {
  .masthead-inner, .workspace {
    width: calc(100% - 1.5rem);
  }

  .masthead-inner {
    min-height: 4.65rem;
  }

  .identity {
    display: block;
  }

  .utility-button {
    gap: .4rem;
    padding-inline: .55rem;
  }

  .workspace {
    margin-top: 1rem;
  }

  figcaption {
    padding: .65rem .75rem;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls fieldset + fieldset::before {
    display: block;
    top: -.55rem;
  }
}

@media (max-height: 32rem) {
  .viewer {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
  }
}
