/* 果子狸のMusic Player — bold black & gold */

:root,
[data-theme="dark"] {
  --bg: #050505;
  --bg-elevated: rgba(18, 16, 12, 0.72);
  --bg-solid: #12100c;
  --bg-soft: rgba(255, 214, 120, 0.06);
  --text: #f6f0e4;
  --text-muted: #a89b82;
  --gold: #d4af37;
  --gold-bright: #f3d778;
  --gold-hot: #ffe9a8;
  --gold-dim: #7a6220;
  --border: rgba(212, 175, 55, 0.22);
  --border-strong: rgba(212, 175, 55, 0.45);
  --danger: #ff8a80;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --shadow-gold: 0 0 60px rgba(212, 175, 55, 0.15);
  --glass: blur(22px) saturate(1.35);
  --radius: 28px;
  --radius-sm: 16px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold);
  --font-display: "Cormorant Garamond", "Goudy Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif SC", serif;
  --font-ui: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
  --scrollbar-thumb: rgba(212, 175, 55, 0.45);
  --scrollbar-thumb-hover: rgba(243, 215, 120, 0.7);
  --scrollbar-track: rgba(255, 255, 255, 0.04);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4eee0;
  --bg-elevated: rgba(255, 252, 245, 0.82);
  --bg-solid: #fffdf7;
  --bg-soft: rgba(154, 114, 9, 0.07);
  --text: #1c160c;
  --text-muted: #6b5c3e;
  --gold: #9a7209;
  --gold-bright: #c9a227;
  --gold-hot: #8a6508;
  --gold-dim: #6b5010;
  --border: rgba(154, 114, 9, 0.22);
  --border-strong: rgba(154, 114, 9, 0.4);
  --danger: #c62828;
  --shadow: 0 20px 50px rgba(90, 60, 10, 0.12);
  --shadow-gold: 0 0 40px rgba(201, 162, 39, 0.18);
  --scrollbar-thumb: rgba(154, 114, 9, 0.4);
  --scrollbar-thumb-hover: rgba(154, 114, 9, 0.65);
  --scrollbar-track: rgba(154, 114, 9, 0.08);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Avoid smooth document scrolling — reduces surprise jumps on focus/hash */
  scroll-behavior: auto;
}

/* —— Custom scrollbars (page + panels) —— */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#lyrics-lines,
.track-table-wrap,
#search-results {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* WebKit (Chrome, Edge, Safari) */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
#lyrics-lines::-webkit-scrollbar,
.track-table-wrap::-webkit-scrollbar,
#search-results::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
#lyrics-lines::-webkit-scrollbar-track,
.track-table-wrap::-webkit-scrollbar-track,
#search-results::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
  margin: 4px 0;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
#lyrics-lines::-webkit-scrollbar-thumb,
.track-table-wrap::-webkit-scrollbar-thumb,
#search-results::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    var(--gold-bright) 0%,
    var(--gold) 55%,
    var(--gold-dim) 100%
  );
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 36px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
#lyrics-lines::-webkit-scrollbar-thumb:hover,
.track-table-wrap::-webkit-scrollbar-thumb:hover,
#search-results::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--gold-hot), var(--gold-bright));
  background-clip: padding-box;
  border: 2px solid transparent;
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner,
.track-table-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Ambient stage */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}

.orb-a {
  width: min(55vw, 520px);
  height: min(55vw, 520px);
  top: -12%;
  left: -8%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.45), transparent 70%);
}

.orb-b {
  width: min(45vw, 420px);
  height: min(45vw, 420px);
  bottom: 5%;
  right: -10%;
  background: radial-gradient(circle, rgba(120, 80, 20, 0.5), transparent 70%);
  animation-delay: -6s;
}

.orb-c {
  width: min(30vw, 280px);
  height: min(30vw, 280px);
  top: 42%;
  left: 48%;
  background: radial-gradient(circle, rgba(243, 215, 120, 0.18), transparent 70%);
  animation-delay: -11s;
}

[data-theme="light"] .orb-a {
  background: radial-gradient(circle, rgba(201, 162, 39, 0.35), transparent 70%);
}
[data-theme="light"] .orb-b {
  background: radial-gradient(circle, rgba(180, 140, 40, 0.22), transparent 70%);
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  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' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(3%, 4%) scale(1.06);
  }
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem clamp(0.75rem, 3vw, 1.5rem) 4rem;
  box-sizing: border-box;
}

