:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --bg: #0d1016;
  --surface-0: #11141b;
  --surface-1: #151a23;
  --surface-2: #1b212d;
  --surface-3: #222a38;
  --surface-4: #2b3546;
  --border: #2b3442;
  --border-soft: #202735;
  --text: #edf3f8;
  --text-muted: #8c99a9;
  --text-faint: #5e6979;
  --accent: #70e7cf;
  --accent-2: #738dff;
  --accent-soft: rgba(112, 231, 207, 0.14);
  --selection: rgba(111, 140, 255, 0.26);
  --selection-border: rgba(132, 157, 255, 0.9);
  --danger: #ff6584;
  --warning: #ffc76a;
  --success: #65e6aa;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --track-height: 112px;
  --ruler-height: 34px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #e8edf3;
  --surface-0: #f8fafc;
  --surface-1: #f0f4f8;
  --surface-2: #e8edf4;
  --surface-3: #dce3ec;
  --surface-4: #cfd9e5;
  --border: #c4cfdb;
  --border-soft: #d7dfe8;
  --text: #18212c;
  --text-muted: #5f6c7b;
  --text-faint: #8793a1;
  --accent: #0b9d83;
  --accent-2: #4b64db;
  --accent-soft: rgba(11, 157, 131, 0.12);
  --selection: rgba(75, 100, 219, 0.18);
  --selection-border: rgba(75, 100, 219, 0.85);
  --danger: #d9375b;
  --warning: #b16c04;
  --success: #168c61;
  --shadow: 0 20px 55px rgba(61, 75, 91, 0.24);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
button:disabled { opacity: 0.42; cursor: not-allowed; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell {
  display: grid;
  grid-template-rows: 58px 32px 74px minmax(0, 1fr) 28px;
  width: 100%;
  height: 100%;
  min-width: 980px;
  background: var(--bg);
}

.titlebar {
  display: grid;
  grid-template-columns: 250px minmax(260px, 1fr) 250px;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  user-select: none;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: flex; gap: 3px; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--surface-3), var(--surface-1));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px rgba(255,255,255,0.06);
}
.brand-mark span { display: block; width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.brand-mark span:nth-child(1) { height: 10px; }
.brand-mark span:nth-child(2) { height: 18px; }
.brand-mark span:nth-child(3) { height: 25px; }
.brand-mark span:nth-child(4) { height: 17px; }
.brand-mark span:nth-child(5) { height: 11px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-copy strong { font-size: 15px; letter-spacing: 0.01em; }
.brand-copy small { margin-top: 5px; font-size: 8px; letter-spacing: 0.2em; color: var(--text-muted); }

.project-heading { justify-self: center; text-align: center; min-width: 260px; max-width: 560px; width: 70%; }
.project-name {
  width: 100%; border: 0; border-radius: 6px; background: transparent; color: var(--text); text-align: center; font-weight: 650; font-size: 14px;
  padding: 4px 9px; transition: background .15s ease;
}
.project-name:hover, .project-name:focus { background: var(--surface-2); }
.save-status { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px color-mix(in srgb, var(--success), transparent 35%); }
.save-status.saving .status-dot { background: var(--warning); }
.save-status.error .status-dot { background: var(--danger); }

.title-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.icon-button, .privacy-pill, .menu-button, .tool-button, .mini-button, .compact-button, .button, .track-button {
  border: 1px solid transparent; background: transparent; cursor: pointer; user-select: none;
}
.icon-button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: var(--text-muted); font-weight: 700; }
.icon-button:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.privacy-pill { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 18px; color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent), transparent 65%); font-size: 11px; font-weight: 650; }
.privacy-icon { font-size: 8px; }

