/* ===========================================================================
   PULSE — Premium Web Music Player
   styles.css : theme engine (15 themes), base shell, glassmorphism, responsive
   grid, loading screen, settings/EQ/admin panels.
   Each theme only overrides the CSS-variable contract for instant switching.
   ======================================================================== */

/* Shared, theme-independent tokens. */
:root {
  --radius: 18px;
  --radius-sm: 12px;
  --blur: 18px;
}

/* ---------- 10 DARK THEMES ------------------------------------------------ */
/* 1. Midnight Black (default) */
:root,
[data-theme="midnight"] {
  --bg-0: #070810; --bg-1: #0b0d16;
  --surface: rgba(22, 26, 40, 0.55); --surface-solid: #12151f;
  --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f7; --text-muted: #9aa3b7;
  --accent: #6ea8ff; --accent-2: #b98cff; --accent-contrast: #07101f;
  --danger: #ff6b6b; --ok: #4bd6a0;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
/* 2. Obsidian Green */
[data-theme="obsidian"] {
  --bg-0: #05100b; --bg-1: #0a1712;
  --surface: rgba(16, 34, 26, 0.55); --surface-solid: #0f1d17;
  --border: rgba(120, 255, 190, 0.08); --border-strong: rgba(120, 255, 190, 0.18);
  --text: #e6f5ee; --text-muted: #86a99a;
  --accent: #37e0a0; --accent-2: #9ff0c8; --accent-contrast: #04140d;
  --danger: #ff7a7a; --ok: #37e0a0;
  --shadow: 0 20px 60px rgba(0, 20, 12, 0.6);
}
/* 3. Deep Space Purple */
[data-theme="deepspace"] {
  --bg-0: #0a0616; --bg-1: #120b24;
  --surface: rgba(34, 22, 58, 0.55); --surface-solid: #1a1030;
  --border: rgba(200, 160, 255, 0.09); --border-strong: rgba(200, 160, 255, 0.2);
  --text: #efe9ff; --text-muted: #a99ac6;
  --accent: #a06bff; --accent-2: #ff8fe0; --accent-contrast: #0d0620;
  --danger: #ff6b8a; --ok: #7cf0c0;
  --shadow: 0 20px 60px rgba(20, 0, 40, 0.6);
}
/* 4. Cyber Neon */
[data-theme="cyber"] {
  --bg-0: #050510; --bg-1: #0a0a1e;
  --surface: rgba(20, 22, 48, 0.55); --surface-solid: #10122b;
  --border: rgba(0, 255, 240, 0.1); --border-strong: rgba(255, 0, 200, 0.25);
  --text: #eafcff; --text-muted: #7fa8c9;
  --accent: #00f0ff; --accent-2: #ff2bd6; --accent-contrast: #04121a;
  --danger: #ff3b6b; --ok: #00f0ff;
  --shadow: 0 20px 60px rgba(0, 240, 255, 0.15);
}
/* 5. Oceanic Dark */
[data-theme="oceanic"] {
  --bg-0: #041018; --bg-1: #071c28;
  --surface: rgba(14, 40, 56, 0.55); --surface-solid: #0b2432;
  --border: rgba(120, 210, 255, 0.09); --border-strong: rgba(120, 210, 255, 0.2);
  --text: #e2f3fb; --text-muted: #82a8bd;
  --accent: #34b6e0; --accent-2: #5ce0c8; --accent-contrast: #041520;
  --danger: #ff7a7a; --ok: #5ce0c8;
  --shadow: 0 20px 60px rgba(0, 20, 32, 0.6);
}
/* 6. Crimson Ember */
[data-theme="crimson"] {
  --bg-0: #140506; --bg-1: #1e0a0c;
  --surface: rgba(48, 20, 24, 0.55); --surface-solid: #2a1013;
  --border: rgba(255, 140, 140, 0.09); --border-strong: rgba(255, 140, 140, 0.2);
  --text: #ffeceb; --text-muted: #c69a98;
  --accent: #ff5a5f; --accent-2: #ffb347; --accent-contrast: #1a0405;
  --danger: #ff5a5f; --ok: #ffb347;
  --shadow: 0 20px 60px rgba(40, 0, 4, 0.6);
}
/* 7. Solar Amber */
[data-theme="solar"] {
  --bg-0: #120c02; --bg-1: #1d1405;
  --surface: rgba(48, 36, 12, 0.5); --surface-solid: #29200c;
  --border: rgba(255, 210, 120, 0.1); --border-strong: rgba(255, 210, 120, 0.22);
  --text: #fff4dd; --text-muted: #c8ac82;
  --accent: #ffb020; --accent-2: #ff7a3c; --accent-contrast: #1a1200;
  --danger: #ff6b6b; --ok: #ffd24a;
  --shadow: 0 20px 60px rgba(30, 18, 0, 0.6);
}
/* 8. Rose Quartz Dark */
[data-theme="rosequartz"] {
  --bg-0: #150810; --bg-1: #200c18;
  --surface: rgba(52, 24, 40, 0.55); --surface-solid: #2c1322;
  --border: rgba(255, 170, 210, 0.09); --border-strong: rgba(255, 170, 210, 0.2);
  --text: #ffe9f3; --text-muted: #c89ab0;
  --accent: #ff77b0; --accent-2: #c79bff; --accent-contrast: #1a0512;
  --danger: #ff6b8a; --ok: #7cf0c0;
  --shadow: 0 20px 60px rgba(40, 0, 24, 0.6);
}
/* 9. Slate Steel */
[data-theme="slate"] {
  --bg-0: #0c0f12; --bg-1: #14181d;
  --surface: rgba(34, 40, 48, 0.55); --surface-solid: #1a1f26;
  --border: rgba(200, 214, 228, 0.08); --border-strong: rgba(200, 214, 228, 0.18);
  --text: #eef2f6; --text-muted: #9aa6b3;
  --accent: #9fb4c9; --accent-2: #c7d4e0; --accent-contrast: #10151a;
  --danger: #ff6b6b; --ok: #7cd0a8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
/* 10. Forest Night */
[data-theme="forest"] {
  --bg-0: #08110a; --bg-1: #0e1c12;
  --surface: rgba(22, 44, 30, 0.55); --surface-solid: #12241a;
  --border: rgba(160, 220, 150, 0.09); --border-strong: rgba(160, 220, 150, 0.2);
  --text: #e9f6e9; --text-muted: #92ab93;
  --accent: #7fce54; --accent-2: #d9e05a; --accent-contrast: #08140a;
  --danger: #ff7a7a; --ok: #7fce54;
  --shadow: 0 20px 60px rgba(0, 16, 6, 0.6);
}

/* ---------- 5 LIGHT THEMES ----------------------------------------------- */
/* 11. Pure White */
[data-theme="white"] {
  --bg-0: #ffffff; --bg-1: #f4f6fa;
  --surface: rgba(255, 255, 255, 0.7); --surface-solid: #ffffff;
  --border: rgba(15, 20, 40, 0.1); --border-strong: rgba(15, 20, 40, 0.2);
  --text: #10131a; --text-muted: #5b6478;
  --accent: #2f6bff; --accent-2: #7a5cf0; --accent-contrast: #ffffff;
  --danger: #d84343; --ok: #1a9e73;
  --shadow: 0 18px 44px rgba(30, 40, 80, 0.14);
}
/* 12. Cream */
[data-theme="cream"] {
  --bg-0: #f7f1e6; --bg-1: #fbf6ec;
  --surface: rgba(255, 250, 240, 0.72); --surface-solid: #fffaf0;
  --border: rgba(80, 60, 30, 0.12); --border-strong: rgba(80, 60, 30, 0.22);
  --text: #2a2114; --text-muted: #7a6a52;
  --accent: #c8873c; --accent-2: #e0a95c; --accent-contrast: #fffaf0;
  --danger: #c0492f; --ok: #4a9e5a;
  --shadow: 0 18px 44px rgba(120, 90, 40, 0.16);
}
/* 13. Soft Sky */
[data-theme="softsky"] {
  --bg-0: #e8f3fb; --bg-1: #f1f8fd;
  --surface: rgba(255, 255, 255, 0.7); --surface-solid: #ffffff;
  --border: rgba(20, 60, 100, 0.1); --border-strong: rgba(20, 60, 100, 0.2);
  --text: #12293a; --text-muted: #5c778a;
  --accent: #1f9fd4; --accent-2: #3fc8b0; --accent-contrast: #ffffff;
  --danger: #d84343; --ok: #1a9e73;
  --shadow: 0 18px 44px rgba(30, 80, 120, 0.16);
}
/* 14. Light Ash */
[data-theme="ash"] {
  --bg-0: #e9ebee; --bg-1: #f2f3f6;
  --surface: rgba(255, 255, 255, 0.66); --surface-solid: #ffffff;
  --border: rgba(30, 35, 45, 0.1); --border-strong: rgba(30, 35, 45, 0.2);
  --text: #1c2027; --text-muted: #5f6772;
  --accent: #556270; --accent-2: #8391a0; --accent-contrast: #ffffff;
  --danger: #c0492f; --ok: #3e8e6d;
  --shadow: 0 18px 44px rgba(30, 40, 60, 0.14);
}
/* 15. Pearl */
[data-theme="pearl"] {
  --bg-0: #eef1f6; --bg-1: #f6f8fc;
  --surface: rgba(255, 255, 255, 0.65); --surface-solid: #ffffff;
  --border: rgba(15, 20, 40, 0.1); --border-strong: rgba(15, 20, 40, 0.2);
  --text: #141824; --text-muted: #5b6478;
  --accent: #3b6fe0; --accent-2: #8a5cf0; --accent-contrast: #ffffff;
  --danger: #d84343; --ok: #1a9e73;
  --shadow: 0 20px 50px rgba(30, 40, 80, 0.18);
}

/* --- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* Never allow horizontal scrolling / right-side overflow on any device. */
html, body { max-width: 100%; overflow-x: hidden; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(110, 168, 255, 0.14), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(185, 140, 255, 0.12), transparent 55%),
    var(--bg-1);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* --- Ambient background canvas (dust + stars) --------------------------- */
.bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; display: block; pointer-events: none;
}
/* App sits above the ambient layer; glass panels let it show through. */
.app { position: relative; z-index: 1; }

/* --- Glass surface ------------------------------------------------------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* --- Loading screen ------------------------------------------------------ */
.loading-screen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background:
    radial-gradient(800px 600px at 50% 30%, rgba(110, 168, 255, 0.18), transparent 60%),
    var(--bg-0);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-inner { text-align: center; display: grid; gap: 14px; justify-items: center; }
.loading-logo { filter: drop-shadow(0 8px 30px rgba(110, 168, 255, 0.4)); animation: float 3s ease-in-out infinite; }
.loading-logo img { display: block; width: 112px; height: 112px; object-fit: contain; }
.loading-title { font-size: 30px; font-weight: 800; letter-spacing: 0.5px; }
.loading-subtitle { color: var(--text-muted); font-size: 14px; }
.loading-bar { width: 220px; height: 4px; border-radius: 99px; background: var(--border); overflow: hidden; }
.loading-bar-fill {
  display: block; height: 100%; width: 40%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px; animation: slide 1.2s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* --- App layout ---------------------------------------------------------- */
.app {
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 12px;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  overflow-x: hidden;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius);
  gap: 8px; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: 0.4px; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 99px; font-size: 12px;
  border: 1px solid var(--border); color: var(--text-muted);
}
.badge-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--text-muted); }
.badge.is-live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.is-live .badge-dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.badge.is-static { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.is-static .badge-dot { background: var(--accent); }
.badge.is-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.is-error .badge-dot { background: var(--danger); }

/* Icon buttons */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.icon-btn:hover { background: var(--border); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
/* Repeat-One: small superscript dot to distinguish from Repeat-All. */
#btn-repeat { position: relative; }
#btn-repeat[data-mode="one"]::after {
  content: "1"; position: absolute; top: 4px; right: 5px;
  font-size: 9px; font-weight: 800; line-height: 1;
  color: var(--accent-contrast); background: var(--accent);
  padding: 1px 3px; border-radius: 6px;
}
.play-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-contrast);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 45%, transparent);
}
.play-btn:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
/* Show exactly one glyph: play when paused, pause when playing. */
.play-btn .icon-pause { display: none; }
.play-btn.is-playing .icon-play { display: none; }
.play-btn.is-playing .icon-pause { display: block; }

