/* ============================================================
   PULSO — Procreate-inspired UI
   Two icon sidebars, floating modals, warm dark palette
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Procreate-style warm dark grey, not pure black */
  --bg-0: #131316;
  --bg-1: #1a1a1d;
  --bg-2: #232328;
  --bg-3: #2c2c32;
  --bg-modal: #1f1f24;
  --bg-elevated: rgba(38, 38, 44, 0.96);

  /* Subtle borders */
  --line-1: rgba(255, 255, 255, 0.05);
  --line-2: rgba(255, 255, 255, 0.09);
  --line-3: rgba(255, 255, 255, 0.14);

  /* Text — softer than VDMX version */
  --text-0: #B388FF;
  --text-1: #b8b3a8;
  --text-2: #7a7670;
  --text-3: #4a4640;

  /* VETA accents — softer, less neon */
  --acc-purple: #B388FF;
  --acc-gold: #d4a83a;
  --acc-purple-soft: rgba(179,136,255, 0.65);
  --acc-violet: #9b87c4;
  --acc-cyan: #6cc8d4;
  --acc-green: #a8c870;
  --acc-red: #d07070;

  /* Type — SF/Inter for UI, Cormorant only for wordmark */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'SF Mono', 'Menlo', monospace;

  /* Procreate-style readable sizes */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;

  /* Generous touch targets */
  --touch: 44px;
  --row-h: 38px;

  /* Procreate-style generous rounding */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-bar: 0 4px 24px rgba(0, 0, 0, 0.35);

  /* Sidebar widths */
  --left-bar: 60px;
  --right-bar: 44px;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  font-weight: 400;
  letter-spacing: -0.01em;
  user-select: none;
  -webkit-user-select: none;
}

#webgl, #source {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  touch-action: none;
}
#source { display: none; }

/* ============================================================
   LEFT SIDEBAR — Section icons (Procreate-style vertical rail)
   ============================================================ */

#leftBar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--left-bar);
  padding: calc(14px + env(safe-area-inset-top)) 0 calc(14px + env(safe-area-inset-bottom));
  background: var(--bg-1);
  border-right: 1px solid var(--line-1);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
}
#leftBar::-webkit-scrollbar { display: none; }

/* Wordmark at top of left bar */
.brand {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--acc-purple);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  font-style: italic;
}

.tool {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
  flex-shrink: 0;
}
.tool svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.tool:active {
  transform: scale(0.94);
}
.tool.on {
  color: var(--acc-purple);
  background: rgba(179,136,255, 0.12);
}
.tool.on::after {
  /* Subtle dot indicator for active state */
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--acc-purple);
}
/* Active feature indicator (when a signal source is active) */
.tool[data-active="1"]::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acc-green);
  box-shadow: 0 0 6px var(--acc-green);
}

.tool-divider {
  width: 30px;
  height: 1px;
  background: var(--line-1);
  margin: 6px 0;
  flex-shrink: 0;
}

/* ============================================================
   RIGHT SIDEBAR — Always-visible quick sliders (Procreate-style)
   ============================================================ */

#rightBar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--right-bar);
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom));
  background: var(--bg-1);
  border-left: 1px solid var(--line-1);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vslider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  width: 32px;
}
.vslider > .lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-2);
  text-transform: uppercase;
}
.vslider > .track {
  position: relative;
  width: 4px;
  height: 140px;
  background: var(--bg-3);
  border-radius: 2px;
  cursor: pointer;
}
.vslider > .track > .fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--acc-purple-soft), var(--acc-purple));
  border-radius: 2px;
  transition: height 80ms ease;
}
.vslider > .track > .thumb {
  position: absolute;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-0);
  border: 2px solid var(--bg-1);
  transform: translate(-50%, 50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: grab;
}
.vslider > .track > .thumb:active { cursor: grabbing; }
.vslider > .val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--acc-purple);
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  text-align: center;
}

/* ============================================================
   TOP-LEFT live indicators
   ============================================================ */

#topInfo {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(var(--left-bar) + 14px);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
#topInfo .bpm {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--acc-green);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  backdrop-filter: blur(12px);
}
#topInfo .bpm.beat { color: var(--acc-purple); }

/* ============================================================
   MODALS — Procreate-style floating sheets
   ============================================================ */

#modalScrim {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: none;
  animation: scrimIn 0.2s ease forwards;
  pointer-events: none;  /* purely decorative — modal closes via × or icon */
}
#modalScrim.on { display: block; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: fixed;
  top: 50%;
  left: calc(var(--left-bar) + 16px);
  transform: translateY(-50%);
  width: min(380px, calc(100vw - var(--left-bar) - var(--right-bar) - 28px));
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
  overscroll-behavior: contain;
  background: var(--bg-modal);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  z-index: 15;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  display: none;
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.modal.on { display: block; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-50%) scale(0.96); }
  to   { opacity: 1; transform: translateY(-50%) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-1);
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text-0);
  font-style: italic;
}
.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-2);
  color: var(--text-1);
  border-radius: var(--r-md);
  font-size: 22px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.modal-close:hover { color: var(--text-0); background: var(--bg-3); }
