/* ============================================================
   RadioTools – CartWall  |  Design System
   ============================================================ */

:root {
  --bg-page: #1c1c20;
  --bg-header: #1c1c20;
  --bg-panel: #26262b;
  --bg-cart: #303037;
  --bg-cart-hover: #3a3a42;
  --bg-ctx: #26262b;

  --txt: #fafafa;
  --txt-muted: #a1a1aa;
  --txt-empty: #71717a;

  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warn: #f59e0b;
  --info: #3b82f6;
  --success: #22c55e;

  --border: #3d3d45;
  --progress-h: 6px;
  --border-r: 8px;
  --radius-sm: 4px;
  --cart-h: 120px;
  --gap: 10px;

  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--txt);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body ─────────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-page);
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  overflow: visible;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--txt);
  white-space: nowrap;
}

.subtitle {
  font-weight: 400;
  color: var(--txt-muted);
  font-size: 0.9rem;
}

/* ── Nav Controls ─────────────────────────────────────────── */
/* STOP ALL button lives directly in the header, always visible */
.header-stop {
  margin-left: auto;
  flex-shrink: 0;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.controls button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.2s;
  color: var(--txt);
  background: var(--bg-cart);
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls button:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

.controls button:active {
  transform: scale(0.96);
}

.controls button svg,
.btn-stop svg {
  vertical-align: middle;
  flex-shrink: 0;
}

.btn-stop {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.2s;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-stop:active {
  transform: scale(0.96);
}

.btn-stop:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
}

.btn-stop span,
.btn-stop .stop-label {
  white-space: nowrap;
}


#clearAll {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

#clearAll:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ── More Menu Dropdown ───────────────────────────────────── */
.more-menu {
  position: relative;
  flex-shrink: 0;
}

.more-menu-btn {
  /* inherits .controls button */
}

.more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  min-width: 210px;
  padding: 4px;
  z-index: 300;
  gap: 2px;
}

.more-dropdown.open {
  display: flex;
}

.more-dropdown button {
  width: 100% !important;
  height: auto !important;
  padding: 9px 14px !important;
  border-radius: var(--radius-sm) !important;
  border: none !important;
  background: transparent !important;
  color: var(--txt) !important;
  justify-content: flex-start !important;
  font-weight: 500 !important;
}

.more-dropdown button:hover {
  background: var(--bg-cart-hover) !important;
  border-color: transparent !important;
}

.btn-text {
  display: none;
}

/* ── Switch Toggle ────────────────────────────────────────── */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.switch input {
  display: none;
}

.switch .slider {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: background 0.22s ease;
  flex-shrink: 0;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.22s ease;
}

.switch input:checked+.slider {
  background: var(--accent);
}

.switch input:checked+.slider::before {
  transform: translateX(16px);
}

.switch .lbl {
  font-size: 0.8rem;
  color: var(--txt-muted);
}

/* ── Nav Menu (inter-app navigation) ──────────────────────── */
.nav-menu {
  position: relative;
  flex-shrink: 0;
}

.nav-hamburger {
  background: none;
  border: 1px solid #00AAEF;
  color: #00AAEF;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  line-height: 1;
}

.nav-hamburger:hover {
  background-color: rgba(0, 170, 239, 0.15);
  border-color: #00AAEF;
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  min-width: 200px;
  z-index: 100;
  overflow: hidden;
}

.nav-dropdown.open {
  display: block;
}

.nav-link {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--txt-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
  border-bottom: 1px solid var(--border);
}

.nav-link:last-child {
  border-bottom: none;
}

.nav-link:hover {
  background-color: var(--bg-cart);
  color: var(--txt);
}

.nav-link.active {
  color: var(--accent);
  background-color: rgba(99, 102, 241, 0.08);
  cursor: default;
}

/* ── Hamburger ────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--txt);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  flex-shrink: 0;
}

/* ── Grid ─────────────────────────────────────────────────── */
#grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  padding: var(--gap);
  overflow: auto;
  align-content: start;
}

