/* GARGANTUA — mission-control instrument styling.
   Palette: blue-tinted near-black void, cyan telemetry, amber accents. */

:root {
  --bg: #04070c;
  --ink: #b9d6e2;
  --ink-dim: #5f7d8c;
  --ink-faint: #3a4f5b;
  --amber: #ffb454;
  --amber-dim: #8a6a3c;
  --cyan: #7fe0ff;
  --line: rgba(127, 224, 255, 0.16);
  --line-strong: rgba(127, 224, 255, 0.32);
  --panel-bg: rgba(4, 8, 13, 0.82);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--mono);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  cursor: grab;
  touch-action: none;
}
#gl:active { cursor: grabbing; }

/* ---------- boot overlay ---------- */
#boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.9s ease;
  pointer-events: none;
}
#boot.done { opacity: 0; }
.boot-inner { text-align: center; }
.boot-title {
  font-size: 28px;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(127, 224, 255, 0.35);
}
.boot-sub {
  margin-top: 14px;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  animation: bootpulse 1.4s ease-in-out infinite;
}
@keyframes bootpulse { 50% { opacity: 0.35; } }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 20;
  font-size: 10px;
  line-height: 1.75;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  white-space: pre;
}
#hud .h-title { color: var(--cyan); letter-spacing: 0.22em; }
#hud .h-warn { color: var(--amber); }
#hud b { color: var(--ink); font-weight: 400; }

#flash {
  position: fixed;
  top: 100px;
  left: 16px;
  z-index: 30;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}
#flash.on { opacity: 1; }

#hint {
  position: fixed;
  right: 16px;
  bottom: 175px;
  z-index: 20;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* ---------- control panel ---------- */
#panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 40px;
  z-index: 25;
  width: 308px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 14px 14px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}
#panel::-webkit-scrollbar { width: 4px; }
#panel::-webkit-scrollbar-thumb { background: var(--ink-faint); }

body.ui-hidden #panel { transform: translateX(340px); opacity: 0; pointer-events: none; }
body.ui-hidden #hud, body.ui-hidden #hint { opacity: 0; }
#hud, #hint { transition: opacity 0.3s ease; }

.p-head {
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--cyan);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-strong);
}
.p-sub {
  margin-top: 4px;
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.p-section {
  margin-top: 16px;
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}
.p-section em { color: var(--amber-dim); font-style: normal; float: right; }

/* buttons */
.btn-row { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.pbtn {
  flex: 1 1 auto;
  min-width: 60px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  background: rgba(127, 224, 255, 0.04);
  border: 1px solid var(--line);
  padding: 7px 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pbtn:hover { color: var(--cyan); border-color: var(--line-strong); }
.pbtn.on {
  color: #08131a;
  background: var(--amber);
  border-color: var(--amber);
  text-shadow: none;
}
.pbtn.warn-on { color: #08131a; background: var(--cyan); border-color: var(--cyan); }

/* sliders */
.srow {
  display: grid;
  grid-template-columns: 108px 1fr 46px;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}
.srow label {
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.srow .sval {
  font-size: 9px;
  color: var(--amber);
  text-align: right;
}
.srow input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  cursor: pointer;
}
.srow input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
}
.srow input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  margin-top: -3px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 180, 84, 0.6);
}
.srow input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); }
.srow input[type="range"]::-moz-range-thumb {
  width: 8px; height: 8px; border: none; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 6px rgba(255, 180, 84, 0.6);
}

/* debug select */
.dsel {
  width: 100%;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: rgba(127, 224, 255, 0.05);
  border: 1px solid var(--line);
  padding: 7px 8px;
  outline: none;
}
.dsel option { background: #060b11; }

/* hotkey list */
.keys { margin-top: 10px; font-size: 8.5px; line-height: 2.0; letter-spacing: 0.1em; color: var(--ink-faint); }
.keys b { color: var(--ink-dim); font-weight: 400; }

/* ---------- floating UI toggle (touch devices) ---------- */
#uitoggle {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 35;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--amber);
  background: rgba(10, 8, 4, 0.72);
  border: 1px solid var(--amber-dim);
  padding: 7px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#uitoggle:active { background: var(--amber); color: #08131a; }
@media (max-width: 760px), (pointer: coarse) {
  #uitoggle { display: block; }
}
body.shot #uitoggle { display: none !important; }

/* ---------- audio LIVE badge (standalone, prominent) ---------- */
#audio-badge {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  font-family: var(--mono);
  color: var(--ink-faint);
  background: rgba(4, 8, 13, 0.72);
  border: 1px solid var(--line);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.25s, border-color 0.25s, background 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}
