/* Layout: a fixed options panel on the left, a live 3D viewport filling the rest; Apple-style neutrals with one blue accent. */
:root {
  --bg: #f5f5f7; --panel: #ffffff; --text: #1d1d1f; --muted: #6e6e73; --line: #d2d2d7; --line-soft: #e8e8ed;
  --seg: #eeeef0; --seg-active: #ffffff; --note-bg: #f7f7f9; --tag: #f0f0f3; --glass: rgba(255,255,255,.85); --bar: rgba(255,255,255,.8);
  --inverse: #1d1d1f; --inverse-fg: #ffffff;
  --vp-a: #ffffff; --vp-b: #f1f1f4; --vp-c: #e9e9ee;
  --ok-bg: #eaf8ee; --ok-fg: #1a7f37; --warn-bg: #fff7e8; --warn-fg: #8a5300;
  --accent: #0071e3; --accent-soft: #e8f1fc; --ok: #34c759; --warn: #ff9f0a; --danger: #ff3b30;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #161618; --panel: #1f1f22; --text: #f5f5f7; --muted: #9a9aa1; --line: #3a3a40; --line-soft: #2c2c31;
  --seg: #2a2a2f; --seg-active: #3b3b41; --note-bg: #26262b; --tag: #2e2e34; --glass: rgba(31,31,34,.85); --bar: rgba(22,22,24,.8);
  --inverse: #f5f5f7; --inverse-fg: #1d1d1f;
  --vp-a: #2a2a2f; --vp-b: #1b1b1e; --vp-c: #141416;
  --ok-bg: #1d3324; --ok-fg: #7ed69a; --warn-bg: #3a2c12; --warn-fg: #f5c26b;
  --accent: #2997ff; --accent-soft: #1b2b3f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #161618; --panel: #1f1f22; --text: #f5f5f7; --muted: #9a9aa1; --line: #3a3a40; --line-soft: #2c2c31;
  --seg: #2a2a2f; --seg-active: #3b3b41; --note-bg: #26262b; --tag: #2e2e34; --glass: rgba(31,31,34,.85); --bar: rgba(22,22,24,.8);
  --inverse: #f5f5f7; --inverse-fg: #1d1d1f;
  --vp-a: #2a2a2f; --vp-b: #1b1b1e; --vp-c: #141416;
  --ok-bg: #1d3324; --ok-fg: #7ed69a; --warn-bg: #3a2c12; --warn-fg: #f5c26b;
  --accent: #2997ff; --accent-soft: #1b2b3f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { display: flex; flex-direction: column; min-height: 100vh; }
button { font-family: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; height: 60px; background: var(--bar); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.logo { width: 30px; height: 30px; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-tag { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.steps { display: flex; gap: 6px; margin: 0 auto; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: none; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.step .n { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.step.active { background: var(--inverse); color: var(--inverse-fg); }
.step.active .n { border-color: rgba(255,255,255,.5); }
.step.done .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.topbar-actions { display: flex; gap: 8px; }
.pill { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.pill:hover { border-color: var(--text); }

/* layout */
.main { flex: 1; display: grid; grid-template-columns: 440px 1fr; min-height: 0; }
.panel { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line-soft); min-height: 0; height: calc(100vh - 60px - 40px); position: sticky; top: 60px; }
.panel-scroll { flex: 1; overflow: auto; padding: 24px 24px 12px; }
.panel-footer { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-top: 1px solid var(--line-soft); background: var(--panel); }
.grow { flex: 1; }
.viewport { position: relative; min-height: 420px; background: radial-gradient(1200px 700px at 60% 30%, var(--vp-a) 0%, var(--vp-b) 60%, var(--vp-c) 100%); }
#gl { width: 100%; height: 100%; display: block; }
.vp-toolbar { position: absolute; top: 14px; left: 14px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 140px); }
.chip-sep { width: 1px; background: var(--line); margin: 4px 2px; }
.chip { border: 1px solid var(--line-soft); background: var(--glass); backdrop-filter: blur(10px); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; color: var(--text); }
.chip.active { background: var(--inverse); color: var(--inverse-fg); border-color: var(--inverse); }
.vp-status { position: absolute; top: 14px; right: 14px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); font-size: 12.5px; color: var(--text); }
.vp-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.vp-status.busy .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: .4 } 50% { opacity: 1 } 100% { opacity: .4 } }
.vp-stats { position: absolute; bottom: 14px; left: 14px; right: 14px; display: flex; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.stat { background: var(--glass); backdrop-filter: blur(10px); border-radius: 12px; padding: 8px 12px; font-size: 12px; color: var(--muted); min-width: 110px; }
.stat b { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-top: 2px; }

/* panel content */
.title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); font-size: 14px; margin: 6px 0 20px; line-height: 1.5; }
.group { margin-bottom: 20px; }
.label { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.label .hint { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.35; flex: 1 1 100%; }
.seg { display: flex; background: var(--seg); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { flex: 1; border: none; background: transparent; padding: 8px 6px; border-radius: 8px; font-size: 13px; color: var(--text); cursor: pointer; transition: background .15s, box-shadow .15s; white-space: nowrap; }
.seg button.active { background: var(--seg-active); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg.cats button { padding: 9px 4px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { border: 1.5px solid var(--line-soft); border-radius: var(--radius); padding: 12px; background: var(--panel); color: var(--text); cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card:hover { border-color: var(--line); transform: translateY(-1px); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card svg { width: 100%; height: 78px; display: block; margin-bottom: 8px; }
.card img { width: calc(100% + 24px); margin: -12px -12px 8px; display: block; border-radius: 12px 12px 0 0; aspect-ratio: 440 / 272; object-fit: cover; }
.card .ct { font-weight: 600; font-size: 14px; }
.card .cd { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--tag); color: var(--muted); }
.tag.ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
input[type=number], input[type=text], select { width: 100%; font: inherit; font-size: 14px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.5; padding: 10px 12px; background: var(--note-bg); border-radius: var(--radius-sm); }
.note.warn { background: var(--warn-bg); color: var(--warn-fg); }
.note.ok { background: var(--ok-bg); color: var(--ok-fg); }
.btn { border: none; border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--seg); color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0077ed; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); font-size: 13.5px; }
.switch { width: 42px; height: 26px; border-radius: 13px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; border: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 19px; }

/* foot photo cards */
.feet { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot-card { border: 1.5px solid var(--line-soft); border-radius: var(--radius); padding: 10px; background: var(--panel); }
.foot-card .fh { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.drop { border: 1.5px dashed var(--line); background: var(--panel); border-radius: var(--radius-sm); height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; text-align: center; padding: 8px; }
.drop:hover { border-color: var(--accent); color: var(--accent); }
.drop svg { width: 28px; height: 28px; }
.photo-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.photo-wrap canvas { width: 100%; display: block; }
.photo-wrap .overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.measure { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.measure div { background: var(--note-bg); border-radius: 8px; padding: 6px 8px; font-size: 11px; color: var(--muted); }
.measure b { display: block; font-size: 13px; color: var(--text); }
.mini { font-size: 12px; color: var(--muted); }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 0; }
.howto { display: flex; gap: 12px; align-items: flex-start; }
.howto svg { width: 96px; flex: none; }

/* footer, modal */
.footer { height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-soft); background: var(--panel); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-card { background: var(--panel); color: var(--text); border-radius: 18px; padding: 24px; width: min(440px, 90vw); box-shadow: var(--shadow); line-height: 1.5; font-size: 14px; }
.modal-card h3 { font-size: 18px; margin-bottom: 8px; }
.progress { height: 6px; background: var(--seg); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.toast { position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%); background: var(--inverse); color: var(--inverse-fg); padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 44vh auto; }
  .viewport { order: 0; min-height: 0; }
  .panel { order: 1; height: auto; position: static; border-right: none; }
  .panel-scroll { padding: 18px 16px; }
  .brand-tag, .steps .t { display: none; }
  .steps { gap: 2px; }
  .step { padding: 4px 5px; }
  .step .n { width: 22px; height: 22px; }
  .topbar { gap: 10px; padding: 8px 12px; }
  .footer { height: auto; padding: 8px 12px; flex-wrap: wrap; text-align: center; font-size: 11px; line-height: 1.4; }
  .footer .sep { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .feet { grid-template-columns: 1fr; }
  .vp-stats { bottom: 8px; left: 8px; right: 8px; gap: 6px; }
  .stat { min-width: 0; flex: 1 1 0; padding: 5px 8px; font-size: 10.5px; border-radius: 9px; }
  .stat b { font-size: 12.5px; }
  .stat:nth-child(4) { display: none; }
  .vp-toolbar { gap: 4px; }
  .chip { padding: 5px 9px; font-size: 11.5px; }
}