.modal-close:active { transform: scale(0.94); }

.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 3px;
}

/* ============================================================
   Form elements inside modals — Procreate style
   ============================================================ */

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 6px;
  font-size: var(--fs-sm);
  color: var(--text-1);
  font-weight: 500;
  letter-spacing: 0;
}
label .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
label .val {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--acc-purple);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

input, select, textarea, button {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  color: var(--text-0);
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  outline: none;
  letter-spacing: -0.01em;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--acc-purple);
  background: var(--bg-3);
}

select {
  touch-action: manipulation;
  position: relative;
  z-index: 30;
  width: 100%;
  height: var(--row-h);
  padding: 0 32px 0 12px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23d4a83a' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>") no-repeat right 12px center;
  background-size: 10px;
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
}
select option { background: var(--bg-2); color: var(--text-0); }

/* Cycle buttons — replace selects, look like inputs */
button.cycle {
  touch-action: manipulation;
  position: relative;
  z-index: 30;
  width: 100%;
  height: var(--row-h);
  padding: 0 32px 0 12px;
  background: var(--bg-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M9 4l-2-2v1.5C4.5 3.5 2.5 5.5 2.5 8H4c0-1.65 1.35-3 3-3v1.5L9 4z M3 8l2 2v-1.5c2.5 0 4.5-2 4.5-4.5H8c0 1.65-1.35 3-3 3V5.5L3 8z' fill='%23d4a83a'/></svg>") no-repeat right 10px center;
  background-size: 14px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-0);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
  letter-spacing: -0.01em;
  text-transform: none;
}
button.cycle:hover { background-color: var(--bg-3); }
button.cycle:active { transform: scale(0.98); }

input[type=number] {
  width: 100%;
  height: var(--row-h);
  padding: 0 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
input[type=color] {
  width: 100%;
  height: var(--row-h);
  padding: 4px;
  cursor: pointer;
}
input[type=file] {
  width: 100%;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

textarea {
  width: 100%;
  min-height: 70px;
  padding: 12px;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  resize: vertical;
  line-height: 1.5;
}

button {
  height: var(--row-h);
  padding: 0 14px;
  background: var(--bg-2);
  border: 1px solid transparent;
  color: var(--text-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
  text-transform: none;
}
button:hover {
  background: var(--bg-3);
}
button:active {
  transform: scale(0.97);
}
button.on {
  background: rgba(179,136,255, 0.16);
  border-color: var(--acc-purple);
  color: var(--acc-purple);
}
button.primary {
  background: var(--acc-purple);
  color: var(--bg-0);
  font-weight: 600;
}
button.primary:hover { background: #e8bc4c; }
button.primary.on {
  background: var(--acc-red);
  color: var(--text-0);
}
button.danger {
  background: rgba(208, 112, 112, 0.14);
  color: var(--acc-red);
  border-color: rgba(208, 112, 112, 0.3);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   Range sliders — Procreate-style: clean track, prominent thumb
   ============================================================ */

input[type=range] {
  position: relative;
  z-index: 30;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border: none;
  touch-action: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-0);
  border: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  margin-top: -9px;
  cursor: grab;
}
input[type=range]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.1);
}
input[type=range]::-moz-range-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-0);
  border: 0;
  cursor: grab;
}

/* ============================================================
   Scene tiles (special — bigger, more visual)
   ============================================================ */

.scene-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
.scene-grid button {
  height: 64px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.03em;
  position: relative;
  background: var(--bg-2);
}
.scene-grid button.on {
  background: linear-gradient(135deg, rgba(179,136,255, 0.18), rgba(155, 135, 196, 0.10));
  border-color: var(--acc-purple);
  color: var(--acc-purple);
}
.scene-actions button[data-scene-clear].on {
  background: rgba(255,255,255,0.06);
  border-color: var(--text-2);
  color: var(--text-1);
}
.slot-heading {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  color: var(--text-1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================================================
   Preset slots
   ============================================================ */
.presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.slot-card {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.025);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.bank-card {
  min-height: 132px;
}
.slot-card.on {
  border-color: var(--acc-green);
  background: linear-gradient(135deg, rgba(168, 200, 112, 0.10), rgba(179,136,255, 0.05));
}
.bank-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.bank-letter {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(179,136,255, 0.65);
  color: var(--acc-purple);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
}
.bank-state {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.08em;
}
.slot-title {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-1);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.slot-preview {
  min-height: 28px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.35;
}
.bank-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.bank-actions button[data-slot-action="clear"] {
  grid-column: span 2;
}
.presets button {
  width: 100%;
  min-height: 30px;
  margin-top: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}
.presets button[data-slot-action="save"] {
  border-color: rgba(179,136,255, 0.45);
}
.presets button[data-slot-action="clear"] {
  opacity: .7;
}
.presets button:disabled {
  opacity: .35;
  pointer-events: none;
}
@media (max-width: 520px) {
  .presets { grid-template-columns: 1fr; }
  .bank-card { min-height: 0; }
}

.hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
  margin: 10px 0 4px;
  font-style: italic;
  font-weight: 400;
}

/* ============================================================
   Signal groups inside Signal modal
   ============================================================ */

.signal-group {
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  padding: 12px;
  margin: 10px 0 14px;
  background: var(--bg-1);
}
.signal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-0);
  font-weight: 600;
  margin-bottom: 8px;
}
.signal-head button {
  height: 28px;
  padding: 0 12px;
  font-size: var(--fs-xs);
}

