/* ============================================================
   Suno Player — "Illuminated Reliquary"
   Cormorant Garamond display + Newsreader body + JetBrains Mono lyrics.
   Gold (illuminated manuscript) primary + Warp-blue secondary.
   ============================================================ */

:root {
  /* Surfaces */
  --bg-0: #0a0b0e;
  --bg-1: #101116;
  --bg-2: #161922;
  --bg-3: #1d212c;
  --bg-hover: #1f232e;

  /* Lines */
  --line: #262a36;
  --line-warm: #2e2820;
  --line-dim: #181a22;

  /* Text */
  --text: #e8e6e0;
  --text-dim: #b6b3aa;
  --muted: #888b97;
  --muted-dim: #5a5d6a;

  /* Accents */
  --gold: #d4a657;
  --gold-bright: #ecc275;
  --gold-dim: #8a6a35;
  --gold-faint: rgba(212, 166, 87, 0.08);
  --gold-glow: rgba(212, 166, 87, 0.18);

  --blue: #7a9eff;
  --blue-bright: #a3bdff;
  --blue-dim: #4f6da6;
  --blue-faint: rgba(122, 158, 255, 0.08);

  --fav: #ff6f93;
  --best: #ffcd57;
  --warn: #f5a25e;
  --hot: #ff6b6b;
  --good: #6ec77a;

  /* Layout */
  --player-h: 88px;
  --tagbar-h: 116px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Typography */
  --font-display: 'Cormorant Garamond', 'Cormorant SC', 'Garamond', Georgia, serif;
  --font-body: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', Consolas, monospace;
  --font-ui: -apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  height: 100%;
  overflow: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Subtle film-grain overlay across the whole app */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 -0.5 1.5'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

/* Warm vignette glow in the upper-center to add atmosphere */
body::after {
  content: '';
  position: fixed;
  inset: -10vh -10vw auto -10vw;
  height: 60vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(212, 166, 87, 0.05), transparent 70%),
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(122, 158, 255, 0.04), transparent 70%);
}

/* ============================================================
   APP LAYOUT
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--tagbar-h) - var(--player-h) - var(--safe-bottom));
  position: relative;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--gold-dim) 30%, var(--gold-dim) 70%, transparent);
  opacity: 0.25;
  pointer-events: none;
}

.sidebar-head {
  padding: 20px 20px 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  gap: 8px;
  position: relative;
}

.sidebar-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
}

.sidebar-head h1::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--gold-glow);
}

.head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

#refresh,
.sidebar-close,
.head-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 3px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
#refresh:hover,
.sidebar-close:hover,
.head-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.sidebar-close { display: none; }

.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 4px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.menu-toggle:hover { border-color: var(--gold-dim); }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 4;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
.scrim.show { display: block; opacity: 1; }

.library {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.library::-webkit-scrollbar { width: 6px; }
.library::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.library::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.section-label {
  padding: 18px 20px 8px;
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.34em;
  color: var(--gold-dim);
  font-weight: 600;
  font-feature-settings: 'smcp';
}

/* Albums */
.album {
  margin-bottom: 2px;
}

.album-head {
  padding: 10px 14px 10px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.album-head:hover {
  background: var(--bg-hover);
}
.album-head.viewing {
  background: linear-gradient(90deg, var(--gold-faint), transparent 80%);
  border-left-color: var(--gold);
  color: var(--gold-bright);
}
.album-head .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.005em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.album-head .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.album-head .album-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, color 0.15s, background 0.15s;
}
.album-head .album-toggle:hover {
  background: var(--line);
  color: var(--text);
}
.album.collapsed .album-head .album-toggle {
  transform: rotate(-90deg);
}
.album.collapsed .album-tracks {
  display: none;
}
.album-tracks {
  padding: 2px 0 8px 0;
}

