/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #020912;
  --glass:     rgba(5, 14, 36, 0.93);
  --edge:      rgba(80, 160, 255, 0.11);
  --edge-t:    rgba(0, 232, 255, 0.30);
  --glass-hi:  rgba(220, 240, 255, 0.13);  /* white specular — top of glass */
  --glass-lo:  rgba(0, 0, 0, 0.52);        /* inner shadow — bottom of glass */
  --text:      #c8e4ff;
  --muted:     rgba(140, 200, 255, 0.38);
  --accent:    #00e8ff;
  --accent-glow: rgba(0, 232, 255, 0.45);
  --fill-bg:   rgba(255, 255, 255, 0.07);
  --font:      'Inter', system-ui, sans-serif;
  --mono:      'SF Mono', 'Fira Code', ui-monospace, monospace;
  /* Safe-area insets — readable by JS via getComputedStyle */
  --sat: env(safe-area-inset-top,    0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  /* iOS Safari: prevent the address bar collapse from causing a layout jump */
  min-height: -webkit-fill-available;
  background: var(--bg);
  overflow: hidden;
  /* Prevent pull-to-refresh / over-scroll bounce from interfering with gestures */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  /* Suppress the 300 ms tap delay and blue highlight on all interactive elements */
  -webkit-tap-highlight-color: transparent;
  touch-callout: none;
  color-scheme: dark;
}

/* hide OS cursor in fullscreen when HUD is dimmed */
.cursor-hidden, .cursor-hidden * { cursor: none !important; }

/* ── Canvas ──────────────────────────────────────────────── */
#main-canvas {
  position: fixed; inset: 0; display: block;
  /* Disable all browser touch gestures on the canvas — we handle them in JS */
  touch-action: none;
  /* Prevent iOS long-press callout on the canvas */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

/* ── Atmosphere: vignette + grain ───────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  /* No gradient here — vignette lives in the Three.js ShaderMaterial */
}
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  opacity: 0.038;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── HUD pill ────────────────────────────────────────────── */
#hud {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  background: var(--glass);
  backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  -webkit-backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  border: 1px solid var(--edge);
  border-top-color: var(--glass-hi);
  border-radius: 100px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.80),
    0 22px 80px rgba(0, 0, 0, 0.92),
    0 6px 22px rgba(0, 0, 0, 0.65),
    inset 0  1px 0 var(--glass-hi),
    inset 0 -1px 0 var(--glass-lo),
    inset 0  1px 22px rgba(0, 232, 255, 0.03);
  z-index: 100;
  opacity: 1;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation: hud-enter 0.65s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  will-change: opacity;
  white-space: nowrap;
  user-select: none;
}
@keyframes hud-enter {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#hud.dimmed { opacity: 0; pointer-events: none; }

/* ── Separator ───────────────────────────────────────────── */
.hud-sep {
  width: 1px;
  height: 12px;
  background: linear-gradient(to bottom, transparent, var(--edge-t), transparent);
  flex-shrink: 0;
  margin: 0 8px;
}

/* ── Play button ─────────────────────────────────────────── */
#play-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(100, 180, 255, 0.18);
  background: rgba(0, 232, 255, 0.06);
  color: rgba(200, 230, 255, 0.65);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
              box-shadow 0.18s ease, opacity 0.40s ease,
              transform 0.20s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Disabled until all rings finish their intro animation */
#play-btn.loading {
  opacity: 0.18;
  pointer-events: none;
  cursor: default;
}
#play-btn:hover {
  background: rgba(0, 232, 255, 0.13);
  border-color: rgba(0, 232, 255, 0.44);
  color: #fff;
  box-shadow: 0 0 16px rgba(0, 232, 255, 0.28);
  transform: scale(1.07);
}
#play-btn:active {
  transform: scale(0.91);
  transition-duration: 0.07s;
  transition-timing-function: linear;
}
#play-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #010c18;
  box-shadow:
    0 0 24px var(--accent-glow),
    0 0 56px rgba(0, 232, 255, 0.22);
  animation: play-pulse 2.2s ease-in-out infinite;
}
/* Play icon slightly offset right for optical balance */
#play-btn #icon-play  { font-size: 11px; line-height: 1; transform: translateX(1px); }
#play-btn #icon-pause { font-size: 13px; line-height: 1; letter-spacing: -1px; }