/* Header / brand */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.35rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  padding: 6px;
  background: linear-gradient(145deg, rgba(243, 215, 120, 0.25), rgba(212, 175, 55, 0.05));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-gold);
  display: grid;
  place-items: center;
}

#logo {
  width: 58px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.35));
}

.brand-kicker {
  margin: 0 0 0.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}

#title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.2vw, 2.45rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  background: linear-gradient(120deg, var(--gold-hot), var(--gold) 40%, var(--gold-bright) 70%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  position: relative;
}

.icon-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass);
  color: var(--gold);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  /* Geometric center — text buttons otherwise sit on the baseline and look low */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-gold);
}

/*
 * Flex centering on .icon-btn handles geometry. Moon/sun emoji metrics differ:
 * ☾ needs a tiny lift; ☀ already sits higher in the em-box, so no extra lift.
 */
#theme-toggle {
  padding-top: 0;
  padding-bottom: 1px; /* ☾ optical center */
}

[data-theme="light"] #theme-toggle {
  padding-bottom: 0; /* ☀ — drop the lift so it matches the moon's visual center */
}

/* —— Sleep timer —— */
.sleep-timer-wrap {
  position: relative;
}

.sleep-timer-btn.is-active {
  border-color: var(--gold-bright);
  box-shadow: var(--shadow-gold), inset 0 0 0 1px rgba(212, 175, 55, 0.25);
  color: var(--gold-hot);
}

.sleep-timer-icon {
  display: block;
  line-height: 1;
}

.sleep-timer-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 1.35rem;
  height: 1.2rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1408;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.sleep-timer-badge[hidden] {
  display: none !important;
}

.sleep-timer-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: min(340px, calc(100vw - 1.5rem));
  padding: 1rem 1.05rem 1.05rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--bg-solid);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.08);
}

[data-theme="light"] .sleep-timer-panel {
  background: #fffdf7;
  box-shadow: 0 16px 40px rgba(90, 60, 10, 0.14);
}

.sleep-timer-panel[hidden] {
  display: none !important;
}

.sleep-timer-panel-head {
  margin-bottom: 0.75rem;
}

.sleep-timer-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.sleep-timer-status {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}

.sleep-timer-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.sleep-mode-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.4rem 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.sleep-mode-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.sleep-mode-btn.is-active {
  border-color: var(--gold);
  color: var(--gold-hot);
  background: rgba(212, 175, 55, 0.14);
}

.sleep-timer-hint {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.sleep-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.sleep-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.sleep-chip:hover {
  border-color: var(--border-strong);
}

.sleep-chip.is-selected {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.16);
  color: var(--gold-hot);
}

.sleep-custom-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.sleep-custom-row label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sleep-custom-row input[type="number"] {
  width: 5rem;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #1c1810;
  color: #f6f0e4;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 0.55rem;
}

[data-theme="dark"] .sleep-custom-row input[type="number"] {
  background: linear-gradient(180deg, #242016 0%, #16130e 100%);
  border-color: rgba(232, 197, 71, 0.4);
  color: #f8f1e0;
}

[data-theme="light"] .sleep-custom-row input[type="number"] {
  background: #fffef9;
  color: #1a1408;
  border-color: rgba(140, 105, 20, 0.4);
}

.sleep-custom-unit {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sleep-timer-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.sleep-timer-start {
  flex: 1;
  min-width: 8rem;
}

.sleep-timer-cancel {
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .sleep-timer-panel {
    position: fixed;
    top: auto;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 1rem;
  }

  .sleep-timer-modes {
    grid-template-columns: 1fr;
  }
}

/* Hero player */
.hero-player {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass);
  box-shadow: var(--shadow), var(--shadow-gold);
  padding: 1.5rem 1.4rem 1.35rem;
  margin-bottom: 1.35rem;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  inset: -40% auto auto 20%;
  width: 60%;
  height: 70%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.18), transparent 65%);
  pointer-events: none;
}

.hero-layout {
  position: relative;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.75rem;
  align-items: center;
}