/* Tracks in sidebar */
.track {
  padding: 7px 14px 7px 38px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 32px;
  position: relative;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s, padding-left 0.12s;
}
.track:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.track.active {
  background: linear-gradient(90deg, var(--gold-faint), transparent 80%);
  border-left-color: var(--gold);
  color: var(--gold-bright);
  padding-left: 36px;
}
.track.playing::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-bright);
  box-shadow: 0 0 8px rgba(122, 158, 255, 0.6);
  animation: pulse 1.8s ease-in-out infinite;
}
.track.playing .num {
  visibility: hidden;
}
.track.no-audio {
  color: var(--muted-dim);
  font-style: italic;
  cursor: default;
}
.track .num {
  color: var(--muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  letter-spacing: 0.05em;
  min-width: 18px;
  flex-shrink: 0;
}
.track .title {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.track .fav-toggle {
  background: transparent;
  border: 0;
  color: var(--muted-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.track:hover .fav-toggle,
.track .fav-toggle.on {
  opacity: 1;
}
.track .fav-toggle:hover {
  color: var(--fav);
  background: rgba(255, 111, 147, 0.1);
}
.track .fav-toggle.on {
  color: var(--fav);
}

/* Favorites section */
.favorites-section .track {
  padding-left: 18px;
}
.favorites-section .track .ctx {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  padding-right: 8px;
  white-space: nowrap;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: translateY(-50%) scale(0.85); }
  50%      { opacity: 1;   transform: translateY(-50%) scale(1.1); }
}

/* ============================================================
   MAIN PANE — TRACK VIEW
   ============================================================ */

.main {
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.main::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.info.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
}
.info .hint {
  color: var(--muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.track-view,
.album-view {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 56px 80px;
}

/* HERO */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 24px;
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--gold-glow), transparent 60%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.hero-context {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.36em;
  margin: 0 0 28px 0;
  position: relative;
  z-index: 1;
  font-weight: 500;
}

.hero-cover-wrap {
  position: relative;
  display: inline-block;
  z-index: 1;
}

.hero-cover {
  width: 360px;
  height: 360px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(212, 166, 87, 0.12),
    0 0 40px -10px rgba(212, 166, 87, 0.1);
  border-radius: 4px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.hero-cover:hover {
  border-color: var(--gold-dim);
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(212, 166, 87, 0.3),
    0 0 60px -10px rgba(212, 166, 87, 0.2);
}
.hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-cover.placeholder {
  cursor: pointer;
  border-style: dashed;
  border-color: var(--gold-dim);
  background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
}
.hero-cover.placeholder:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.hero-cover .placeholder-inner {
  text-align: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.08em;
  line-height: 1.6;
  padding: 16px;
}
.hero-cover .placeholder-inner b {
  display: block;
  font-size: 36px;
  font-style: normal;
  margin-bottom: 6px;
  color: var(--gold-dim);
}

.hero-play {
  position: absolute;
  bottom: -22px;
  right: -22px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg-0);
  border: 0;
  font-size: 28px;
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow:
    0 12px 40px -8px rgba(212, 166, 87, 0.5),
    0 0 0 4px var(--bg-0),
    0 0 0 5px rgba(212, 166, 87, 0.4);
  transition: transform 0.15s ease-out, background 0.15s;
  line-height: 1;
  padding-left: 3px; /* optical centering of play icon */
}
.hero-play:hover {
  transform: scale(1.06);
  background: var(--gold-bright);
}
.hero-play:active {
  transform: scale(0.96);
}

.hero-title {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.005em;
  line-height: 1.05;
  margin: 40px 0 14px;
  text-align: center;
  position: relative;
  z-index: 1;
  color: var(--text);
}
.hero-title .title-fav {
  background: transparent;
  border: 0;
  color: var(--muted-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-style: normal;
  vertical-align: middle;
  margin-left: 4px;
  transition: color 0.15s, background 0.15s;
}
.hero-title .title-fav:hover {
  color: var(--fav);
  background: rgba(255, 111, 147, 0.08);
}
.hero-title .title-fav.on {
  color: var(--fav);
}

/* Tags */
.track-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}
.tag-chip-mini {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 3px 10px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Section dividers — manuscript style */
.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 48px 0;
  position: relative;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.section-divider .divider-mark {
  color: var(--gold-dim);
  font-size: 14px;
  letter-spacing: 0.6em;
  font-family: var(--font-display);
}

.track-section {
  position: relative;
  z-index: 1;
}
.track-section > .section-label {
  display: block;
  padding: 0;
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.42em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 18px;
  text-align: center;
}

/* Background prose */
.md.md-background,
.md.md-notes,
.md.album-notes {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.78;
  color: var(--text);
}
.md.md-background p,
.md.md-notes p,
.md.album-notes p {
  margin: 16px 0;
}
.md.md-background p:first-child {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-dim);
  margin-top: 0;
  letter-spacing: 0.005em;
}
.md.md-background p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 1.8em;
  line-height: 1;
  padding-right: 4px;
  vertical-align: baseline;
  color: var(--gold);
  font-weight: 600;
  font-style: normal;
}
.md em {
  color: var(--muted);
  font-style: italic;
}
.md strong {
  color: var(--text);
  font-weight: 600;
}
.md a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: var(--blue-dim);
  text-underline-offset: 3px;
}
.md h1, .md h2, .md h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-top: 28px;
  margin-bottom: 10px;
}
.md h1 { font-size: 22px; color: var(--gold); display: none; } /* hide internal H1s — we render our own title */
.md h2 { font-size: 18px; color: var(--gold-bright); }
.md h3 { font-size: 15px; color: var(--text); }
.md.md-notes,
.md.album-notes {
  font-size: 14px;
  color: var(--text-dim);
}
.md.md-notes h2,
.md.album-notes h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--gold-dim);
}