@keyframes play-pulse {
  0%, 100% {
    box-shadow: 0 0 24px var(--accent-glow), 0 0 56px rgba(0,232,255,0.18),
                0 0 0 0 rgba(0,232,255,0.5);
  }
  55% {
    box-shadow: 0 0 24px var(--accent-glow), 0 0 56px rgba(0,232,255,0.18),
                0 0 0 12px rgba(0,232,255,0);
  }
}
/* Active chip glow breathes — box-shadow only so filter stays free for hover */
@keyframes chip-breathe {
  0%, 100% {
    box-shadow:
      0 0  6px color-mix(in srgb, var(--c) 50%, transparent),
      0 0 14px color-mix(in srgb, var(--c) 18%, transparent);
  }
  50% {
    box-shadow:
      0 0 10px color-mix(in srgb, var(--c) 72%, transparent),
      0 0 22px color-mix(in srgb, var(--c) 30%, transparent);
  }
}

/* ── Control groups (label + slider + optional value) ────── */
.hud-group {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
}
.hud-lbl {
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  color: var(--muted);
  text-transform: lowercase;
  font-family: var(--mono);
  user-select: none;
  flex-shrink: 0;
  transition: color 0.15s;
}
.hud-group:hover .hud-lbl,
.hud-group:focus-within .hud-lbl { color: rgba(255, 255, 255, 0.48); }

/* #bpm-label moved to adv-panel section */

/* ── Range sliders with left-fill ────────────────────────── */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(
    to right,
    var(--accent) 0% var(--fill, 0%),
    var(--fill-bg) var(--fill, 0%) 100%
  );
}
#bpm-slider   { width: 100px; }
#vol-slider   { width:  56px; }
#vol-slider:disabled { opacity: 0.25; cursor: not-allowed; }
#arc-slider   { width: 100px; }
#swing-slider { width: 100px; }

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  /* gel cap: bright specular top-left, saturated edge — reads as a physical lever knob */
  background: radial-gradient(circle at 38% 32%, #ffffff 0%, #c4e8ff 38%, #74b8e4 100%);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.55), 0 0 10px var(--accent-glow);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
input[type='range']:active::-webkit-slider-thumb {
  cursor: pointer;
  transform: scale(1.20);
}
input[type='range']:hover::-webkit-slider-thumb,
input[type='range']:focus::-webkit-slider-thumb {
  box-shadow: 0 1px 4px rgba(0,0,0,0.55),
              0 0 18px var(--accent),
              0 0 34px rgba(0, 232, 255, 0.40);
}

/* ── Play + inline vol group ─────────────────────────────── */
.hud-play-vol {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
/* Vol slider thumb slightly smaller for inline use */
.hud-play-vol input[type='range']::-webkit-slider-thumb {
  width: 11px; height: 11px;
}


/* ── Track chips (circles with beat count) ───────────────── */
#track-list {
  display: flex;
  gap: 5px;
  align-items: center;
}
.track-chip {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--c, rgba(255, 255, 255, 0.3));
  /* subtle top-bevel gradient — reads as a physical button face */
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--c, rgba(255,255,255,0.15)) 22%, rgba(255,255,255,0.07)) 0%,
    color-mix(in srgb, var(--c, rgba(255,255,255,0.15))  8%, transparent) 100%
  );
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 0;
  flex-shrink: 0;
  transition: filter 0.14s ease, opacity 0.40s ease,
              box-shadow 0.18s ease,
              transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.track-chip:active {
  transform: scale(0.86);
  transition-duration: 0.07s;
  transition-timing-function: linear;
}
.track-chip::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--c, rgba(255, 255, 255, 0.2));
  opacity: 0;
  transition: opacity 0.14s;
}
.track-chip:hover::after { opacity: 0.5; }

.chip-num {
  font-size: 8px;
  font-weight: 600;
  font-family: var(--font);
  font-style: italic;
  color: var(--c, rgba(255, 255, 255, 0.85));
  line-height: 1;
  letter-spacing: 0.01em;
  user-select: none;
  pointer-events: none;
  text-align: center;
  display: block;
}

