/* Retro-Literary Parchment (Default) + Starry Night Theme */
:root,
html[data-theme="parchment"] {
  --bg: #f4ecdc;
  --bg-wash-1: rgba(182, 72, 58, 0.08);
  --bg-wash-2: rgba(197, 140, 56, 0.12);
  --surface: #fbf6eb;
  --surface-card: rgba(252, 248, 239, 0.88);
  --surface-inset: #efe4cf;
  --surface-hover: rgba(158, 42, 43, 0.06);
  --border: rgba(74, 48, 38, 0.15);
  --border-strong: rgba(158, 42, 43, 0.32);
  --text: #261916;
  --text-muted: #6e5952;
  --accent: #9e2a2b;       /* Sindoor / vintage cinema crimson */
  --accent-2: #c58c38;     /* Antique brass */
  --accent-soft: rgba(158, 42, 43, 0.09);
  --sleeve-bg: linear-gradient(155deg, #2d3849 0%, #1a2130 100%);
  --sleeve-ink: #ebd8b7;
  --vis-bar-top: #9e2a2b;
  --vis-bar-bottom: #c58c38;
  --vis-bar-idle: rgba(38, 25, 22, 0.16);
  --shadow: 0 18px 42px rgba(61, 38, 24, 0.11);
  --radius: 20px;
}

html[data-theme="night"] {
  --bg: #111524;
  --bg-wash-1: rgba(224, 152, 145, 0.12);
  --bg-wash-2: rgba(241, 184, 102, 0.11);
  --surface: #181d31;
  --surface-card: rgba(24, 29, 49, 0.86);
  --surface-inset: #13182a;
  --surface-hover: rgba(241, 184, 102, 0.08);
  --border: rgba(244, 231, 211, 0.12);
  --border-strong: rgba(241, 184, 102, 0.36);
  --text: #f5ecdf;
  --text-muted: #b0a8ba;
  --accent: #f1b866;       /* Fairy-light amber */
  --accent-2: #df8e88;     /* Dusty rose */
  --accent-soft: rgba(241, 184, 102, 0.13);
  --sleeve-bg: linear-gradient(155deg, #5d292d 0%, #31171c 100%);
  --sleeve-ink: #f6e7cf;
  --vis-bar-top: #f1b866;
  --vis-bar-bottom: #df8e88;
  --vis-bar-idle: rgba(245, 236, 223, 0.18);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 8%, var(--bg-wash-1), transparent 46%),
    radial-gradient(circle at 88% 84%, var(--bg-wash-2), transparent 48%),
    var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Subtle archival paper grain */
.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: radial-gradient(var(--text) 0.65px, transparent 0.65px);
  background-size: 16px 16px;
}

/* Twinkling starfield visible in Starry Night mode */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  background-image:
    radial-gradient(1.5px 1.5px at 14% 18%, rgba(255, 240, 210, 0.7), transparent),
    radial-gradient(1.2px 1.2px at 42% 11%, rgba(255, 240, 210, 0.5), transparent),
    radial-gradient(1.8px 1.8px at 78% 22%, rgba(241, 184, 102, 0.75), transparent),
    radial-gradient(1.2px 1.2px at 88% 58%, rgba(255, 240, 210, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 22% 72%, rgba(255, 240, 210, 0.6), transparent),
    radial-gradient(1.2px 1.2px at 64% 85%, rgba(241, 184, 102, 0.55), transparent);
}

html[data-theme="night"] .starfield {
  opacity: 1;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Top bar */
.top-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.marginalia {
  font-family: "Caveat", cursive;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.theme-pill:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.theme-icon {
  color: var(--accent-2);
}

/* Hero Keepsake Card */
.hero-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 32px 30px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-header::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  pointer-events: none;
}

.corner-motif {
  position: absolute;
  width: 58px;
  height: 58px;
  color: var(--accent-2);
  opacity: 0.55;
  pointer-events: none;
}

.corner-tl { top: 10px; left: 10px; }
.corner-br { bottom: 10px; right: 10px; transform: rotate(180deg); }

/* Record Sleeve + Peeking Vinyl */
.sleeve-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 210px;
  height: 162px;
  display: flex;
  align-items: center;
}

.record-sleeve {
  position: relative;
  z-index: 2;
  width: 148px;
  height: 154px;
  border-radius: 12px;
  background: var(--sleeve-bg);
  color: var(--sleeve-ink);
  padding: 10px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sleeve-frame {
  height: 100%;
  border: 1px solid rgba(235, 216, 183, 0.35);
  border-radius: 8px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
}

.sleeve-stamp {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
}

.sleeve-lotus {
  width: 56px;
  height: 56px;
  color: var(--sleeve-ink);
  opacity: 0.92;
}

.sleeve-note {
  font-family: "Caveat", cursive;
  font-size: 1rem;
  opacity: 0.9;
}

.vinyl-disc {
  position: absolute;
  right: 0;
  z-index: 1;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #262228 0%, #0d0b0e 58%, #201c22 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  transition: transform 0.4s ease;
  animation: spin 9s linear infinite;
  animation-play-state: paused;
}

.vinyl-disc.is-playing {
  animation-play-state: running;
}

.vinyl-grooves {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 11px rgba(255, 255, 255, 0.03),
    inset 0 0 0 22px rgba(255, 255, 255, 0.03);
}

.vinyl-label {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-2), var(--accent));
  display: grid;
  place-items: center;
  color: #fff8ed;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255, 248, 237, 0.32);
}