#audio-badge .ab-icon { font-size: 15px; line-height: 1; }
#audio-badge .ab-label { font-size: 10px; letter-spacing: 0.26em; }
#audio-badge .ab-bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
#audio-badge .ab-bars i { width: 3px; height: 4px; background: currentColor; transition: height 0.2s; }
#audio-badge:hover { color: var(--ink-dim); border-color: var(--line-strong); }
#audio-badge.on {
  color: var(--cyan);
  border-color: rgba(127, 224, 255, 0.55);
  background: rgba(127, 224, 255, 0.08);
  box-shadow: 0 0 22px rgba(127, 224, 255, 0.35);
}
#audio-badge.on .ab-bars i { animation: abbar 0.85s ease-in-out infinite; }
#audio-badge.on .ab-bars i:nth-child(2) { animation-delay: 0.28s; }
#audio-badge.on .ab-bars i:nth-child(3) { animation-delay: 0.56s; }
@keyframes abbar { 0%, 100% { height: 4px; } 50% { height: 14px; } }
body.ui-hidden #audio-badge { opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
body.shot #audio-badge { display: none; }

/* ---------- DJ deck (3-tier: mixer / rails / transport) ---------- */
#deck {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: min(920px, calc(100vw - 20px));
  background: rgba(4, 8, 13, 0.82);
  border: 1px solid var(--line);
  border-top: 1px solid rgba(255, 84, 200, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 32px rgba(255, 84, 200, 0.08), 0 6px 24px rgba(0, 0, 0, 0.55);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}
body.ui-hidden #deck { transform: translateX(-50%) translateY(140%); opacity: 0; pointer-events: none; }