/* Lyrics block */
.lyrics-block {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.85;
  color: var(--text-dim);
  background: linear-gradient(180deg, rgba(212, 166, 87, 0.02), transparent);
  padding: 24px 28px 28px;
  border-left: 2px solid var(--gold-dim);
  border-right: 1px solid var(--line-dim);
  border-radius: 0 4px 4px 0;
  white-space: pre-wrap;
  margin: 0;
  overflow-x: auto;
}
.lyrics-block .lyric-tag {
  color: var(--gold);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.lyrics-block em {
  color: var(--blue);
  font-style: italic;
  font-family: var(--font-body);
  font-size: 13.5px;
  opacity: 0.85;
}
.lyrics-block strong {
  color: var(--gold-bright);
  font-weight: 500;
}

/* Track details — style/model, less prominent */
.track-details {
  margin-top: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.track-details dl {
  margin: 0;
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px 16px;
}
.track-details dt {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--gold-dim);
  font-size: 10px;
  font-weight: 600;
  padding-top: 1px;
}
.track-details dd {
  margin: 0;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.55;
}

/* ============================================================
   ALBUM VIEW
   ============================================================ */

.album-view .hero-cover { width: 320px; height: 320px; }
.album-view .hero-play { display: none; }

.album-tracklist {
  display: flex;
  flex-direction: column;
  margin: 32px 0 0;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 12px 40px -20px rgba(0, 0, 0, 0.6);
}
.album-tracklist-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.album-tracklist-row:last-child { border-bottom: 0; }
.album-tracklist-row:hover {
  background: var(--bg-hover);
}
.album-tracklist-row.no-audio {
  color: var(--muted);
  font-style: italic;
  cursor: default;
}
.album-tracklist-row .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  width: 28px;
  flex-shrink: 0;
  letter-spacing: 0.06em;
}
.album-tracklist-row .title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: 18px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.album-tracklist-row:hover .title { color: var(--gold-bright); }
.album-tracklist-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.album-tracklist-row .fav-toggle {
  background: transparent;
  border: 0;
  color: var(--muted-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
}
.album-tracklist-row .fav-toggle:hover {
  color: var(--fav);
  background: rgba(255, 111, 147, 0.1);
}
.album-tracklist-row .fav-toggle.on { color: var(--fav); }

@media (max-width: 768px) {
  .album-tracklist-tags { display: none; }
}

/* ============================================================
   COVER PROMPT MODAL
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow:
    0 40px 80px -20px rgba(0, 0, 0, 0.8),
    0 0 0 1px var(--gold-faint);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--gold-bright);
}
.modal-hint {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 8px 0;
}
.modal-label {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.36em;
  color: var(--gold-dim);
  margin-top: 8px;
  font-weight: 600;
}
.modal textarea,
.modal input {
  background: var(--bg-0);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  width: 100%;
  resize: vertical;
}
.modal textarea:focus,
.modal input:focus {
  outline: none;
  border-color: var(--gold-dim);
}
.modal textarea { min-height: 160px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.modal-actions button {
  background: var(--bg-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.modal-actions button:hover {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
}
.modal-actions button.primary {
  background: var(--gold);
  color: var(--bg-0);
  border-color: var(--gold);
  font-weight: 600;
}
.modal-actions button.primary:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}
.modal-actions button.danger {
  color: var(--fav);
  border-color: var(--fav);
}
.modal-actions button.danger:hover {
  background: var(--fav);
  color: var(--bg-0);
  border-color: var(--fav);
}
.modal-actions button.danger:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Welcome overlay — cloud-only first-visit greeting. */
.welcome[hidden] {
  display: none !important;
}
.welcome {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #161922 0%, #0a0b0e 70%, #050608 100%);
  padding: 24px;
  overflow-y: auto;
}
.welcome::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.65  0 0 0 0 0.34  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.welcome-inner {
  max-width: 620px;
  text-align: center;
  position: relative;
  z-index: 1;
}
.welcome-ornament {
  font-family: var(--font-display);
  color: var(--gold-dim);
  letter-spacing: 0.8em;
  font-size: 14px;
  margin: 0 0 36px;
}
.welcome-ornament:last-of-type {
  margin: 36px 0;
}
.welcome-prose {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1.7;
  color: var(--text);
  letter-spacing: 0.01em;
  text-align: left;
}
.welcome-prose p {
  margin: 0 0 22px;
}
.welcome-prose p:last-child {
  margin-bottom: 0;
}
.welcome-prose p:first-child::first-letter {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: 56px;
  color: var(--gold);
  line-height: 1;
  padding-right: 4px;
  vertical-align: baseline;
}
.welcome-enter {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: 14px 48px;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, letter-spacing 0.25s;
}
.welcome-enter:hover {
  background: var(--gold);
  color: var(--bg-0);
  border-color: var(--gold);
  letter-spacing: 0.4em;
}
@media (max-width: 600px) {
  .welcome-prose { font-size: 18px; }
  .welcome-prose p:first-child::first-letter { font-size: 44px; }
}

/* Read-only mode (Cloudflare static deploy): hide all write affordances. */
body.read-only .fav-toggle,
body.read-only .title-fav,
body.read-only #favCurrent,
body.read-only #bestCurrent {
  display: none;
}
body.read-only .hero-cover {
  cursor: default;
}
body.read-only .hero-cover:hover {
  border-color: var(--line);
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(212, 166, 87, 0.12),
    0 0 40px -10px rgba(212, 166, 87, 0.1);
}

