:root {
  color-scheme: dark;
  --bg: #0b1018;
  --bg-2: #121926;
  --panel: rgba(19, 27, 40, 0.8);
  --panel-strong: rgba(13, 20, 31, 0.94);
  --line: rgba(145, 178, 215, 0.16);
  --line-strong: rgba(145, 178, 215, 0.34);
  --ink: #eef4ff;
  --muted: #8ea1bf;
  --accent: #ff7a45;
  --accent-2: #56d7ff;
  --accent-3: #ffd166;
  --success: #77f2a3;
  --danger: #ff5f7a;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  --mono: "SFMono-Regular", "Menlo", "Consolas", monospace;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --track-strip-width: 132px;
  --master-strip-width: 30px;
  --track-strip-padding-left: 42px;
  --track-strip-padding-inline: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(86, 215, 255, 0.16), transparent 22%),
    radial-gradient(circle at 85% 12%, rgba(255, 122, 69, 0.18), transparent 20%),
    linear-gradient(180deg, #0f1623 0%, var(--bg) 44%, #070b12 100%);
  color: var(--ink);
  font-family: var(--sans);
}

body[data-app-ready="false"] {
  overflow: hidden;
}

body[data-app-ready="false"] .app-shell {
  visibility: hidden;
}

body[data-app-ready="false"]::after {
  content: "Restoring session...";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  font: 600 0.9rem/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background:
    radial-gradient(circle at 10% 10%, rgba(86, 215, 255, 0.16), transparent 22%),
    radial-gradient(circle at 85% 12%, rgba(255, 122, 69, 0.18), transparent 20%),
    linear-gradient(180deg, #0f1623 0%, var(--bg) 44%, #070b12 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0;
}

.panel {
  background: linear-gradient(180deg, rgba(24, 34, 48, 0.9), rgba(12, 18, 28, 0.92));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand h1,
.stage-header h2,
.monitor-header h2,
.console-header h2,
.inspector-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.transport-deck {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.72);
  border: 1px solid var(--line);
}

.zoom-deck {
  display: inline-flex;
  align-items: stretch;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.72);
  border: 1px solid var(--line);
}

