* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg-app); color: var(--fg1); font-family: var(--font-ui); }
button, input, select, textarea { font: inherit; }
button { min-height: 34px; padding: 0 12px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); color: var(--fg3); background: transparent; cursor: pointer; transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
button:hover:not(:disabled) { color: var(--fg1); background: var(--white-a05); border-color: var(--white-a25); }
button:disabled { opacity: .4; cursor: not-allowed; }
button[aria-busy="true"]:disabled { display: inline-flex; align-items: center; justify-content: center; gap: 8px; opacity: .82; }
button.primary { color: var(--on-brand); background: var(--teal); border-color: var(--teal); font-weight: 600; }
button.primary:hover:not(:disabled) { color: var(--gray-131); background: var(--teal-bright); }
button.selected { color: var(--teal-bright); border-color: var(--teal-a50); background: var(--teal-a10); }
h1, h2, p { margin: 0; }
h1 { margin-top: 5px; font-size: 20px; letter-spacing: -.02em; }
h2 { margin-top: 3px; font-size: var(--fs-pane); }
.eyebrow { color: var(--fg-muted); font: 600 11px/1.2 var(--font-ui); text-transform: uppercase; letter-spacing: var(--ls-label); }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border-hair); }
.header-actions, .button-row { display: flex; align-items: center; gap: 8px; }
.workspace { display: grid; grid-template-columns: 310px minmax(560px, 1fr) 370px; height: calc(100vh - 82px); }
.workspace.comparing { grid-template-columns: 260px minmax(460px, 1fr) minmax(620px, 45vw); transition: grid-template-columns var(--dur-pane) var(--ease); }
.scene-pane, .inspector-pane { min-width: 0; overflow: auto; border-right: 1px solid var(--border-hair); }
.inspector-pane { border-right: 0; border-left: 1px solid var(--border-hair); }
.pane-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 8px 22px; border-bottom: 1px solid var(--border-hair); }
.state { color: var(--fg-muted); font: 11px/1 var(--font-mono); border: 1px solid var(--border-hair); border-radius: var(--r-full); padding: 5px 9px; }
.state.pass { color: var(--approved); border-color: color-mix(in oklab, var(--approved) 35%, transparent); }
.state.warning { color: var(--contender); border-color: color-mix(in oklab, var(--contender) 35%, transparent); }
.warning-section, .elements-section, #selected-controls, .camera-section, .generation-section { padding: 18px 22px; border-bottom: 1px solid var(--border-hair); }
.warning-section ul { margin: 10px 0 0; padding-left: 17px; color: var(--contender); font-size: 11px; line-height: 1.5; }
.element-row { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: space-between; border: 0; border-bottom: 1px solid var(--border-hair); border-radius: 0; text-align: left; }
.element-row strong { display: block; color: var(--fg2); font-size: 12.5px; }
.element-row small { color: var(--fg-muted); font: 10.5px/1.4 var(--font-mono); }
.element-row.sel { background: var(--teal-a10); box-shadow: inset 2px 0 0 var(--teal); }
.section-label { margin: 16px 0 8px; color: var(--fg-muted); font: 600 10px/1 var(--font-ui); text-transform: uppercase; letter-spacing: var(--ls-label); }
.stage-pane { min-width: 0; min-height: 0; position: relative; background: var(--gray-1d); }
#world { position: absolute; inset: 50% auto auto 50%; display: block; max-width: 100%; max-height: 100%; transform: translate(-50%, -50%); }
.stage-toolbar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; background: rgba(19,19,19,.86); border-bottom: 1px solid var(--border-hair); }
.stage-toolbar button { min-height: 30px; font-size: 11px; }
#loading { position: absolute; z-index: 4; inset: 52px 0 38px; display: grid; place-items: center; color: var(--fg3); background: var(--gray-1d); font-size: 13px; }
#loading[hidden] { display: none; }
.loading-state { width: min(420px, calc(100% - 48px)); }
#loading-phase { margin-top: 9px; color: var(--fg2); font-size: 13px; }
.loading-track { height: 4px; margin-top: 18px; overflow: hidden; background: var(--white-a10); border-radius: var(--r-full); }
#loading-progress-fill { display: block; width: 0; height: 100%; background: var(--teal); border-radius: inherit; transition: width var(--dur-fast) var(--ease); }
#loading-detail { margin-top: 10px; color: var(--fg-muted); font-size: 11px; }
#loading[data-error-code] #loading-phase, #loading[data-error-code] #loading-detail { color: var(--rejected); }
#loading[data-error-code] #loading-progress-fill { background: var(--rejected); }
.stage-readout { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; min-height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; color: var(--fg-muted); background: rgba(19,19,19,.9); border-top: 1px solid var(--border-hair); font: 11px/1 var(--font-mono); }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stack { display: grid; gap: 11px; }
.field-grid label, .stack label, .generation-section label { display: block; color: var(--fg-muted); font-size: 10.5px; }
input, select, textarea { width: 100%; border: 1px solid var(--border-hair); border-radius: var(--r-sm); background: var(--white-a05); color: var(--fg1); outline: 0; }
input, select { height: 34px; padding: 0 9px; margin-top: 5px; }
textarea { padding: 10px; margin-top: 7px; resize: vertical; font: 11px/1.45 var(--font-mono); }
input:focus, select:focus, textarea:focus { border-color: var(--white-a25); background: var(--bg-focus); }
.check { display: flex !important; align-items: center; gap: 7px; color: var(--fg3) !important; font-size: 11px; }
.check input { width: 15px; height: 15px; margin: 0; }
.joint-note, .note { margin-top: 9px; color: var(--fg-faint); font: 10px/1.45 var(--font-mono); }
.camera-section > .eyebrow, .generation-section > .eyebrow { margin-bottom: 12px; }
.generation-section button { width: 100%; margin-top: 9px; }
.renderer-buttons { display: grid; gap: 0; margin-top: 8px; }
.operation-status { display: grid; gap: 7px; margin-top: 9px; padding: 9px 0; border-top: 1px solid var(--border-hair); border-bottom: 1px solid var(--border-hair); }
.operation-status[hidden] { display: none; }
.operation-entry { display: flex; align-items: flex-start; gap: 8px; color: var(--fg2); font: 11px/1.35 var(--font-ui); }
.operation-entry > span:last-child { min-width: 0; }
.operation-entry strong, .operation-entry small { display: block; }
.operation-entry small { margin-top: 2px; color: var(--fg-muted); font: 9.5px/1.35 var(--font-mono); }
.operation-entry[data-state="error"] strong, .operation-status[data-state="error"] { color: var(--rejected); }
.operation-entry[data-state="success"] .operation-mark { background: var(--approved); }
.operation-spinner, .operation-mark { flex: 0 0 auto; width: 12px; height: 12px; margin-top: 1px; border-radius: var(--r-full); }
.operation-spinner { border: 1.5px solid currentColor; border-top-color: transparent; animation: operation-spin 800ms linear infinite; }
.operation-mark { width: 7px; height: 7px; margin: 4px 3px 0 2px; background: var(--fg-muted); }
.readiness-note { margin-top: 7px; color: var(--fg-muted); font: 9.5px/1.4 var(--font-mono); }
.readiness-note[data-state="ready"] { color: var(--approved); }
.readiness-note[data-state="error"], #provider-note[data-state="error"] { color: var(--rejected); }
.video-wait-controls { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 8px; margin-top: 10px; }
.video-wait-controls select { margin-top: 5px; }
.video-wait-controls button { margin-top: 0; }
.video-wait-controls button[hidden] { display: none; }
.background-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.background-compare button.selected { color: var(--teal-bright); background: var(--teal-a10); box-shadow: inset 2px 0 0 var(--teal); }
.generation-section label:not(:first-of-type) { margin-top: 18px; }
.output { margin-top: 10px; padding: 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--white-a05); }
.candidate-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.candidate-list.empty { padding: 10px; color: var(--fg-faint); border: 1px solid var(--border-hair); border-radius: var(--r-md); font-size: 11px; }
.candidate-card { padding: 10px; border: 1px solid var(--border-hair); border-radius: var(--r-md); background: var(--white-a05); }
.candidate-card.selected { border-color: var(--teal-a50); background: var(--teal-a10); box-shadow: inset 2px 0 0 var(--teal); }
.candidate-card header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--fg2); font-size: 11px; }
.candidate-card img, .candidate-card video { display: block; width: 100%; border-radius: var(--r-sm); }
.candidate-card code { display: block; margin-top: 7px; overflow: hidden; color: var(--fg-muted); font: 9px/1.4 var(--font-mono); text-overflow: ellipsis; }
.candidate-card .media-link { display: block; margin-top: 8px; color: var(--teal-bright); font-size: 10px; }
.candidate-card button { min-height: 28px; margin-top: 7px; font-size: 10px; }
.candidate-card.failed { color: var(--rejected); border-color: color-mix(in oklab, var(--rejected) 35%, transparent); }
.candidate-card.failed p { font-size: 11px; line-height: 1.45; }
.candidate-card.pending { color: var(--fg-muted); }
.identity-gate { display: grid; gap: 6px; margin-top: 8px; padding: 8px; border: 1px solid var(--border-hair); border-radius: var(--r-sm); font-size: 10px; }
.identity-gate strong, .identity-gate span { display: block; }
.identity-gate ul { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.identity-gate li { display: flex; justify-content: space-between; gap: 8px; }
.identity-gate.pass { color: var(--approved); border-color: color-mix(in oklab, var(--approved) 35%, transparent); }
.identity-gate.blocked { color: var(--rejected); border-color: color-mix(in oklab, var(--rejected) 35%, transparent); }
.identity-gate .approved-copy { color: var(--approved); font: 9px/1.4 var(--font-mono); }
.candidate-card details { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border-hair); }
.candidate-card summary { color: var(--fg-muted); cursor: pointer; font-size: 10px; }
.candidate-card details small { display: block; margin-top: 7px; color: var(--fg-faint); font-size: 9px; }
.candidate-card .prompt-copy { max-height: 120px; overflow: auto; white-space: pre-wrap; text-overflow: clip; }
.output.empty { color: var(--fg-faint); font-size: 11px; }
.output.error { color: var(--rejected); border-color: color-mix(in oklab, var(--rejected) 35%, transparent); font-size: 11px; }
.output img, .output video { display: block; width: 100%; border-radius: var(--r-sm); }
.output code { display: block; margin-top: 7px; overflow: hidden; color: var(--fg-muted); font: 9px/1.4 var(--font-mono); text-overflow: ellipsis; }
@keyframes operation-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .operation-spinner { animation: none; } }
@media (max-width: 1200px) { .workspace { grid-template-columns: 275px minmax(480px, 1fr) 330px; } }
@media (max-width: 1500px) { .workspace.comparing { grid-template-columns: 220px minmax(430px, 1fr) 620px; } }
@media (max-width: 1200px) {
  .workspace.comparing { grid-template-columns: minmax(400px, 1fr) minmax(520px, 55vw); }
  .workspace.comparing .scene-pane { display: none; }
}