@media (max-width: 720px) {
  .hero-layout {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

/* Vinyl disc */
.disc-stage {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}

.disc-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 30px rgba(212, 175, 55, 0.12), 0 0 40px rgba(212, 175, 55, 0.1);
}

.disc {
  width: 186px;
  height: 186px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #1a150c 0 18%, transparent 19%),
    repeating-radial-gradient(
      circle at 50% 50%,
      #0d0b08 0 2px,
      #1c1810 3px,
      #12100c 5px
    );
  border: 3px solid rgba(212, 175, 55, 0.55);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 40px rgba(212, 175, 55, 0.08);
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 0.4s ease;
}

[data-theme="light"] .disc {
  background:
    radial-gradient(circle at 50% 50%, #f7efd8 0 18%, transparent 19%),
    repeating-radial-gradient(circle at 50% 50%, #e8dcb8 0 2px, #f3ead0 3px, #e5d7b0 5px);
}

body.is-playing .disc {
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.disc-label {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2314, #0e0c08);
  border: 2px solid var(--gold);
  display: grid;
  place-items: center;
  z-index: 1;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.35);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

[data-theme="light"] .disc-label {
  background: linear-gradient(145deg, #fff8e8, #f0e2b8);
}

#disc-art,
.disc-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

#disc-art {
  z-index: 1;
  transition: opacity 0.35s ease;
}

#disc-art.is-covered {
  opacity: 0;
}

.disc-cover {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.disc-label.has-cover .disc-cover {
  opacity: 1;
}

.disc-label.has-cover .disc-cover:not([hidden]) {
  opacity: 1;
}

/* Keep brand present without dominating the label */
.disc-watermark {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  z-index: 3;
  opacity: 0.72;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px;
  box-sizing: content-box;
}

.disc-label.has-cover .disc-watermark {
  opacity: 0.55;
  background: rgba(0, 0, 0, 0.35);
}

.disc-hole {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--gold-dim);
  z-index: 2;
}

.hero-meta {
  min-width: 0;
  width: 100%;
}

.meta-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

@media (max-width: 720px) {
  .meta-top {
    justify-content: center;
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1a1408;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
}

.pill-soft {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 500;
  /* Multi-artist labels: show every name, wrap cleanly when long */
  max-width: min(100%, 28rem);
  white-space: normal;
  text-align: left;
  line-height: 1.35;
  height: auto;
  min-height: 1.6rem;
  padding: 0.35rem 0.75rem;
  border-radius: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pill-soft.is-long-scope {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  max-width: min(100%, 36rem);
}

#player-status {
  font-size: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-left: 0.15rem;
}

#player-status[data-status="playing"] {
  background: #6dce6d;
  box-shadow: 0 0 10px rgba(109, 206, 109, 0.7);
}

#player-status[data-status="loading"] {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.7);
  animation: pulse 1s ease infinite;
}

#player-status[data-status="error"] {
  background: var(--danger);
}

#player-status[data-status="paused"] {
  background: var(--gold-dim);
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

#musicplaying {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.8vw, 2.35rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--gold-hot);
  letter-spacing: 0.01em;
}

#artistplaying {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-muted);
}

.visualizer {
  width: 100%;
  height: 72px;
  display: block;
  margin-bottom: 0.85rem;
  border-radius: 14px;
}

.player-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.progress-row time {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 2.4rem;
  font-weight: 500;
}

#progress-bar,
#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.08));
  border: none;
  padding: 0;
  min-height: 6px;
  cursor: pointer;
}

#progress-bar {
  flex: 1;
  height: 7px;
  background: rgba(212, 175, 55, 0.12);
}

#progress-bar::-webkit-slider-thumb,
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-hot), var(--gold));
  border: 2px solid var(--bg-solid);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.55);
  cursor: pointer;
}

#progress-bar::-moz-range-thumb,
#volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-hot), var(--gold));
  border: 2px solid var(--bg-solid);
  cursor: pointer;
}

/* Transport */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.ctrl-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--gold-bright);
  font-size: 1.05rem;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

[data-theme="light"] .ctrl-btn {
  background: rgba(255, 255, 255, 0.55);
}

.ctrl-btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.15);
}

