:root {
  --bg: #08090d;
  --panel: #0f1117;
  --panel2: #151823;
  --line: #222636;
  --text: #e6e7ee;
  --dim: #8a8fa6;
  --faint: #5b6078;
  --accent: #a78bfa;
  --rec: #f43f5e;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.35 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; background: #1d2130; border: 1px solid #2c3146; color: var(--dim); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#topbar { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); background: #0b0c12; }
.brand { font-weight: 650; letter-spacing: 0.04em; font-size: 15px; display: flex; align-items: center; gap: 9px; margin-right: 10px; }
.logo { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(from 200deg, #a78bfa, #22d3ee, #4ade80, #f472b6, #fb923c, #a78bfa); box-shadow: 0 0 14px #a78bfa88; }
.spacer { flex: 1; }
.transport { display: flex; align-items: center; gap: 8px; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: #1c2030; border-color: #343a52; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn.primary { background: #2a2350; border-color: #4c3f8f; min-width: 84px; }
.btn.primary.active { background: #3b2f7a; box-shadow: 0 0 16px #a78bfa55; }
.btn.rec { color: #fda4af; }
.btn.rec.active { background: #4c1424; border-color: var(--rec); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 18px #f43f5e88; } }
.rec-time { font-family: var(--mono); color: #fda4af; min-width: 40px; }
.key-badge { background: transparent; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; color: var(--dim); font-size: 12px; }
.key-badge:hover { color: var(--text); border-color: #3a4060; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 250px 1fr 372px; height: calc(100% - 52px); }
#layersPanel { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 12px 10px 24px; }
#controls { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#stage { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 14px; gap: 12px;
  background: radial-gradient(ellipse at 50% 40%, #12142099 0%, transparent 70%), var(--bg); }
.canvas-wrap { position: relative; flex: 1; min-height: 0; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scope-wrap { min-height: 160px; }
.panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); margin: 2px 4px 10px; }
.panel-title.small { margin-top: 20px; }
.empty { color: var(--faint); padding: 8px 4px; }
.empty.pad { padding: 30px 18px; }
.hint { color: var(--faint); font-size: 11.5px; margin-top: 6px; }

/* ---------- layer cards ---------- */
.lc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 8px var(--c, var(--accent)); flex: none; display: inline-block; }
.layer-card { position: relative; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px 7px; margin-bottom: 7px; cursor: pointer; transition: border-color .15s; }
.layer-card:hover { border-color: #33395100; border-color: #343a52; }
.layer-card.selected { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c), 0 0 18px -6px var(--c); }
.layer-card.silent { opacity: 0.5; }
.lc-level { position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--lvl, 0) * 100%); background: var(--c); box-shadow: 0 0 8px var(--c); transition: width .05s; }
.lc-top { display: flex; align-items: center; gap: 7px; }
.lc-name { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-engine { color: var(--faint); font-size: 11px; }
.lc-warn { color: #fbbf24; font-size: 11px; margin: 3px 0 0 16px; }
.lc-bottom { display: flex; align-items: center; gap: 4px; margin-top: 7px; }
.mini { width: 22px; height: 20px; border-radius: 5px; border: 1px solid var(--line); background: #0d0f16; font-size: 10.5px; font-weight: 700; color: var(--dim); padding: 0; }
.mini.on { background: #f59e0b; color: #111; border-color: #f59e0b; }
.mini.solo.on { background: #22d3ee; border-color: #22d3ee; }
.mini.x { margin-left: auto; font-weight: 400; }
.mini.x:hover { color: #fda4af; border-color: #7f1d1d; }
.lc-vol { flex: 1; min-width: 40px; }

.add-btn { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 2px 8px; width: 100%; text-align: left; background: transparent; border: 1px dashed #262b3d; border-radius: 9px; padding: 7px 9px; margin-bottom: 6px; }
.add-btn:hover { border-style: solid; border-color: var(--c); background: #12141d; }
.ab-name { font-weight: 600; }
.ab-blurb { grid-column: 2 / 4; color: var(--faint); font-size: 11.5px; }
#takeBox { margin-top: 8px; }
.take-name { color: var(--dim); margin: 0 4px 6px; font-family: var(--mono); font-size: 12px; }
.take-btns { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- waveform ---------- */
#wavePanel { flex: none; height: 150px; display: flex; flex-direction: column; background: #0c0e15; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; }
.wave-head { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-bottom: 6px; gap: 10px; }
#waveHint { color: var(--faint); text-align: right; }
#wave { cursor: crosshair; touch-action: none; }

#dropHint { position: absolute; inset: 14px; border: 2px dashed #a78bfa; border-radius: 14px; background: #08090dcc; display: none; align-items: center; justify-content: center; text-align: center; font-size: 20px; pointer-events: none; }
#dropHint span { display: block; font-size: 13px; color: var(--dim); margin-top: 6px; }
body.dragging #dropHint { display: flex; }
#toast { position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 10px); background: #1a1d2b; border: 1px solid #2f3550; padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 80%; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- controls panel ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: transparent; border: 0; padding: 11px 0; color: var(--faint); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { overflow-y: auto; flex: 1; padding-bottom: 40px; }
.layer-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 9%, transparent), transparent); }
.lh-row { display: flex; align-items: center; gap: 9px; }
.lh-name { flex: 1; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); font: 600 16px/1.2 inherit; font-family: inherit; padding: 3px 5px; margin-left: -5px; }
.lh-name:hover { border-color: var(--line); }
.lh-name:focus { outline: none; border-color: var(--c); background: #0b0c12; }
.lh-blurb { color: var(--faint); font-size: 12px; margin: 4px 0 10px 18px; }
.lh-btns { display: flex; gap: 6px; margin-left: 18px; }

.ctl-section { border-bottom: 1px solid var(--line); }
.ctl-head { padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.ctl-head:hover { color: var(--text); }
.chev { display: inline-block; transition: transform .15s; font-size: 10px; }
.ctl-section.collapsed .chev { transform: rotate(-90deg); }
.ctl-section.collapsed .ctl-body { display: none; }
.ctl-body { padding: 0 14px 10px; }
.row { display: grid; grid-template-columns: 108px 1fr 62px 20px; align-items: center; gap: 8px; min-height: 28px; }
.row label { color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider-wrap { position: relative; display: flex; align-items: center; }
.live-dot { display: none; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; will-change: transform; border-radius: 50%; background: #fff; box-shadow: 0 0 6px #fff; pointer-events: none; transition: transform .07s linear; }
.num-wrap { display: flex; align-items: center; background: #0b0c12; border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }
.num-wrap:focus-within { border-color: var(--accent); }
.num { width: 100%; min-width: 0; background: transparent; border: 0; color: var(--text); font: 11.5px var(--mono); padding: 3px 0; text-align: right; outline: none; }
.unit { color: var(--faint); font-size: 10px; margin-left: 2px; }
.reset { background: transparent; border: 0; color: var(--dim); padding: 0; font-size: 13px; width: 20px; height: 20px; border-radius: 4px; }
.reset:hover { color: #fff; background: #1d2130; }
.reset.dim { opacity: 0.22; }
.row select { grid-column: 2 / 4; background: #0b0c12; color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font: inherit; }
.row.select > span, .row.toggle > span { display: none; }
.switch { grid-column: 2 / 4; justify-self: start; background: #0b0c12; border: 1px solid var(--line); border-radius: 20px; padding: 3px 14px; font-size: 12px; color: var(--dim); }
.switch.on { background: #2a2350; border-color: var(--accent); color: #fff; }
.row.actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.row.file { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 2px 0 8px; }
.file-name b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name span { color: var(--faint); font-size: 12px; }
.file-name .warn { color: #fbbf24; }
.file-btns { display: flex; gap: 6px; }
.master-extra { padding: 14px; }

/* range inputs */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) calc(var(--t, 0) * 100%), #2a2f43 calc(var(--t, 0) * 100%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #e9e6ff; margin-top: -5px; border: 0; box-shadow: 0 0 0 3px #a78bfa33; }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: #2a2f43; }
input[type=range]::-moz-range-progress { height: 3px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #e9e6ff; border: 0; }
.lc-vol::-webkit-slider-runnable-track { background: #2a2f43; }
.lc-vol::-webkit-slider-thumb { width: 10px; height: 10px; margin-top: -3.5px; background: var(--c); box-shadow: none; }

/* help */
#help { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 10; }
.help-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 24px 20px; width: min(560px, 92vw); max-height: 86vh; overflow: auto; }
.help-card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); margin: 12px 0 10px; }
.help-card td { padding: 4px 14px 4px 0; vertical-align: top; }
.help-card li { margin-bottom: 6px; color: #c9cbd8; }
.help-card .close { position: absolute; top: 12px; right: 12px; }

::-webkit-scrollbar { width: 9px; } ::-webkit-scrollbar-thumb { background: #232838; border-radius: 9px; } ::-webkit-scrollbar-track { background: transparent; }

#wavePanel.env-view { height: 190px; }
#wavePanel.env-view #wave { cursor: default; }
