:root {
  color-scheme: dark;
  --panel: rgba(8, 19, 28, .82);
  --line: rgba(184, 220, 235, .18);
  --text: #edf7fb;
  --muted: #a8bdc6;
  --accent: #90e0e3;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #071016; color: var(--text); }
button, input, summary { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; outline-offset: -4px; }
#scene.dragging { cursor: grabbing; }
#scene.screen-mode { cursor: default; }
.ui { position: fixed; inset: 0; pointer-events: none; transition: opacity .2s; }
.ui > * { pointer-events: auto; }
.glass { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 42px rgba(0, 0, 0, .18); backdrop-filter: blur(16px); }
.top { position: absolute; top: max(24px, env(safe-area-inset-top)); left: 28px; right: 28px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.brand { text-shadow: 0 2px 20px #071016; }
.kicker { color: var(--accent); font: 600 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.title { margin: 8px 0 0; font-size: clamp(24px, 3vw, 38px); font-weight: 550; letter-spacing: -.04em; line-height: 1.1; }
.subtitle { margin: 10px 0 0; color: #d2e0e5; font-size: 12px; }
.back { display: inline-flex; padding: 10px 15px; border-radius: 999px; color: var(--text); text-decoration: none; font-size: 12px; white-space: nowrap; }
.back:hover { color: var(--accent); border-color: var(--accent); }
.panel { position: absolute; left: 28px; bottom: 28px; width: 226px; max-height: calc(100dvh - 170px); padding: 17px 10px 12px; border-radius: 18px; display: flex; flex-direction: column; }
.panel h2 { margin: 0 10px 7px; font-size: 11px; font-weight: 500; letter-spacing: .12em; color: var(--muted); }
.stage-list { overflow: auto; scrollbar-width: thin; scrollbar-color: #47636d transparent; }
.group-title { padding: 15px 10px 7px; font-size: 10px; color: var(--muted); letter-spacing: .12em; }
.group-title:first-child { padding-top: 6px; }
.stage { display: flex; align-items: center; gap: 14px; width: 100%; padding: 9px 10px; text-align: left; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text); transition: background .15s; }
.stage:hover { background: rgba(255, 255, 255, .06); }
.stage[aria-current=true] { border-color: rgba(144, 224, 227, .38); background: rgba(75, 160, 174, .19); }
.stage strong { font-size: 13px; font-weight: 450; }
.stage .num { color: #829da8; font: 10px ui-monospace, monospace; }
.stage[aria-current=true] .num { color: var(--accent); }
.inspector { position: absolute; right: 28px; bottom: 28px; width: 300px; padding: 22px; border-radius: 18px; max-height: calc(100dvh - 210px); overflow: auto; scrollbar-width: thin; }
.inspector h2 { font-size: 24px; font-weight: 500; letter-spacing: -.025em; margin: 9px 0; }
.inspector p { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 0; }
.controls { display: grid; gap: 14px; padding-top: 16px; }
.control { display: grid; grid-template-columns: 1fr 1.12fr 42px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.control output { font: 10px ui-monospace, monospace; color: var(--accent); text-align: right; white-space: nowrap; }
.control input { width: 100%; min-width: 0; margin: 0; accent-color: var(--accent); }
#parameterDetails { margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--line); }
#parameterDetails summary { font-size: 11px; color: var(--muted); }
.variants { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }
.variants:empty { display: none; }
.variants button { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); color: var(--muted); border-radius: 6px; font-size: 10px; padding: 7px 9px; }
.variants button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.reset-params { color: var(--muted); font-size: 10px; border: 0; background: transparent; padding: 0; margin-top: 16px; text-decoration: underline; text-underline-offset: 3px; }
.toolbar { position: absolute; right: 28px; top: 80px; display: flex; gap: 3px; align-items: center; padding: 5px; border-radius: 999px; }
.tool { border: 0; border-radius: 999px; padding: 9px 11px; background: transparent; color: var(--text); font-size: 11px; }
.tool:hover, .tool[aria-pressed=true] { background: rgba(144, 224, 227, .13); color: var(--accent); }
#status { color: var(--accent); font-size: 10px; display: block; margin-top: 15px; }
.hint { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); color: #d2e0e5; font-size: 11px; white-space: nowrap; text-shadow: 0 1px 6px #000; transition: opacity .3s; }
.hint.hide { opacity: 0; }
.hide-ui .ui { opacity: 0; pointer-events: none; }
.hide-ui .ui > * { pointer-events: none; }
#showUI { position: fixed; top: 20px; right: 20px; z-index: 4; border-radius: 999px; }
#loader, #fatal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; background: #0a1820; padding: 24px; text-align: center; }
#loader.done { display: none; }
.loader-box { width: min(380px, 90vw); }
.loader-box h2 { font-size: 24px; font-weight: 450; }
.loader-box p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.loader-bar { height: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 24px 0; }
.loader-bar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: load 1.4s ease-in-out infinite; }
#fatalMsg { overflow-wrap: anywhere; }
.error-actions { display: flex; gap: 12px; justify-content: center; }
.error-actions button { color: var(--text); }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(330%); } }
@media (max-width: 1050px) { .hint { display: none; } .inspector { width: 270px; padding: 18px; } }
@media (max-width: 720px) {
  .top { top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; }
  .title { font-size: 24px; max-width: 65vw; }
  .kicker { font-size: 8px; letter-spacing: .1em; }
  .subtitle { display: none; }
  .back { padding: 8px 10px; font-size: 10px; }
  .toolbar { top: auto; bottom: calc(110px + env(safe-area-inset-bottom)); right: 12px; left: 12px; justify-content: center; }
  .tool { flex: 1; padding: 8px 6px; font-size: 10px; }
  .panel { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; max-height: 90px; padding: 11px 8px 8px; }
  .panel h2 { font-size: 9px; margin-bottom: 7px; }
  .stage-list { display: flex; gap: 4px; overflow-x: auto; }
  .group-title { display: none; }
  .stage { min-width: max-content; gap: 7px; padding: 8px 10px; }
  .stage strong { font-size: 12px; }
  .inspector { top: 94px; bottom: auto; right: 12px; left: 12px; width: auto; padding: 12px 14px; max-height: calc(100dvh - 270px - env(safe-area-inset-bottom)); }
  .inspector h2 { font-size: 18px; margin: 5px 0; }
  .inspector p { font-size: 11px; line-height: 1.6; }
  #stageNumber, #status { display: none; }
  #parameterDetails { margin-top: 9px; padding-top: 8px; }
  .controls { grid-template-columns: 1fr; gap: 12px; }
  .control { grid-template-columns: 90px 1fr 44px; }
}
@media (max-height: 520px) and (min-width: 721px) {
  .title { font-size: 24px; } .subtitle { display: none; }
  .panel { max-height: calc(100dvh - 110px); bottom: 14px; }
  .inspector { max-height: calc(100dvh - 144px); bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