.ctrl-main {
  width: 68px;
  height: 68px;
  min-width: 68px;
  font-size: 1.35rem;
  color: #1a1408;
  border: none;
  background: linear-gradient(145deg, var(--gold-hot), var(--gold) 55%, #b8922a);
  box-shadow: 0 10px 30px rgba(212, 175, 55, 0.35);
}

.ctrl-main:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 36px rgba(212, 175, 55, 0.45);
}

/* Mode = same circular size as replay/prev/next so ▶ stays centered */
.ctrl-mode {
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 50%;
  letter-spacing: 0;
  color: var(--gold-bright);
}

/* Monochrome SVG icons (shuffle / loop) — stroke+fill use button gold.
   Slightly short so optical weight matches ↻ ⏮ ⏭; a touch larger for clarity.
   Nudge right+down so the glyph sits on the optical center of the circle. */
.ctrl-mode .ctrl-icon {
  display: block;
  width: 1.38rem;
  height: 1.18rem;
  flex-shrink: 0;
  pointer-events: none;
  overflow: visible;
  position: relative;
  left: 0.06rem;
  top: 0.05rem;
}

.ctrl-mode .ctrl-icon path[stroke] {
  stroke: currentColor;
  fill: none;
}

.ctrl-mode .ctrl-icon path[fill]:not([fill="none"]) {
  fill: currentColor;
  stroke: none;
}

.utility-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .utility-row {
    flex-direction: column;
  }
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 140px;
  flex: 1 1 160px;
  max-width: 240px;
}

.vol-icon {
  color: var(--gold);
  font-size: 0.95rem;
}

.utility-actions {
  display: flex;
  gap: 0.45rem;
}

.ghost-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.95rem;
  min-height: 40px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ghost-btn:hover,
.ghost-btn[aria-pressed="true"] {
  border-color: var(--border-strong);
  color: var(--gold-bright);
  background: var(--bg-soft);
}

/* Lyrics */
.lyrics-panel {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  /* Prevent browser scroll-anchoring from jumping the page when lyrics inject */
  overflow-anchor: none;
}

.lyrics-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  min-height: 1.1rem;
  margin-bottom: 0.45rem;
}

.lyrics-status,
#lyrics-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Hide header chrome when there is nothing to show */
.lyrics-header:empty,
.lyrics-header:has(#lyrics-status:empty) {
  display: none;
  margin: 0;
  min-height: 0;
}

#lyrics-lines {
  /* Fixed box so first lyrics load does not grow the page / shift scroll */
  position: relative;
  height: 240px;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  /*
   * Padding ≈ half the viewport so first/last lines can truly sit in the middle.
   * (Must match center math: content can scroll until active line is centered.)
   */
  padding: 100px 0.55rem;
  scroll-behavior: auto;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
  text-align: center;
}

#lyrics-lines.is-synced {
  /* Keep scroll metrics stable */
  scroll-padding-block: 100px;
}

[data-theme="light"] #lyrics-lines {
  background: rgba(255, 255, 255, 0.35);
}

.lyric-line {
  display: block;
  margin: 0.45rem auto;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease, font-weight 0.15s ease;
  font-size: 0.98rem;
  line-height: 1.45;
  max-width: 36em;
  opacity: 0.72;
  /* Avoid transform — it breaks vertical centering math / causes jump on click */
  transform: none;
}

.lyric-line:hover {
  color: var(--text);
  opacity: 0.95;
}

.lyric-line.active {
  opacity: 1;
  font-size: 1.05rem;
  color: var(--gold-hot);
  background: rgba(212, 175, 55, 0.16);
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.25);
}

[data-theme="light"] .lyric-line.active {
  background: rgba(201, 162, 39, 0.2);
  color: #5c4508;
  box-shadow: 0 0 0 1px rgba(154, 114, 9, 0.25);
}

.lyric-plain {
  white-space: pre-wrap;
  font-family: var(--font-ui);
  line-height: 1.75;
  text-align: left;
  max-width: 40em;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.lyrics-note {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-align: center;
}

.lyrics-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Panels */
.panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.3rem 1.35rem;
  margin-bottom: 1.15rem;
}