.menubar { display: flex; align-items: center; padding: 0 9px; background: var(--surface-0); border-bottom: 1px solid var(--border); user-select: none; position: relative; z-index: 20; }
.menu-wrap { height: 100%; position: relative; display: flex; align-items: center; }
.menu-button { height: 26px; min-width: 51px; padding: 0 10px; border-radius: 5px; color: var(--text-muted); font-size: 12px; }
.menu-button:hover, .menu-button.open { color: var(--text); background: var(--surface-2); }
.menu-spacer { flex: 1; }
.sample-rate-badge { display: flex; gap: 11px; align-items: center; font-size: 9px; letter-spacing: .06em; color: var(--text-faint); padding-right: 6px; }
.sample-rate-badge span:first-child { color: var(--text-muted); }
.dropdown-menu {
  position: absolute; display: none; top: 29px; left: 0; min-width: 250px; padding: 6px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); box-shadow: var(--shadow); z-index: 100; max-height: calc(100vh - 130px); overflow-y: auto;
}
.dropdown-menu.open { display: block; }
.dropdown-menu.tall { min-width: 235px; }
.dropdown-menu button { display: flex; justify-content: space-between; align-items: center; gap: 22px; width: 100%; min-height: 31px; padding: 6px 9px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); cursor: pointer; text-align: left; font-size: 12px; }
.dropdown-menu button:hover { background: var(--surface-3); color: var(--text); }
.dropdown-menu kbd { color: var(--text-faint); font-size: 9px; font-family: inherit; }
.menu-separator { height: 1px; background: var(--border); margin: 5px 4px; }

.transport { display: flex; align-items: center; gap: 13px; padding: 9px 12px; background: linear-gradient(180deg, var(--surface-1), var(--surface-0)); border-bottom: 1px solid var(--border); user-select: none; }
.tool-group { display: flex; align-items: center; gap: 4px; }
.tool-button {
  min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 8px; border-radius: 7px; border-color: var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 12px; box-shadow: inset 0 1px rgba(255,255,255,.025);
}
.tool-button:hover { background: var(--surface-3); color: var(--text); }
.tool-button.primary { width: 44px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent-2), var(--surface-2) 70%), var(--surface-2)); color: #fff; border-color: color-mix(in srgb, var(--accent-2), var(--border) 55%); }
.tool-button.primary.playing { background: linear-gradient(145deg, var(--accent-2), color-mix(in srgb, var(--accent-2), black 25%)); }
.tool-button.record { color: var(--danger); }
.tool-button.record.recording { background: color-mix(in srgb, var(--danger), var(--surface-2) 72%); color: #fff; animation: recordPulse 1.3s infinite; }
.tool-button.toggle.active, .tool-button.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent), transparent 58%); }
.tool-divider { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }
@keyframes recordPulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger), transparent 78%); } }
.transport-readout { width: 122px; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--border); background: #080b10; font-variant-numeric: tabular-nums; }
[data-theme="light"] .transport-readout { background: #fff; }
.transport-readout span { display: block; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .02em; }
.transport-readout small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-faint); font-size: 9px; margin-top: 3px; }
.mode-switch { margin-left: auto; }
.meter-bank { display: grid; grid-template-columns: 12px 92px; gap: 3px 5px; align-items: center; }
.meter-label { color: var(--text-faint); font-size: 8px; }
.meter-track { height: 7px; border-radius: 5px; overflow: hidden; background: #080b10; border: 1px solid var(--border-soft); }
.meter-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--warning) 78%, var(--danger)); transition: width .04s linear; }
.master-volume { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-faint); font-size: 8px; letter-spacing: .08em; }
.master-volume input { width: 92px; accent-color: var(--accent); }

