:root {
  --bg-app: #0f0f12;
  --bg-topbar: #18181a;
  --bg-panel: #18181a;
  --bg-card: #222226;
  --bg-btn: #2b2b30;
  --bg-btn-hover: #383840;
  --bg-row-hover: #27272b;
  --border-subtle: #2e2e34;
  --text-main: #f4f4f5;
  --text-sub: #d0d0d5;
  --text-muted: #8e8e98;
  --accent-fg: #FFFFFF;
  --accent-hover: #E4E4E7;
  --accent-contrast: #111111;
  --accent-text: var(--accent-contrast);
}

html.light {
  --bg-app: #e5e7eb;
  --bg-topbar: #f3f4f6;
  --bg-panel: #f3f4f6;
  --bg-card: #ffffff;
  --bg-btn: #e5e7eb;
  --bg-btn-hover: #d1d5db;
  --bg-row-hover: #e5e7eb;
  --border-subtle: #d1d5db;
  --text-main: #111827;
  --text-sub: #1f2937;
  --text-muted: #6b7280;
  --accent-fg: #18181B;
  --accent-hover: #27272A;
  --accent-contrast: #FFFFFF;
  --accent-text: var(--accent-contrast);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  user-select: none;
}

input, textarea {
  user-select: text;
}

.pulse-topbar { background: var(--bg-topbar); border-bottom: 1px solid var(--border-subtle); }
.pulse-panel { background: var(--bg-panel); border: 1px solid var(--border-subtle); }
.pulse-card { background: var(--bg-card); border: 1px solid var(--border-subtle); }
.pulse-btn-sec { background: var(--bg-btn); color: var(--text-main); transition: background 0.15s, transform 0.1s; }
.pulse-btn-sec:hover { background: var(--bg-btn-hover); }
.pulse-btn-sec:active { transform: scale(0.97); }

.pulse-btn-accent {
  background: var(--accent-fg);
  color: var(--accent-contrast);
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.pulse-btn-accent:hover { background: var(--accent-hover); }
.pulse-btn-accent:active { transform: scale(0.96); }

.pulse-accent-text { color: var(--accent-fg); }
.pulse-muted { color: var(--text-muted); }

.pulse-input {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pulse-input:focus {
  border-color: var(--accent-fg);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-fg) 22%, transparent);
}
.pw-toggle-btn {
  transition: color 0.15s ease, background-color 0.15s ease;
}
.pw-toggle-btn:hover {
  background: var(--bg-row-hover);
}

/* Song row & Differential Highlight + Queued Emerald Flash (250ms) */
.song-row {
  height: 36px;
  border-radius: 8px;
  color: var(--text-sub);
  transition: background-color 0.12s ease, color 0.12s ease;
  touch-action: pan-y;
}
.song-row:hover { background: var(--bg-row-hover); }

.song-row.is-playing {
  background: var(--accent-fg) !important;
  color: var(--accent-contrast) !important;
  font-weight: 600;
}
.song-row.is-playing .song-meta-sub { color: var(--accent-contrast) !important; opacity: 0.8; }

.song-row.is-dragging {
  height: 42px;
  border: 2px solid var(--text-main);
  background: var(--accent-fg) !important;
  color: var(--accent-contrast) !important;
  font-weight: 700;
  z-index: 20;
}

.song-row.flash-queued {
  background: #10B981 !important;
  color: #ffffff !important;
}

.queue-drop-active {
  outline: 2px solid var(--accent-fg) !important;
  outline-offset: -2px;
}

/* Range Sliders */
input[type="range"].pulse-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-btn-hover);
  outline: none;
  cursor: pointer;
}
input[type="range"].pulse-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-fg);
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.12s ease;
}
input[type="range"].pulse-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Custom thin scrollbars */
.pulse-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.pulse-scroll::-webkit-scrollbar-track { background: transparent; }
.pulse-scroll::-webkit-scrollbar-thumb { background: var(--bg-btn-hover); border-radius: 999px; }

