:root {
  --bg: #fbf4ea;
  --card: #fffdf9;
  --ink: #2b1a10;
  --muted: #7a6656;
  --brown: #7a3b17;
  --ginger: #b5652b;
  --line: #ead9c6;
  --red: #b3261e;
  --gold: #e9a23b;
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
main { max-width: 760px; margin: 0 auto; padding: 0 14px 110px; }

.top {
  background: linear-gradient(135deg, #7a3b17, #a8582a);
  color: #fff8ec;
  padding: 18px 16px 22px;
  padding-top: max(18px, env(safe-area-inset-top));
}
.brand { max-width: 760px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.brand img { border-radius: 10px; box-shadow: 0 2px 8px #0003; }
.top h1 { font-size: 1.25rem; margin: 0; letter-spacing: .01em; }
.top p { margin: 2px 0 0; font-size: .88rem; opacity: .85; }

.designs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: -12px 0 12px; position: relative;
}
.design {
  appearance: none; border: 2px solid transparent; background: var(--card);
  border-radius: 14px; padding: 8px 6px 10px; text-align: center; cursor: pointer;
  box-shadow: 0 2px 10px #7a3b1720; color: var(--ink); font: inherit;
}
.design svg { width: 100%; height: 54px; display: block; }
.design b { display: block; font-size: .86rem; line-height: 1.2; margin-top: 4px; }
.design small { display: none; color: var(--muted); font-size: .75rem; }
.design[aria-pressed="true"] { border-color: var(--ginger); background: #fff6ec; }

.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  padding: 14px; margin-bottom: 12px;
}
.stage { padding: 0; overflow: hidden; }
#view {
  display: block; width: 100%; aspect-ratio: 1.1 / 1; touch-action: none; cursor: grab;
  background: radial-gradient(ellipse at 50% 35%, #fffaf3 0%, #f3e4d2 70%, #ead6bf 100%);
}
#view:active { cursor: grabbing; }
.stage-foot {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px;
  font-size: .85rem; border-top: 1px solid var(--line); color: var(--muted);
}
#dims { color: var(--ink); font-weight: 600; white-space: nowrap; }
.hint { text-align: right; }

.controls { display: grid; gap: 12px; }
.ctl { display: grid; gap: 4px; }
.ctl span { display: flex; justify-content: space-between; font-size: .92rem; }
.ctl b { font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--ginger); height: 28px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.sel { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
select {
  font: inherit; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
}
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: .85rem; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ginger); color: #fff; border-color: var(--ginger); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); }

.warn {
  background: #fdecea; color: var(--red); border: 1px solid #f3c3bf; border-radius: 12px;
  padding: 10px 12px; margin-bottom: 12px; font-size: .9rem;
}

.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button {
  flex: 1; font: inherit; font-weight: 600; padding: 10px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--brown); color: #fff8ec; border-color: var(--brown); }

.parts { list-style: none; margin: 0; padding: 0; }
.parts li {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.parts li:last-child { border-bottom: 0; }
.parts svg { width: 56px; height: 44px; }
.parts .nm { font-weight: 600; }
.parts .sz { font-size: .82rem; color: var(--muted); }
.parts .ct {
  font-weight: 700; background: #f6e8d8; border-radius: 999px; padding: 2px 10px; font-size: .9rem;
}

.note { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 1px 6px #0001; }
.sheet svg { display: block; width: 100%; height: auto; }

.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 8px; }
.tips { margin-top: 12px; padding: 10px 12px; background: #fff6ec; border-radius: 12px; font-size: .9rem; }
.tips h3 { margin: 0 0 4px; font-size: .95rem; }
.tips ul { margin: 0; padding-left: 1.2em; }

.foot { text-align: center; color: var(--muted); font-size: .78rem; margin: 18px 0; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 8px; justify-content: center;
  padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #fbf4eaee; backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.actionbar button {
  font: inherit; font-weight: 700; border-radius: 14px; padding: 12px 18px; cursor: pointer; border: 0;
}
.primary { background: var(--red); color: #fff; flex: 1; max-width: 420px; box-shadow: 0 3px 10px #b3261e44; }
.ghost { background: #fff; color: var(--brown); border: 1px solid var(--line) !important; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 9;
  background: #2b1a10; color: #fff; padding: 8px 14px; border-radius: 10px; font-size: .9rem;
}

@media (min-width: 640px) {
  .design small { display: block; }
  .design svg { height: 70px; }
}

.print-only { display: none; }
@media print {
  .screen { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .page { break-after: page; page-break-after: always; overflow: hidden; }
  .page:last-child { break-after: auto; page-break-after: auto; }
  .page svg { display: block; }
}
