@font-face {
  font-family: Manrope;
  src: url("assets/manrope.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif";
  src: url("assets/source-serif.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}

:root {
  font-family: Manrope, system-ui, sans-serif;
  color: #23332c;
  background: #f4f3ef;
  --forest: #264339;
  --ink: #22332c;
  --muted: #52635b;
  --line: #d7dcd5;
  --paper: #fffefa;
  --photo: #f2f1ec;
  scroll-behavior: smooth;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
a { color: inherit; }
:focus-visible { outline: 2px solid #347356; outline-offset: 3px; }
.wrap { width: min(100% - 72px, 1352px); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--line); background: #fbfaf6; }
.masthead-inner { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; gap: 11px; align-items: center; font-weight: 800; text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border: 2px solid var(--forest); border-radius: 4px; transform: rotate(12deg); box-shadow: inset 0 0 0 3px #fbfaf6, inset 0 0 0 9px var(--forest); }
.about-link { color: var(--muted); text-underline-offset: 4px; font-size: .925rem; }
.intro { padding: clamp(30px, 4vw, 58px) 0 24px; }
.intro h1, .factory h2 { margin: 0; font-size: clamp(2.2rem, 5vw, 4.65rem); line-height: .99; letter-spacing: -.064em; font-weight: 650; }
.intro em, .factory em { font-family: "Source Serif", Georgia, serif; font-weight: 450; color: var(--forest); }
.intro p { max-width: 90ch; font-size: clamp(1rem, 1.4vw, 1.125rem); line-height: 1.65; color: var(--muted); margin: 17px 0 0; }
.category-switch { display: flex; gap: 6px; width: fit-content; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); margin-bottom: 14px; }
.category-switch button { min-width: 101px; min-height: 39px; padding: 5px 16px; border: 0; border-radius: 5px; background: transparent; color: var(--ink); font-weight: 750; }
.category-switch button.selected { background: var(--forest); color: white; }
.category-switch button:not(.selected):hover { background: #eaeee7; }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) clamp(270px, 28vw, 375px); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 36px #263e350d; }
.visual-area { padding: clamp(12px, 2vw, 22px); min-width: 0; }
.visual-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 13px; }
.visual-caption { min-width: 0; }
.visual-head h2 { margin: 0; font-size: clamp(1.2rem, 2.25vw, 1.7rem); line-height: 1.3; letter-spacing: -.04em; font-weight: 800; }
.visual-head p { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
.ghost, .solid { border: 1px solid var(--line); border-radius: 5px; font-size: .875rem; font-weight: 750; min-height: 43px; padding: 8px 13px; }
.ghost { background: var(--paper); color: var(--forest); white-space: nowrap; }
.ghost[aria-pressed="true"], .ghost:hover:not(:disabled) { background: #e8eee8; }
.solid { width: 100%; background: var(--forest); color: white; border-color: var(--forest); }
.solid:hover:not(:disabled) { background: #315547; }
.viewport { position: relative; display: grid; place-items: center; overflow: hidden; min-width: 0; height: clamp(285px, 45vw, 510px); background: var(--photo); border-radius: 7px; }
.viewport canvas, .viewport img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.viewport[aria-busy="true"]::after { content: ""; height: 3px; position: absolute; inset: auto 0 0; background: #83a693; }
.preview-error { position: absolute; inset: auto 10px 10px; padding: 10px; margin: 0; background: var(--paper); color: #77362f; border-radius: 4px; }
.angle-row { display: flex; align-items: center; gap: 11px; margin-top: 13px; }
.angle-row p { margin: 0; font-size: .875rem; color: var(--muted); }
.views { display: flex; align-items: center; gap: 7px; padding: 4px 4px 5px; overflow-x: auto; scrollbar-width: thin; }
.view { position: relative; width: 64px; height: 47px; flex: 0 0 64px; border-radius: 4px; border: 1px solid var(--line); background: var(--photo); padding: 1px; }
.view[aria-pressed="true"] { border-color: var(--forest); outline: 1px solid var(--forest); }
.view img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.controls { border-left: 1px solid var(--line); padding: clamp(16px, 2vw, 25px); min-width: 0; display: flex; flex-direction: column; gap: 19px; }
.control-label { display: block; font-size: .95rem; margin: 0 0 9px; font-weight: 800; }
select { appearance: none; background: linear-gradient(45deg, transparent 50%, #496558 50%) calc(100% - 17px) center / 6px 6px no-repeat, linear-gradient(135deg, #496558 50%, transparent 50%) calc(100% - 11px) center / 6px 6px no-repeat, var(--paper); color: var(--ink); width: 100%; border: 1px solid var(--line); border-radius: 5px; min-height: 46px; padding: 8px 27px 8px 11px; font-weight: 720; }
.palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.swatch { position: relative; height: clamp(43px, 4.2vw, 56px); border: 1px solid #aeb8af; border-radius: 4px; padding: 0; background: var(--swatch-color, var(--photo)) center / cover; }
.swatch img { display: block; width: 100%; height: 100%; border-radius: 3px; object-fit: cover; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--forest); outline-offset: 2px; }
.swatch[aria-pressed="true"]::after { content: "✓"; position: absolute; right: 3px; bottom: 3px; display: grid; place-items: center; min-width: 17px; min-height: 17px; border-radius: 3px; background: var(--forest); color: white; font-size: 13px; }
.swatch.default { font-size: .77rem; color: var(--ink); }
.material-name { color: var(--muted); font-size: .875rem; line-height: 1.4; margin: 10px 0 0; min-height: 1.3em; }
.zones { display: grid; gap: 4px; }
.zone { display: flex; text-align: left; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; min-height: 36px; border: 1px solid transparent; border-radius: 5px; color: var(--ink); background: none; font-size: .875rem; font-weight: 700; }
.zone span { color: var(--muted); font-weight: 580; font-size: .8rem; }
.zone[aria-pressed="true"], .zone:hover { border-color: var(--line); background: #eef1eb; }
.selection { margin-top: auto; border-top: 1px solid var(--line); padding-top: 15px; }
.selection p { margin: 0 0 12px; font-size: .875rem; color: var(--muted); line-height: 1.45; }
.factory { margin: 0; padding: clamp(30px, 5vw, 65px) 0; }
.factory h2 { font-size: clamp(1.75rem, 3.3vw, 3.1rem); }
.factory p { margin: 14px 0 0; max-width: 65ch; color: var(--muted); font-size: 1rem; line-height: 1.65; }

@media (max-width: 780px) {
  .wrap { width: calc(100% - 34px); }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .controls { border-left: 0; border-top: 1px solid var(--line); }
  .viewport { height: clamp(210px, 55vw, 400px); }
}
@media (min-width: 781px) and (max-height: 850px) {
  .masthead-inner { min-height: 56px; }
  .intro { padding: 27px 0 17px; }
  .intro h1 { font-size: clamp(2.4rem, 4.65vw, 4rem); }
  .intro p { margin-top: 12px; }
  .viewport { height: clamp(275px, 52vh, 430px); }
}
@media (max-width: 390px) {
  .wrap { width: calc(100% - 24px); }
  .about-link { max-width: 95px; text-align: right; }
  .visual-head { gap: 8px; }
  .view { width: 56px; flex-basis: 56px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
}