.transport,
button,
.soft-button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.transport:hover,
button:hover,
.soft-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.transport {
  min-width: 56px;
  height: var(--toolbar-control-height, 34px);
  border-radius: 999px;
  padding: 6px 12px;
  color: white;
  font-weight: 700;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

.transport-return {
  min-width: 40px;
  background: linear-gradient(135deg, #44556e, #243244);
}

.transport-play {
  background: linear-gradient(135deg, #ff7a45, #ff4d6d);
}

.transport-toggle {
  min-width: 110px;
}

.transport-toggle[aria-pressed="true"] {
  background: linear-gradient(135deg, #56d7ff, #1b9dff);
  box-shadow: 0 12px 28px rgba(27, 157, 255, 0.28);
}

.transport-export {
  min-width: 132px;
  background: linear-gradient(135deg, #42536b, #1b2638);
}

.transport-help {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  padding-inline: 0;
  justify-content: center;
  font-size: 0.78rem;
  background: linear-gradient(135deg, #31445c, #182434);
}

.transport-export:disabled {
  opacity: 0.64;
  cursor: wait;
}

.transport-zoom {
  min-width: 78px;
  background: linear-gradient(135deg, #44556e, #243244);
}

.zoom-readout {
  min-width: 260px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 21, 33, 0.92);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: nowrap;
}

label span,
.readout-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.stage-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.stage-header,
.monitor-header,
.console-header,
.inspector-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  margin-bottom: 0;
  background: #000;
}

.stage-summary {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.stage-logo {
  display: block;
  width: 120px;
  height: auto;
  object-fit: contain;
  grid-area: logo;
}

.stage-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.toolbar-tutorial {
  display: block;
  inline-size: calc(var(--toolbar-control-height, 56px) * 16 / 9);
  width: calc(var(--toolbar-control-height, 56px) * 16 / 9);
  min-width: calc(var(--toolbar-control-height, 56px) * 16 / 9);
  max-width: calc(var(--toolbar-control-height, 56px) * 16 / 9);
  block-size: var(--toolbar-control-height, 56px);
  height: var(--toolbar-control-height, 56px);
  min-height: var(--toolbar-control-height, 56px);
  max-height: var(--toolbar-control-height, 56px);
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  border: 1px solid rgba(145, 178, 215, 0.16);
  background: linear-gradient(180deg, #101826, #0b1320);
  object-fit: cover;
  overflow: hidden;
  pointer-events: none;
}

.toolbar-tutorial-button {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  padding: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toolbar-tutorial-button:hover .toolbar-tutorial {
  border-color: rgba(86, 215, 255, 0.42);
}

.stage-header-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.stage-zoom-deck {
  padding: 4px;
}

.session-transport {
  --toolbar-control-height: 34px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin: 0;
  min-width: 0;
}

.session-timecode-input {
  height: var(--toolbar-control-height, 34px);
}

.stage-header-action {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.stage-session-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}


.session-drag-handle {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(145, 178, 215, 0.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(21, 32, 48, 0.98), rgba(11, 18, 30, 0.98));
  color: rgba(238, 244, 255, 0.9);
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  -webkit-user-drag: element;
  user-select: none;
}

.session-drag-handle:hover {
  border-color: rgba(86, 215, 255, 0.42);
}

.session-drag-handle:active {
  cursor: grabbing;
}

.session-drag-handle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stage-session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-combo {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  height: 34px;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: rgba(10, 16, 26, 0.94);
  min-width: 320px;
  max-width: 520px;
  width: 360px;
  overflow: visible;
}

.session-combo-input {
  width: 100%;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 0 12px;
}

.session-combo-input:focus {
  outline: none;
}

.session-combo-toggle {
  width: 34px;
  min-width: 34px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(238, 244, 255, 0.88);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.session-combo-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 100%;
  padding: 6px;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: rgba(7, 12, 20, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  display: grid;
  gap: 4px;
}

.session-combo-menu[hidden] {
  display: none;
}

.session-combo-item {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: rgba(18, 28, 42, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  white-space: nowrap;
}

.session-combo-item[aria-selected="true"] {
  background: rgba(58, 83, 117, 0.92);
}

.session-combo-item-create {
  color: var(--accent-2);
}

.transport-compact {
  min-width: auto;
  height: 34px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.transport-delete {
  background: linear-gradient(135deg, #a94d45, #cf5548);
}

@media (max-width: 1279px) {
  .toolbar-tutorial {
    display: none;
  }

  .session-combo {
    min-width: 260px;
    flex-basis: 300px;
  }
}

.shortcuts-popover {
  position: relative;
}

.shortcuts-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 12;
  min-width: 212px;
  padding: 10px 10px 12px;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: rgba(7, 12, 20, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.shortcuts-title {
  margin: 0 0 12px;
  color: rgba(142, 161, 191, 0.9);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.shortcuts-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.shortcuts-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
}

.shortcuts-key {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
}

.shortcuts-label {
  color: rgba(142, 161, 191, 0.88);
  font-size: 0.68rem;
  white-space: nowrap;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.tutorial-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 12, 0.56);
}

.tutorial-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100vw - 40px));
  padding: 24px 24px 20px;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: rgba(8, 13, 22, 0.78);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(12px);
  transform: translateY(18px) scale(0.98);
  transition: transform 220ms ease;
}

.tutorial-overlay.is-open .tutorial-overlay-panel {
  transform: translateY(0) scale(1);
}

.tutorial-overlay-close {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(20, 30, 44, 0.92);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
}

.tutorial-overlay-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.tutorial-overlay-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: #000;
}

.session-timecode-input {
  width: min(100%, 320px);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(8, 13, 22, 0.92);
  border: 1px solid rgba(145, 178, 215, 0.24);
  color: var(--ink);
  text-align: center;
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.session-timecode-input:focus {
  outline: none;
  border-color: rgba(86, 215, 255, 0.82);
  box-shadow: 0 0 0 3px rgba(86, 215, 255, 0.16);
}

.timeline-board {
  --lane-height: 66px;
  overflow: hidden;
  background: linear-gradient(180deg, #0c1320, #09111b);
  border-top: 1px solid rgba(145, 178, 215, 0.08);
  border-bottom: 1px solid var(--line);
}

.timeline-ruler {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: var(--track-strip-width) minmax(0, 1fr) var(--master-strip-width);
  height: 68px;
  border-bottom: 1px solid var(--line);
  -webkit-user-select: none;
  user-select: none;
}

.timeline-board {
  position: relative;
}

.timeline-shared-grid {
  position: absolute;
  inset: 0 var(--master-strip-width) 0 var(--track-strip-width);
  pointer-events: none;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.shared-grid-block {
  position: absolute;
  top: 0;
  bottom: 0;
}

.shared-grid-block-lines {
  position: absolute;
  inset: 0;
}

.shared-grid-label-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 68px;
  pointer-events: none;
  z-index: 3;
}

.shared-grid-label {
  position: absolute;
  width: 0;
  pointer-events: none;
  z-index: 3;
}

.shared-grid-label-primary {
  top: 12px;
}

.shared-grid-label-secondary {
  top: 0;
  bottom: 0;
}

.shared-grid-label::after {
  position: absolute;
  left: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
  content: attr(data-label);
}

.shared-grid-label-primary::after {
  top: 0;
}

.shared-grid-label-secondary::after {
  top: auto;
  bottom: 6px;
  font-size: 0.66rem;
  color: rgba(142, 161, 191, 0.82);
}

.shared-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0.5px;
}

.shared-grid-line-primary {
  background:
    linear-gradient(
      180deg,
      rgba(145, 178, 215, 0.12) 0,
      rgba(145, 178, 215, 0.12) 100%
    );
}

.shared-grid-line-secondary {
  background:
    linear-gradient(
      180deg,
      transparent 0,
      transparent 34px,
      rgba(145, 178, 215, 0.06) 34px,
      rgba(145, 178, 215, 0.06) 100%
    );
}

.shared-grid-line-tertiary {
  background:
    linear-gradient(
      180deg,
      transparent 0,
      transparent 52px,
      rgba(145, 178, 215, 0.06) 52px,
      rgba(145, 178, 215, 0.06) 100%
    );
}

.timeline-ruler-spacer {
  position: relative;
  z-index: 3;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    linear-gradient(180deg, #101826, #0b1320);
  -webkit-user-select: none;
  user-select: none;
}

.timeline-ruler-master-spacer {
  position: relative;
  z-index: 3;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    linear-gradient(180deg, #101826, #0b1320);
}

.timeline-ruler-scale {
  position: relative;
  height: 68px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(86, 215, 255, 0.05), transparent);
  cursor: grab;
  touch-action: none;
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
}

.timeline-ruler-scale.shift-seek {
  cursor: pointer;
}

.timeline-ruler-labels {
  position: relative;
  height: 68px;
  overflow: hidden;
  z-index: 3;
  -webkit-user-select: none;
  user-select: none;
}

.ruler-label-anchor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  pointer-events: none;
  z-index: 3;
}

.ruler-label-anchor span {
  position: absolute;
  top: 12px;
  left: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  -webkit-user-select: none;
  user-select: none;
}

.ruler-label-anchor-secondary span {
  top: auto;
  bottom: 6px;
  left: 2px;
  font-size: 0.66rem;
  color: rgba(142, 161, 191, 0.82);
}

.timeline-ruler-scale.dragging {
  cursor: grabbing;
}

.timeline-ruler-scale.dragging.shift-seek {
  cursor: pointer;
}

.zoom-indicator {
  position: fixed;
  z-index: 40;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(7, 12, 20, 0.92);
  border: 1px solid rgba(145, 178, 215, 0.18);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
}

.timeline-lane {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: var(--track-strip-width) minmax(0, 1fr) var(--master-strip-width);
  height: calc(var(--lane-height) * 8);
}

.fx-panel {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-panel[hidden] {
  display: none;
}

.fx-panel-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.fx-panel-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(900px, 90vw);
  min-width: 400px;
  min-height: 250px;
  max-width: 95vw;
  max-height: 90vh;
  background: linear-gradient(180deg, rgba(20, 32, 47, 0.92), rgba(13, 24, 37, 0.92));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(145, 178, 215, 0.15);
  border-radius: 12px;
  overflow: auto;
  resize: both;
}

.fx-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(145, 178, 215, 0.1);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.fx-panel-header:active {
  cursor: grabbing;
}

.fx-panel-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #b68aff;
  text-transform: uppercase;
}

.fx-panel-track-label {
  flex: 1;
  font-size: 11px;
  color: rgba(200, 220, 240, 0.5);
  letter-spacing: 0.04em;
}

.fx-panel-new {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.fx-panel-new:hover {
  background: rgba(145, 178, 215, 0.15);
  color: var(--text);
}

.fx-panel-content > .fx-panel-list {
  flex: 1;
  min-height: 200px;
}

.fx-panel-list {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 12px;
}

/* The panel-list itself doesn't need a visible focus marker — the
   surrounding window picks it up (see `.transform-panel-content:has(...)`
   and `.fx-panel:has(...)` below). */
.fx-panel-list:focus {
  outline: none;
}

.fx-panel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  opacity: 0.6;
}

/* When the chain itself has focus (not a slot), accent the whole
   surrounding window — Faust Transform overlay or FX panel — so the
   user sees that Cmd+Z affects the chain (add / remove / move /
   bypass) rather than a slot. The accent matches the per-slot
   `:focus-within` colour. */
.transform-panel-content:has(> .fx-panel-list:focus),
.fx-panel-content:has(> .fx-panel-list:focus) {
  border-color: rgba(182, 138, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(182, 138, 255, 0.25);
}

.fx-panel-effect {
  display: flex;
  flex-direction: column;
  min-width: 320px;
  border: 1px solid rgba(145, 178, 215, 0.25);
  border-radius: 5px;
  background: rgba(145, 178, 215, 0.08);
  flex-shrink: 0;
  overflow: hidden;
}

.fx-panel-effect:focus-within {
  border-color: rgba(182, 138, 255, 0.5);
  box-shadow: 0 0 0 1px rgba(182, 138, 255, 0.2);
}

.fx-panel-effect:focus {
  outline: none;
}

.fx-panel-effect-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(145, 178, 215, 0.12);
  flex-shrink: 0;
}

.fx-panel-effect-name {
  flex: 1;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-panel-effect-channels {
  font-size: 0.6rem;
  color: var(--muted);
  margin-left: 4px;
  white-space: nowrap;
}

/* Preset count badge — styled as a pill so it sits flush alongside the
   Center / Random / Zoom buttons in the orbit toolbar. inline-flex +
   `min-height: 23px` so the span matches the buttons' total height
   (the buttons measure 23px because their inner Material icon is 13px,
   not because of the text). Without this, a plain text-only span sits
   at ~19px and looks visibly shorter.
   `min-width` reserves enough room to fit the « K/N » selected-count
   form without growing — otherwise toggling between « N » and « K/N »
   would reflow the toolbar (and cascade to the canvas via scrollbar). */
.fx-panel-effect-presets {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  min-width: 44px;
  box-sizing: border-box;
  font-size: 0.6rem;
  color: #d7dde7;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border: 1px solid #3a4a5f;
  border-radius: 999px;
  background: #1a2230;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.fx-panel-effect-presets:hover {
  background: #25324a;
  color: #ffffff;
}

/* Niveau-0 named-preset recall dropdown — anchored under the header span,
   only one open at a time across the app. */
.fx-panel-effect-recall-menu {
  position: fixed;
  /* Above the transform-panel (9000) and other modal overlays in the app
     (9500). Capped at 10000 so future modals can sit above this menu by
     default if they need to. */
  z-index: 10000;
  min-width: 140px;
  max-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(20, 27, 37, 0.97);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  font-family: inherit;
  font-size: 0.72rem;
}
.fx-panel-effect-recall-menu-item {
  display: block;
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(238, 244, 255, 0.92);
  text-align: left;
  /* Left padding reserves room for the active checkmark so all items
     align regardless of their state. */
  padding: 6px 12px 6px 24px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}
.fx-panel-effect-recall-menu-item:hover {
  background: rgba(232, 201, 122, 0.18);
  color: rgba(255, 230, 170, 1);
}
.fx-panel-effect-recall-menu-item--active::before {
  content: "✓";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(232, 201, 122, 1);
  font-weight: 600;
}
.fx-panel-effect-recall-menu-item--active {
  color: rgba(255, 230, 170, 1);
}
.fx-panel-effect-recall-menu-empty {
  padding: 8px 12px;
  color: rgba(238, 244, 255, 0.5);
  font-style: italic;
}

.fx-ctrl {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 4px;
  font-size: 0.6rem;
  line-height: 1;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
/* Material-icon sized variants for the preset actions injected into the
   orbit toolbar — match the toolbar's own icon size. */
.fx-ctrl-trash .material-symbols-outlined,
.fx-ctrl-overlay .material-symbols-outlined,
.fx-ctrl-bypass .material-symbols-outlined {
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 20;
}
/* Preset-actions group inside the orbit-header. Visual divider on the
   right separates it from center / random which follow. */
.orbit-presets-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid #263242;
}
/* Inside the orbit-presets-actions group, trash + overlay-toggle adopt
   the orbit toolbar's pill style so they sit flush with the Center /
   Random buttons. */
.orbit-presets-actions .fx-ctrl-trash,
.orbit-presets-actions .fx-ctrl-overlay {
  border: 1px solid #3a4a5f;
  background: #1a2230;
  color: #d7dde7;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.6rem;
  line-height: 1;
}
.orbit-presets-actions .fx-ctrl-trash:hover:not(:disabled),
.orbit-presets-actions .fx-ctrl-overlay:hover:not(:disabled) {
  background: #25324a;
  color: #ffffff;
}
.fx-ctrl:hover { background: rgba(145, 178, 215, 0.15); color: var(--fg); }
.fx-ctrl:disabled { opacity: 0.25; pointer-events: none; }
/* Bypass button — power-icon semantics : effect ON by default (cyan
   accent), bypass active = effect OFF (muted gray + slash overlay-like
   feel via reduced opacity). */
.fx-ctrl-bypass { color: var(--accent-2); }
.fx-ctrl-bypass--bypassed { color: var(--muted); opacity: 0.6; }
.fx-ctrl-edit { font-size: 0.7rem; }
.fx-ctrl-edit:hover { color: #b68aff; }
.fx-ctrl-delete:hover { color: #ff4444; }
/* Dim only the orbit / content area, not the header — so the bypass
   toggle stays at full luminosity and the user can clearly see its
   off state. */
.fx-panel-effect[data-bypassed="true"] .fx-panel-effect-orbit { opacity: 0.45; }
.fx-panel-effect-header { cursor: grab; }
.fx-panel-effect--dragging { opacity: 0.35; }
/* The list lays effects horizontally — the insertion bar is therefore
   vertical, and we use box-shadow rather than border so that the
   neighbours don't shift sideways while the bar is shown. */
.fx-panel-effect--drop-before { box-shadow: -2px 0 0 0 var(--accent, #5b9bd5); }
.fx-panel-effect--drop-after { box-shadow: 2px 0 0 0 var(--accent, #5b9bd5); }

.fx-panel-effect-orbit {
  flex: 1;
  min-height: 120px;
  overflow: hidden;
  position: relative;
  outline: none;
}

.fx-panel-effect-orbit:focus,
.fx-panel-effect-orbit:focus-visible,
.fx-panel-effect:focus,
.fx-panel-effect:focus-visible {
  outline: none;
}

.fx-panel-effect-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}

.fx-panel-effect-orbit[data-overlay-active="true"] .orbit-detail,
.fx-panel-effect-orbit[data-overlay-active="true"] .orbit-canvas {
  opacity: 0.1;
  filter: grayscale(0.7);
}
/* Header (Center / Random / Zoom) stays fully lit — it now drives the
   calque's viewport, not niveau 0. */

.fx-panel-effect-orbit[data-overlay-active="true"] .orbit-detail {
  pointer-events: none;
}
/* Header stays interactive while the calque is active : Center / Random /
   Zoom are intercepted in capture phase by PresetOverlay and rebound to
   calque-specific actions (pan / random ψ / zoom). The pointer-events
   stay on so the user can still click the header buttons. */

/* Overlay-toggle "active" state (calque visible) : filled amber pill
   with dark icon. Strong toggle-on signal, aligned with the gold accent
   used elsewhere for named presets and for the bypass-active highlight. */
.fx-ctrl-overlay--active,
.orbit-presets-actions .fx-ctrl-overlay--active {
  background: #e8a435;
  border-color: #e8a435;
  color: #0d1016;
}
.fx-ctrl-overlay--active:hover:not(:disabled),
.orbit-presets-actions .fx-ctrl-overlay--active:hover:not(:disabled) {
  background: #f1b455;
  border-color: #f1b455;
  color: #0d1016;
}

/* Portamento bottom bar — overlays the (dimmed) orbit-ui detail bar
   while the niveau-1 calque is open. Same height as .orbit-detail (48px)
   so it lines up exactly. */
.fx-panel-effect-portamento {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(20, 27, 37, 0.96);
  border-top: 1px solid #263242;
  z-index: 4;
  pointer-events: auto;
  font-family: inherit;
  font-size: 0.7rem;
  color: rgba(238, 244, 255, 0.85);
}
.fx-panel-effect-portamento-label {
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.fx-panel-effect-portamento-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: 1.1rem;
  letter-spacing: 0;
  cursor: help;
  color: rgba(238, 244, 255, 0.9);
}
.fx-panel-effect-portamento input[type="range"] {
  flex: 1 1 60px;
  min-width: 60px;
  /* Reset the global `input { padding / border / background / width: 100% }`
     rule (further down this file, scoped to the cards forms) which leaks
     onto our range slider and shrinks its track. */
  width: auto;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}
.fx-panel-effect-portamento-value {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 5em;
  text-align: right;
}
.fx-panel-effect-portamento-loop {
  width: 26px;
  height: 26px;
  border: 1px solid #3a4a5f;
  border-radius: 999px;
  background: #1a2230;
  color: rgba(238, 244, 255, 0.85);
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fx-panel-effect-portamento-loop:hover:not(:disabled) {
  background: #25324a;
}
.fx-panel-effect-portamento-loop:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Inline name editor — surfaced over the calque on double-click. */
.fx-panel-effect-name-edit {
  position: absolute;
  z-index: 5;
  width: 120px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(232, 201, 122, 0.85);
  border-radius: 4px;
  background: rgba(20, 27, 37, 0.96);
  color: rgba(238, 244, 255, 0.95);
  font-family: inherit;
  font-size: 0.7rem;
}
.fx-panel-effect-name-edit:focus {
  outline: 1px solid rgba(232, 201, 122, 1);
  outline-offset: 1px;
}

.fx-panel-effect-context-menu {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-width: 120px;
  padding: 4px 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(20, 27, 37, 0.97);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  font-family: inherit;
  font-size: 0.72rem;
}
.fx-panel-effect-context-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(238, 244, 255, 0.92);
  text-align: left;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.fx-panel-effect-context-menu-item:hover {
  background: rgba(232, 201, 122, 0.18);
  color: rgba(255, 230, 170, 1);
}

/* ─── Transform panel overlay ─── */

.transform-panel[hidden] {
  display: none;
}

.transform-panel {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transform-panel-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.transform-panel-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(900px, 90vw);
  min-width: 400px;
  min-height: 250px;
  max-width: 95vw;
  max-height: 90vh;
  background: linear-gradient(180deg, rgba(20, 32, 47, 0.92), rgba(13, 24, 37, 0.92));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(145, 178, 215, 0.15);
  border-radius: 12px;
  overflow: auto;
  resize: both;
}

.transform-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(145, 178, 215, 0.1);
  cursor: grab;
  user-select: none;
}

.transform-panel-header:active {
  cursor: grabbing;
}

.transform-panel-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #b68aff;
  text-transform: uppercase;
}

.transform-panel-status {
  flex: 1;
  font-size: 11px;
  color: rgba(200, 220, 240, 0.5);
}

.transform-panel-content > .fx-panel-list {
  flex: 1;
  min-height: 200px;
}

.transform-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(145, 178, 215, 0.1);
}

.transform-panel-button {
  padding: 6px 20px;
  border: 1px solid rgba(145, 178, 215, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(145, 178, 215, 0.08);
  color: rgba(200, 220, 240, 0.8);
  transition: background 120ms, border-color 120ms;
}

.transform-panel-button:hover {
  background: rgba(145, 178, 215, 0.15);
  border-color: rgba(145, 178, 215, 0.3);
}

.transform-panel-button--apply {
  background: rgba(130, 100, 220, 0.25);
  border-color: rgba(130, 100, 220, 0.4);
  color: #d4c0ff;
}

.transform-panel-button--apply:hover {
  background: rgba(130, 100, 220, 0.35);
  border-color: rgba(130, 100, 220, 0.6);
}

.transform-panel-button--cancel {
  color: rgba(200, 220, 240, 0.6);
}

/* ─── Faust Code Editor ─── */

.faust-editor[hidden] {
  display: none;
}

.faust-editor {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.faust-editor-content {
  pointer-events: auto;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(800px, 85vw);
  height: min(600px, 75vh);
  min-width: 350px;
  min-height: 250px;
  max-width: 95vw;
  max-height: 90vh;
  background: linear-gradient(180deg, rgba(16, 26, 38, 0.94), rgba(10, 18, 28, 0.94));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(145, 178, 215, 0.18);
  border-radius: 12px;
  overflow: auto;
  resize: both;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.faust-editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(145, 178, 215, 0.1);
  cursor: grab;
  user-select: none;
}

.faust-editor-header:active {
  cursor: grabbing;
}

.faust-editor-title {
  font-size: 12px;
  font-weight: 700;
  color: #b68aff;
  letter-spacing: 0.04em;
}

.faust-editor-channels {
  font-size: 11px;
  color: var(--muted);
}

.faust-editor-header-spacer {
  flex: 1;
}

.faust-editor-code {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.faust-editor-code .cm-editor {
  height: 100%;
}

.faust-editor-code .cm-scroller {
  overflow: auto;
}

.faust-editor-error {
  padding: 8px 14px;
  font-size: 12px;
  font-family: monospace;
  color: rgba(255, 95, 122, 0.9);
  background: rgba(255, 50, 80, 0.08);
  border-top: 1px solid rgba(255, 95, 122, 0.15);
  max-height: 80px;
  overflow: auto;
  white-space: pre-wrap;
}

.faust-editor-error[hidden] {
  display: none;
}

.faust-editor-options {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border-top: 1px solid rgba(145, 178, 215, 0.08);
}

.faust-editor-option-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(200, 220, 240, 0.5);
  cursor: pointer;
  user-select: none;
}

.faust-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(145, 178, 215, 0.1);
}

.faust-editor-button {
  padding: 5px 16px;
  border: 1px solid rgba(145, 178, 215, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(145, 178, 215, 0.08);
  color: rgba(200, 220, 240, 0.8);
  transition: background 120ms, border-color 120ms;
}

.faust-editor-button:hover {
  background: rgba(145, 178, 215, 0.15);
  border-color: rgba(145, 178, 215, 0.3);
}

.faust-editor-button--compile {
  background: rgba(130, 100, 220, 0.25);
  border-color: rgba(130, 100, 220, 0.4);
  color: #d4c0ff;
}

.faust-editor-button--compile:hover {
  background: rgba(130, 100, 220, 0.35);
  border-color: rgba(130, 100, 220, 0.6);
}

.faust-editor-button--close {
  color: rgba(200, 220, 240, 0.6);
}

.timeline-footer {
  display: grid;
  grid-template-columns: var(--track-strip-width) minmax(0, 1fr) var(--master-strip-width);
  height: 34px;
  border-top: 1px solid rgba(145, 178, 215, 0.1);
}

.timeline-footer-spacer,
.timeline-footer-master-spacer {
  position: relative;
  z-index: 3;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    linear-gradient(180deg, #101826, #0b1320);
}

.timeline-footer-spacer {
  border-right: 1px solid var(--line);
}

.timeline-footer-master-spacer {
  border-left: 1px solid var(--line);
}

.timeline-footer-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(86, 215, 255, 0.04), transparent);
}

.timeline-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-footer-meta {
  color: rgba(142, 161, 191, 0.78);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.timeline-footer-message {
  flex: 1 1 auto;
  min-width: 0;
  color: rgba(142, 161, 191, 0.86);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-footer-message[data-state="error"] {
  color: rgba(255, 95, 122, 0.84);
}

.timeline-footer-message[data-state="scope"] {
  color: rgba(142, 161, 191, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
}

.track-strips {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-rows: repeat(8, var(--lane-height));
  height: calc(var(--lane-height) * 8);
  -webkit-user-select: none;
  user-select: none;
}

.track-strip {
  --track-activity-level: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: var(--lane-height);
  padding: 4px var(--track-strip-padding-inline) 4px var(--track-strip-padding-left);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    linear-gradient(180deg, #101826, #0b1320);
}

.master-strip {
  position: relative;
  z-index: 3;
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: calc(var(--lane-height) * 8);
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    linear-gradient(180deg, #101826, #0b1320);
  padding: 12px 0;
}

.master-slider {
  width: 22px;
  align-self: stretch;
}

.master-scale {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: var(--slider-track-height);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
}

.master-scale-tick {
  position: absolute;
  left: 50%;
  top: calc(100% - (var(--tick-ratio) * 100%));
  width: 12px;
  height: 1px;
  border-radius: 999px;
  background: rgba(145, 178, 215, 0.3);
  transform: translate(-50%, -50%);
}

.master-scale-tick-zero {
  width: 16px;
  height: 2px;
  background: rgba(145, 178, 215, 0.5);
}

.master-volume-value {
  position: absolute;
  right: calc(100% + 6px);
  top: 10px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(145, 178, 215, 0.16);
  background: rgba(7, 12, 20, 0.92);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.5rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 2;
}

.track-strip:last-child {
  border-bottom: 0;
}

.track-strip.active {
  background:
    linear-gradient(180deg, rgba(86, 215, 255, 0.06), transparent),
    linear-gradient(180deg, #101826, #0b1320);
}

.track-strip.playing {
  box-shadow: inset 3px 0 0 rgba(86, 215, 255, calc(0.09 + (var(--track-activity-level) * 0.9)));
}

.track-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  justify-content: center;
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
}

.track-badge {
  background: rgba(255, 122, 69, 0.14);
  color: var(--accent);
}

.track-fx-button {
  position: absolute;
  top: 28px;
  left: 6px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 7px;
  border: none;
  border-radius: 999px;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  background: rgba(145, 178, 215, 0.1);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.track-fx-button:hover {
  background: rgba(145, 178, 215, 0.22);
  color: var(--text);
}

.track-fx-button[aria-pressed="true"] {
  background: rgba(86, 215, 255, 0.18);
  color: var(--accent-2);
}

.track-controls {
  --slider-track-height: 40px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  height: 100%;
}

.track-toggle-stack {
  --track-toggle-size: calc(var(--slider-track-height) / 3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  width: 16px;
  height: 100%;
  margin-right: 2px;
}

.track-toggle-button {
  width: var(--track-toggle-size);
  height: var(--track-toggle-size);
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(145, 178, 215, 0.18);
  background: rgba(17, 24, 36, 0.92);
  color: rgba(206, 220, 242, 0.82);
  font-family: var(--mono);
  font-size: 0.48rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.track-toggle-button:hover {
  border-color: rgba(145, 178, 215, 0.34);
  background: rgba(23, 31, 46, 0.96);
}

.track-toggle-button[aria-pressed="true"] {
  color: #07121b;
}

.track-mute-button[aria-pressed="true"] {
  background: rgba(255, 95, 122, 0.92);
  border-color: rgba(255, 95, 122, 0.86);
}

.track-solo-button[aria-pressed="true"] {
  background: rgba(255, 209, 102, 0.94);
  border-color: rgba(255, 209, 102, 0.88);
}

.track-slider {
  --slider-track-height: 40px;
  --slider-thumb-size: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 100%;
  min-height: 52px;
  min-width: 0;
}

.master-slider.track-slider {
  --slider-track-height: calc((var(--lane-height) * 8) - 24px);
  --slider-travel-height: calc(var(--slider-track-height) + var(--slider-thumb-size));
  width: 22px;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  flex: 0 0 auto;
  overflow: visible;
}

.track-slider-rail,
.track-slider-fill {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: var(--slider-track-height);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.track-slider-rail {
  background: rgba(145, 178, 215, 0.2);
  z-index: 0;
}

.track-pan .track-slider-rail {
  background: rgba(145, 178, 215, 0.24);
}

.track-slider-fill {
  top: calc(50% + (var(--slider-track-height) / 2) - (var(--slider-track-height) * var(--track-fill-ratio, 0)));
  height: calc(var(--slider-track-height) * var(--track-fill-ratio, 0));
  transform: translateX(-50%);
  background: rgba(86, 215, 255, 0.72);
  z-index: 1;
}

.track-volume-value,
.track-pan-value {
  position: absolute;
  right: calc(100% - 8px);
  top: 2px;
  transform: none;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(145, 178, 215, 0.16);
  background: rgba(7, 12, 20, 0.92);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.46rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 2;
}

.track-slider.show-overlay .track-slider-overlay {
  opacity: 1;
}

.vertical-slider {
  -webkit-appearance: none;
  appearance: none;
  width: calc(var(--slider-track-height) + var(--slider-thumb-size));
  height: 14px;
  margin: 0;
  min-height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: rotate(-90deg);
  transform-origin: center;
  cursor: ns-resize;
  position: relative;
  z-index: 2;
}

.master-volume-slider.vertical-slider {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--slider-travel-height);
  min-width: var(--slider-travel-height);
  max-width: var(--slider-travel-height);
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  flex: 0 0 auto;
}

.vertical-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.track-volume .vertical-slider::-webkit-slider-runnable-track {
  background: transparent;
}

.vertical-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  border: 2px solid rgba(7, 12, 20, 0.95);
  background: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(86, 215, 255, 0.2);
}

.vertical-slider::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.track-volume .vertical-slider::-moz-range-track {
  background: transparent;
}

.track-volume .vertical-slider::-moz-range-progress {
  background: transparent;
}

.vertical-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(7, 12, 20, 0.95);
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(86, 215, 255, 0.2);
}

.track-pan .vertical-slider::-webkit-slider-thumb {
  background: rgba(145, 178, 215, 0.95);
  box-shadow: 0 0 0 1px rgba(145, 178, 215, 0.18);
}

.track-pan .vertical-slider::-moz-range-thumb {
  background: rgba(145, 178, 215, 0.95);
  box-shadow: 0 0 0 1px rgba(145, 178, 215, 0.18);
}

.timeline-grid {
  --clip-left: 10%;
  --clip-width: 22%;
  --clip-width-px: 180px;
  --clip-top-px: 16px;
  --playhead-left-px: 0px;
  position: relative;
  height: calc(var(--lane-height) * 8);
  overflow: hidden;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent calc(var(--lane-height) - 1px),
      rgba(145, 178, 215, 0.14) calc(var(--lane-height) - 1px),
      rgba(145, 178, 215, 0.14) var(--lane-height)
    ),
    linear-gradient(180deg, rgba(86, 215, 255, 0.04), transparent 40%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  z-index: 1;
}

.timeline-grid::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: rgba(145, 178, 215, 0.12);
  pointer-events: none;
}

.timeline-negative-overlay {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  pointer-events: none;
  z-index: 1;
  will-change: width;
}

.timeline-negative-overlay-ruler {
  background:
    linear-gradient(180deg, rgba(7, 12, 20, 0.46), rgba(7, 12, 20, 0.58)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent);
  border-right: 1px solid rgba(145, 178, 215, 0.18);
}

.timeline-negative-overlay-grid {
  background:
    linear-gradient(180deg, rgba(7, 12, 20, 0.4), rgba(7, 12, 20, 0.5)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent);
  border-right: 1px solid rgba(145, 178, 215, 0.18);
}

.clip-ghost {
  position: absolute;
  left: 20px;
  top: calc((var(--lane-height) - 28px) / 2);
  color: var(--muted);
  font-style: italic;
  z-index: 1;
}

.drag-overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  contain: paint;
}

.drag-overlay-canvas {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  contain: paint;
  will-change: transform, left, top;
}

.selection-rectangle {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 1px solid rgba(86, 215, 255, 0.72);
  background: rgba(86, 215, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(86, 215, 255, 0.18);
}

.drag-alignment-guide {
  position: absolute;
  top: 0;
  width: 1px;
  background: linear-gradient(180deg, rgba(86, 215, 255, 0.65), rgba(255, 255, 255, 0.35));
  opacity: 0.75;
  pointer-events: none;
}

.popup-menu {
  position: fixed;
  min-width: 160px;
  padding: 6px;
  border: 1px solid rgba(145, 178, 215, 0.28);
  border-radius: 10px;
  background: rgba(8, 13, 22, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.popup-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
}

.popup-menu-item:disabled {
  opacity: 0.35;
  cursor: default;
}

.popup-menu-item:hover:not(:disabled),
.popup-menu-item:focus-visible:not(:disabled) {
  background: rgba(145, 178, 215, 0.14);
  outline: none;
}

.popup-menu-item kbd {
  float: right;
  margin-left: 24px;
  opacity: 0.45;
  font: inherit;
  font-size: 0.85em;
}

.popup-menu-separator {
  border: none;
  border-top: 1px solid rgba(145, 178, 215, 0.15);
  margin: 4px 6px;
}

.onset-panel {
  position: fixed;
  right: 18px;
  top: 102px;
  width: min(340px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid rgba(145, 178, 215, 0.3);
  border-radius: 18px;
  background: rgba(8, 13, 22, 0.78);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  z-index: 22;
}

.onset-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.onset-panel-kicker {
  display: block;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  font-weight: 700;
}

.onset-panel-title {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
}

.onset-panel-body {
  display: grid;
  gap: 14px;
}

.onset-panel-field {
  display: grid;
  gap: 8px;
}

.onset-panel-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
}

.onset-panel-value {
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.onset-panel-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.onset-panel-check input {
  inline-size: 16px;
  block-size: 16px;
}

.onset-panel-status {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.onset-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.compact-button {
  min-width: 0;
  height: auto;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.84rem;
}

.compact-button.secondary {
  background: rgba(145, 178, 215, 0.12);
  color: var(--ink);
}

.monitor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) 1fr;
  gap: 16px;
}

.monitor-output,
.state {
  margin: 0;
  border-radius: 18px;
  padding: 16px;
  background: rgba(5, 10, 16, 0.95);
  border: 1px solid rgba(145, 178, 215, 0.14);
  color: #e8f8ff;
  font-family: var(--mono);
  line-height: 1.45;
  overflow: auto;
}

.monitor-output {
  min-height: 126px;
  font-size: 0.95rem;
}

.state {
  min-height: 280px;
  font-size: 0.88rem;
}

.summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 14px;
  margin: 0;
  align-content: start;
}

.summary dt {
  color: var(--muted);
  font-weight: 700;
}

.summary dd {
  margin: 0;
  font-family: var(--mono);
}

.monitor-lamp {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(255, 95, 122, 0.12);
}

.monitor-lamp.active {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(119, 242, 163, 0.16), 0 0 20px rgba(119, 242, 163, 0.5);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 0;
}

input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  padding: 12px 14px;
  background: rgba(6, 12, 20, 0.86);
  color: var(--ink);
}

button {
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 122, 69, 0.92), rgba(255, 94, 98, 0.92));
  color: white;
  font-weight: 700;
}

.soft-button {
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(145, 178, 215, 0.1);
  color: var(--ink);
  font-weight: 700;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.log {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.log li {
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 820px) {
  :root {
    --track-strip-width: 88px;
    --master-strip-width: 24px;
    --track-strip-padding-left: 24px;
    --track-strip-padding-inline: 4px;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .stage-header {
    align-items: center;
    grid-template-columns: 120px max-content auto;
    overflow-x: auto;
  }

  .toolbar-tutorial {
    display: none;
  }

  .stage-header-center,
  .stage-header-action,
  .stage-session-bar,
  .stage-session-actions {
    width: max-content;
  }

  .stage-header-action,
  .stage-session-bar,
  .stage-session-actions {
    justify-content: flex-start;
  }

  .stage-logo {
    width: 120px;
  }

  .session-transport {
    width: max-content;
  }

  .session-timecode-input {
    width: 320px;
  }

  .session-combo {
    width: 320px;
    min-width: 260px;
  }

  .shortcuts-panel {
    right: 0;
    left: auto;
    min-width: 212px;
    max-width: min(260px, calc(100vw - 16px));
  }

  .tutorial-overlay-panel {
    width: calc(100vw - 16px);
    padding: 40px 12px 12px;
  }

  .tutorial-overlay-grid {
    grid-template-columns: 1fr;
  }

  .track-strips {
    min-height: auto;
  }

  .track-strip {
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .track-badge {
    top: 4px;
    left: 3px;
    min-width: 18px;
    padding: 2px 4px;
    font-size: 0.48rem;
  }

  .track-fx-button {
    top: 22px;
    left: 3px;
    min-width: 18px;
    padding: 1px 4px;
    font-size: 0.42rem;
  }

  .track-controls {
    gap: 1px;
  }

  .track-toggle-stack {
    gap: 10px;
    width: 14px;
    margin-right: 1px;
  }

  .track-slider {
    width: 22px;
  }

  .master-strip {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .master-slider.track-slider {
    width: 18px;
  }
}

select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  padding: 12px 14px;
  background: rgba(6, 12, 20, 0.86);
  color: var(--ink);
}

/* ---------------------------------------------------------------------------
   Marker system
   --------------------------------------------------------------------------- */

.marker-layer {
  position: absolute;
  top: 0;
  height: calc(68px + var(--lane-height) * 8);
  left: var(--track-strip-width);
  right: var(--master-strip-width);
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.marker {
  will-change: transform;
}

.marker--inactive {
  opacity: 0.35;
  filter: grayscale(0.8);
}

/* Cursor marker: gradient line and diamond glow */
.marker--cursor > .marker-line {
  background: linear-gradient(180deg, var(--accent-2), white) !important;
  box-shadow: 0 0 12px rgba(86, 215, 255, 0.45);
}

.marker--cursor > .marker-icon {
  color: rgba(86, 215, 255, 0.78) !important;
  filter: drop-shadow(0 0 6px rgba(86, 215, 255, 0.6));
}