/*
 * Stacking: backdrop-filter on .panel creates a stacking context, so a child
 * z-index cannot paint above a later sibling panel. Native <select> popups
 * escape that (genre looks fine); the artist combobox list does not.
 * Keep Library above Search so the combobox list covers the search bar.
 */
.library-panel {
  position: relative;
  z-index: 5;
}

.search-panel {
  /* position: relative already set below for #search-results */
  z-index: 4;
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.panel-head.compact {
  margin-bottom: 0.75rem;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.section-sub {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-primary {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.35rem;
  min-height: 48px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  color: #1a1408;
  background: linear-gradient(135deg, var(--gold-hot), var(--gold));
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.28);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

/* Light mode: brighter gold fill + near-white label for clear contrast */
[data-theme="light"] .btn-primary {
  color: #fffef8;
  background: linear-gradient(135deg, #d4a84b 0%, #b8891a 55%, #9a7209 100%);
  box-shadow: 0 8px 22px rgba(154, 114, 9, 0.28);
  text-shadow: 0 1px 1px rgba(80, 55, 0, 0.25);
  border: 1px solid rgba(120, 88, 10, 0.35);
}

[data-theme="light"] .btn-primary:hover {
  filter: brightness(1.06);
}

.selection-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

@media (max-width: 640px) {
  .selection-row {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

select,
input[type="search"],
input[type="text"] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #1c1810;
  color: #f6f0e4;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  min-height: 46px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  /* Native dropdown list (where supported) */
  color-scheme: dark;
}

/* High-contrast options in open lists */
select option {
  background: #1c1810;
  color: #f6f0e4;
}

[data-theme="dark"] select,
[data-theme="dark"] input[type="search"] {
  background: linear-gradient(180deg, #242016 0%, #16130e 100%);
  color: #f8f1e0;
  border-color: rgba(232, 197, 71, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 230, 150, 0.06);
}

[data-theme="dark"] select:hover,
[data-theme="dark"] input[type="search"]:hover {
  border-color: rgba(243, 215, 120, 0.65);
  background: linear-gradient(180deg, #2a2418 0%, #1a1610 100%);
}

[data-theme="light"] select,
[data-theme="light"] input[type="search"] {
  background: #fffef9;
  color: #1a1408;
  border-color: rgba(140, 105, 20, 0.45);
  color-scheme: light;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(90, 60, 10, 0.06);
}

[data-theme="light"] select option {
  background: #fffef9;
  color: #1a1408;
}

[data-theme="light"] select:hover,
[data-theme="light"] input[type="search"]:hover {
  border-color: rgba(154, 114, 9, 0.65);
  background: #ffffff;
}

select:focus,
input:focus,
button:focus-visible,
.track-table tr:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus);
}

/* —— Genre / Artist combobox (shared list + field styles) —— */
.combobox {
  position: relative;
  min-width: 0;
}

.combobox-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #1c1810;
  color: #f6f0e4;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.65rem 2.4rem 0.65rem 0.9rem;
  min-height: 46px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

/* Genre is a fixed select (not type-ahead) — same look, pointer cursor */
.combobox--select .combobox-input {
  cursor: pointer;
  caret-color: transparent;
  user-select: none;
}

[data-theme="dark"] .combobox-input {
  background: linear-gradient(180deg, #242016 0%, #16130e 100%);
  color: #f8f1e0;
  border-color: rgba(232, 197, 71, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 230, 150, 0.06);
}

[data-theme="dark"] .combobox-input:hover {
  border-color: rgba(243, 215, 120, 0.65);
  background: linear-gradient(180deg, #2a2418 0%, #1a1610 100%);
}

[data-theme="light"] .combobox-input {
  background: #fffef9;
  color: #1a1408;
  border-color: rgba(140, 105, 20, 0.45);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(90, 60, 10, 0.06);
}

[data-theme="light"] .combobox-input:hover {
  border-color: rgba(154, 114, 9, 0.65);
  background: #ffffff;
}

.combobox-input:focus {
  border-color: var(--gold);
  box-shadow: var(--focus);
}

.combobox-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.combobox-toggle:hover {
  color: var(--gold-bright);
  background: var(--bg-soft);
}

.combobox.is-open .combobox-toggle {
  color: var(--gold);
}

.combobox-list {
  position: absolute;
  /* Above siblings inside the library panel (selection-meta, track table) */
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: min(280px, 45vh);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #16130e;
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.08);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

[data-theme="light"] .combobox-list {
  background: #fffdf7;
  box-shadow: 0 12px 36px rgba(90, 60, 10, 0.14), 0 0 0 1px rgba(154, 114, 9, 0.1);
}

.combobox-option {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option:hover,
.combobox-option.is-active {
  background: rgba(212, 175, 55, 0.16);
  color: var(--gold-hot);
}

[data-theme="light"] .combobox-option:hover,
[data-theme="light"] .combobox-option.is-active {
  background: rgba(154, 114, 9, 0.12);
  color: var(--gold-hot);
}

.combobox-option.is-selected {
  color: var(--gold-bright);
  font-weight: 600;
}

.combobox-option.is-selected::after {
  content: ' ✓';
  font-weight: 700;
  opacity: 0.85;
}

/* “All involving …” row — collabs + solo for a typed singer */
.combobox-option.is-involves {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
  padding-bottom: 0.65rem;
  color: var(--gold);
  font-weight: 600;
}

.combobox-option.is-involves.is-selected::after {
  content: ' +';
}

/* —— Multi-artist chips (below the combobox so the input bar stays put) —— */
.artist-filter {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.artist-filter .combobox {
  /* Keep the type-ahead bar as the stable first row */
  order: 0;
  flex-shrink: 0;
}

.artist-chips {
  order: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  /* Growing chip rows only expand downward; do not reflow the input above */
  min-height: 0;
}

.artist-chips[hidden] {
  display: none !important;
}

.artist-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  max-width: 100%;
  padding: 0.28rem 0.35rem 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold-hot);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.artist-chip.is-involves {
  border-color: rgba(212, 175, 55, 0.55);
  background: rgba(212, 175, 55, 0.16);
}

.artist-chip.is-exact {
  color: var(--text);
  background: var(--bg-soft);
}

.artist-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.artist-chip-remove {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.artist-chip-remove:hover {
  color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.15);
}

.combobox-empty {
  padding: 0.65rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Range thumbs: avoid sticky gold "outline" after drag; keyboard still gets :focus-visible */
#progress-bar:focus,
#volume-slider:focus {
  outline: none;
  box-shadow: none;
  border: none;
}

#progress-bar:focus-visible,
#volume-slider:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(212, 175, 55, 0.55);
}

/* Count + Sort + Show list: one row (even on narrow phones) */
.selection-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.85rem 0 0.45rem;
  flex-wrap: nowrap;
  min-width: 0;
}

#selection-count {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#selection-count.is-multi-filter {
  font-size: 0.86rem;
  font-weight: 500;
}

.selection-meta-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Sort: ghost button (like Show list) + Genre/Artist combobox-list dropdown */
.library-sort {
  position: relative;
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
}

.library-sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  max-width: 11.5rem;
  border-color: var(--border-strong);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem 0.45rem 0.95rem;
  min-height: 40px;
  white-space: nowrap;
}

.library-sort-btn:hover,
.library-sort.is-open .library-sort-btn {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: var(--bg-soft);
}

#library-sort-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.library-sort-caret {
  flex-shrink: 0;
  font-size: 0.7rem;
  line-height: 1;
  opacity: 0.9;
  transform: translateY(1px);
}

/* Same panel as Genre/Artist (.combobox-list) — anchor under the button */
.library-sort-list.combobox-list {
  left: auto;
  right: 0;
  min-width: 11.5rem;
  width: max-content;
  max-width: min(16rem, 70vw);
}

/* Match Lyrics ghost-btn presence (full padding / height, slightly stronger edge) */
.library-list-toggle {
  flex: 0 0 auto;
  border-color: var(--border-strong);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  min-height: 40px;
  white-space: nowrap;
}

.library-list-toggle:hover,
.library-list-toggle[aria-expanded="true"] {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: var(--bg-soft);
}

/* Track table — full width, scroll inside wrap (not display:block on table) */
#selected {
  width: 100%;
  min-width: 0;
}

#selected.is-collapsed,
#selected[hidden] {
  display: none;
}

.track-table-wrap {
  width: 100%;
  max-height: min(42vh, 360px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  -webkit-overflow-scrolling: touch;
}

[data-theme="light"] .track-table-wrap {
  background: rgba(255, 255, 255, 0.45);
}



.track-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  display: table;
}

.track-table col.col-name {
  width: 58%;
}

.track-table col.col-artist {
  width: 42%;
}

.track-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1408;
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/*
 * Light mode: separate columns with adjacent gold gradients (no vertical lines).
 * Dark mode keeps the original single header gradient only.
 */
[data-theme="light"] .track-table thead th {
  color: #2a1f06;
  text-shadow: 0 1px 0 rgba(255, 248, 220, 0.35);
  border-bottom: none;
}

/* Same start color on both headers (like dark mode); soft shift only toward the end */
[data-theme="light"] .track-table thead th.col-name {
  background: linear-gradient(165deg, #e8c96a 0%, #dcb44a 50%, #d0a834 100%);
}

[data-theme="light"] .track-table thead th.col-artist {
  background: linear-gradient(165deg, #e8c96a 0%, #dcb44a 50%, #c9a227 100%);
}

/* Body: same light start, gentle column wash without a darker left edge on Artist */
[data-theme="light"] .track-table td.col-name {
  background: linear-gradient(90deg, rgba(255, 250, 235, 0.95) 0%, rgba(250, 240, 210, 0.5) 100%);
}

[data-theme="light"] .track-table td.col-artist {
  background: linear-gradient(90deg, rgba(255, 250, 235, 0.95) 0%, rgba(255, 252, 245, 0.92) 100%);
}

[data-theme="light"] .track-table tbody tr:hover td.col-name {
  background: linear-gradient(90deg, rgba(255, 244, 210, 1) 0%, rgba(245, 228, 165, 0.55) 100%);
}

[data-theme="light"] .track-table tbody tr:hover td.col-artist {
  background: linear-gradient(90deg, rgba(255, 244, 210, 1) 0%, rgba(255, 250, 230, 1) 100%);
}

[data-theme="light"] .track-table tbody tr.playing td.col-name {
  background: linear-gradient(90deg, rgba(232, 201, 106, 0.28) 0%, rgba(212, 175, 55, 0.14) 100%);
}

[data-theme="light"] .track-table tbody tr.playing td.col-artist {
  background: linear-gradient(90deg, rgba(232, 201, 106, 0.28) 0%, rgba(232, 201, 106, 0.2) 100%);
}

.track-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  max-width: none;
}

.track-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.track-table tbody tr:hover {
  background: var(--bg-soft);
}

.track-table tbody tr.playing {
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold-hot);
}

.empty-hint {
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0.15rem;
}

/* —— Responsive / mobile —— */
@media (max-width: 720px) {
  /* Keep count · sort · show/hide on one line */
  .selection-meta {
    gap: 0.4rem;
  }

  #selection-count {
    font-size: 0.82rem;
    flex: 1 1 0;
    min-width: 3.5rem;
  }

  .selection-meta-actions {
    gap: 0.35rem;
  }

  .library-sort-btn {
    max-width: min(8.75rem, 38vw);
    min-height: 36px;
    padding: 0.3rem 0.65rem 0.3rem 0.7rem;
    font-size: 0.78rem;
  }

  .library-sort-list.combobox-list {
    min-width: 10.5rem;
  }

  .library-list-toggle {
    min-height: 36px;
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
  }

  .page {
    padding: 0.85rem 0.85rem 3.5rem;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  #logo {
    width: 44px;
  }

  #title {
    font-size: clamp(1.35rem, 6vw, 1.75rem);
  }

  .hero-player {
    padding: 1.15rem 1rem 1.1rem;
    border-radius: 22px;
  }

  .disc-stage {
    width: min(168px, 52vw);
    height: min(168px, 52vw);
  }

  .disc {
    width: min(156px, 48vw);
    height: min(156px, 48vw);
  }

  .panel {
    padding: 1rem 0.95rem 1.1rem;
    border-radius: 22px;
  }

  .panel-head {
    align-items: stretch;
  }

  .panel-head .btn-primary {
    width: 100%;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .track-table col.col-name {
    width: 55%;
  }

  .track-table col.col-artist {
    width: 45%;
  }

  .track-table thead th,
  .track-table td {
    padding: 0.65rem 0.7rem;
    font-size: 0.9rem;
  }

  .track-table thead th {
    font-size: 0.7rem;
  }

  .track-table-wrap {
    max-height: min(48vh, 320px);
  }

  .transport {
    gap: 0.4rem;
  }

  .ctrl-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .ctrl-main {
    width: 60px;
    height: 60px;
    min-width: 60px;
  }

  .ctrl-mode {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
  }

  .ctrl-mode .ctrl-icon {
    width: 1.28rem;
    height: 1.08rem;
  }

  .volume-wrap {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }

  .utility-actions {
    width: 100%;
    justify-content: center;
  }

  .shortcuts-hint {
    display: none; /* keyboard-only hints; hide on phones */
  }

  #footer p {
    font-size: 0.75rem;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .meta-top {
    justify-content: center;
  }

  .pill {
    font-size: 0.65rem;
    padding: 0.22rem 0.55rem;
  }

  #musicplaying {
    font-size: 1.4rem;
  }

  #selection-count {
    font-size: 0.78rem;
  }

  .library-sort-btn {
    max-width: min(7.75rem, 36vw);
    min-height: 34px;
    font-size: 0.74rem;
    padding: 0.28rem 0.5rem 0.28rem 0.55rem;
  }

  .library-list-toggle {
    min-height: 34px;
    padding: 0.28rem 0.55rem;
    font-size: 0.74rem;
  }

  /* Slightly more room for long titles on very small screens */
  .track-table col.col-name {
    width: 60%;
  }

  .track-table col.col-artist {
    width: 40%;
  }
}