/* Audio meter (live FFT bars) */
#audioMeter {
  display: none;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--bg-0);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
}
#audioMeter.on { display: grid; }
#audioMeter .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--acc-green);
  box-shadow: 0 0 6px var(--acc-green);
  animation: pulseDot 1.2s infinite alternate;
}
@keyframes pulseDot { from { opacity: 0.4; } to { opacity: 1; } }
#audioMeterBars {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 3px;
  height: 16px;
  align-items: end;
}
#audioMeterBars span {
  background: linear-gradient(to top, var(--acc-green), var(--acc-cyan));
  border-radius: 2px;
  transform-origin: bottom;
  transform: scaleY(0.05);
  transition: transform 60ms linear;
}

/* Motion meter (webcam) */
.single-meter {
  display: none;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.single-meter.on { display: grid; }
.single-meter .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--acc-green);
  box-shadow: 0 0 6px var(--acc-green);
  animation: pulseDot 1.2s infinite alternate;
}
.single-meter .bar {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.single-meter .bar > span {
  display: block;
  height: 100%;
  width: 5%;
  background: linear-gradient(to right, var(--acc-cyan), var(--acc-green));
  transition: width 80ms linear;
  border-radius: 3px;
}

/* Tilt meters (per-axis bipolar needles) */
#tiltMeters {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}
#tiltMeters.on { display: flex; }
.axis-meter {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  align-items: center;
  height: 18px;
}
.axis-meter .lbl {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-align: center;
  font-weight: 600;
}
.axis-meter .track {
  position: relative;
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.axis-meter .track::before {
  content: "";
  position: absolute;
  top: -1px; bottom: -1px;
  left: 50%;
  width: 1px;
  background: var(--line-3);
}
.axis-meter .needle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--acc-cyan);
  box-shadow: 0 0 6px var(--acc-cyan);
  transform: translateX(-50%);
  transition: left 60ms linear;
}
.axis-meter .bar-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  background: linear-gradient(to right, var(--acc-violet), var(--acc-red));
  transition: width 60ms linear;
  border-radius: 3px;
}

#tiltMap {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-1);
}
#tiltMap.on { display: block; }
.tilt-map-row {
  display: grid;
  grid-template-columns: 18px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}
.tilt-map-row .lbl {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--acc-purple);
  font-weight: 700;
  text-align: center;
}
.tilt-map-row select { height: 30px; font-size: var(--fs-xs); padding: 0 24px 0 8px; }
.tilt-map-row button { height: 30px; padding: 0; font-size: var(--fs-xs); }
.tilt-map-row button.on {
  background: rgba(168, 200, 112, 0.16);
  border-color: var(--acc-green);
  color: var(--acc-green);
}

/* MIDI status pill */
#midiStatus {
  display: none;
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--bg-0);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
#midiStatus.on {
  display: block;
  color: var(--acc-violet);
}
#midiStatus .badge {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--acc-violet);
  margin-right: 8px;
  vertical-align: middle;
  animation: pulseDot 1.5s infinite alternate;
}

body.midi-learn { cursor: crosshair; }
body.midi-learn label[data-midi-learnable] {
  outline: 1px dashed var(--acc-violet);
  outline-offset: 2px;
  border-radius: 4px;
}
label[data-midi-bound] { position: relative; }
label[data-midi-bound]::after {
  content: "M";
  position: absolute;
  top: 0;
  right: 0;
  width: 16px; height: 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--acc-violet);
  background: rgba(155, 135, 196, 0.16);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* --- MIDI ampliado (fix23): vsliders y botones cycle aprendibles + blink --- */

/* Cuando Learn está armado, resaltar también los nuevos objetivos aprendibles. */
body.midi-learn .vslider[data-midi-learnable],
body.midi-learn button.cycle[data-midi-learnable] {
  outline: 1px dashed var(--acc-violet);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Marca "M" en vsliders/botones ya mapeados. */
.vslider[data-midi-bound],
button.cycle[data-midi-bound] { position: relative; }
.vslider[data-midi-bound]::after,
button.cycle[data-midi-bound]::after {
  content: "M";
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  font-family: var(--font-mono);
  font-size: 8px; font-weight: 700;
  color: var(--acc-violet);
  background: rgba(155, 135, 196, 0.16);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Blink al recibir un CC: pulso de luz que confirma que el MIDI está vivo. */
.midi-active {
  animation: pulsoMidiPulse .18s ease-out;
}
.midi-active::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--acc-cyan, #6ee7ff), 0 0 12px var(--acc-cyan, #6ee7ff);
  opacity: .9;
  pointer-events: none;
  animation: pulsoMidiFade .18s ease-out forwards;
}
@keyframes pulsoMidiPulse {
  0% { filter: brightness(1.6); }
  100% { filter: brightness(1); }
}
@keyframes pulsoMidiFade {
  0% { opacity: .9; }
  100% { opacity: 0; }
}
/* el ::before necesita un contexto posicionado */
.vslider, button.cycle, .modal label { position: relative; }

.hydra-status {
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: 8px 12px;
  background: var(--bg-0);
  border-radius: var(--r-sm);
  margin: 8px 0;
}
.hydra-status.on { color: var(--acc-violet); }
.hydra-status.loading { color: var(--acc-purple); }
.hydra-status.error { color: var(--acc-red); }

.hydra-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}
.hydra-presets button {
  height: 40px;
  font-size: var(--fs-xs);
  text-align: left;
  padding: 0 12px;
  font-weight: 500;
}
.hydra-presets button.on {
  background: rgba(155, 135, 196, 0.16);
  border-color: var(--acc-violet);
  color: var(--acc-violet);
}