/* ── Add / Remove ring ─ removed; chips self-manage ─────── */
/* .hud-ring-btns was removed from HTML */

/* ── Fullscreen icon button ──────────────────────────────── */
.hud-icon-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(80, 160, 255, 0.10);
  background: rgba(0, 232, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease,
              box-shadow 0.14s ease,
              transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.hud-icon-btn span {
  font-size: 13px;
  line-height: 1;
  display: block;
}
.hud-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.hud-icon-btn:hover {
  background: rgba(0, 232, 255, 0.10);
  border-color: rgba(0, 232, 255, 0.28);
  color: var(--text);
  box-shadow: 0 0 12px rgba(0, 232, 255, 0.15);
  transform: scale(1.10);
}
.hud-icon-btn:active {
  transform: scale(0.88);
  transition-duration: 0.06s;
  transition-timing-function: linear;
}
#adv-btn.active,
#help-btn.active {
  background: rgba(0, 232, 255, 0.16);
  border-color: rgba(0, 232, 255, 0.55);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(0, 232, 255, 0.30), inset 0 0 10px rgba(0,232,255,0.08);
}
#adv-btn  { font-size: 17px; }
#help-btn {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
}

/* ── Track chip states ───────────────────────────────────── */
.track-chip.chip-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
  filter: none;
}
/* Unmuted = bright, saturated, breathing glow */
.track-chip.chip-active {
  filter: brightness(1.08) saturate(1.4);
  animation: chip-breathe 3.6s ease-in-out infinite;
}
.track-chip.chip-active:hover {
  animation: none; /* halt breathe so filter takes full control */
  filter: brightness(1.32) saturate(1.80);
  box-shadow:
    0 0 14px color-mix(in srgb, var(--c) 95%, transparent),
    0 0 34px color-mix(in srgb, var(--c) 55%, transparent),
    0 0 58px color-mix(in srgb, var(--c) 20%, transparent);
  transform: scale(1.18);
}
/* Muted = dormant — grayscale first so all palette colours map to same grey */
.track-chip.chip-inactive {
  filter: grayscale(1) brightness(0.38);
  opacity: 0.44;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), inset 0 1px 0 rgba(0,0,0,0.18);
}
/* Inactive hover = preview-lit: colour bleeds back in as if the ring is considering waking */
.track-chip.chip-inactive:hover {
  filter: grayscale(0.35) brightness(0.68) saturate(1.1);
  opacity: 0.88;
  transform: scale(1.13);
}

/* ── Ghost chip (empty ring slot) – no longer needed; all 8 always loaded */

/* ── Advanced controls panel ─────────────────────────────── */
#adv-panel {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 101;
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 11px;
  column-gap: 9px;
  padding: 16px 20px 16px 14px;
  background: var(--glass);
  backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  -webkit-backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  border: 1px solid var(--edge);
  border-top-color: var(--glass-hi);
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.82),
    0 0 44px rgba(0, 232, 255, 0.05),
    0 24px 80px rgba(0, 0, 0, 0.94),
    inset 0  1px 0 var(--glass-hi),
    inset 0 -1px 0 var(--glass-lo),
    inset 0  1px 20px rgba(0, 232, 255, 0.03);
  transition: opacity 0.12s ease, transform 0.14s ease;
  will-change: opacity, transform;
  white-space: nowrap;
  user-select: none;
}
#adv-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.adv-row {
  display: contents; /* participate in parent grid — label and slider land in their columns */
  cursor: default;
}
.adv-lbl {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  color: var(--muted);
  text-transform: uppercase;
  font-family: var(--mono);
  user-select: none;
  flex-shrink: 0;
  text-align: right;
  transition: color 0.12s;
}
.adv-lbl:hover { color: var(--accent); }

#bpm-label {
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: -0.04em;
  display: inline-block;
  width: 3ch;           /* always reserves space for 3 digits — no reflow */
  text-align: right;
}

