:root {
  color-scheme: dark;
  --ink: #f5f7fa;
  --muted: #9aa5b3;
  --dim: #687482;
  --surface: #111820;
  --surface-2: #17212c;
  --surface-3: #202d39;
  --line: #2b3946;
  --acid: #d8ff4f;
  --acid-ink: #142000;
  --orange: #ff7a45;
  --amber: #ffc857;
  --cyan: #57d6df;
  --red: #ff6b6b;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #0a1016; color: var(--ink); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
button, .upload-button, .upload-wide { min-height: 44px; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, label:focus-within { outline: 3px solid rgba(216,255,79,.55); outline-offset: 2px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 20; background: var(--acid); color: var(--acid-ink); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar { min-height: 72px; padding: 12px clamp(16px, 2.4vw, 34px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(9,15,21,.95); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; text-transform: uppercase; letter-spacing: .08em; }
.brand-mark { width: 34px; height: 34px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; align-items: end; transform: skew(-8deg); }
.brand-mark i { background: var(--acid); display: block; border-radius: 2px; }
.brand-mark i:nth-child(1) { height: 42%; }.brand-mark i:nth-child(2) { height: 70%; }.brand-mark i:nth-child(3) { height: 100%; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.privacy-pill { font-size: 12px; color: var(--muted); padding-right: 10px; }
.privacy-pill span { color: var(--acid); margin-right: 5px; }

.ghost, .secondary, .primary { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: transparent; color: var(--ink); font-weight: 700; }
.ghost:hover, .secondary:hover { border-color: #597083; background: rgba(255,255,255,.04); }
.danger { color: #ffaaa6; }
.primary { border-color: var(--acid); background: var(--acid); color: var(--acid-ink); }
.primary:hover { background: #e5ff83; }
.primary:disabled, .secondary:disabled, .ghost:disabled { opacity: .38; cursor: not-allowed; }
.full { width: 100%; }

.steps { min-height: 52px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.steps ol { list-style: none; margin: 0 auto; padding: 0 18px; max-width: 980px; min-width: 670px; display: grid; grid-template-columns: repeat(6, 1fr); }
.steps li { position: relative; padding: 13px 8px; color: var(--dim); font-size: 12px; font-weight: 700; text-align: center; }
.steps li span { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 7px; border: 1px solid #40505f; border-radius: 999px; }
.steps li.active, .steps li.done { color: var(--ink); }
.steps li.active::after { content: ""; position: absolute; left: 16%; right: 16%; bottom: 0; height: 3px; background: var(--acid); border-radius: 4px 4px 0 0; }
.steps li.done span { background: var(--acid); color: var(--acid-ink); border-color: var(--acid); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(360px, .75fr); min-height: calc(100vh - 125px); }
.viewport-panel { min-width: 0; display: flex; flex-direction: column; background: #0b1219; border-right: 1px solid var(--line); }
.viewport { position: relative; flex: 1; min-height: 560px; overflow: hidden; background: radial-gradient(circle at 45% 42%, #182531 0, #0d151d 46%, #091017 100%); }
#sceneCanvas { width: 100%; height: 100%; display: block; }
.empty-state { position: absolute; inset: 0; margin: auto; width: min(570px, calc(100% - 36px)); height: max-content; padding: 38px; text-align: center; border: 1px solid rgba(255,255,255,.1); border-radius: 24px; background: rgba(12,20,27,.86); box-shadow: 0 24px 80px rgba(0,0,0,.28); backdrop-filter: blur(14px); }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; color: var(--acid); border: 1px solid rgba(216,255,79,.38); border-radius: 18px; font-size: 34px; }
.eyebrow { margin: 0 0 7px; color: var(--acid); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.empty-state h1 { margin: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.02; letter-spacing: -.045em; }
.empty-state > p:not(.eyebrow):not(.file-hint) { max-width: 480px; margin: 18px auto 24px; color: #c2cbd5; line-height: 1.55; }
.upload-button, .upload-wide { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.demo-button { display: block; margin: 10px auto 0; }
.demo-secondary { margin-top: 8px; }
.file-hint { color: var(--dim); font-size: 12px; margin: 14px 0 0; }
.view-toolbar { position: absolute; top: 16px; left: 16px; display: flex; gap: 5px; }
.view-toolbar button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,22,29,.9); color: var(--muted); font-size: 10px; font-weight: 800; }
.viewport-status { position: absolute; left: 16px; bottom: 16px; max-width: calc(100% - 32px); padding: 8px 11px; border-radius: 8px; background: rgba(8,14,19,.86); color: var(--muted); font-size: 12px; }
.webgl-error { position: absolute; inset: auto 16px 58px; padding: 14px; border: 1px solid var(--red); border-radius: 10px; background: rgba(55,10,14,.92); }
.legend { min-height: 46px; padding: 0 18px; display: flex; align-items: center; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.dot { width: 8px; height: 8px; display: inline-block; margin-right: 5px; border-radius: 50%; }.dot.model{background:#7c8796}.dot.critical{background:var(--orange)}.dot.support{background:var(--acid)}.dot.review{background:var(--amber)}

.control-panel { padding: 28px clamp(18px, 2.2vw, 32px); overflow-y: auto; max-height: calc(100vh - 125px); background: var(--surface); }
.panel-intro { padding-bottom: 21px; border-bottom: 1px solid var(--line); }
.panel-intro h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.panel-intro p:last-child { color: var(--muted); line-height: 1.5; margin-bottom: 0; }
.stage-card { margin-top: 16px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.015); opacity: .48; }
.stage-card.current, .stage-card.complete { opacity: 1; }.stage-card.current { border-color: #55697b; background: rgba(255,255,255,.027); }
.stage-heading { display: flex; gap: 12px; margin-bottom: 14px; }
.stage-heading > span { color: var(--acid); font: 800 11px/1.7 ui-monospace, monospace; }
.stage-heading h3 { margin: 0; font-size: 16px; }.stage-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.upload-wide { width: 100%; }
.summary-box, .decision-box { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: #cbd3dc; background: #0d151c; font-size: 12px; line-height: 1.5; }
.summary-box.muted { color: var(--dim); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field-grid.rotations { grid-template-columns: repeat(3, 1fr); }
.nozzle-policy { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.nozzle-policy > label:first-child { display: grid; gap: 7px; }
.nozzle-policy fieldset { margin: 12px 0 8px; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; }
.nozzle-policy legend { padding: 0 6px; color: var(--muted); font-size: .78rem; }
.nozzle-policy fieldset label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 0 0; }
.check-line { display: flex; align-items: flex-start; gap: 8px; margin-top: 9px; line-height: 1.35; }
.check-line input, .nozzle-policy fieldset input { inline-size: 18px; block-size: 18px; flex: 0 0 auto; margin-top: 0; padding: 0; }
label { color: var(--muted); font-size: 11px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #0c141b; color: var(--ink); }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.microcopy { margin: 11px 0 0; color: var(--dim); font-size: 11px; line-height: 1.45; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.metric { padding: 12px; border-radius: 11px; background: #0d151c; border: 1px solid var(--line); }.metric strong { display:block; font-size: 20px; }.metric span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.decision-box { border-left: 3px solid var(--amber); margin-bottom: 12px; }
.decision-box.good { border-left-color: var(--acid); }
.expert-only { padding-top: 12px; }
.check-list { display: grid; gap: 8px; }.check-item { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.4; }.check-item b { color: var(--acid); }.check-item.warn b { color: var(--amber); }
.history-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 13px 0; }
.gate-details { margin-top: 12px; color: var(--muted); font-size: 12px; }.gate-details summary { cursor: pointer; color: var(--ink); }.gate-details li { margin: 8px 0; line-height: 1.45; }
.panel-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; color: var(--dim); font-size: 10px; }.panel-footer a { color: var(--muted); }
.toast { position: fixed; z-index: 30; right: 18px; bottom: 18px; max-width: 360px; padding: 13px 16px; color: #111; background: var(--acid); border-radius: 10px; box-shadow: 0 14px 46px rgba(0,0,0,.35); font-weight: 750; font-size: 13px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .viewport-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .viewport { min-height: 54vh; }
  .control-panel { max-height: none; }
}

@media (max-width: 620px) {
  .topbar { min-height: 64px; padding: 10px 13px; }
  .brand small, .privacy-pill { display: none; }
  .top-actions { gap: 5px; }.top-actions button { min-height: 38px; padding: 8px 9px; font-size: 11px; }
  .steps ol { min-width: 0; width: 100%; padding: 0 4px; }.steps li { padding: 7px 1px 8px; font-size: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; }.steps li span { width: 20px; height: 20px; margin-right: 0; font-size: 9px; }
  .viewport { min-height: 480px; }
  .empty-state { padding: 22px 16px; border-radius: 18px; }.empty-state h1 { font-size: 34px; }.empty-state > p:not(.eyebrow):not(.file-hint) { margin: 13px auto 16px; font-size: 14px; }.empty-state .empty-icon { width: 50px; height: 50px; margin-bottom: 12px; }.empty-state .file-hint { display: none; }
  .view-toolbar { top: 10px; left: 10px; }.view-toolbar button { padding: 5px 7px; }
  .legend { gap: 8px 10px; padding-block: 8px; flex-wrap: wrap; white-space: normal; }
  .control-panel { padding: 22px 14px; }.panel-intro h2 { font-size: 23px; }
  .field-grid { grid-template-columns: 1fr; }.field-grid.rotations { grid-template-columns: repeat(3, 1fr); }
  .button-row { grid-template-columns: 1fr; }
  .panel-footer { flex-direction: column; }
}

@media (max-width: 340px) {
  .topbar { padding-inline: 8px; gap: 10px; }
  .brand { gap: 7px; }
  .brand > span:not(.brand-mark) { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .brand strong { font-size: 15px; }
  .top-actions button { padding-inline: 6px; font-size: 10px; }
  .history-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