/* Working area grid: library + stage. */
.layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 12px; min-height: 0; min-width: 0;
}
.panel { border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); }
.panel-head-actions { display: flex; align-items: center; gap: 2px; }
.panel-head-actions .icon-btn { width: 34px; height: 34px; }
.panel-body { padding: 14px; overflow: auto; min-height: 0; }
/* Minimized panel: collapse to just its header row. */
.panel.is-min { align-self: start; }
.panel.is-min .panel-body { display: none; }
.panel.is-min .panel-head { border-bottom: none; }
.panel-min svg { transition: transform 0.15s ease; }
.panel.is-min .panel-min svg { transform: rotate(-90deg); }

/* Stage */
.stage { position: relative; padding: 0; }
.stage-visual { position: absolute; inset: 0; }
.viz-canvas { width: 100%; height: 100%; display: block; }
.stage-placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.nowcard {
  position: absolute; left: 20px; bottom: 20px; right: 20px;
  padding: 16px 18px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-solid) 55%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  transform-style: preserve-3d; will-change: transform; backface-visibility: hidden;
  display: flex; align-items: center; gap: 14px;
}
.nowcard-cover {
  width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-solid); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.nowcard-text { min-width: 0; }
.nowcard-title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.nowcard-file {
  color: var(--text); opacity: 0.85; font-size: 13px; margin-top: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nowcard-file:empty { display: none; }
.nowcard-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* Library tree */
.library-tree { display: grid; gap: 6px; }
.tree-folder > .tree-folder-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; user-select: none;
  font-weight: 600;
}
.tree-folder-head:hover { background: var(--border); }
.tree-count { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.tree-songs { display: grid; gap: 2px; margin: 2px 0 8px 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.tree-song {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text-muted);
}
.tree-song-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.tree-song-cover { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--surface-solid); }
.tree-song-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-song:hover { background: var(--border); color: var(--text); }
.tree-song.is-playing { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tree-collapsed .tree-songs { display: none; }

/* Fields */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-solid); color: var(--text);
  border: 1px solid var(--border-strong);
}