@media (min-width: 900px) {
  .track-table-wrap {
    max-height: min(46vh, 400px);
  }

  .track-table col.col-name {
    width: 62%;
  }

  .track-table col.col-artist {
    width: 38%;
  }
}

/* Search */
.search-engine {
  position: relative;
}

#search-input {
  border-radius: 999px;
  padding-left: 1.15rem;
}

[data-theme="dark"] #search-input {
  background: linear-gradient(180deg, #242016 0%, #16130e 100%);
  color: #f8f1e0;
  border-color: rgba(232, 197, 71, 0.45);
}

[data-theme="light"] #search-input {
  background: #fffef9;
  color: #1a1408;
  border: 1px solid rgba(140, 105, 20, 0.45);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(90, 60, 10, 0.08);
}

[data-theme="light"] #search-input::placeholder {
  color: #8a7350;
  opacity: 1;
}

[data-theme="light"] #search-results {
  background: #fffef9;
  border-color: rgba(140, 105, 20, 0.4);
  color: #1a1408;
}

[data-theme="light"] .search-item:hover,
[data-theme="light"] .search-item.active {
  background: rgba(201, 162, 39, 0.14);
}

[data-theme="light"] .search-artist {
  color: #6b5c3e;
}

#search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 30;
}

#search-results[hidden] {
  display: none !important;
}

.search-panel {
  position: relative;
}

.search-item {
  padding: 0.7rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  border-bottom: 1px solid var(--border);
}

.search-item:hover,
.search-item.active {
  background: var(--bg-soft);
}

.search-item.muted {
  color: var(--text-muted);
  cursor: default;
}

.search-name {
  font-weight: 600;
}

.search-artist {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.search-item mark {
  background: rgba(212, 175, 55, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.search-picked {
  margin: 0.65rem 0 0;
  color: var(--gold);
  font-weight: 600;
}

/* Footer & hints */
.shortcuts-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  justify-content: center;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.5rem 0 1.5rem;
}

.shortcuts-hint kbd {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.2);
  color: var(--gold);
}

#footer {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
}

#footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.7;
  text-align: center;
}

#footer a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

#footer a:hover {
  border-bottom-color: var(--gold);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-solid);
  color: var(--text);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.7rem 1.3rem;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  max-width: min(90vw, 420px);
  text-align: center;
  pointer-events: none;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Hidden audio */
#audio-el {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  body.is-playing .disc {
    animation: none !important;
  }
  .ctrl-btn,
  .btn-primary,
  .icon-btn {
    transition: none;
  }
}
