:root {
  --bg: #f4f1ec; --panel: #ffffff; --ink: #1f2328; --muted: #6a6f76; --line: #ddd8cf;
  --accent: #d65d34; --accent-ink: #ffffff; --accent-soft: #fbe6dc; --ok: #2e7d4f; --warn: #b26a00; --bad: #c0392b;
  --canvas: #e9e5de;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1c1e; --panel: #25272a; --ink: #ece9e4; --muted: #a0a4aa; --line: #3a3d41;
    --accent: #ec7a52; --accent-ink: #1b1c1e; --accent-soft: #3a2a23; --ok: #5ec286; --warn: #e0a64a; --bad: #ef7b6d;
    --canvas: #2d2f33;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, "Segoe UI", sans-serif; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 20px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.muted { color: var(--muted); font-size: 12px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; }
nav button[aria-current="step"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
nav button:disabled { opacity: .4; cursor: not-allowed; }
main { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 16px; overflow: auto; }
aside h2 { margin: 0 0 4px; font-size: 18px; }
aside p { margin: 4px 0 12px; color: var(--muted); }
aside .row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
aside .row label { flex: 1; }
aside input[type=number] { width: 84px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
aside input[type=text] { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
aside input[type=range] { width: 100%; accent-color: var(--accent); }
aside .unit { color: var(--muted); width: 24px; font-size: 13px; }
aside hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
aside .hint { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
button.btn { border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
button.btn:hover:not(:disabled) { border-color: var(--accent); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.nextbar { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.checks { list-style: none; padding: 0; margin: 8px 0; }
.checks li { padding: 3px 0 3px 22px; position: relative; font-size: 14px; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.checks li.warn::before { content: "!"; color: var(--warn); }
.checks li.bad::before { content: "✗"; color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); font-size: 12.5px; }
#stage { position: relative; background: var(--canvas); min-width: 0; overflow: hidden; }
#cv, #v3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#v3d canvas { display: block; }
#drop { position: absolute; inset: 12px; border: 3px dashed var(--accent); background: color-mix(in srgb, var(--panel) 85%, transparent); display: grid; place-items: center; font-size: 22px; z-index: 5; border-radius: 12px; }
#drop[hidden], #v3d[hidden], #toast[hidden], #pop[hidden], #busy[hidden] { display: none; }
#toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 80%; z-index: 6; }
#busy { position: absolute; top: 12px; right: 12px; background: var(--panel); border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px; z-index: 6; }
#pop { position: absolute; z-index: 7; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 6px; }
.legend { position: absolute; left: 12px; bottom: 12px; background: color-mix(in srgb, var(--panel) 90%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; z-index: 4; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cvhint { position: absolute; left: 12px; top: 12px; background: color-mix(in srgb, var(--panel) 90%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; z-index: 4; max-width: 60%; }
@media (max-width: 800px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); max-height: 45vh; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { width: 28px; height: 28px; border-radius: 6px; border: 2px solid var(--line, #888); display: inline-flex; align-items: center; justify-content: center; color: #fff; text-shadow: 0 0 3px #000; cursor: pointer; font-weight: 700; }
.checks .btn.small { padding: 2px 8px; font-size: 12px; margin-left: 6px; }