/* Transport */
.transport {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(200px, 2fr) auto;
  align-items: center; gap: 16px;
  padding: 12px 18px; border-radius: var(--radius);
}
.transport-info { min-width: 0; }
.transport-info { display: flex; align-items: center; gap: 10px; }
.transport-info-text { min-width: 0; flex: 1; }
.transport-info-actions { display: flex; align-items: center; gap: 2px; }
.t-cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface-solid); }
.small-icon-btn { width: 34px; height: 34px; }
.t-title { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { display: block; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport-controls { display: flex; align-items: center; gap: 6px; }
.transport-seek { display: flex; align-items: center; gap: 10px; }
.transport-volume { display: flex; align-items: center; gap: 8px; }
.time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-muted); min-width: 38px; text-align: center; }

/* Range inputs */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 5px; border-radius: 99px;
  background: var(--border-strong); outline: none;
}
.seek { width: 100%; }
.volume { width: 110px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  padding: 12px 18px; border-radius: 12px; z-index: 90;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 14px; max-width: 90vw;
}
.toast.is-error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(200px, 260px) 1fr; }
}
@media (max-width: 720px) {
  body { overflow-x: hidden; overflow-y: auto; }
  .app { height: auto; min-height: 100dvh; overflow-x: hidden; overflow-y: visible; }
  .layout { grid-template-columns: 1fr; }
  .stage { min-height: 46vh; }
  .transport {
    grid-template-columns: 1fr; gap: 10px; text-align: center;
    position: sticky; bottom: 0;
    padding: 12px;
  }
  .transport-controls { justify-content: center; }
  .transport-info { text-align: center; }
  .transport-seek, .transport-volume { width: 100%; min-width: 0; }
  .volume { width: 100%; }
  /* Keep the topbar tidy on small phones. */
  .topbar { padding: 8px 10px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .icon-btn { width: 36px; height: 36px; }
}
/* Very small phones: hide the data-source badge to save width. */
@media (max-width: 400px) {
  #backend-badge { display: none; }
  .brand-name { font-size: 16px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* --- Modals (settings / admin) ------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.modal-panel {
  position: relative; width: min(560px, 92vw); max-height: 86vh; overflow: auto;
  border-radius: var(--radius); padding: 0;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); backdrop-filter: blur(var(--blur));
}
.modal-title { font-size: 18px; font-weight: 800; }
.modal-body { padding: 18px; display: grid; gap: 22px; }
.settings-section { display: grid; gap: 12px; }
.settings-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); }
.settings-row-between { display: flex; align-items: center; justify-content: space-between; }