/* ── Help modal ──────────────────────────────────────────── */
#help-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 2, 14, 0.80);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
#help-modal.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-pane {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(70px) saturate(200%) brightness(1.05);
  -webkit-backdrop-filter: blur(70px) saturate(200%) brightness(1.05);
  border: 1px solid var(--edge);
  border-top-color: var(--glass-hi);
  border-radius: 24px;
  padding: 28px 30px 22px;
  width: min(340px, 90vw);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.84),
    0 0 60px rgba(0, 232, 255, 0.04),
    0 32px 100px rgba(0, 0, 0, 0.97),
    inset 0  1px 0 var(--glass-hi),
    inset 0 -1px 0 var(--glass-lo),
    inset 0  1px 28px rgba(0, 232, 255, 0.03);
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.modal-close:hover {
  background: rgba(0, 232, 255, 0.10);
  border-color: rgba(0, 232, 255, 0.20);
  color: var(--accent);
}
.modal-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
  font-family: var(--mono);
  margin-bottom: 20px;
  opacity: 0.8;
}
.sh-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sh-group + .sh-group { margin-top: 14px; }
.sh-group-label {
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--mono);
  margin-bottom: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(0, 232, 255, 0.14);
}
.sh-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sh-keys {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 110px;
  flex-shrink: 0;
}
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 18, 48, 0.70);
  border: 1px solid rgba(0, 232, 255, 0.18);
  border-bottom: 2px solid rgba(0, 100, 200, 0.38);
  color: rgba(200, 235, 255, 0.78);
  white-space: nowrap;
  line-height: 1.5;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 5px rgba(0, 0, 0, 0.40);
}
.sh-desc {
  font-size: 12px;
  color: rgba(180, 218, 255, 0.55);
  font-family: var(--font);
  font-weight: 400;
}
.sh-sep {
  font-size: 10px;
  color: rgba(100, 180, 255, 0.30);
  font-family: var(--mono);
  padding: 0 1px;
}
.modal-hint {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--edge);
  font-size: 10px;
  color: rgba(100, 180, 255, 0.30);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  line-height: 1.7;
}

/* ── Responsive HUD ──────────────────────────────────────── */

/* Vol-wrap: transparent by default — slider is a direct flex child of hud-play-vol */
#vol-wrap { display: contents; }

/* Tablet: 601–1024px — slightly larger touch targets, same layout */
@media (min-width: 601px) and (max-width: 1024px) {
  #hud {
    gap: 3px;
    padding: 7px 12px;
  }
  #play-btn {
    width: 42px; height: 42px;
  }
  #play-btn #icon-play  { font-size: 12px; }
  #play-btn #icon-pause { font-size: 14px; }
  .track-chip {
    width: 30px; height: 30px;
  }
  .chip-num { font-size: 8.5px; }
  .hud-icon-btn {
    width: 32px; height: 32px;
    font-size: 15px;
  }
  .hud-icon-btn span { font-size: 14px; }
  #adv-btn  { font-size: 18px; }
  #vol-slider { width: 62px; }
  .hud-play-vol input[type='range']::-webkit-slider-thumb {
    width: 13px; height: 13px;
  }
}

/* Mobile common (≤600px) — compact sizing */
@media (max-width: 600px) {
  #hud {
    gap: 2px;
    padding: 6px 8px;
    bottom: max(18px, env(safe-area-inset-bottom, 18px));
  }
  .hud-sep {
    margin: 0 4px;
    height: 10px;
  }
  #play-btn {
    width: 36px; height: 36px;
  }
  #play-btn #icon-play  { font-size: 10px; }
  #play-btn #icon-pause { font-size: 12px; }
  #track-list { gap: 2px; }
  .track-chip {
    width: 24px; height: 24px;
    border-width: 1px;
  }
  .chip-num { font-size: 7px; }
  .track-chip::after { inset: -4px; }
  .hud-icon-btn {
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: 13px;
  }
  .hud-icon-btn span { font-size: 12px; }
  .hud-actions { gap: 2px; }
  #adv-btn  { font-size: 15px; }
  #help-btn { font-size: 10px; }
  #adv-panel {
    bottom: max(74px, calc(env(safe-area-inset-bottom, 18px) + 56px));
    padding: 14px 16px 14px 12px;
    row-gap: 9px;
    column-gap: 8px;
  }
  #bpm-slider, #arc-slider, #swing-slider { width: 85px; }
}

