:root {
  color-scheme: dark;
  --ground: #1A1A1A;
  --panel: #262626;
  --raised: #2E2E2E;
  --hairline: #3A3A3A;
  --text: #E6E6E6;
  --secondary: #A3A3A3;
  --accent: #FF3D7F;
  --success: #3FB950;
  --warning: #D29922;
  --error: #F85149;
  --font-ui: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --type-ui: 13px;
  --type-label: 12px;
  --type-meta: 11px;
  --radius: 4px;
  font-family: var(--font-ui);
  font-size: var(--type-ui);
  color: var(--text);
  background: var(--ground);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, output { font: inherit; }
button, input { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; color: var(--secondary); }
button, input { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent); color: var(--ground); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
[hidden] { display: none !important; }
h2, h3, p, dl, dd { margin: 0; }
button { min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius); background: transparent; }
button:hover:not(:disabled) { background: var(--raised); }
button:active:not(:disabled) { background: var(--hairline); }

.editor { height: 100dvh; min-height: 600px; display: grid; grid-template-rows: 44px minmax(0, 1fr) 44px; }
.top-bar { position: relative; display: flex; align-items: center; justify-content: space-between; background: var(--panel); }
.top-bar::after, .bottom-bar::before { content: ''; position: absolute; left: 0; right: 0; height: 1px; background: var(--hairline); pointer-events: none; }
.top-bar::after { bottom: 0; }
.bottom-bar::before { top: 0; }
.photo-name { min-width: 0; padding: 0 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-rail { display: flex; flex-shrink: 0; align-items: center; height: 44px; gap: 4px; padding-right: 8px; }
.action-rail .primary-action { color: var(--ground); background: var(--accent); font-weight: 600; }
.action-rail .primary-action:hover:not(:disabled) { background: var(--accent); filter: brightness(1.1); }
.action-rail .primary-action:active:not(:disabled) { filter: brightness(.9); }
.action-rail .primary-action:disabled { background: var(--raised); color: var(--secondary); }
.primary-action:focus-visible { outline-color: var(--text); outline-offset: -4px; }

.workspace { min-height: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr) 360px; }
.scene-sidebar, .inspector { min-height: 0; min-width: 0; background: var(--panel); }
.scene-sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--hairline); }
.panel-heading { height: 44px; padding: 16px; font-size: var(--type-meta); font-weight: 600; letter-spacing: .08em; line-height: 12px; text-transform: uppercase; color: var(--secondary); }
.layers { min-height: 0; display: flex; flex-direction: column; }
.layer-list { min-height: 0; overflow-y: auto; }
.layer-row { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 64px; padding: 8px 16px; text-align: left; border-radius: 0; }
.layer-thumbnail { width: 48px; height: 48px; flex-shrink: 0; background: var(--ground); border-radius: var(--radius); }
.layer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row.is-selected { background: var(--raised); outline: 1px solid var(--accent); outline-offset: -1px; }
.layer-row.is-selected .layer-thumbnail { outline: 1px solid var(--accent); }
.layer-hint { padding: 12px 16px 20px; color: var(--secondary); font-size: var(--type-label); line-height: 1.5; }
.scene-info { border-top: 1px solid var(--hairline); padding-bottom: 16px; flex-shrink: 0; }
.scene-facts { padding: 0 16px; font-size: var(--type-label); }
.scene-facts div { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.scene-facts dt { color: var(--secondary); }
.scene-facts dd { text-align: right; }
.fact-time:not(:empty) { margin-left: 8px; color: var(--secondary); font-size: var(--type-meta); }
.fact-ready::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--success); }
.local-models { display: block; padding: 16px 16px 0; font-size: var(--type-meta); color: var(--secondary); }

.viewer { min-width: 0; min-height: 0; display: grid; grid-template-rows: 32px minmax(0, 1fr); }
.viewer-toolbar { display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--hairline); color: var(--secondary); font-size: var(--type-label); }
.stage-area { min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.stage-canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; cursor: crosshair; }
.empty-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty-stage p { font-size: var(--type-ui); color: var(--secondary); }
.empty-actions { display: flex; gap: 8px; }
.empty-actions button { background: var(--raised); }
.empty-actions button:hover { background: var(--hairline); }

