:root {
  --bg: #faf5ee;
  --card: #ffffff;
  --ink: #2c2433;
  --muted: #7a6f80;
  --line: #e8dfd3;
  --accent: #6d4fa0;
  --accent-2: #d4577a;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Heebo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
h1, h2, .brand, .price { font-family: 'Secular One', 'Heebo', sans-serif; font-weight: 400; }

/* header */
.top {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1180px; margin: 0 auto; padding: 18px 20px;
}
.brand { font-size: 26px; color: var(--ink); text-decoration: none; direction: ltr; }
.brand span { color: var(--accent-2); }
.top-link { color: var(--muted); text-decoration: none; font-size: 15px; }
.top-link:hover { color: var(--accent); }

/* layout */
.builder {
  max-width: 1180px; margin: 0 auto; padding: 0 20px 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 36px; align-items: start;
}
.stage { position: sticky; top: 16px; }
.stage-card {
  background: radial-gradient(ellipse at 50% 40%, #fff 0%, #f3ebe0 80%);
  border: 1px solid var(--line); border-radius: 22px; padding: 22px 22px 14px;
}
.board svg { display: block; width: 100%; max-height: 74vh; }
.stage-cap { text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }
.stage-note { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

/* steps */
.intro h1 { font-size: 36px; margin: 6px 0 6px; line-height: 1.15; }
.intro p { margin: 0 0 22px; color: var(--muted); font-size: 17px; }
.step { margin-bottom: 26px; }
.step-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-h h2 { font-size: 21px; margin: 0; }
.num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; flex: none;
}
.pick { margin-inline-start: auto; color: var(--accent); font-weight: 500; font-size: 15px; }

.seg {
  display: inline-flex; background: #efe7dc; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px;
}
.seg-b {
  font: inherit; font-size: 14.5px; font-weight: 500; color: var(--muted); cursor: pointer;
  border: 0; background: transparent; padding: 8px 16px; border-radius: 9px;
}
.seg-b.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg-b:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 1px; }
.sub-h { font-size: 14px; font-weight: 700; color: var(--muted); margin: 4px 0 8px; }
#alt-wrap .sub-h { margin-top: 16px; }

.grid { display: grid; gap: 10px; }
.fabrics { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.stitches { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.pieces { grid-template-columns: 1fr 1fr; }

.opt {
  position: relative; font: inherit; color: inherit; cursor: pointer; text-align: start;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.opt:hover:not(:disabled) { border-color: #cbbfd8; transform: translateY(-1px); }
.opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 79, 160, .15); }
.opt:disabled { opacity: .5; cursor: not-allowed; }
.opt:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

.fab { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 10px; display: block; }
.fab.tri .swatch { border-radius: 0; overflow: visible; }
/* triangle pickers: wider cells so the point keeps its board proportions */
#opt-ta, #opt-tb { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fab.tri { justify-content: space-between; }
.tri-sw { aspect-ratio: auto; height: auto; padding: 6px 2px 2px; }
.o-name { font-weight: 500; font-size: 14.5px; }
.o-price { color: var(--muted); font-size: 13px; }
.o-desc { display: block; color: var(--muted); font-size: 13px; }
.sold {
  position: absolute; top: 8px; inset-inline-start: 8px; background: var(--ink); color: #fff;
  font-size: 12px; padding: 1px 8px; border-radius: 99px;
}

.st { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.dot { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }

.pc { display: flex; align-items: center; gap: 12px; }
.pc-img { width: 74px; flex: none; }
.pc .o-text { flex: 1; }
.pc .o-price { white-space: nowrap; }

/* summary + order */
.summary {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
}
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.sum-label { font-weight: 700; }
.sum-lines { color: var(--muted); font-size: 14px; }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.qty-b {
  font: inherit; font-size: 20px; line-height: 1; width: 42px; height: 40px; cursor: pointer;
  border: 0; background: #fffdfa; color: var(--accent);
}
.qty-b:hover:not(:disabled) { background: #f4eff9; }
.qty-b:disabled { color: #cfc6d8; cursor: default; }
.qty-n { min-width: 40px; text-align: center; font-weight: 700; font-size: 17px; }
.ship-note { font-size: 13.5px; color: var(--accent-2); margin: -8px 0 14px; }
.ship-note.free { color: #1f8a4c; font-weight: 500; }
.price { font-size: 34px; color: var(--accent); white-space: nowrap; }

.order label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 10px; }
.opt-t { color: var(--muted); font-weight: 400; }
.order input, .order textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: inherit;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fffdfa;
}
.order input:focus, .order textarea:focus { outline: none; border-color: var(--accent); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: #b3261e; font-size: 14px; margin-bottom: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 12px;
  padding: 13px 22px; background: var(--accent); color: #fff; flex: 1 1 auto;
}
.btn:hover { background: #5b3f8c; }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid #d6cbe4; flex: 0 1 auto; font-weight: 500; }
.btn.ghost:hover { background: #f4eff9; }

.friend {
  margin-top: 14px; padding: 14px; border-radius: 14px; background: #f4eff9;
}
.friend label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.friend-row { display: flex; gap: 8px; }
.friend-row input {
  flex: 1; min-width: 0; font: inherit; color: inherit; direction: ltr; text-align: right;
  padding: 10px 12px; border: 1.5px solid #d6cbe4; border-radius: 10px; background: #fff;
}
.friend-row input:focus { outline: none; border-color: var(--accent); }
.btn.wa { flex: 0 0 auto; background: #1fa855; padding: 10px 18px; }
.btn.wa:hover { background: #188d47; }
.friend-hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.friend .err { margin: 8px 0 0; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }

/* mobile */
@media (max-width: 860px) {
  .builder { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 0 16px 32px; }
  /* board stays pinned at the top while choosing (landscape, drawn by JS) */
  .stage {
    position: sticky; top: 0; z-index: 10;
    margin: 0 -16px; padding: 8px 16px 6px;
    background: var(--bg);
    box-shadow: 0 6px 12px -8px rgba(44, 36, 51, .25);
  }
  .stage-card { padding: 8px 10px 6px; border-radius: 16px; }
  .board svg { max-height: 36vh; margin: 0 auto; }
  .stage-cap { font-size: 12.5px; margin-top: 4px; line-height: 1.35; }
  .stage-note { display: none; }
  .intro h1 { font-size: 26px; }
  .intro p { font-size: 15.5px; }
  .pieces { grid-template-columns: 1fr; }
  .fabrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .fab { padding: 6px; gap: 5px; }
  .fab .o-name { font-size: 12.5px; line-height: 1.25; }
  #opt-ta, #opt-tb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .actions .btn { flex: 1 1 100%; }
  .btn.wa { padding: 10px 14px; }
  .f2 { grid-template-columns: 1fr; }
}