/* ── Cart ─────────────────────────────────────────────────── */
.cart {
  height: var(--cart-h);
  background: var(--bg-cart);
  border-radius: var(--border-r);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  user-select: none;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cart:hover {
  background: var(--bg-cart-hover);
}

.cart.empty .label {
  color: var(--txt-empty) !important;
}

.cart.playing {
  box-shadow: 0 0 0 2px var(--accent);
}

.cart .label {
  padding: 0 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
}

.cart .time {
  font-size: 0.75rem;
  color: var(--txt-muted);
  margin-top: 0.25rem;
}

/* ── Progress bar ─────────────────────────────────────────── */
.cart .progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: var(--progress-h);
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 0 4px 4px;
}

/* ── Cart loop dot ────────────────────────────────────────── */
.cart.loop::after {
  content: '∞';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.75rem;
  color: var(--warn);
  line-height: 1;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.cart.blinking {
  animation: blink 0.8s step-end infinite;
}

/* ── Context Menu ─────────────────────────────────────────── */
#ctxMenu {
  display: none;
  position: fixed;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem;
  background: var(--bg-ctx);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  z-index: 1000;
  width: auto;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.swatch {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.swatch:hover {
  transform: scale(1.2);
  border-color: #fff6;
}

#ctxMenu button {
  width: 100%;
  padding: 0.45rem 0.6rem;
  margin-top: 0.2rem;
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

#ctxMenu button:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

#ctxMenu button.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Collaboration Modal ──────────────────────────────────── */
.collab-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.collab-overlay.hidden {
  display: none;
}

.collab-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.collab-modal h2 {
  font-size: 1.2rem;
  margin-bottom: 1.4rem;
  text-align: center;
}

.collab-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--txt);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.collab-close:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

.collab-section h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--txt);
}

.collab-section p {
  font-size: 0.82rem;
  color: var(--txt-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.collab-divider {
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.collab-info {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-page);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.collab-info.hidden {
  display: none;
}

.collab-link-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.collab-link-row input {
  flex: 1;
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  font-size: 0.78rem;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  padding: 0.4rem 0.6rem;
  outline: none;
}

.collab-link-row button,
.btn-primary {
  padding: 0.45rem 0.85rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.2s;
  white-space: nowrap;
}

.collab-link-row button:hover,
.btn-primary:hover {
  background: rgba(99, 102, 241, 0.25);
}

.collab-status {
  font-size: 0.8rem;
  color: var(--txt-muted);
  margin: 0 !important;
}

#peerCount {
  color: var(--accent);
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ── Mode client : masquer les contrôles réservés à l'hôte ── */
body.is-client #clearAll,
body.is-client #moreMenu,
body.is-client .menu-toggle {
  display: none !important;
}

/* Masquer la section hôte dans le modal en mode client */
body.is-client #hostSection {
  display: none;
}

body.is-client .cart {
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  #grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .menu-toggle {
    display: block;
  }

  /* Hide the STOP ALL label on tablet/mobile – show icon only */
  .header-stop .stop-label {
    display: none;
  }

  .header-stop {
    padding: 0.4rem;
  }

  .title {
    font-size: 0.9rem;
  }

  /* Collapse all controls – hidden by default on mobile */
  .controls {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--border-r) var(--border-r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
    gap: 0.6rem;
    min-width: 220px;
    flex-direction: column;
    align-items: stretch;
    z-index: 200;
  }

  /* Open state – revealed by JS */
  .controls.open {
    display: flex;
  }

  .controls button {
    width: 100%;
    text-align: left;
  }

  /* Sur mobile : le more-menu s'intègre dans le flux hamburger */
  .more-menu {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .more-menu-btn {
    display: none !important;
  }

  .more-dropdown {
    display: flex !important;
    position: static !important;
    flex-direction: column !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    min-width: 0 !important;
    padding: 0 !important;
    gap: 0.6rem !important;
  }

  .more-dropdown button {
    height: 36px !important;
    padding: 0 14px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--bg-cart) !important;
    color: var(--txt) !important;
    font-weight: 600 !important;
  }

  .more-dropdown button:hover {
    background: var(--bg-cart-hover) !important;
    border-color: var(--txt-muted) !important;
  }

  .btn-text {
    display: inline;
  }

  #ctxMenu {
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    max-width: none !important;
    border-radius: 14px 14px 0 0;
  }
}

@media (max-width: 600px) {
  #grid {
    grid-template-columns: 1fr;
  }
}