.workspace { min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr) 250px; background: var(--bg); }
.track-panel, .inspector { min-width: 0; background: var(--surface-0); overflow: hidden; display: flex; flex-direction: column; }
.track-panel { border-right: 1px solid var(--border); }
.inspector { border-left: 1px solid var(--border); }
.panel-heading { min-height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 12px; background: var(--surface-1); border-bottom: 1px solid var(--border); user-select: none; }
.panel-heading > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.panel-heading span { color: var(--text-muted); font-size: 9px; font-weight: 750; letter-spacing: .13em; }
.panel-heading small { color: var(--text-faint); font-size: 9px; }
.panel-actions { display: flex; gap: 4px; }
.mini-button { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 5px; border-color: var(--border); background: var(--surface-2); color: var(--text-muted); }
.mini-button:hover { color: var(--text); background: var(--surface-3); }
.track-list { flex: 1; min-height: 0; overflow-y: auto; }
.empty-tracks { height: 100%; min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; color: var(--text-faint); padding: 22px; }
.empty-tracks strong { color: var(--text-muted); font-size: 12px; }
.empty-tracks span { font-size: 10px; line-height: 1.5; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; border: 1px dashed var(--border); font-size: 24px; color: var(--accent); }
.track-card { height: var(--track-height); padding: 9px; border-bottom: 1px solid var(--border-soft); background: var(--surface-0); cursor: pointer; user-select: none; position: relative; }
.track-card:hover { background: var(--surface-1); }
.track-card.selected { background: linear-gradient(90deg, var(--accent-soft), var(--surface-0) 75%); box-shadow: inset 3px 0 var(--accent); }
.track-card-top { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 7px; }
.track-number { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); font-size: 9px; font-weight: 700; }
.track-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 11px; font-weight: 620; }
.track-duration { color: var(--text-faint); font-size: 8px; font-variant-numeric: tabular-nums; }
.track-controls { display: grid; grid-template-columns: 24px 24px 24px 1fr; gap: 4px; align-items: center; margin-top: 9px; }
.track-button { width: 24px; height: 22px; display: grid; place-items: center; border-radius: 4px; border-color: var(--border); color: var(--text-faint); background: var(--surface-1); font-size: 8px; font-weight: 750; }
.track-button:hover { color: var(--text); background: var(--surface-3); }
.track-button.on { color: #0c1714; background: var(--accent); border-color: var(--accent); }
.track-button.mute.on { color: #201305; background: var(--warning); border-color: var(--warning); }
.track-button.arm.on { color: #fff; background: var(--danger); border-color: var(--danger); }
.mini-fader { display: grid; grid-template-columns: 15px 1fr; align-items: center; gap: 4px; color: var(--text-faint); font-size: 8px; }
.mini-fader input { width: 100%; accent-color: var(--accent); }
.track-pan-row { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--text-faint); font-size: 8px; }
.track-pan-row input { flex: 1; min-width: 0; accent-color: var(--accent-2); }

.timeline-section { min-width: 0; min-height: 0; position: relative; display: grid; grid-template-rows: 42px minmax(0, 1fr) 26px; background: var(--surface-1); }
.timeline-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--surface-0); user-select: none; }
.timeline-tools-left, .timeline-tools-right { display: flex; align-items: center; gap: 7px; }
.compact-button { height: 25px; min-width: 28px; padding: 0 8px; border-radius: 5px; border-color: var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 10px; }
.compact-button:hover { color: var(--text); background: var(--surface-3); }
.timeline-toolbar input[type="range"] { width: 130px; accent-color: var(--accent-2); }
.zoom-label { width: 56px; color: var(--text-faint); font-size: 8px; font-variant-numeric: tabular-nums; }
.check-control { display: flex; gap: 4px; align-items: center; color: var(--text-faint); font-size: 9px; }
.check-control input { accent-color: var(--accent); }
.timeline-viewport { min-height: 0; overflow: auto; position: relative; background: var(--surface-1); overscroll-behavior: contain; }
#timelineCanvas { display: block; width: 100%; min-height: 100%; cursor: crosshair; }
.timeline-viewport.move-mode #timelineCanvas { cursor: ew-resize; }
.drop-overlay { position: absolute; inset: 51px 12px 36px; z-index: 15; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--surface-0), transparent 10%); color: var(--accent); font-weight: 700; box-shadow: var(--shadow); pointer-events: none; }
.drop-overlay[hidden] { display: none; }
.timeline-scroll-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 7px; align-items: center; padding: 0 7px; border-top: 1px solid var(--border); background: var(--surface-0); color: var(--text-faint); font-size: 8px; font-variant-numeric: tabular-nums; }
.timeline-scroll-row input { width: 100%; accent-color: var(--accent-2); }
.timeline-scroll-row span:last-child { text-align: right; }

.inspector-content { padding: 12px; border-bottom: 1px solid var(--border); overflow-y: auto; max-height: 55%; }
.inspector-placeholder { min-height: 180px; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; text-align: center; color: var(--text-faint); font-size: 10px; line-height: 1.5; }
.inspector-placeholder div { color: var(--accent); font-size: 26px; }
.inspector-form { display: grid; gap: 13px; }
.inspector-form .field { display: grid; gap: 6px; }
.inspector-form label, .form-field label { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 9px; letter-spacing: .05em; }
.inspector-form input[type="text"], .inspector-form input[type="number"], .form-field input, .form-field select, .form-field textarea {
  width: 100%; min-height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: var(--surface-2); color: var(--text); }