.hydra-editor {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-1);
}
.hydra-editor.on { display: block; }
#hydraCode {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  min-height: 150px;
  background: var(--bg-0);
  padding: 12px;
}
.hydra-error {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--acc-red);
  background: rgba(208, 112, 112, 0.10);
  border: 1px solid rgba(208, 112, 112, 0.3);
  line-height: 1.4;
}
.hydra-error.on { display: block; }

.editor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--text-1);
}
.editor-head span {
  font-size: var(--fs-xs);
  font-weight: 700;
}
.editor-head small {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
}
.hydra-editor-status {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-2);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--line-1);
}
.hydra-editor-status.ok { color: var(--acc-purple); border-color: rgba(179,136,255,0.35); }
.hydra-editor-status.warn { color: var(--acc-purple); }
.hydra-editor-status.error { color: var(--acc-red); border-color: rgba(208,112,112,0.35); }


/* ============================================================
   Timeline (kept functional, restyled to fit Procreate look)
   ============================================================ */

.pulso-mini-transport {
  display: grid;
  grid-template-columns: 40px 40px 40px 1fr;
  gap: 6px;
  align-items: center;
  margin: 8px 0 12px;
}
.pulso-mini-transport button {
  height: 38px;
  font-size: 16px;
  padding: 0;
}
#ndTimecode {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--acc-cyan);
  font-size: var(--fs-md);
  font-weight: 500;
  padding-right: 6px;
}

#ndTimeline {
  position: relative;
  border-radius: var(--r-md);
  min-height: 140px;
  padding: 22px 8px 8px 56px;
  margin-top: 8px;
  background: var(--bg-0);
  overflow: hidden;
}
#ndTimeline::before {
  content: "";
  position: absolute;
  top: 0; left: 56px; right: 8px; height: 18px;
  background: repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px 36px);
}
#ndPlayhead {
  position: absolute;
  top: 0; bottom: 0; left: 56px;
  width: 1px;
  background: var(--acc-cyan);
  box-shadow: 0 0 6px var(--acc-cyan);
  z-index: 5;
}
.ndTrack {
  height: 26px;
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
}
.ndTrack > span {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.06em;
}
.ndTrack > div {
  height: 20px;
  border-radius: 4px;
  background: var(--bg-1);
  position: relative;
}
.ndKey {
  position: absolute;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--acc-purple);
  box-shadow: 0 0 6px rgba(179,136,255, 0.5);
}

#teTracks {
  margin-top: 8px;
  border-radius: var(--r-md);
  background: var(--bg-0);
  padding: 8px;
  max-height: 240px;
  overflow: auto;
}
.teTrack {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
}
.teTrack label {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.teLane {
  position: relative;
  height: 18px;
  border-radius: 3px;
  background: var(--bg-1);
}
.teKey {
  position: absolute;
  top: 3px;
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--acc-cyan);
}
.teKey.scene { background: var(--acc-violet); }

/* ============================================================
   Floating chrome — REC, watermark, restore button
   ============================================================ */

#restoreUI {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 16;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--acc-purple);
  border: 1px solid var(--line-2);
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
}
body.hide-ui #restoreUI { display: flex; }
body.hide-ui #leftBar,
body.hide-ui #rightBar,
body.hide-ui #topInfo,
/* hide-ui modal: ver whiteOverlayFix.css */
body.hide-ui #rightBar { transform: translateX(100vw); }
body.hide-ui #topInfo { opacity: 0; }

#recHud {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(var(--right-bar) + 14px);
  z-index: 20;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: rgba(208, 112, 112, 0.14);
  border: 1px solid var(--acc-red);
  color: var(--acc-red);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  display: none;
  backdrop-filter: blur(8px);
}
#recHud::before {
  content: "●";
  margin-right: 6px;
  animation: recBlink 1s infinite;
}
#recHud.active { display: block; }
@keyframes recBlink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.2; } }

#recProgress {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top));
  right: calc(var(--right-bar) + 14px);
  z-index: 20;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: rgba(179,136,255, 0.14);
  border: 1px solid var(--acc-purple);
  color: var(--acc-purple);
  font-size: var(--fs-xs);
  display: none;
  backdrop-filter: blur(8px);
}