/* Synced Lyrics active line */
.lyric-line {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: all 0.22s ease;
  cursor: pointer;
}
.lyric-line:hover { background: var(--bg-row-hover); color: var(--text-main); }
.lyric-line.active {
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 1.06rem;
  background: rgba(128, 128, 140, 0.08);
}

/* Safe area padding for PWA on iOS/Android */
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* Mobile Bento Drawer & Presence Indicators */
.drawer-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bento-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.bento-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.bento-tile:hover { background: var(--bg-btn-hover); border-color: var(--accent-fg); }
.bento-tile:active { transform: scale(0.97); }
.bento-tile:disabled { opacity: 0.45; cursor: not-allowed; }

.adm-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.adm-icon-btn:active { transform: scale(0.94); }
.adm-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.presence-dot-on {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  display: inline-block;
  flex-shrink: 0;
}
.presence-dot-off {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #71717a;
  display: inline-block;
  flex-shrink: 0;
}

#playlist-select {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

@media (max-width: 1023px) {
  .song-row { height: 44px; }
  .drag-handle { touch-action: none; }
  #pane-player {
    justify-content: flex-start;
    gap: 15px;
  }
}

/* Mobile (< 768px): always show bottom nav in all browsers & PWA; hide duplicate Playlist | YouTube tabs */
@media (max-width: 767px) {
  #mobile-nav {
    display: flex !important;
    height: auto;
    min-height: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    padding-top: 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-subtle);
    border-bottom: none;
  }
  #library-tab-group {
    display: none !important;
  }
  #pane-library[data-active-tab="youtube"] #library-top-bar {
    display: none !important;
  }
}

@media (max-width: 400px) {
  #seek-btn-row {
    gap: 6px;
  }
  #seek-btn-row button {
    padding-left: 7px;
    padding-right: 7px;
    height: 30px;
    font-size: 11px;
  }
  #volume-card {
    padding: 7px 9px;
    gap: 5px;
  }
  #volume-card button {
    width: 26px;
    height: 24px;
  }
  #vtext {
    width: 30px;
    font-size: 11px;
  }
}

/* Full 3-Slider HSL Accent Color Picker */
input[type="range"].hsl-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(128, 128, 140, 0.28);
  outline: none;
  cursor: pointer;
}
input[type="range"].hsl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-fg);
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 5px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease;
}
input[type="range"].hsl-slider::-webkit-slider-thumb:hover { transform: scale(1.14); }
input[type="range"].hsl-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-fg);
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 5px rgba(0, 0, 0, 0.45);
}

/* Clean Pill Toggle Switch */
.pulse-switch { position: relative; display: inline-flex; width: 40px; height: 22px; cursor: pointer; }
.pulse-switch input { opacity: 0; width: 0; height: 0; }
.pulse-switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-btn-hover); transition: background 0.18s; }
.pulse-switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.18s, background 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.35); }
.pulse-switch input:checked + .pulse-switch-track { background: var(--accent-fg); }
.pulse-switch input:checked + .pulse-switch-track::after { transform: translateX(18px); background: var(--accent-contrast); }

@keyframes pulseStepFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.auth-step-enter { animation: pulseStepFade 0.18s ease-out; }

/* Quick EQ Floating Popover (PC) / Bottom Sheet (Mobile) */
#eq-popover { left: 16px; bottom: 64px; width: 320px; max-width: calc(100vw - 32px); max-height: 78vh; border-radius: 16px; }
@media (max-width: 639px) {
  #eq-popover { left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
  html.compact-mobile #btn-rw10, html.compact-mobile #btn-ff10 { display: none !important; }
}

/* Player Card Swipe Feedback */
#card-frame.swipe-left { transform: translateX(-18px); opacity: 0.85; }
#card-frame.swipe-right { transform: translateX(18px); opacity: 0.85; }
