:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #09100e;
  color: #eff9f2;
  --green: #7dff9f;
  --muted: #8ca399;
  --panel: rgba(16, 29, 25, 0.94);
  --line: rgba(173, 218, 188, 0.14);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 30% 10%, #173329 0, #09100e 46%); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: minmax(0, 1fr) 350px; align-items: start; gap: 18px; height: 100dvh; padding: 18px; overflow: hidden; }
.stage-card, .control-card { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.stage-card { display: grid; grid-template-rows: auto auto minmax(180px, 1fr) auto auto; gap: 10px; height: calc(100dvh - 36px); min-height: 0; padding: 18px 22px; overflow: hidden; }
.stage-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.03em; }
h1 { font-size: 26px; } h2 { font-size: 23px; }
.device-pill { border: 1px solid var(--line); background: rgba(0,0,0,.18); border-radius: 99px; padding: 9px 13px; color: #c6d8ce; font-size: 12px; }
.device-pill span { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 11px var(--green); }

.canvas-wrap { position: relative; min-height: 0; overflow: hidden; border-radius: 15px; border: 1px solid var(--line); background: #10251c; }
canvas { display: block; width: 100%; height: 100%; }
.target-badge { position: absolute; left: 18px; bottom: 18px; padding: 8px 12px; border-radius: 8px; background: rgba(6, 15, 12, .75); border: 1px solid rgba(255,255,255,.12); font-size: 12px; backdrop-filter: blur(8px); }
.distance-scale { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); color: rgba(239,249,242,.55); font-size: 11px; letter-spacing: .08em; }

.section-view-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-height: 0; }
.section-view-card { min-width: 0; padding: 8px; border: 1px solid rgba(173,218,188,.22); border-radius: 12px; background: rgba(6,15,12,.76); }
.section-view-card header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 12px; align-items: baseline; margin-bottom: 9px; }
.section-view-card header strong { font-size: 13px; font-weight: 650; }
.section-view-card header span { color: var(--muted); font-size: 10px; text-align: right; }
.section-canvas-wrap { height: clamp(105px, 14vh, 140px); overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #0b1b16; }

.playback-bar { display: grid; grid-template-columns: 80px 1fr 58px; align-items: center; gap: 12px; }
.ghost-button { color: #d8e9dd; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.ghost-button:disabled { opacity: .35; cursor: default; }
.timeline { height: 4px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.timeline div { width: 0; height: 100%; background: var(--green); box-shadow: 0 0 8px var(--green); }
#timeReadout { color: var(--muted); text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }

.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.scene-metrics { padding: 7px; border: 1px solid rgba(173,218,188,.2); border-radius: 11px; background: rgba(6,15,12,.72); }
.metric-grid article { padding: 13px; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 10px; }
.metric-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.metric-grid strong { font-size: 16px; font-weight: 620; white-space: nowrap; }

.control-card { height: calc(100dvh - 36px); min-height: 0; padding: 24px; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
.control-heading > p:last-child { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 10px 0 20px; }
.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 20px; }
.preset { padding: 8px 4px; color: var(--muted); border: 1px solid var(--line); background: transparent; border-radius: 7px; font-size: 11px; }
.preset.active { color: #07130c; background: var(--green); border-color: var(--green); font-weight: 700; }
form { display: grid; gap: 12px; }
label { position: relative; display: grid; grid-template-columns: 1fr 76px; align-items: center; color: #dcebe1; font-size: 13px; }
label span { position: absolute; right: 84px; color: #64796e; font-size: 10px; }
.parameter-tip-button { position: absolute; right: 166px; width: 20px; height: 20px; padding: 0; color: var(--green); background: rgba(125,255,159,.06); border: 1px solid rgba(125,255,159,.32); border-radius: 50%; font-size: 11px; font-weight: 800; line-height: 18px; }
.parameter-tip-button:hover, .parameter-tip-button:focus-visible, .parameter-tip-button[aria-expanded="true"] { color: #07130c; background: var(--green); outline: none; }
.parameter-tip { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; padding: 10px 11px; color: #dcebe1; background: #10231c; border: 1px solid rgba(125,255,159,.35); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,.42); font-size: 11px; line-height: 1.55; }
input { width: 76px; padding: 8px; color: #eff9f2; text-align: right; background: #0a1512; border: 1px solid var(--line); border-radius: 7px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(125,255,159,.1); }
textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(125,255,159,.1); outline: none; }
details { margin-top: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { color: var(--muted); font-size: 12px; margin-bottom: 10px; cursor: pointer; }
details label + label { margin-top: 10px; }
.launch-button { margin-top: 7px; padding: 13px; color: #07130c; background: var(--green); border: 0; border-radius: 9px; font-weight: 800; box-shadow: 0 8px 24px rgba(85,255,132,.15); }
.launch-button:hover { filter: brightness(1.06); }

.json-injection { margin-top: 16px; }
.json-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.json-injection textarea { width: 100%; resize: vertical; padding: 9px; color: #eff9f2; background: #0a1512; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; line-height: 1.4; }
.json-actions { display: grid; grid-template-columns: 1fr 100px; gap: 7px; margin-top: 8px; }
.json-actions .launch-button { margin-top: 0; padding: 8px; }
.validation-errors { margin-top: 10px; padding: 9px 11px; color: #ffb5aa; background: rgba(255, 128, 108, .08); border: 1px solid rgba(255, 128, 108, .28); border-radius: 7px; font-size: 11px; }
.validation-errors ul { margin: 0; padding-left: 16px; }
.validation-errors li + li { margin-top: 4px; }

.diagnostic-panel { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(125,255,159,.035); }
.diagnostic-panel h3 { margin: 0 0 7px; font-size: 13px; }
.diagnostic-panel > p { margin: 0 0 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.diagnostic-panel dl { display: grid; gap: 5px; margin: 0; }
.diagnostic-panel dl div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; font-size: 10px; }
.diagnostic-panel dt { color: var(--muted); }
.diagnostic-panel dd { margin: 0; color: #c9ddd0; overflow-wrap: anywhere; }

.event-log { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 9px; }
.event-log div { display: flex; justify-content: space-between; gap: 12px; }
.event-log span { color: var(--muted); font-size: 11px; }
.event-log code { overflow: hidden; color: #c9ddd0; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

@media (max-height: 760px) {
  .stage-card { padding-block: 12px; gap: 7px; }
  .stage-header { margin-bottom: 4px; }
  .section-canvas-wrap { height: 96px; }
  .control-card { padding: 18px 22px; }
  form { gap: 8px; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; padding: 12px; overflow: visible; }
  .stage-card { grid-template-rows: auto auto minmax(360px, 52vh) auto auto; height: auto; overflow: visible; }
  .control-card { width: 100%; height: auto; max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; }
}

@media (max-width: 640px) {
  .app-shell { padding: 8px; gap: 10px; }
  .stage-card, .control-card { padding: 14px; border-radius: 14px; }
  .stage-header { align-items: flex-start; gap: 12px; }
  .device-pill { padding: 7px 9px; white-space: nowrap; }
  .stage-card { grid-template-rows: auto auto 340px auto auto; }
  .control-card { max-height: calc(100dvh - 16px); }
  .canvas-wrap { min-height: 0; }
  .scene-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .section-view-grid { grid-template-columns: minmax(0, 1fr); }
  .section-canvas-wrap { height: 190px; }
  .metric-grid article { padding: 8px; }
  .metric-grid strong { font-size: 13px; }
  .parameter-tip-button { right: 166px; }
  .playback-bar { grid-template-columns: 72px minmax(0, 1fr) 50px; gap: 8px; }
}