#performStopBtn {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  right: calc(var(--right-bar) + 16px);
  z-index: 25;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--acc-red);
  background: rgba(30, 0, 0, 0.65);
  color: var(--acc-red);
  font-size: 14px;
  display: none;
  backdrop-filter: blur(12px);
  opacity: 0.3;
  transition: opacity 0.2s;
}
#performStopBtn:hover, #performStopBtn:active { opacity: 1; }
body.perform-mode #performStopBtn { display: flex; align-items: center; justify-content: center; }

/* Watermark */
#pulsoWatermark {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  right: calc(var(--right-bar) + 14px);
  z-index: 20;
  text-align: right;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.3s;
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: rgba(179,136,255, 0.5);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
  line-height: 1;
}
#pulsoWatermark small {
  display: block;
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(122, 118, 112, 0.7);
  margin-top: 4px;
  font-style: normal;
  font-weight: 500;
}
body.clean-mode #pulsoWatermark { opacity: 0; visibility: hidden; }
body.clean-mode #recHud,
body.clean-mode #recProgress { opacity: 0; pointer-events: none; }

#firstHint {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--acc-purple);
  color: var(--acc-purple);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  display: none;
  backdrop-filter: blur(8px);
  animation: hintFade 4s forwards;
  pointer-events: none;
}
#firstHint.show { display: block; }
@keyframes hintFade {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ============================================================
   Small phones / narrow screens — collapse right bar
   ============================================================ */
@media (max-width: 480px) {
  :root {
    --left-bar: 52px;
    --right-bar: 36px;
  }
  .modal {
    left: calc(var(--left-bar) + 10px);
    width: calc(100vw - var(--left-bar) - var(--right-bar) - 20px);
  }
  .vslider > .track { height: 100px; }
}

/* ============================================================
   Visual Sequencer V2 — clearer timeline, tracks and automation
   ============================================================ */
.seq-section {
  margin: 12px 0 16px;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
}
.seq-section-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--acc-purple);
  margin-bottom: 10px;
  font-weight: 700;
}
.seq-mode-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0 12px;
}
.seq-mode {
  height: 36px;
  padding: 0 8px;
  font-size: var(--fs-xs);
  border-color: rgba(255,255,255,0.08);
}
.seq-mode.active {
  color: var(--acc-purple);
  border-color: rgba(179,136,255,0.65);
  background: rgba(179,136,255,0.13);
  box-shadow: 0 0 12px rgba(179,136,255,0.12);
}
.visual-sequencer {
  min-height: 244px !important;
  padding: 34px 10px 12px 116px !important;
  touch-action: none;
}
.visual-sequencer .seq-ruler {
  position: absolute;
  top: 8px;
  left: 116px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
}
.visual-sequencer::before {
  left: 116px !important;
  right: 12px !important;
  top: 24px !important;
  height: calc(100% - 36px) !important;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.13) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.055) 0 1px, transparent 1px 16px) !important;
  opacity: .8;
}
.visual-sequencer #ndPlayhead {
  left: 116px;
  top: 24px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
}
.visual-sequencer .ndTrack {
  grid-template-columns: 104px 1fr !important;
  height: 26px;
  margin: 6px 0;
}
.visual-sequencer .ndTrack > span {
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: none;
  color: rgba(255,255,255,.62);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.visual-sequencer .ndTrack > div {
  height: 22px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.035);
}
.visual-sequencer .ndKey {
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 5px;
  transform: translateX(-50%);
}
#teTracks {
  max-height: 280px;
  padding: 10px;
}
.teTrack {
  grid-template-columns: 104px 1fr;
  margin: 7px 0;
}
.teLane {
  height: 22px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, transparent 1px 42px),
    rgba(255,255,255,.04);
}
.teKey {
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 5px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(104,224,255,.35);
}
.teTrack label {
  font-size: 11px;
  color: rgba(255,255,255,.72);
}


/* iOS slider rescue: bigger hit area and no scroll-stealing while dragging range controls */
.modal label:has(input[type="range"]) { touch-action: none; }
input[type=range] {
  min-height: 38px;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
}
input[type=range]::-webkit-slider-runnable-track { height: 5px; }
input[type=range]::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -10.5px;
}

/* Pulso real slider fix: range controls inside glass modals must drag on iOS, not scroll the panel like a cursed receipt. */
input[type="range"], #tunnelDepth, #tunnelOpacity, #tunnelSpeed, #tunnelSegments, #tunnelGlow, #tunnelGrid {
  touch-action: none !important;
  -webkit-user-select: none;
  user-select: none;
}

/* ============================================================
   FX Chain (reorderable pass list inside Effects modal)
   ============================================================ */
