:root {
  --paper: #f4efe7;
  --card: #fffdf9;
  --ink: #1c1915;
  --ink-2: #4a443c;
  --muted: #8a8176;
  --line: #e2d9ca;
  --accent: #9c5b2e;
  --accent-ink: #7d4520;
  --accent-soft: #f2e5d6;
  --dark: #1c1915;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --bar-h: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* Top bar */
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand__mark { width: 34px; height: 34px; color: var(--accent); }
.brand__name { font: 600 22px/1 var(--serif); letter-spacing: .14em; text-transform: uppercase; }
.brand__sub { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }
.topbar__meta { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--ink-2); }
.counter strong { color: var(--ink); }
.badge { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft); padding: 4px 10px; border-radius: 99px; }

/* Stepper */
.stepper { background: var(--dark); color: #cfc6b8; position: sticky; top: 0; z-index: 5; }
.stepper__inner { display: flex; align-items: center; gap: 28px; height: 52px; }
.stepper__count { font-size: 13px; color: #fff; white-space: nowrap; }
.stepper__list { display: flex; align-items: center; gap: 10px; list-style: none; margin: 0; padding: 0; font-size: 13px; overflow-x: auto; }
.stepper__list li { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.stepper__list li + li::before { content: ''; width: 18px; height: 1px; background: #5a5248; }
.stepper__list .is-done { color: #fff; }
.stepper__list .is-current span { background: var(--accent); color: #fff; padding: 4px 12px; border-radius: 99px; }

/* Stage */
.stage { padding: 56px 0 calc(var(--bar-h) + 64px); overflow-x: clip; }
.head { margin-bottom: 36px; }
.eyebrow { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); margin: 0 0 10px; }
h1 { font: 500 clamp(36px, 5vw, 54px)/1.05 var(--serif); margin: 0 0 12px; letter-spacing: -.01em; }
.lede { color: var(--ink-2); font-size: 16px; margin: 0; max-width: 56ch; }
.group-title { display: flex; align-items: baseline; gap: 12px; margin: 36px 0 14px; }
.group-title h2 { font: 500 26px/1 var(--serif); margin: 0; }
.group-title span { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

/* Option cards */
.grid { display: grid; gap: 16px; }
.grid--fabrics { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.option {
  position: relative; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: 2px;
  padding: 0; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.option:hover { border-color: #cbbfae; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(60, 40, 20, .06); }
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.option.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fdf7f0; }
.option.is-selected::after {
  content: ''; position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 12.5 3.2 3L17 9' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") center/18px no-repeat;
}
.option__swatch { aspect-ratio: 1; width: 100%; object-fit: cover; border-bottom: 1px solid var(--line); }
.option__body { padding: 14px 16px 16px; }
.option__code { font-size: 11px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.option__name { font: 600 21px/1.15 var(--serif); margin: 2px 0 4px; }
.option__detail { font-size: 13px; color: var(--ink-2); margin: 0; }
.grid--cards .option__body { padding: 20px 22px 22px; min-height: 104px; }
.grid--cards .option__body:not(:has(.option__detail)) { min-height: 0; padding-block: 22px; }

/* Garment free text */
.describe { background: var(--card); border: 1px solid var(--line); padding: 22px; }
.describe label { display: block; font: 600 21px/1.2 var(--serif); margin-bottom: 4px; }
.describe p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.describe textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px; border: 1px solid var(--line); border-radius: 2px;
  background: var(--paper); font: 15px/1.5 var(--sans); color: var(--ink);
}
.describe textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.describe.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.describe__count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 6px; }
.divider { display: flex; align-items: center; gap: 16px; margin: 30px 0 22px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Action bar */
.actionbar { position: fixed; inset: auto 0 0 0; background: rgba(255, 253, 249, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); z-index: 10; }
.actionbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--bar-h); }
.chips { display: flex; gap: 8px; flex: 1; justify-content: center; overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; max-width: 240px;
  background: var(--accent-soft); border: 1px solid #e6cfb6; padding: 6px 12px; border-radius: 2px; font-size: 13px;
}
.chip img { width: 18px; height: 18px; border-radius: 2px; }
.chip b { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); font-weight: 600; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 600 15px/1 var(--serif); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; border: 0; border-radius: 2px;
  height: 46px; padding: 0 24px; font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap; transition: background .15s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #000; }
.btn--primary:disabled { background: #d9d1c4; color: #9a9184; cursor: not-allowed; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-ink); }
.btn--outline { background: transparent; border: 1px solid var(--ink); color: var(--ink); }
.btn--outline:hover { background: var(--ink); color: #fff; }
.btn--ghost { background: transparent; color: var(--ink-2); padding: 0 8px; letter-spacing: .04em; text-transform: none; font-weight: 500; font-size: 14px; }
.btn--ghost:disabled { opacity: .35; cursor: default; }

/* Intro */
.intro { display: grid; grid-template-columns: 1.05fr 1fr; gap: 64px; align-items: center; min-height: calc(100vh - 72px - 120px); }
.intro h1 { font-size: clamp(44px, 6.4vw, 80px); }
.intro h1 em { color: var(--accent); }
.intro .lede { font-size: 18px; margin-bottom: 32px; }
.intro__steps { display: flex; gap: 22px; margin: 0 0 36px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.intro__steps b { font: 600 18px/1 var(--serif); color: var(--accent); margin-right: 6px; }
.mosaic { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; transform: rotate(-4deg); }
.mosaic img { aspect-ratio: 3/4; object-fit: cover; box-shadow: 0 10px 30px rgba(40, 25, 10, .18); }
.mosaic img:nth-child(3n+2) { transform: translateY(28px); }

/* Generating */
.loading { display: grid; place-items: center; text-align: center; min-height: 56vh; }
.loading__swatch { width: 180px; height: 240px; position: relative; overflow: hidden; margin: 0 auto 32px; box-shadow: 0 16px 40px rgba(40, 25, 10, .22); }
.loading__swatch img { width: 100%; height: 100%; object-fit: cover; }
.loading__swatch::before {
  content: ''; position: absolute; inset: 18px; border: 1.5px dashed rgba(255, 255, 255, .55); z-index: 1;
  animation: stitch 1.2s linear infinite;
}
.loading__swatch::after {
  content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%);
  animation: sheen 2.2s ease-in-out infinite;
}
@keyframes sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes stitch { to { border-color: rgba(255, 255, 255, .25); } }
.loading__msg { font: 500 28px/1.2 var(--serif); margin: 0 0 8px; min-height: 34px; }
.loading__time { font-size: 13px; color: var(--muted); }

/* Result */
.result { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 48px; align-items: start; }
.result__image { background: var(--card); border: 1px solid var(--line); padding: 12px; }
.result__image img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.preview { position: relative; aspect-ratio: 2/3; display: grid; place-items: center; overflow: hidden; }
.preview > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview__note { position: relative; background: rgba(255, 253, 249, .94); padding: 22px 26px; max-width: 320px; text-align: center; }
.preview__note b { display: block; font: 600 22px/1.2 var(--serif); margin-bottom: 6px; }
.preview__note span { font-size: 13px; color: var(--ink-2); }
.result__side h1 { font-size: 44px; }
.recap { list-style: none; margin: 24px 0 28px; padding: 0; border-top: 1px solid var(--line); }
.recap li { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.recap b { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.recap span { font: 600 18px/1.25 var(--serif); }
.recap small { display: block; font: 400 12px/1.4 var(--sans); color: var(--muted); }
.recap button { background: none; border: 0; color: var(--accent); font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.recap img { width: 28px; height: 28px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn--wide { grid-column: 1 / -1; }
.prompt { margin-top: 24px; font-size: 13px; color: var(--ink-2); }
.prompt summary { cursor: pointer; color: var(--muted); letter-spacing: .06em; }
.prompt pre { white-space: pre-wrap; font: 12px/1.6 ui-monospace, Menlo, monospace; background: var(--card); border: 1px solid var(--line); padding: 14px; margin-top: 10px; }
.error { background: #fbeee9; border: 1px solid #ecc7ba; color: #7a2e17; padding: 18px 20px; margin-bottom: 24px; font-size: 14px; }
.error b { display: block; font: 600 20px/1.2 var(--serif); margin-bottom: 4px; color: #5c210f; }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 40px; min-height: 0; }
  .mosaic { max-width: 420px; }
  .result { grid-template-columns: 1fr; }
  .chips { display: none; }
  .brand__sub { display: none; }
}
@media (max-width: 560px) {
  .stage { padding-top: 36px; }
  .grid--fabrics { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid--cards { grid-template-columns: 1fr; }
  .stepper__list li:not(.is-current) { display: none; }
  .stepper__list li + li::before { display: none; }
  .brand__name { font-size: 18px; }
  .btn { padding: 0 16px; }
}