.inspector { display: flex; flex-direction: column; border-left: 1px solid var(--hairline); }
.scope-heading { flex-shrink: 0; height: 44px; padding: 14px 16px; font-size: var(--type-ui); font-weight: 600; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--hairline); }
.node-stack { flex: 1; min-height: 0; overflow-y: auto; }
.node { border-bottom: 1px solid var(--hairline); }
.node-heading { display: flex; min-height: 44px; align-items: center; }
.node-disclosure { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; text-align: left; font-weight: 600; border-radius: 0; }
.disclosure-icon { flex-shrink: 0; fill: none; stroke: var(--secondary); stroke-width: 1.5; transition: transform 140ms ease-out; }
.node-disclosure[aria-expanded="true"] .disclosure-icon { transform: rotate(90deg); }
.range-row { min-height: 44px; display: grid; grid-template-columns: 96px minmax(0, 1fr) 48px; gap: 8px; align-items: center; padding: 0 16px; font-size: var(--type-label); }
.node[aria-label="Fry"] .range-row { min-height: 48px; }
.range-label { line-height: 1.25; }
.range-value { width: 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--secondary); }
input[type="range"] { appearance: none; width: 100%; min-width: 0; height: 44px; margin: 0; background: transparent; cursor: pointer; border-radius: var(--radius); }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--secondary) 0 var(--fill), var(--hairline) var(--fill) 100%); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%; background: var(--accent); }
input[type="range"]:hover::-webkit-slider-thumb { outline: 2px solid var(--text); outline-offset: 2px; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--hairline); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--secondary); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); }
.node[aria-label="Fry"] input[type="range"] { grid-column: 1 / span 2; grid-row: 1; }
.node[aria-label="Fry"] .range-value { grid-column: 3; grid-row: 1; color: var(--text); font-size: var(--type-ui); }
.node[aria-label="Fry"] input[type="range"]::-webkit-slider-runnable-track { height: 8px; }
.node[aria-label="Fry"] input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -6px; }
.node[aria-label="Fry"] input[type="range"]::-moz-range-track,
.node[aria-label="Fry"] input[type="range"]::-moz-range-progress { height: 8px; }
.node[aria-label="Fry"] input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; }
.enable-switch { width: 52px; height: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.enable-switch input { appearance: none; width: 36px; height: 20px; margin: 0; border: 1px solid var(--secondary); border-radius: 10px; background: var(--ground); cursor: pointer; transition: background-color 140ms ease-out, border-color 140ms ease-out; }
.enable-switch input::before { content: ''; display: block; width: 14px; height: 14px; margin: 2px; border-radius: 50%; background: var(--secondary); transition: transform 140ms ease-out; }
.enable-switch input:checked { border-color: var(--accent); background: var(--accent); }
.enable-switch input:checked::before { background: var(--ground); transform: translateX(16px); }
.enable-switch:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.enable-switch:hover input { border-color: var(--text); }
.object-node { border-bottom: 1px solid var(--hairline); }
.object-heading { height: 40px; padding: 12px 16px; font-size: var(--type-ui); font-weight: 600; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatches { margin: 0; padding: 0 16px 4px; min-width: 0; border: 0; }
.swatch-actions { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.swatch-actions button { padding: 0 8px; }
.swatch-actions button[aria-pressed="true"] { color: var(--text); background: var(--raised); }
.swatch-grid { display: grid; grid-template-columns: repeat(4, minmax(40px, 1fr)); gap: 4px; padding-top: 4px; }
.swatch { min-height: 40px; padding: 0; border: 2px solid transparent; }
.swatch:hover { filter: brightness(1.1); }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.swatch:focus-visible { outline: 2px solid var(--ground); outline-offset: -5px; border-color: var(--accent); }

.bottom-bar { position: relative; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; background: var(--panel); }
.status-line { min-width: 0; padding-left: 16px; line-height: 16px; overflow-wrap: anywhere; }
.mode-rail { display: flex; align-items: center; gap: 4px; padding: 0 16px; }
.mode-rail button { font-size: var(--type-label); }
.mode-rail button[aria-pressed="true"] { color: var(--text); background: var(--raised); outline: 1px solid var(--accent); outline-offset: -1px; }
.build-meta { display: flex; justify-content: flex-end; gap: 12px; padding-right: 16px; color: var(--secondary); white-space: nowrap; }
.build-meta small { font-size: var(--type-meta); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--hairline) var(--panel); }

@media (prefers-reduced-motion: reduce) {
  .enable-switch input::before, .disclosure-icon, .enable-switch input { transition-duration: 0ms; }
}

@media (max-width: 1350px) {
  .workspace { grid-template-columns: 232px minmax(0, 1fr) 336px; }
  .build-meta { gap: 8px; }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 180px minmax(0, 1fr) 312px; }
  .range-row { grid-template-columns: 88px minmax(0, 1fr) 48px; gap: 6px; padding: 0 12px; }
  .build-meta [data-testid="isolation"] { display: none; }
}