.fx-chain-panel { background: var(--bg-0); }
.fx-chain-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.fx-chain-item {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background .12s, border-color .12s, opacity .15s, transform .15s;
}
.fx-chain-item.off { opacity: .35; }
.fx-chain-item.dragging { opacity: .6; border-color: var(--acc-cyan); transform: scale(.985); }
.fx-chain-item.drop-target { border-color: var(--acc-violet); background: rgba(155, 135, 196, 0.08); }
.fx-chain-item.no-op .fx-chain-name::after {
  content: ' · idle';
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-style: italic;
  font-weight: 400;
}
.fx-chain-handle {
  cursor: grab;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1;
  text-align: center;
  letter-spacing: -2px;
  touch-action: none;
}
.fx-chain-handle:active { cursor: grabbing; color: var(--acc-violet); }
.fx-chain-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .04em;
  color: var(--text-0);
}
.fx-chain-toggle {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.fx-chain-toggle.on {
  background: var(--acc-cyan);
  border-color: var(--acc-cyan);
  box-shadow: 0 0 6px var(--acc-cyan);
}
.fx-chain-move {
  width: 26px; height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 10px;
  line-height: 24px;
  cursor: pointer;
}
.fx-chain-move:active { background: var(--bg-0); border-color: var(--acc-violet); color: var(--acc-violet); }
.fx-chain-move[disabled] { opacity: .25; cursor: default; }

/* ============================================================
   Tunnel modal — Resolume-style refit
   ============================================================ */
.tunnel-toolbar {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.tunnel-toolbar button {
  height: 38px;
  padding: 0 10px;
  font-size: var(--fs-sm);
  letter-spacing: .02em;
}
.tunnel-power {
  font-weight: 700;
  border: 1px solid var(--line-1);
}
.tunnel-power.on {
  background: var(--acc-cyan);
  color: #0a0a0c;
  border-color: var(--acc-cyan);
  box-shadow: 0 0 12px rgba(108, 200, 212, 0.35);
}

/* Headline Depth slider: bigger thumb, FLAT↔DEEP end labels */
.tunnel-depth-group { background: var(--bg-0); }
.tunnel-big-slider {
  display: block;
}
.tunnel-big-slider .row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  margin-bottom: 8px;
}
.tunnel-big-slider .lbl-left,
.tunnel-big-slider .lbl-right {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--text-3);
}
.tunnel-big-slider .lbl-right { text-align: right; }
.tunnel-big-slider .val {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--acc-cyan);
  text-align: center;
  letter-spacing: .02em;
}
.tunnel-big-slider input[type="range"] {
  height: 44px;  /* large touch target on iPad */
  width: 100%;
}

/* iPad/iOS touch friendliness for all tunnel sliders */
.modal[data-modal="tunnel"] input[type="range"] {
  touch-action: none !important;
  -webkit-user-select: none;
  user-select: none;
  /* prevent the modal from intercepting drags before they reach the slider */
  position: relative;
  z-index: 2;
}

/* Alpha 19: surgical video-collage layer stack */
.layer-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:260px;
  overflow:auto;
  padding:6px;
  border:1px solid rgba(255,255,255,.1);
  border-radius:14px;
  background:rgba(0,0,0,.18);
}
.layer-list.empty{
  color:rgba(255,255,255,.55);
  font-size:12px;
  padding:14px;
}
.layer-row{
  display:grid;
  grid-template-columns:42px 1fr 34px;
  gap:10px;
  align-items:center;
  width:100%;
  min-height:52px;
  padding:7px;
  border:1px solid rgba(255,255,255,.09);
  border-radius:14px;
  background:rgba(255,255,255,.045);
  color:inherit;
  text-align:left;
}
.layer-row.active{
  border-color:rgba(231,200,108,.8);
  background:rgba(231,200,108,.13);
}
.layer-row.muted{ opacity:.48; }
.layer-row.locked .layer-meta b::after{ content:'  🔒'; font-size:11px; opacity:.8; }
.layer-thumb{
  display:grid;
  place-items:center;
  width:42px;
  height:38px;
  border-radius:10px;
  overflow:hidden;
  background:linear-gradient(135deg,rgba(255,255,255,.12),rgba(255,255,255,.03));
  background-size:cover;
  background-position:center;
  font-size:16px;
}
.layer-meta{ display:flex; flex-direction:column; min-width:0; }
.layer-meta b{ font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.layer-meta small{ font-size:10px; color:rgba(255,255,255,.58); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.layer-eye{
  display:grid;
  place-items:center;
  min-height:32px;
  border-radius:10px;
  background:rgba(0,0,0,.18);
  font-size:13px;
}
.collage-loader input[type="file"]{
  width:100%;
}


/* Alpha 20.1 UI interaction rescue: only modals + quick sliders. */
#leftBar, #rightBar { pointer-events: auto; }
#modalScrim { z-index: 90; pointer-events: none; }
.modal { z-index: 100; pointer-events: auto; }
.modal.on { display: block !important; visibility: visible !important; opacity: 1 !important; }
.tool { touch-action: manipulation; }
.vslider {
  width: 40px;
  min-height: 190px;
  touch-action: none;
  pointer-events: auto;
  justify-content: center;
}
.vslider > .track {
  width: 18px;
  background: transparent;
  touch-action: none;
}
.vslider > .track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-50%);
  background: var(--bg-3);
  border-radius: 2px;
}
.vslider > .track > .fill {
  left: 7px;
  right: 7px;
  z-index: 1;
}
.vslider > .track > .thumb { z-index: 2; }
body.hide-ui .modal.on,
body.hide-ui #modalScrim.on { display: none !important; }