/* ── Shortcut / MIDI Badge ────────────────────────────────── */
.shortcut-badge {
  position: absolute;
  top: 4px;
  left: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 55%;
  pointer-events: none;
  z-index: 1;
}

.shortcut-badge span {
  display: block;
  background: rgba(0, 0, 0, 0.62);
  color: #d1d5db;
  font-size: 0.60rem;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.5;
}

/* ── Key / MIDI Capture Overlay ───────────────────────────── */
.key-capture-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.key-capture-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  min-width: 280px;
}

.key-capture-msg {
  font-size: 1rem;
  color: var(--txt);
  margin-bottom: 1.5rem;
  animation: key-capture-pulse 1.4s ease-in-out infinite;
}

@keyframes key-capture-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.key-capture-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.key-capture-actions button {
  padding: 0.4rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--txt);
  transition: all 0.15s;
}

.key-capture-cancel {
  background: var(--bg-cart);
}

.key-capture-cancel:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

.key-capture-clear {
  background: var(--danger);
}

.key-capture-clear:hover {
  background: var(--danger-hover);
}

/* Wider context menu to fit shortcut labels */
#ctxMenu {
  max-width: 290px;
}

/* ── Audio Output Button ──────────────────────────────────── */
#audioOutputBtn {
  border-color: var(--border);
  background: var(--bg-cart);
  color: var(--txt-muted);
}

#audioOutputBtn:hover {
  background: var(--bg-cart-hover);
  color: var(--txt);
  border-color: var(--txt-muted);
}

/* ── Audio Output Panel ───────────────────────────────────── */
.audio-output-panel {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  padding: 6px 0;
  z-index: 600;
  min-width: 260px;
  max-width: 400px;
  max-height: 320px;
  overflow-y: auto;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 0.85rem;
}

.aop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--txt);
  cursor: pointer;
  transition: background 0.15s;
}

.aop-item:hover {
  background: var(--bg-cart-hover);
}

.aop-item.aop-active {
  color: var(--accent);
}

.aop-check {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.85rem;
}

.aop-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aop-msg {
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--txt-muted);
  line-height: 1.5;
}

.aop-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.aop-unlock {
  color: var(--txt-muted);
  font-size: 0.82rem;
  font-style: italic;
}

.aop-unlock:hover {
  background: var(--bg-cart-hover);
}

/* ── CUE badge on cart ────────────────────────────────────── */
.cue-badge {
  position: absolute;
  bottom: 10px;
  right: 6px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  pointer-events: none;
  z-index: 1;
  text-transform: uppercase;
}

/* ── Cue Modal Overlay ────────────────────────────────────── */
.cue-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  padding: 1rem;
}

.cue-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.5rem 1.2rem;
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* Header */
.cue-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.cue-modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.cue-cart-name {
  color: var(--txt-muted);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-close-btn {
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--txt);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.cue-close-btn:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

/* Info row (CUT-IN time | Total | CUT-OUT time) */
.cue-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-page);
  border-radius: 8px;
  padding: 0.6rem 1rem;
}

.cue-point-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cue-in-info  { align-items: flex-start; }
.cue-out-info { align-items: flex-end; }

.cue-point-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--txt-muted);
}

.cue-in-lbl  { color: #22c55e; }
.cue-out-lbl { color: #ef4444; }

.cue-point-time {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--txt-muted);
  transition: color 0.2s;
}

.cue-total-dur {
  font-size: 0.78rem;
  color: var(--txt-muted);
  text-align: center;
  flex-shrink: 0;
}

/* Waveform canvas */
.cue-canvas-wrap {
  position: relative;
  height: 96px;
  background: var(--bg-cart);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.cue-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.cue-canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-muted);
  font-size: 0.82rem;
  pointer-events: none;
  background: var(--bg-cart);
}

/* Controls row */
.cue-controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cue-mode-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.cue-mode-lbl {
  font-size: 0.78rem;
  color: var(--txt-muted);
  white-space: nowrap;
}

.cue-mode-btn {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--bg-cart);
  color: var(--txt-muted);
}

.cue-mode-btn:hover {
  background: var(--bg-cart-hover);
  color: var(--txt);
}