/* Mobile landscape — optimized for short viewport with safe-area notch compensation */
@media (max-width: 900px) and (orientation: landscape) and (pointer: coarse) {
  /* HUD snaps to the right edge — visualization gets the full left 2/3 */
  #hud {
    bottom: auto !important;
    top: 50%;
    transform: translateY(-50%);
    right: max(8px, env(safe-area-inset-right, 8px));
    left: auto;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border-radius: 24px;
  }
  @keyframes hud-enter {
    from { opacity: 0; transform: translateY(-50%) translateX(16px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0);    }
  }
  .hud-sep {
    width: 10px; height: 1px;
    margin: 4px 0;
  }
  /* Hide controls that aren't usable on phone (no keyboard, no true fullscreen API) */
  #help-btn { display: none; }
  #fs-btn   { display: none; }
  /* Keep only the adv gear button from hud-actions */
  .hud-actions { flex-direction: column; gap: 0; }

  /* Vertical vol-slider pill floats to left of HUD */
  #vol-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    right: max(60px, calc(env(safe-area-inset-right, 8px) + 52px)); /* sits left of HUD */
    width: 28px;
    height: 80px;
    background: var(--glass);
    backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
    -webkit-backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
    border: 1px solid var(--edge);
    border-top-color: var(--glass-hi);
    border-radius: 14px;
    box-shadow:
      0 0 0 1px rgba(0,0,0,0.80),
      0 8px 28px rgba(0,0,0,0.88),
      inset 0  1px 0 var(--glass-hi),
      inset 0 -1px 0 var(--glass-lo);
    z-index: 102;
  }
  #vol-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 3px;
    height: 56px;
    background: linear-gradient(
      to top,
      var(--accent) 0% var(--fill, 65%),
      var(--fill-bg) var(--fill, 65%) 100%
    );
  }
  #vol-slider::-webkit-slider-thumb {
    width: 11px; height: 11px;
  }
  .hud-play-vol { gap: 0; flex-direction: column; }

  /* Chips in a column */
  #track-list { flex-direction: column; gap: 3px; }
  .track-chip { width: 24px; height: 24px; }

  /* Adv panel pops out left of HUD when open */
  #adv-panel {
    top: 50%;
    bottom: auto !important;
    left: auto;
    right: max(118px, calc(env(safe-area-inset-right, 8px) + 110px));
    transform: translateY(-50%) translateX(10px);
  }
  #adv-panel.open {
    transform: translateY(-50%) translateX(0);
  }
}

/* Mobile portrait — chips-only HUD; tap = play/pause, swipe = volume */
@media (max-width: 600px) and (orientation: portrait) {
  /* HUD: compact chips strip only — no pill controls */
  #hud {
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    padding: 6px 14px;
    gap: 2px;
  }
  .hud-play-vol { display: none; }
  .hud-sep      { display: none; }
  .hud-actions  { display: none; }
  #vol-wrap     { display: none !important; }

  /* Slightly larger chips — primary input on portrait */
  .track-chip {
    width: 28px; height: 28px;
  }
  .track-chip::after { inset: -6px; } /* bigger tap zone */

  /* adv-panel: still accessible via keyboard / long-press if ever wired */
  #adv-panel {
    bottom: max(70px, calc(env(safe-area-inset-bottom, 14px) + 52px));
  }
}

/* ── Volume OSD (shown on swipe-to-adjust, all breakpoints) ────────── */
#vol-osd {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 20px 24px 18px;
  background: var(--glass);
  backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  -webkit-backdrop-filter: blur(70px) saturate(200%) brightness(1.06);
  border: 1px solid var(--edge);
  border-top-color: var(--glass-hi);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.80),
    0 12px 40px rgba(0,0,0,0.90),
    inset 0  1px 0 var(--glass-hi),
    inset 0 -1px 0 var(--glass-lo);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  will-change: opacity;
  min-width: 110px;
}
#vol-osd.visible { opacity: 1; }
#vol-osd-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
#vol-osd-bar-track {
  width: 80px;
  height: 4px;
  background: var(--fill-bg);
  border-radius: 2px;
  overflow: hidden;
}
#vol-osd-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.08s linear;
}
#vol-osd-pct {
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -0.02em;
  line-height: 1;
}