/* ---- expandable mixer panel ---- */
#mixer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid transparent;
}
body.mixer-open #mixer {
  max-height: 340px;
  border-bottom-color: var(--line);
}
.mx-section { padding: 10px 14px 4px; }
.mx-section:last-child { padding-bottom: 12px; }
.mx-label {
  font-size: 8px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.mx-label em { color: var(--ink-faint); font-style: normal; letter-spacing: 0.14em; margin-left: 8px; }

/* crossfader row */
.xfade-row { display: flex; align-items: center; gap: 12px; }
.xfade-side { display: flex; align-items: center; gap: 7px; min-width: 0; }
.xfade-side.right { justify-content: flex-end; }
.xfade-tag {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #08131a;
  background: var(--cyan);
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  box-shadow: 0 0 8px rgba(127, 224, 255, 0.5);
}
.xfade-side.right .xfade-tag { background: #ff54c8; box-shadow: 0 0 8px rgba(255, 84, 200, 0.5); }
.xfade-name {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xfade {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
  min-width: 80px;
}
.xfade::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(90deg, var(--cyan), #2a3a4a 50%, #ff54c8);
}
.xfade::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 20px;
  margin-top: -8px;
  background: var(--amber);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 180, 84, 0.8);
}
.xfade::-moz-range-track { height: 4px; background: linear-gradient(90deg, var(--cyan), #2a3a4a 50%, #ff54c8); }
.xfade::-moz-range-thumb {
  width: 12px; height: 20px; border: none; border-radius: 2px;
  background: var(--amber); box-shadow: 0 0 10px rgba(255, 180, 84, 0.8);
}
.xfade-sel {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: rgba(255, 84, 200, 0.07);
  border: 1px solid rgba(255, 84, 200, 0.35);
  padding: 5px 6px;
  outline: none;
  max-width: 130px;
}
.xfade-sel option { background: #0a0610; }

/* stem chips */
.stem-row { display: flex; gap: 6px; flex-wrap: wrap; }
.stem-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
  padding: 6px 8px;
  font-family: var(--mono);
  color: var(--ink-dim);
  background: rgba(127, 224, 255, 0.04);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.stem-chip:hover { border-color: var(--line-strong); color: var(--cyan); }
.stem-chip .stem-name { font-size: 7.5px; letter-spacing: 0.22em; color: var(--ink-faint); }
.stem-chip .stem-src { font-size: 9.5px; letter-spacing: 0.08em; }
.stem-chip.set {
  border-color: rgba(255, 84, 200, 0.55);
  background: rgba(255, 84, 200, 0.10);
}
.stem-chip.set .stem-src { color: #ffd7f0; }
.stem-chip.set .stem-name { color: rgba(255, 84, 200, 0.7); }

/* color faders row */
.color-row { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---- chip rails (BODY / TRACK) ---- */
.rail {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 0;
}
.rail-label {
  font-size: 8px;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
  flex: none;
  width: 44px;
}
.rail-strip {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
  -webkit-overflow-scrolling: touch;
}
.rail-strip::-webkit-scrollbar { height: 3px; }
.rail-strip::-webkit-scrollbar-thumb { background: var(--ink-faint); }

.chip {
  flex: none;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  background: rgba(127, 224, 255, 0.05);
  border: 1px solid var(--line);
  padding: 8px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { color: var(--cyan); border-color: var(--line-strong); }
.chip.on {
  color: #08131a;
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 14px rgba(255, 180, 84, 0.45);
}
.chip.track.live {
  box-shadow: 0 0 16px rgba(255, 84, 200, 0.55);
  border-color: #ff54c8;
  color: #ffd7f0;
}
.chip.track.on.live { color: #08131a; }
.chip.power {
  color: var(--cyan);
  border-color: var(--line-strong);
  font-size: 12px;
  padding: 6px 13px;
}
.chip.power.warn-on {
  color: #08131a;
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(127, 224, 255, 0.6);
  animation: powerpulse 1.6s ease-in-out infinite;
}
@keyframes powerpulse { 50% { box-shadow: 0 0 6px rgba(127, 224, 255, 0.3); } }

/* ---- transport bar ---- */
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 12px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.tbtn {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  background: rgba(127, 224, 255, 0.05);
  border: 1px solid var(--line);
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:hover { color: var(--cyan); border-color: var(--line-strong); }
.tbtn.on {
  color: #08131a;
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 12px rgba(255, 180, 84, 0.4);
}
.tbtn.drop {
  color: #ffd7f0;
  border-color: rgba(255, 84, 200, 0.6);
  background: rgba(255, 84, 200, 0.12);
  font-weight: 700;
  padding: 9px 20px;
}
.tbtn.drop:hover, .tbtn.drop:active {
  background: #ff54c8;
  color: #14040f;
  box-shadow: 0 0 22px rgba(255, 84, 200, 0.8);
}
.t-spacer { flex: 1; }

/* horizontal fader */
.fader { display: flex; align-items: center; gap: 8px; }
.fader-label { font-size: 8px; letter-spacing: 0.22em; color: var(--ink-dim); flex: none; }
.fader-val { font-size: 9px; letter-spacing: 0.06em; color: var(--amber); min-width: 34px; text-align: right; flex: none; }
.fader input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
.fader input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, #ff54c8, #7fe0ff);
}
.fader input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px; height: 16px;
  margin-top: -6.5px;
  background: var(--amber);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 180, 84, 0.8);
}
.fader input[type="range"]::-moz-range-track { height: 3px; background: linear-gradient(90deg, #ff54c8, #7fe0ff); }
.fader input[type="range"]::-moz-range-thumb {
  width: 9px; height: 16px; border: none; border-radius: 2px;
  background: var(--amber); box-shadow: 0 0 8px rgba(255, 180, 84, 0.8);
}

/* ---------- mode flash ---------- */
#modeflash {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 28;
  font-size: clamp(38px, 9vw, 104px);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 84, 200, 0.9), 0 0 60px rgba(127, 224, 255, 0.6);
  opacity: 0;
  pointer-events: none;
}
#modeflash.on { animation: modepop 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes modepop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
}

/* params drawer is closed by default in the DJ build */
#panel { transform: translateX(340px); opacity: 0; pointer-events: none; }
body.adv #panel { transform: translateX(0); opacity: 1; pointer-events: auto; }
body.adv.ui-hidden #panel { transform: translateX(340px); opacity: 0; pointer-events: none; }

/* ---------- fatal / recovery overlay ---------- */
#fatal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 7, 0.92);
}
#fatal[hidden] { display: none; }
#fatal-box { text-align: center; max-width: 80vw; }
#fatal-title {
  font-size: 18px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--amber);
}
#fatal-msg {
  margin-top: 14px;
  font-size: 10px;
  line-height: 2;
  letter-spacing: 0.15em;
  color: var(--ink-dim);
  white-space: pre-wrap;
}

/* ---------- screenshot mode ---------- */
body.shot #hud, body.shot #hint, body.shot #panel, body.shot #boot { display: none !important; }
body.shot #gl { position: absolute; inset: auto; left: 0; top: 0; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  #panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 200px;
    width: auto;
    max-height: 42vh;
  }
  body.ui-hidden #panel { transform: translateY(120%); }
  #hud { font-size: 9px; top: 10px; left: 10px; }
  #hint { display: none; }
  #flash { top: 82px; left: 10px; }

  /* stack audio badge above the HIDE UI button */
  #audio-badge { top: 10px; right: 10px; padding: 8px 12px; }
  #uitoggle { top: 56px; }

  #deck {
    left: 8px;
    right: 8px;
    bottom: 8px;
    transform: none;
    width: auto;
  }
  body.ui-hidden #deck { transform: translateY(140%); }

  /* bigger touch targets */
  .chip { padding: 11px 13px; font-size: 10px; }
  .tbtn { padding: 11px 14px; font-size: 10px; }

  /* stem chips: guaranteed 3-column grid, taller for touch */
  .stem-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stem-chip { min-width: 0; padding: 10px 4px; }
  .stem-chip .stem-src { font-size: 10px; }

  .rail { padding: 9px 10px 0; gap: 8px; }
  .rail-label { width: 38px; font-size: 7.5px; }

  .transport { padding: 9px 10px 11px; gap: 6px; }
  .fader input[type="range"] { width: 70px; }

  .xfade-row { flex-wrap: wrap; }
  .xfade { flex-basis: 100%; order: 3; }
  .xfade-name { max-width: 80px; }

  /* mixer becomes a scrollable sheet, capped so the visual stays visible */
  body.mixer-open #mixer { max-height: 44vh; overflow-y: auto; }
}