/* Theme picker grid */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.theme-swatch {
  cursor: pointer; border-radius: 12px; padding: 8px; border: 1px solid var(--border);
  background: var(--surface-solid); display: grid; gap: 6px; text-align: left;
  transition: border-color 0.15s ease, transform 0.05s ease;
}
.theme-swatch:hover { border-color: var(--border-strong); }
.theme-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.theme-swatch:active { transform: scale(0.97); }
.theme-chips { display: flex; gap: 4px; height: 24px; border-radius: 8px; overflow: hidden; }
.theme-chip { flex: 1; }
.theme-name { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Equalizer */
.eq-actions { display: flex; align-items: center; gap: 12px; }
.eq-bands { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 150px; }
.eq-band { display: grid; justify-items: center; gap: 6px; flex: 1; }
.eq-slider { writing-mode: vertical-lr; direction: rtl; width: 6px; height: 110px; accent-color: var(--accent); }
.eq-slider::-webkit-slider-thumb { width: 16px; height: 16px; }
.eq-label { font-size: 9px; color: var(--text-muted); }
.eq-bands.is-disabled { opacity: 0.4; pointer-events: none; }

/* Switches + small buttons */
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.ghost-btn {
  padding: 6px 12px; border-radius: 10px; background: transparent;
  border: 1px solid var(--border-strong); color: var(--text); font-size: 13px;
}
.ghost-btn:hover { background: var(--border); }
.wide-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px; border-radius: 12px; margin-top: 4px;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong);
  font-weight: 600;
}
.wide-btn:hover { border-color: var(--accent); }
.sleep-row { display: flex; align-items: center; gap: 12px; }
.sleep-row .select { flex: 1; }

