:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --panel-2: #f1f1ed;
  --line: #d7d7d1;
  --line-soft: #e8e8e3;
  --text: #181816;
  --muted: #74746d;
  --acid: #625af6;
  --acid-ink: #ffffff;
  --danger: #ff5b55;
  --radius: 3px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell { height: 100vh; display: grid; grid-template-rows: 58px minmax(0, 1fr) 30px; }
.topbar { -webkit-app-region: drag; display: flex; align-items: center; justify-content: space-between; padding: 0 18px 0 76px; border-bottom: 1px solid var(--line); background: #fffffff2; backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.brand-mark { width: 13px; height: 13px; border: 2px solid var(--acid); transform: rotate(45deg); box-shadow: inset 0 0 0 2px var(--bg); }
.phase-pill { border: 1px solid var(--line); color: var(--muted); font: 600 9px/1 ui-monospace, monospace; letter-spacing: .09em; padding: 5px 7px; margin-left: 6px; }
.lab-link { -webkit-app-region: no-drag; color: var(--muted); text-decoration: none; font: 700 9px/1 ui-monospace, monospace; letter-spacing: .08em; padding: 7px 8px; border-bottom: 1px solid transparent; }
.lab-link:hover, .lab-link.active { color: var(--text); border-bottom-color: var(--acid); }
.top-actions { -webkit-app-region: no-drag; display: flex; gap: 7px; }
.view-actions { display: flex; gap: 3px; padding-right: 5px; border-right: 1px solid var(--line); }
.view-actions .button { padding-left: 9px; padding-right: 9px; }
.view-actions .button.active { color: var(--acid); border-color: #b9b7ee; background: #eeedff; }
.button { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 9px 13px; cursor: pointer; font-size: 12px; font-weight: 700; }
.button:hover:not(:disabled) { border-color: #aaa9a1; background: #e9e9e4; }
.button:focus-visible, .tool:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.button.primary { background: var(--acid); border-color: var(--acid); color: var(--acid-ink); }
.button.primary:hover:not(:disabled) { background: #5148ed; border-color: #5148ed; }
.button.ghost { background: transparent; }
.button.large { padding: 12px 18px; }
.button:disabled { opacity: .32; cursor: not-allowed; }

.workspace { min-height: 0; display: grid; grid-template-columns: 90px minmax(0, 1fr) 292px; }
.toolrail { border-right: 1px solid var(--line); background: var(--panel); padding: 10px 7px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.tool { border: 1px solid transparent; background: transparent; min-height: 70px; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 700; }
.tool:hover { color: var(--text); background: var(--panel-2); }
.tool.active { border-color: #c9c8c1; background: #f5f4ff; color: var(--text); }
.tool-icon { height: 24px; min-width: 28px; display: grid; place-items: center; font: 700 16px/1 ui-monospace, monospace; }
.tool.active .tool-icon { color: var(--acid); }
.tool-icon.dots { letter-spacing: -2px; }
.tool-icon.split { width: 22px; background: linear-gradient(90deg, var(--text) 50%, #52564b 50%); border-radius: 50%; }
.tool-icon.grain { font-size: 24px; }

.stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; background-color: #e9e9e5; background-image: linear-gradient(#deded8 1px, transparent 1px), linear-gradient(90deg, #deded8 1px, transparent 1px); background-size: 24px 24px; }
.empty-state { text-align: center; max-width: 470px; padding: 28px; }
.empty-state h1 { font-size: clamp(44px, 5vw, 76px); line-height: .91; letter-spacing: -.06em; margin: 10px 0 18px; }
.empty-state > p:not(.eyebrow) { color: var(--muted); font-size: 13px; margin: 0 auto 24px; }
.eyebrow { color: var(--acid); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .18em; }
.empty-orbit { width: 64px; height: 64px; margin: 0 auto 25px; border: 1px solid #aaa9a2; border-radius: 50%; display: grid; place-items: center; }
.empty-orbit::before { content: ""; width: 84px; height: 22px; border: 1px solid #aaa9a2; border-radius: 50%; transform: rotate(-22deg); position: absolute; }
.empty-orbit span { width: 9px; height: 9px; background: var(--acid); border-radius: 50%; box-shadow: 0 0 22px var(--acid); }
.canvas-wrap { width: 100%; height: 100%; padding: 28px; display: grid; place-items: center; }
#previewCanvas { max-width: 100%; max-height: 100%; box-shadow: 0 22px 70px #38383033; background: #fff; image-rendering: auto; }
.media-source.offscreen { position: absolute; width: 2px; height: 2px; opacity: .01; pointer-events: none; left: 0; top: 0; }
.drop-overlay { position: absolute; inset: 18px; border: 2px dashed var(--acid); background: #f5f4fff0; color: var(--acid); display: grid; place-items: center; font-size: 28px; font-weight: 800; letter-spacing: -.03em; z-index: 5; }
.render-badge { position: absolute; right: 18px; bottom: 18px; padding: 8px 10px; background: var(--acid); color: var(--acid-ink); font: 800 9px/1 ui-monospace, monospace; letter-spacing: .12em; }
.hidden { display: none !important; }

.inspector { min-height: 0; border-left: 1px solid var(--line); background: var(--panel); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.inspector-heading { padding: 22px 18px 17px; border-bottom: 1px solid var(--line-soft); }
.inspector-heading h2 { margin: 7px 0 6px; font-size: 25px; letter-spacing: -.04em; }
.inspector-heading > p:last-child { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 0; }
.controls { padding: 6px 18px 24px; overflow-y: auto; }
.control { padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.control label { color: #555650; font-size: 11px; font-weight: 700; }
.control output { color: var(--acid); font: 700 10px/1 ui-monospace, monospace; }
input[type="range"] { width: 100%; accent-color: var(--acid); }
input[type="color"] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); background: transparent; }
input[type="checkbox"] { accent-color: var(--acid); width: 16px; height: 16px; }
select, input[type="text"] { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px; color: var(--text); background: var(--panel-2); font-size: 11px; }
.control.inline { display: flex; align-items: center; justify-content: space-between; }
.control.inline .control-row { margin: 0; flex: 1; }
.inspector-placeholder { color: var(--muted); font-size: 11px; line-height: 1.5; padding: 18px 0; }
.inspector-footer { border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; }
.inspector-footer div { padding: 12px 14px; display: flex; justify-content: space-between; gap: 8px; font: 700 8px/1 ui-monospace, monospace; }
.inspector-footer div:first-child { border-right: 1px solid var(--line); }
.inspector-footer span { color: var(--muted); }
.inspector-footer strong { color: var(--acid); }

.statusbar { border-top: 1px solid var(--line); background: #fafaf8; display: flex; align-items: center; padding: 0 12px; gap: 0; color: var(--muted); font: 700 8px/1 ui-monospace, monospace; letter-spacing: .08em; }
.statusbar span { padding: 0 12px; border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statusbar span:first-child { flex: 1; padding-left: 0; }
.statusbar span:last-child { border: 0; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 78px minmax(0, 1fr) 260px; }
  .topbar { padding-left: 68px; }
  .phase-pill { display: none; }
}