/* Alpha 21 modular layer engine */
.module-stack-panel .module-row .layer-thumb{font-size:15px;}
.module-stack-panel select{width:100%;min-height:38px;border-radius:12px;background:rgba(255,255,255,.08);color:var(--text,#B388FF);border:1px solid rgba(255,255,255,.14);padding:8px 10px;}
.module-stack-panel option{background:#111;color:#fff;}
.module-row.active{outline:1px solid rgba(231,200,108,.75);}

/* Alpha 21.4a: Layers modal scroll rescue for iPad Safari.
   The previous touch kernel correctly protected controls, but it also left
   .modal with touch-action:none, so long panels could not pan down to the
   Independent Modules section. Only canvas/drag controls should block pan. */
.modal,
.modal.on,
.modal[data-modal="layers"] {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior-y: contain !important;
  max-height: calc(100dvh - 56px) !important;
}
@supports not (height: 100dvh) {
  .modal,
  .modal.on,
  .modal[data-modal="layers"] {
    max-height: calc(100vh - 56px) !important;
  }
}
.modal[data-modal="layers"] {
  padding-bottom: calc(42px + env(safe-area-inset-bottom)) !important;
}
.modal .signal-group,
.modal .layer-list,
.modal .module-stack-panel {
  touch-action: pan-y !important;
}
.modal button,
.modal select,
.modal input[type="file"],
.modal .layer-row,
.modal .module-row,
.modal .cycle {
  touch-action: manipulation !important;
}
.modal input[type="range"],
.modal label:has(input[type="range"]),
.vslider,
.vslider * {
  touch-action: none !important;
}

/* Alpha 24 Phase 1 — Performance Flow / Node System */
.state-dock,.node-list{display:grid;gap:10px;margin-top:12px}
.state-card,.node-card,.cue-pad{border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.045);color:inherit;border-radius:14px;padding:12px;text-align:left;backdrop-filter:blur(10px)}
.state-card{display:flex;justify-content:space-between;align-items:center;width:100%}
.state-card.active{border-color:rgba(190,150,255,.8);box-shadow:0 0 24px rgba(160,90,255,.18)}
.state-card span,.node-card b{display:block;font-weight:650;letter-spacing:.02em}
.state-card small,.node-card small{display:block;opacity:.62;margin-top:4px;font-size:11px;line-height:1.3}
.cue-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.cue-pad{min-height:62px;text-align:center;font-weight:650;letter-spacing:.03em;background:radial-gradient(circle at 50% 0%, rgba(180,120,255,.16), rgba(255,255,255,.035));}
.cue-pad:active{transform:scale(.98);filter:brightness(1.25)}
.node-list{grid-template-columns:1fr}
.node-card.on{border-color:rgba(120,220,255,.25)}
.node-card.off{opacity:.45}

/* Pulso Alpha 24 Phase 2 — Modulation Matrix */
.route-list{display:grid;gap:8px;margin-top:10px;max-height:180px;overflow:auto}
.route-card{display:grid;grid-template-columns:1fr auto 1fr auto;gap:8px;align-items:center;padding:9px 10px;border:1px solid rgba(255,255,255,.13);border-radius:12px;background:rgba(255,255,255,.045)}
.route-card small{grid-column:1/4;opacity:.65;font-size:11px}.route-card.off{opacity:.45}.route-card .mini{padding:2px 8px;min-height:24px}.signal-monitor{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.signal-monitor span{font-size:11px;padding:4px 7px;border-radius:999px;background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.08)}

/* Alpha 24 Phase 4 — Environment States */
.environment-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem;margin-top:.65rem}
.env-card{min-height:72px;text-align:left;border:1px solid rgba(255,255,255,.12);background:linear-gradient(135deg,rgba(255,255,255,.055),rgba(255,255,255,.018));border-radius:16px;padding:.72rem .8rem;color:inherit;box-shadow:inset 0 0 0 1px rgba(255,255,255,.025);transition:transform .18s ease,border-color .18s ease,background .18s ease}
.env-card b{display:block;font-size:.92rem;letter-spacing:.01em}
.env-card small{display:block;margin-top:.25rem;opacity:.68;font-size:.72rem;line-height:1.25}
.env-card.active{border-color:rgba(204,167,255,.72);background:radial-gradient(circle at 20% 0%,rgba(179,103,255,.22),rgba(255,255,255,.035) 48%,rgba(255,255,255,.018));box-shadow:0 0 22px rgba(150,88,255,.18), inset 0 0 0 1px rgba(255,255,255,.05)}
.env-card:active{transform:scale(.985)}

/* ============================================================
   CLEAN BOOT — overrides de arranque limpio
   Añadido al desactivar la cascada de fixes y el boot orchestrator.
   Apaga las capas visuales huérfanas que daban el velo blanco al inicio.
   ============================================================ */

/* El overlay/grain atmosférico ya no tiene engine que lo module:
   sin esto, atmosphere.css los pinta como un velo blanco permanente. */
#pulso-atmospheric-overlay,
#pulso-atmospheric-grain {
  opacity: 0 !important;
  background: none !important;
  pointer-events: none !important;
}