/* Per-song action buttons in the tree */
.song-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; opacity: 0; transition: opacity 0.12s ease; }
.tree-song:hover .song-actions { opacity: 1; }
.song-actions .mini-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  border-radius: 7px; background: transparent; border: none; color: var(--text-muted);
}
.song-actions .mini-btn:hover { background: var(--border-strong); color: var(--text); }

/* Draggable panels (layout manager) */
.panel[draggable="true"] .panel-head { cursor: grab; }
.panel.is-dragging { opacity: 0.5; }
.panel.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* --- Minimal player mode ------------------------------------------------- */
.app.is-minimal .topbar-actions .icon-btn:not(#btn-minimal),
.app.is-minimal .panel[data-module="library"],
.app.is-minimal #backend-badge { display: none; }
.app.is-minimal .layout { grid-template-columns: 1fr; }
.app.is-minimal #btn-minimal { color: var(--accent); }

/* --- See-through Visualizer modal --------------------------------------- */
/* Clear backdrop + side-docked panel so the live stage viz shows behind it. */
.modal-backdrop-clear { background: transparent; backdrop-filter: none; }
.modal-seethrough { place-items: stretch; }
.modal-panel-side {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(380px, 92vw); max-height: 100%; border-radius: 0;
  border-left: 1px solid var(--border-strong);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}
.fx-controls { display: grid; gap: 8px; }
.fx-row { justify-content: flex-start; }
.fx-controls.is-disabled { opacity: 0.45; pointer-events: none; }
@media (max-width: 720px) {
  /* On phones, dock the visualizer panel to the bottom instead of the side. */
  .modal-panel-side {
    top: auto; bottom: 0; right: 0; left: 0; width: 100%; height: auto;
    max-height: 80vh; border-left: none; border-top: 1px solid var(--border-strong);
  }
}