.inspector-form input[type="range"], .form-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.value-badge { color: var(--accent); font-variant-numeric: tabular-nums; }
.inspector-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 4px; }
.button { min-height: 34px; padding: 7px 11px; border-radius: 6px; border-color: var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 10px; font-weight: 650; }
.button:hover { color: var(--text); background: var(--surface-3); }
.button.primary { color: #08110f; background: var(--accent); border-color: var(--accent); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger), transparent 55%); }
.button.ghost { background: transparent; }
.marker-panel { flex: 1; min-height: 0; padding: 11px; overflow: hidden; display: flex; flex-direction: column; }
.subheading { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 9px; letter-spacing: .11em; font-weight: 750; }
.marker-list { overflow-y: auto; margin-top: 8px; display: grid; gap: 4px; }
.marker-row { display: grid; grid-template-columns: 45px minmax(0, 1fr) 22px; gap: 5px; align-items: center; min-height: 28px; padding: 3px 4px 3px 7px; border: 1px solid var(--border-soft); border-radius: 5px; background: var(--surface-1); color: var(--text-muted); font-size: 9px; cursor: pointer; }
.marker-row:hover { border-color: var(--border); background: var(--surface-2); }
.marker-time { color: var(--accent-2); font-variant-numeric: tabular-nums; }
.marker-delete { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.marker-delete:hover { color: var(--danger); }
.muted { color: var(--text-faint); font-size: 9px; }

.statusbar { display: flex; align-items: center; gap: 17px; padding: 0 10px; border-top: 1px solid var(--border); background: var(--surface-0); color: var(--text-muted); font-size: 9px; user-select: none; }
.status-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-label { color: var(--text-faint); font-size: 8px; letter-spacing: .08em; }
.status-spacer { flex: 1; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.mode-dot.full { background: var(--success); }
.mode-dot.basic { background: var(--warning); }
.private-status { color: var(--accent); }

.modal-backdrop { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 24px; background: rgba(3, 5, 8, 0.72); backdrop-filter: blur(7px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px, calc(100vw - 48px)); max-height: min(760px, calc(100vh - 48px)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-1); box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { width: min(840px, calc(100vw - 48px)); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface-0); }
.modal-header h2 { margin: 2px 0 0; font-size: 17px; }
.modal-kicker { color: var(--accent); font-size: 8px; letter-spacing: .17em; font-weight: 750; }
.modal-body { overflow-y: auto; padding: 18px; color: var(--text-muted); font-size: 12px; line-height: 1.55; }
.modal-body p:first-child { margin-top: 0; }
.modal-body h3 { color: var(--text); font-size: 12px; margin: 20px 0 8px; }
.modal-body code { padding: 2px 5px; border-radius: 4px; background: var(--surface-3); color: var(--accent); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-0); }
.form-grid { display: grid; gap: 14px; }
.form-field { display: grid; gap: 7px; }
.form-field small { color: var(--text-faint); }
.form-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { accent-color: var(--accent); }
.capability-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.capability-card { border: 1px solid var(--border); border-radius: 7px; padding: 10px; background: var(--surface-2); }
.capability-card strong { display: block; color: var(--text); font-size: 10px; }
.capability-card span { display: block; margin-top: 4px; color: var(--text-faint); font-size: 9px; }
.capability-card.ok { border-color: color-mix(in srgb, var(--success), transparent 55%); }
.capability-card.warn { border-color: color-mix(in srgb, var(--warning), transparent 55%); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-card { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.stat-card span { display: block; color: var(--text-faint); font-size: 8px; letter-spacing: .08em; }
.stat-card strong { display: block; margin-top: 4px; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 7px 18px; align-items: center; }
.shortcuts kbd { padding: 3px 7px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--text); font-size: 9px; }
.spectrum-canvas { width: 100%; height: 260px; border: 1px solid var(--border); border-radius: 8px; background: #080b10; }
.progress-shell { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s ease; }

.toast-region { position: fixed; z-index: 1000; right: 15px; bottom: 42px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 380px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); font-size: 11px; animation: toastIn .2s ease; }
.toast.error { border-color: color-mix(in srgb, var(--danger), transparent 45%); }
.toast.success { border-color: color-mix(in srgb, var(--success), transparent 45%); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-0); }
::-webkit-scrollbar-thumb { background: var(--surface-4); border: 2px solid var(--surface-0); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--surface-4), var(--text-muted) 25%); }

@media (max-width: 1220px) {
  .workspace { grid-template-columns: 205px minmax(0, 1fr) 220px; }
  .edit-buttons { display: none; }
  .titlebar { grid-template-columns: 210px minmax(240px, 1fr) 210px; }
}
.track-list { padding-top: var(--ruler-height); }
.track-list .empty-tracks { margin-top: calc(-1 * var(--ruler-height)); }