.cover-drop {
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 28px 14px;
  text-align: center;
  color: var(--muted);
  margin: 10px 0 4px;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.05em;
}
.cover-drop.dragover {
  border-color: var(--gold);
  background: var(--gold-faint);
  color: var(--gold-bright);
}
.cover-drop.uploading {
  border-color: var(--warn);
  color: var(--warn);
}
.cover-drop.success {
  border-color: var(--good);
  color: var(--good);
}
.cover-drop.error {
  border-color: var(--hot);
  color: var(--hot);
}
.cover-upload-status {
  margin-top: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-style: normal;
  letter-spacing: 0;
}

/* ============================================================
   TAG BAR
   ============================================================ */

.tag-bar {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  height: var(--tagbar-h);
  overflow-y: auto;
  overflow-x: hidden;
  align-content: flex-start;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.tag-bar:empty { display: none; }
.tag-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 30%, var(--gold-dim) 70%, transparent);
  opacity: 0.25;
  pointer-events: none;
}
.tag-bar::-webkit-scrollbar { width: 6px; }
.tag-bar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.tag-bar::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.tag-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 5px 12px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  text-transform: uppercase;
}
.tag-chip:hover {
  border-color: var(--gold-dim);
  color: var(--text-dim);
}
.tag-chip.on {
  background: var(--gold);
  color: var(--bg-0);
  border-color: var(--gold);
  font-weight: 600;
  box-shadow: 0 0 12px var(--gold-glow);
}
.tag-chip .count {
  font-family: var(--font-mono);
  opacity: 0.55;
  margin-left: 5px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
}
.tag-chip.clear {
  background: transparent;
  border-color: var(--gold-dim);
  color: var(--gold);
  font-style: italic;
}
.tag-chip.clear:hover {
  background: var(--gold-faint);
}

