:root {
  --bg: #f4efe6;
  --panel: #fffdf8;
  --ink: #2b2318;
  --muted: #7a6b57;
  --line: #e2d8c6;
  --accent: #b8742a;
  --accent-ink: #fff8ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
header { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.steps span { margin-left: 14px; color: var(--muted); font-size: 13px; }
.steps span.on { color: var(--ink); font-weight: 600; }
.steps .hdr-link { margin-left: 22px; font-size: 13px; font-weight: 600; color: var(--accent, #8a5a2b); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.steps .hdr-link:hover { background: var(--bg, #f4efe6); }

main { display: grid; grid-template-columns: 330px 1fr 1fr; gap: 14px; padding: 14px; height: calc(100% - 52px); }
@media (max-width: 1100px) { main { grid-template-columns: 300px 1fr; } .preview-wrap { grid-column: 1 / -1; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; }
.panel section { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
label input[type=text], label select { display: block; width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; color: var(--ink); background: #fff; }
input[type=range] { width: 100%; margin: 6px 0 0; accent-color: var(--accent); }
output { float: right; color: var(--ink); font-weight: 600; }
.ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: -2px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input[type=text] { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.row label { flex: 1; }
.search { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 4px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.08); display: none; max-height: 240px; overflow: auto; }
.suggest.show { display: block; }
.suggest li { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest li:last-child { border-bottom: 0; }
.suggest li:hover, .suggest li.active { background: #fbf3e6; }
button { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.small { padding: 5px 9px; font-size: 12px; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; margin-bottom: 8px; }
#makeBtn { width: 100%; }
button:disabled { opacity: .5; cursor: progress; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.checks label { margin: 4px 0; color: var(--ink); }
.checks input { margin-right: 6px; }
.icons { display: flex; gap: 6px; margin-top: 4px; }
.icons button { width: 40px; height: 36px; font-size: 18px; }
.icons button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: 10px; overflow: hidden; display: none; }
.progress.show { display: block; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }

.map-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #ddd; }
#map { position: absolute; inset: 0; }
.map-note { position: absolute; left: 8px; bottom: 8px; z-index: 500; background: rgba(255,253,248,.9); padding: 3px 8px; border-radius: 6px; font-size: 11px; color: var(--muted); }

.preview-wrap { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.preview-box { position: relative; flex: 0 0 auto; aspect-ratio: 1 / 1; max-height: 80vh; min-height: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; touch-action: none; }
.snap-line { position: absolute; display: none; width: 0; border-left: 2px dashed var(--accent); pointer-events: none; opacity: .9; }
.snap-line.show { display: block; }
.zoom-note.zoomed { background: var(--accent); color: #fff; }
.stage { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; transform-origin: 0 0; cursor: grab; }
.stage.panning { cursor: grabbing; }
#preview { display: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
#preview.show { display: block; }
.title-handle { position: absolute; display: none; border: 2px dashed var(--accent); border-radius: 4px; background: rgba(184,116,42,.08); cursor: move; user-select: none; }
.title-handle.show { display: block; }
.title-handle .grip { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; }
.zoom-note { position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: var(--muted); background: rgba(255,253,248,.85); padding: 2px 7px; border-radius: 6px; pointer-events: none; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; background: rgba(255,253,248,.82); text-align: center; padding: 20px; }
.loading.hidden { display: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; display: none; }
.loading.busy .spinner { display: block; }
.elapsed { font-variant-numeric: tabular-nums; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { margin-top: 10px; font-size: 13px; }
.result .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0; }
.result .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; }
.result .card b { display: block; font-size: 20px; }
.result .files a { display: inline-block; margin: 2px 8px 2px 0; }
.carousel { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 8px; }
.carousel img { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto; border-radius: 6px; }
.carousel .nav { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; }
.carousel .nav button { padding: 4px 12px; font-size: 16px; }
pre.log { max-height: 160px; overflow: auto; background: #faf6ee; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 11px; white-space: pre-wrap; }

/* shop mode */
.result .cartrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.result button.cart { font-size: 14px; padding: 8px 14px; }
body.shop header .steps { display: none; }
