/* ============================================================
   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: #f0ece4;
  --text-1: #b8b3a8;
  --text-2: #7a7670;
  --text-3: #4a4640;

  /* VETA accents — softer, less neon */
  --acc-gold: #d4a83a;
  --acc-gold-soft: rgba(212, 168, 58, 0.7);
  --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-gold);
  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-gold);
  background: rgba(212, 168, 58, 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-gold);
}
/* 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-gold-soft), var(--acc-gold));
  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-gold);
  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-gold); }

/* ============================================================
   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-gold);
  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-gold);
  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(212, 168, 58, 0.16);
  border-color: var(--acc-gold);
  color: var(--acc-gold);
}
button.primary {
  background: var(--acc-gold);
  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(212, 168, 58, 0.18), rgba(155, 135, 196, 0.10));
  border-color: var(--acc-gold);
  color: var(--acc-gold);
}
.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(212, 168, 58, 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(212, 168, 58, 0.65);
  color: var(--acc-gold);
  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(212, 168, 58, 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-gold);
  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;
}

/* ============================================================
   Hydra modal extras
   ============================================================ */

.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-gold); }
.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-gold); border-color: rgba(218,178,62,0.35); }
.hydra-editor-status.warn { color: var(--acc-gold); }
.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-gold);
  box-shadow: 0 0 6px rgba(212, 168, 58, 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-gold);
  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,
body.hide-ui .modal,
body.hide-ui #modalScrim { transform: translateX(-100vw); pointer-events: none; }
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(212, 168, 58, 0.14);
  border: 1px solid var(--acc-gold);
  color: var(--acc-gold);
  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(212, 168, 58, 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-gold);
  color: var(--acc-gold);
  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-gold);
  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-gold);
  border-color: rgba(218,178,62,0.65);
  background: rgba(218,178,62,0.13);
  box-shadow: 0 0 12px rgba(218,178,62,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 20.2 iPad touch routing fix: controls are touch-first, canvas stays behind UI. */
button, input, select, textarea, .tool, .vslider, .modal, #leftBar, #rightBar {
  -webkit-tap-highlight-color: transparent;
}
#leftBar, #rightBar, .modal {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#webgl, #source {
  z-index: 0;
}
#leftBar, #rightBar {
  z-index: 120 !important;
  pointer-events: auto !important;
}
.modal {
  z-index: 140 !important;
  pointer-events: auto !important;
}
#modalScrim {
  z-index: 130 !important;
}
.tool, .modal-close {
  touch-action: none !important;
  pointer-events: auto !important;
}
.vslider, .vslider * {
  touch-action: none !important;
}


/* Alpha 20.3: iPad UI kernel hard overrides */
#webgl, #source { z-index: 0 !important; pointer-events: auto; }
#leftBar, #rightBar { z-index: 300 !important; pointer-events: auto !important; }
#leftBar .tool { pointer-events: auto !important; touch-action: none !important; }
#modalScrim { z-index: 310 !important; pointer-events: none !important; }
.modal { z-index: 320 !important; pointer-events: auto !important; }
.modal.on { display: block !important; visibility: visible !important; opacity: 1 !important; }
.modal input[type=range] { touch-action: none !important; pointer-events: auto !important; }
body.hide-ui #leftBar { transform: 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,#f6f2ff);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;
}