/* ============================================================
   PLAYER FOOTER
   ============================================================ */

.player {
  height: var(--player-h);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "now controls scrub takebar"
    "now controls scrub takebar";
  align-items: center;
  padding: 8px 22px calc(8px + var(--safe-bottom));
  gap: 6px 24px;
  position: relative;
}
.player::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 20%, var(--gold-dim) 80%, transparent);
  opacity: 0.35;
}

.now {
  grid-area: now;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.now-cover {
  width: 56px;
  height: 56px;
  border-radius: 3px;
  background: var(--bg-2);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
}
.now-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.now-cover:empty::after {
  content: '♪';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--muted-dim);
  font-style: italic;
}
.now-meta {
  min-width: 0;
  overflow: hidden;
}
.now-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  color: var(--text);
}
.now-sub {
  font-family: var(--font-body);
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.controls {
  grid-area: controls;
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
}
.controls button {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.controls button:hover {
  background: var(--bg-2);
  color: var(--text);
}
.controls button.big {
  width: 48px;
  height: 48px;
  background: var(--gold);
  color: var(--bg-0);
  font-size: 19px;
  margin: 0 4px;
  padding-left: 2px;
  box-shadow: 0 6px 20px -6px rgba(212, 166, 87, 0.5);
}
.controls button.big:hover {
  background: var(--gold-bright);
  color: var(--bg-0);
}
.controls .toggle.on {
  color: var(--gold);
  background: var(--gold-faint);
}
.controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

.scrub {
  grid-area: scrub;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.scrub span {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  color: var(--muted);
  width: 40px;
  text-align: center;
  letter-spacing: 0.04em;
}
.scrub input[type="range"] {
  flex: 1;
  max-width: 520px;
}

.takebar {
  grid-area: takebar;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  font-family: var(--font-display);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}
.takebar select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  min-height: 28px;
  letter-spacing: 0.04em;
}
.takebar select:focus {
  outline: none;
  border-color: var(--gold-dim);
}
.takebar input[type="range"] {
  width: 86px;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.icon-btn:hover {
  background: var(--bg-2);
  color: var(--text);
}
.icon-btn.on#favCurrent { color: var(--fav); }
.icon-btn.on#bestCurrent { color: var(--best); }
.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ============================================================
   RANGE INPUTS (scrubber, volume)
   ============================================================ */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 22px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--gold);
  height: 12px;
  width: 12px;
  border-radius: 50%;
  margin-top: -4.5px;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(212, 166, 87, 0.4);
}
input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  background: var(--gold);
  height: 12px;
  width: 12px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(212, 166, 87, 0.4);
}
#progress::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--gold) var(--progress, 0%), var(--line) var(--progress, 0%));
}

audio { display: none; }

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 768px) {
  :root {
    --player-h: 152px;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 86vw;
    max-width: 360px;
    height: calc(100vh - var(--tagbar-h) - var(--player-h) - var(--safe-bottom));
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .track-view,
  .album-view {
    padding: 60px 22px 32px;
  }
  .hero-cover { width: 280px; height: 280px; }
  .hero-play {
    width: 64px;
    height: 64px;
    font-size: 24px;
    bottom: -18px;
    right: -18px;
  }
  .hero-title { font-size: 36px; }
  .album-view .hero-cover { width: 240px; height: 240px; }

  .player {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "now"
      "scrub"
      "controls";
    gap: 4px;
    padding: 6px 12px calc(6px + var(--safe-bottom));
  }
  .takebar { display: none; }
  .now { justify-self: stretch; }
  .controls { gap: 8px; }
  .controls button { width: 42px; height: 42px; font-size: 16px; }
  .controls button.big { width: 50px; height: 50px; font-size: 22px; }
  .scrub input[type="range"] { max-width: none; }

  .track { padding-top: 10px; padding-bottom: 10px; min-height: 44px; }
  .album-head { padding-top: 12px; padding-bottom: 12px; min-height: 48px; }
  .track .fav-toggle { opacity: 1; }

  .album-tracklist-tags { display: none; }
}
