:root {
  color-scheme: dark;
  --bg: #0c0d0b;
  --surface: #141511;
  --surface-2: #1b1d18;
  --surface-3: #23261f;
  --line: rgba(238, 244, 222, 0.12);
  --line-strong: rgba(238, 244, 222, 0.22);
  --text: #f2f3ed;
  --muted: #999e91;
  --acid: #d8ff54;
  --acid-ink: #171c07;
  --good: #90e85c;
  --viewer: #f2efe9;
  --radius: 18px;
  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: var(--bg); color: var(--text); }
body { overflow: auto; }
button, input, label { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-shell { min-height: 100vh; padding: 14px; background: radial-gradient(circle at 0 0, rgba(216,255,84,.055), transparent 30%), var(--bg); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 10px 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 10px; background: var(--acid); color: var(--acid-ink); font-size: 13px; font-weight: 900; letter-spacing: -.04em; transform: rotate(-3deg); }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; letter-spacing: -.025em; }
.brand small, .eyebrow { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.top-actions, .viewer-actions { display: flex; align-items: center; gap: 8px; }
.privacy-note { display: flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(144,232,92,.09); }

.button, .icon-button, .text-button { border: 0; cursor: pointer; transition: .18s ease; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 15px; border-radius: 10px; font-size: 12px; font-weight: 800; }
.button-ghost { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.button-primary { color: var(--acid-ink); background: var(--acid); }
.button-block { grid-column: 1 / -1; width: 100%; color: var(--text); background: var(--surface-3); border: 1px solid var(--line); }
.button:hover, .icon-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }

.workspace { min-width: 640px; display: grid; grid-template-columns: 640px 390px; justify-content: center; align-items: start; gap: 12px; }
.viewer-card, .inspector { min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.viewer-card { width: 640px; height: 548px; display: grid; grid-template-rows: 480px 68px; }
.viewer { position: relative; width: 640px; height: 480px; min-height: 0; overflow: hidden; background: var(--viewer); }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer:fullscreen { width: 100vw; height: 100vh; border-radius: 0; }
.viewer:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; }
.viewer-topline { position: absolute; z-index: 3; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.model-state, .viewer-actions { pointer-events: auto; }
.model-state { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 11px; color: #22251f; background: rgba(255,255,255,.86); border: 1px solid rgba(0,0,0,.08); backdrop-filter: blur(14px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.model-state strong { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.model-state > span:last-child { color: #6b7164; font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.icon-button { min-height: 34px; padding: 0 10px; border-radius: 9px; color: #31352c; background: rgba(255,255,255,.82); border: 1px solid rgba(0,0,0,.08); backdrop-filter: blur(14px); font-size: 10px; font-weight: 800; }
.icon-button[aria-pressed="true"] { color: #151a08; background: rgba(216,255,84,.92); }
.viewer-hint { position: absolute; z-index: 2; left: 50%; bottom: 15px; transform: translateX(-50%); padding: 8px 12px; color: rgba(27,30,25,.64); background: rgba(255,255,255,.62); border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; backdrop-filter: blur(12px); }
.drop-zone, .loading { position: absolute; z-index: 8; inset: 0; display: grid; place-items: center; background: rgba(12,13,11,.54); backdrop-filter: blur(5px); }
.drop-zone[hidden], .loading[hidden], .toast[hidden] { display: none; }
.drop-card { min-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px; color: var(--text); background: #171914; border: 1px solid rgba(216,255,84,.48); border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.drop-icon { display: grid; place-items: center; width: 64px; height: 64px; border: 1px dashed var(--acid); border-radius: 18px; color: var(--acid); font-weight: 900; }
.drop-card strong { font-size: 18px; }
.drop-card span:last-child, .loading span:last-child { color: var(--muted); font-size: 12px; }
.loading { color: var(--text); align-content: center; gap: 10px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--acid); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.toast { position: absolute; z-index: 10; left: 50%; bottom: 50px; transform: translateX(-50%); max-width: min(620px, calc(100% - 28px)); padding: 11px 14px; color: var(--text); background: rgba(20,21,17,.94); border: 1px solid var(--line-strong); border-radius: 10px; font-size: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.24); }
.toast.error { border-color: rgba(255,111,86,.52); }

.model-strip { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.model-strip > div { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 16px; border-right: 1px solid var(--line); }
.model-strip > div:last-child { border-right: 0; }
.model-strip span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.model-strip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.inspector { height: 548px; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.inspector-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.inspector-head h1 { margin: 6px 0 0; font-size: 18px; line-height: 1.15; letter-spacing: -.035em; }
.text-button { flex: none; padding: 5px 0; color: var(--acid); background: none; font-size: 10px; font-weight: 800; }
.panel { border-bottom: 1px solid var(--line); }
.panel summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; list-style: none; cursor: pointer; font-size: 12px; font-weight: 800; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary small { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.panel summary::after { content: "+"; color: var(--muted); font-size: 16px; order: 3; }
.panel[open] summary::after { content: "−"; }
.panel-content { padding: 2px 20px 18px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 14px; }
.control { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.control-wide { grid-column: 1 / -1; }
.control > span { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; }
.control output { color: var(--text); font-variant-numeric: tabular-nums; }
.control-note { grid-column: 1 / -1; margin: -2px 0 0; padding: 10px 11px; color: var(--muted); background: rgba(216,255,84,.045); border: 1px solid rgba(216,255,84,.12); border-radius: 9px; font-size: 9px; line-height: 1.45; }
input[type="range"] { width: 100%; height: 4px; margin: 6px 0; appearance: none; border-radius: 999px; background: linear-gradient(90deg, var(--acid) 0 var(--range-progress, 50%), var(--surface-3) var(--range-progress, 50%) 100%); }
input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; appearance: none; border: 3px solid var(--surface); border-radius: 50%; background: var(--acid); box-shadow: 0 0 0 1px rgba(216,255,84,.4); cursor: pointer; }
.positions { display: grid; gap: 12px; }
.positions fieldset { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 11px; }
.positions legend { padding: 0 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.positions label { display: grid; grid-template-columns: 12px 1fr; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; }
.positions input[type="number"] { width: 100%; height: 31px; padding: 0 7px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; font-size: 10px; }
.toggles { display: grid; gap: 2px; }
.toggles > label { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggles label > span { display: flex; flex-direction: column; gap: 2px; }
.toggles strong { font-size: 11px; }
.toggles small { color: var(--muted); font-size: 9px; }
input[role="switch"] { position: relative; width: 34px; height: 19px; flex: none; appearance: none; border-radius: 999px; background: var(--surface-3); cursor: pointer; transition: .18s; }
input[role="switch"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: var(--muted); transition: .18s; }
input[role="switch"]:checked { background: var(--acid); }
input[role="switch"]:checked::after { left: 18px; background: var(--acid-ink); }
input[type="color"] { width: 34px; height: 26px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); cursor: pointer; }
.inspector-footer { margin-top: auto; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; color: var(--muted); font-size: 9px; }
.inspector-footer strong { color: var(--text); }

@media (max-width: 1100px) {
  .app-shell { min-height: 100svh; padding: 10px; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; }
  .privacy-note, #reset-all { display: none; }
  .workspace { grid-template-columns: 640px; }
  .inspector { width: 640px; height: auto; max-height: none; }
}

@media (max-width: 620px) {
  .top-actions { margin-left: auto; }
  .button { min-height: 36px; padding: 0 12px; }
  .button-ghost { display: none; }
  .workspace { gap: 8px; }
  .viewer-topline { align-items: flex-start; }
  .model-state { max-width: calc(100% - 74px); }
  .viewer-actions { flex-direction: column; align-items: stretch; }
  .viewer-actions .icon-button:not(#fullscreen) { display: none; }
  .model-strip { grid-template-columns: repeat(3, 1fr); }
  .model-strip > div { min-height: 54px; padding: 10px; border-bottom: 1px solid var(--line); }
  .viewer-hint { max-width: calc(100% - 30px); overflow: hidden; text-overflow: ellipsis; }
}

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