/* Lienzo de arranque: negro real, sin filtros heredados de los fixes. */
html, body {
  background: #000 !important;
}
#webgl, #source {
  background: transparent !important;
  filter: none !important;
}

/* ============================================================
   PROGRESSIVE DISCLOSURE — modos Play / Perform / Studio
   ============================================================ */

/* --- Selector de modo en la barra superior --- */
#uiModeSelector {
  display: inline-flex;
  gap: 2px;
  margin-left: 12px;
  padding: 2px;
  border-radius: 9px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  vertical-align: middle;
  pointer-events: auto; /* #topInfo sets pointer-events:none; re-enable for buttons */
}
#uiModeSelector .ui-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.55);
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#uiModeSelector .ui-mode-btn:hover { color: rgba(255,255,255,.8); }
#uiModeSelector .ui-mode-btn.on {
  background: linear-gradient(135deg, rgba(110,231,255,.22), rgba(155,139,255,.22));
  color: #eafcff;
  box-shadow: inset 0 0 0 1px rgba(110,231,255,.35);
}

/* --- Visibilidad de los tools del leftBar según el modo --- */
/* Por defecto (sin modo / o studio): todo visible. */
#leftBar .tool[data-tier] { transition: opacity .2s ease; }

/* PLAY: solo tier 1 (scenes, inputs, layers, settings). */
body[data-ui-mode="play"]    #leftBar .tool[data-tier="2"],
body[data-ui-mode="play"]    #leftBar .tool[data-tier="3"] { display: none; }

/* PERFORM: tier 1 + 2 (oculta solo tier 3: Performance Flow). */
body[data-ui-mode="perform"] #leftBar .tool[data-tier="3"] { display: none; }

/* STUDIO: todo visible (no se oculta nada). */

/* En PLAY ocultamos también los divisores para que no queden huérfanos. */
body[data-ui-mode="play"] #leftBar .tool-divider { display: none; }

/* El rightBar (FBK/GLT/HYD) es minimalista: visible en todos los modos.
   Pero en PLAY lo simplificamos a solo Feedback para reducir carga. */
body[data-ui-mode="play"] #rightBar .vslider[data-target="quickGlitch"],
body[data-ui-mode="play"] #rightBar .vslider[data-target="quickHydraOpacity"] { display: none; }

/* ============================================================
   Botón de captura flotante — solo modo Play (fix24)
   ============================================================ */
#playCapture {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 60px; height: 60px;
  border-radius: 50%;
  display: none;            /* oculto por defecto; solo Play lo muestra */
  align-items: center; justify-content: center;
  color: #eafcff;
  background: linear-gradient(135deg, rgba(110,231,255,.28), rgba(155,139,255,.28));
  border: 1px solid rgba(110,231,255,.4);
  box-shadow: 0 6px 24px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease;
}
#playCapture:active { transform: translateX(-50%) scale(.92); }
#playCapture.flash {
  box-shadow: 0 0 0 4px rgba(110,231,255,.6), 0 6px 24px rgba(0,0,0,.45);
}
/* Solo aparece en Play. En Perform/Studio se usa el panel Archive. */
body[data-ui-mode="play"] #playCapture { display: flex; }
/* Y se esconde si la UI está oculta (modo limpio de performance). */
body.hide-ui #playCapture,
body.clean-mode #playCapture { display: none !important; }

/* ============================================================
   Toast de feedback (fix27) — confirma acciones y ayuda a diagnosticar
   ============================================================ */
#pulsoToast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 10px;
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .02em;
  color: #eafcff;
  background: rgba(20, 22, 30, .92);
  border: 1px solid rgba(110, 231, 255, .35);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  max-width: 80vw;
  text-align: center;
}
#pulsoToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* status text del panel 3D (y reutilizable) */
.hint-text {
  font: 500 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  color: rgba(255,255,255,.5);
  padding: 6px 2px 2px;
  letter-spacing: .02em;
}

/* Grid de botones para añadir módulos a una capa (reemplaza el <select>) */
.module-add-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0;
}
.mod-add-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: #e8eef6;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .02em;
  padding: 9px 6px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .14s ease, border-color .14s ease, transform .1s ease;
}
.mod-add-btn:hover { background: rgba(110,231,255,.12); border-color: rgba(110,231,255,.3); }
.mod-add-btn:active { transform: scale(.94); background: rgba(110,231,255,.2); }

/* FIX35: Hydra panel visible render preview */
.hydra-preview{
  width:100%;
  aspect-ratio:16/9;
  display:block;
  margin:8px 0 10px;
  border:1px solid rgba(255,255,255,.13);
  border-radius:14px;
  background:#050308;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), 0 10px 30px rgba(0,0,0,.28);
}

/* ============================================================
   LAYER ORDER: ver src/fx/whiteOverlayFix.css
   Z-indexes, display/visibility de modales y sidebars se definen
   allí como fuente única de verdad. No duplicar aquí.
   ============================================================ */