.label-stars {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
}

.vinyl-spindle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bg);
  opacity: 0.7;
  bottom: 6px;
}

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

.hero-meta {
  min-width: 0;
  flex: 1;
  position: relative;
  z-index: 2;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.hero-meta h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.04;
}

.subtitle {
  margin: 6px 0 12px;
  color: var(--text-muted);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.18rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.86rem;
  margin-bottom: 18px;
}

.hand-tag {
  font-family: "Caveat", cursive;
  font-size: 1.12rem;
  color: var(--accent);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff8ef;
  box-shadow: 0 8px 20px rgba(158, 42, 43, 0.24);
}

html[data-theme="night"] .btn-primary {
  color: #16141f;
  box-shadow: 0 8px 22px rgba(241, 184, 102, 0.25);
}

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

.btn-ghost {
  background: var(--surface-inset);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
}

/* Player Deck */
.player-card {
  padding: 22px 26px;
  border-radius: var(--radius);
  background: var(--surface-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.now-playing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.now-playing-info {
  min-width: 0;
  flex: 1;
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 4px;
}

.now-playing-info h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.62rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-meta {
  margin: 3px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.now-note {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
}

#visualizer {
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
}

/* Progress & Volume ranges */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-label {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 38px;
}

.time-label:last-child {
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
}

#seekBar { flex: 1; }
#volumeBar { width: 86px; }

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

/* Controls */
.controls-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.controls-left,
.controls-center,
.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls-center {
  justify-content: center;
  gap: 14px;
}

.controls-right {
  justify-content: flex-end;
}

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.icon-btn.is-active {
  color: var(--accent);
}

.repeat-one-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 800;
  color: var(--accent);
}

.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff8ef;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(158, 42, 43, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}

html[data-theme="night"] .play-btn {
  color: #16141f;
  box-shadow: 0 8px 22px rgba(241, 184, 102, 0.3);
}

.play-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.06);
}

.speed-btn {
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

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

/* Ornamental Divider */
.floral-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--accent-2);
  padding: 0 12px;
  opacity: 0.75;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

/* Playlist Liner Notes */
.playlist-section {
  padding: 24px 26px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.playlist-header h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.playlist-caption {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--text-muted);
  width: 240px;
  max-width: 100%;
}

.search-box input {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  width: 100%;
  outline: none;
}

.tracklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.track-row:hover {
  background: var(--surface-hover);
}

.track-row.is-current {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

.track-num {
  text-align: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.track-row.is-current .track-num {
  color: var(--accent);
}

.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 14px;
}

.eq-bars span {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: eq 0.8s ease-in-out infinite alternate;
}

.eq-bars span:nth-child(2) { animation-delay: 0.2s; }
.eq-bars span:nth-child(3) { animation-delay: 0.4s; }

.eq-bars.paused span {
  animation-play-state: paused;
  height: 5px !important;
}

@keyframes eq {
  from { height: 4px; }
  to { height: 14px; }
}

.track-main {
  min-width: 0;
}

.track-title {
  display: block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row.is-current .track-title {
  color: var(--accent);
}

.track-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}

.keepsake-footer {
  text-align: center;
  font-family: "Caveat", cursive;
  font-size: 1.15rem;
  color: var(--text-muted);
  padding-top: 4px;
}

@media (max-width: 680px) {
  .hero-header {
    flex-direction: column;
    text-align: center;
    padding: 26px 20px;
    gap: 20px;
  }
  .sleeve-wrap {
    margin: 0 auto;
  }
  .hero-stats,
  .hero-actions {
    justify-content: center;
  }
  .now-playing-row {
    flex-direction: column;
    align-items: flex-start;
  }
  #visualizer {
    width: 100%;
  }
  .controls-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .controls-left,
  .controls-right {
    justify-content: center;
  }
  .playlist-header {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
}