.cue-mode-in-btn.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: #22c55e;
  color: #22c55e;
}

.cue-mode-out-btn.active {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #ef4444;
}

.cue-hint {
  font-size: 0.7rem;
  color: var(--txt-empty);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.cue-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.cue-btn {
  padding: 0.42rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.15s;
}

.cue-btn-clear {
  background: var(--bg-cart);
  border: 1px solid var(--border);
  color: var(--txt-muted);
}

.cue-btn-clear:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
  color: var(--txt);
}

.cue-btn-apply {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.cue-btn-apply:hover {
  background: rgba(99, 102, 241, 0.28);
}

/* ── Responsive – Cue Modal ───────────────────────────────── */
@media (max-width: 600px) {
  .cue-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .cue-modal {
    border-radius: 14px 14px 0 0;
    max-width: 100%;
    padding: 1.2rem 1rem 1rem;
    max-height: 75vh;
    overflow-y: auto;
  }

  .cue-hint {
    display: none;
  }

  .cue-canvas-wrap {
    height: 76px;
  }

  .cue-info-row {
    padding: 0.5rem 0.75rem;
  }

  .cue-point-time {
    font-size: 0.95rem;
  }

  .cue-controls-row {
    gap: 0.5rem;
  }
}

/* ============================================================
   PAD MODE ICON
   ============================================================ */
.pad-mode-icon {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  color: #fafafa;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, transform 0.15s;
  user-select: none;
  line-height: 1;
}

.pad-mode-icon:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.15);
}

/* ============================================================
   PAD EDIT BUTTON
   ============================================================ */
.pad-edit-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--txt-muted);
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s, transform 0.15s;
  user-select: none;
}

.cart:hover .pad-edit-btn {
  opacity: 1;
}

.pad-edit-btn:hover {
  background: rgba(99, 102, 241, 0.5);
  color: #fff;
  transform: scale(1.15);
}

/* ============================================================
   PAD VOLUME BAR
   ============================================================ */
.pad-volume-bar {
  position: absolute;
  bottom: var(--progress-h);
  right: 0;
  width: 4px;
  height: 0%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.4s ease, height 0.1s linear;
  border-radius: 2px 0 0 0;
  z-index: 2;
  pointer-events: none;
}

/* ============================================================
   CART HOLDING STATE
   ============================================================ */
.cart.holding {
  box-shadow: 0 0 0 2px var(--success);
}

/* ============================================================
   EDIT MODAL
   ============================================================ */
.edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  padding: 1rem;
}

.edit-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.edit-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.edit-modal-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.edit-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.edit-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--txt-muted);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.edit-tab:hover {
  color: var(--txt);
}

.edit-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tab content ──────────────────────────────────────────── */
.edit-tab-content {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.edit-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.edit-section.edit-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.edit-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.edit-input {
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  font-size: 0.85rem;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  padding: 0.45rem 0.7rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.edit-input:focus {
  border-color: var(--accent);
}

.edit-input-sm {
  width: 90px;
}

.edit-range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.edit-btn {
  padding: 0.5rem 0.85rem;
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.15s;
  text-align: left;
}

.edit-btn:hover {
  background: var(--bg-cart-hover);
  border-color: var(--txt-muted);
}

.edit-btn-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.edit-btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* ── Mode selector buttons ────────────────────────────────── */
.edit-mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.edit-mode-btn {
  padding: 0.5rem 0.7rem;
  background: var(--bg-cart);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.edit-mode-btn:hover {
  background: var(--bg-cart-hover);
  color: var(--txt);
}

.edit-mode-btn.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.edit-current-value {
  font-size: 0.85rem;
  color: var(--txt);
  padding: 0.3rem 0;
}

.edit-hint {
  font-size: 0.78rem;
  color: var(--txt-muted);
  padding: 0.3rem 0;
  line-height: 1.5;
}

/* ── Responsive – Edit Modal ──────────────────────────────── */
@media (max-width: 600px) {
  .edit-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .edit-modal {
    border-radius: 14px 14px 0 0;
    max-width: 100%;
    max-height: 85vh;
  }

  .edit-tabs {
    overflow-x: auto;
  }

  .edit-mode-group {
    grid-template-columns: 1fr;
  }
}