:root {
  --glass-bg: rgba(255, 255, 255, 0.22);
  --glass-bg-strong: rgba(255, 255, 255, 0.32);
  --glass-border: rgba(255, 255, 255, 0.38);
  --glass-blur: blur(28px);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.72);
  --text-soft: rgba(255, 255, 255, 0.55);
  --accent: rgba(255, 255, 255, 0.95);
  --radius-sm: 16px;
  --radius: 24px;
  --radius-lg: 28px;
  --nav-h: 62px;
  --player-h: 72px;
  --dock-gap: 10px;
  --dock-pad: 14px;
  --dock-h: calc(var(--nav-h) + var(--dock-pad) * 2);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --card-w: 148px;
  --cover-size: 120px;
  --card-meta-h: 62px;
  --frame-border: rgba(255, 255, 255, 0.28);
  --frame-bg: rgba(255, 255, 255, 0.08);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #8a8278;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--dock-h) + var(--safe-b) + 8px);
}

body.has-player {
  --dock-h: calc(var(--nav-h) + var(--player-h) + var(--dock-gap) + var(--dock-pad) * 2);
}

.bg-wallpaper {
  position: fixed;
  inset: 0;
  background:
    url("/assets/bg.png") center center / cover no-repeat,
    linear-gradient(145deg, #c4b8a8 0%, #9a9084 45%, #7a7268 100%);
  pointer-events: none;
  z-index: 0;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.22) 100%),
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur) saturate(180%);
  -webkit-backdrop-filter: var(--glass-blur) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur) saturate(180%);
  -webkit-backdrop-filter: var(--glass-blur) saturate(180%);
  border: 1px solid var(--glass-border);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px 0;
  min-height: calc(100dvh - var(--dock-h) - var(--safe-b));
}

/* ── Header ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 14px;
}

.greeting {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.greeting-line {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.user-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark svg {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--accent);
  opacity: 0.9;
}

/* ── Floating dock ── */
.dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--dock-gap);
  padding: 0 var(--dock-pad) calc(var(--dock-pad) + var(--safe-b));
  pointer-events: none;
}

.dock > * { pointer-events: auto; }

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  order: 1;
}

.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 12px;
  order: 2;
}

.player-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  padding: 0;
}

.player-controls {
  flex-shrink: 0;
}

/* ── Views ── */
.view {
  display: none;
  animation: fadeIn 0.28s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.panel {
  padding: 18px 16px 20px;
  margin-bottom: 14px;
}

.panel-padded { padding: 0 2px 20px; }

.sections-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-block {
  padding: 18px 14px 16px;
  border-radius: var(--radius);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur) saturate(180%);
  -webkit-backdrop-filter: var(--glass-blur) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 4px 14px;
  letter-spacing: -0.02em;
}

.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.h-scroll::-webkit-scrollbar { display: none; }

/* ── Cover frames ── */
.cover-frame {
  width: var(--cover-size);
  height: var(--cover-size);
  flex-shrink: 0;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--frame-border);
  background: var(--frame-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.cover-frame-sm {
  width: 48px;
  height: 48px;
  padding: 2px;
  border-radius: 12px;
}

.cover-frame-sm img { border-radius: 9px; }

.cover-frame-wide {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: 160px;
}

.cover-frame-hero {
  width: min(220px, 70%);
  height: min(220px, 70vw);
  margin: 12px auto 0;
}

.cover-frame-hero img { border-radius: 12px; }

/* ── Media cards ── */
.media-card {
  flex: 0 0 var(--card-w);
  width: var(--card-w);
  height: calc(var(--cover-size) + var(--card-meta-h) + 14px);
  scroll-snap-align: start;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(20px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s, background 0.15s;
}

.media-card:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.2);
}

.card-meta {
  width: 100%;
  height: var(--card-meta-h);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  overflow: hidden;
  text-align: center;
  padding: 0 2px;
}

.card-meta .t-title,
.media-card .t-title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta .t-artist,
.media-card .t-artist {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card .pl-count {
  font-size: 0.68rem;
  color: var(--text-soft);
  margin-top: auto;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(16px);
}

.track-row .info { flex: 1; min-width: 0; cursor: pointer; }
.track-row .t-title { font-weight: 600; font-size: 0.9rem; }
.track-row .t-artist { font-size: 0.78rem; color: var(--text-muted); }

.row-actions { display: flex; gap: 6px; }

.mini-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-btn.light {
  background: rgba(255, 255, 255, 0.88);
  color: #3a3630;
  border-color: transparent;
}

.mini-btn .ico svg { width: 1rem; height: 1rem; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-box input {
  flex: 1;
  padding: 12px 4px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}

.search-box input::placeholder { color: var(--text-soft); }

.search-icon svg { width: 1.1rem; height: 1.1rem; opacity: 0.7; }

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.library-head .section-title { margin: 0; }

.fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fab:active { transform: scale(0.95); }

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(2, var(--card-w));
  justify-content: center;
  gap: 12px;
}

.pl-card {
  width: var(--card-w);
  height: calc(var(--cover-size) + var(--card-meta-h) + 14px);
}

.playlist-header {
  padding: 20px 16px;
  margin-bottom: 14px;
  text-align: center;
}

.playlist-header h2 { font-size: 1.35rem; margin-top: 12px; }
.pl-detail-desc { padding: 8px 8px 0; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.pl-detail-count { padding: 8px; color: var(--text-soft); font-size: 0.85rem; }

/* ── Track page ── */
.view-track { padding-bottom: 20px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  margin-bottom: 14px;
  cursor: pointer;
}

.back-btn .ico svg { width: 1rem; height: 1rem; }

.track-hero {
  text-align: center;
  padding: 20px 16px;
  margin-bottom: 14px;
}

.track-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 14px;
  letter-spacing: -0.02em;
}

.track-artist {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

.track-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.action-btn.primary {
  background: rgba(255, 255, 255, 0.92);
  color: #3a3630;
  border-color: transparent;
}

.action-btn .ico svg { width: 1rem; height: 1rem; }
.action-btn.primary .ico svg { color: #3a3630; }

.lyrics-panel { padding: 18px 16px 22px; margin-top: 4px; }

.lyrics-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.lyrics-head h3 { font-size: 0.95rem; font-weight: 600; }
.lyrics-head .ico svg { width: 1.1rem; height: 1.1rem; opacity: 0.85; }

.lyrics-neon {
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  text-align: center;
}

.lyrics-neon .lyric-line {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.02rem;
  line-height: 2.1;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.25s, text-shadow 0.25s, transform 0.25s;
}

.lyrics-neon .lyric-line.active {
  color: #ffffff;
  font-weight: 600;
  font-size: 1.1rem;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.95),
    0 0 20px rgba(255, 255, 255, 0.55),
    0 0 36px rgba(200, 220, 255, 0.35);
  transform: scale(1.02);
}

.lyrics-loading,
.lyrics-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 12px;
  font-size: 0.9rem;
}

/* ── Bottom nav (icons only) ── */
.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 10px;
  border-radius: 14px;
  transition: color 0.2s, background 0.2s;
  min-height: 44px;
}

.nav-item.active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.18);
}

.nav-icon { display: flex; align-items: center; justify-content: center; }
.nav-icon .ico svg { width: 1.4rem; height: 1.4rem; }

.player-info { flex: 1; min-width: 0; }
.player-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-artist { font-size: 0.78rem; color: var(--text-muted); }

.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #3a3630;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.play-btn .ico svg { width: 1.1rem; height: 1.1rem; color: #3a3630; }

.fab .ico svg { width: 1.25rem; height: 1.25rem; }
.cover-placeholder .ico-lg svg { color: var(--text-muted); }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h3 { margin-bottom: 16px; font-size: 1.15rem; }

.create-form input,
.create-form textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 12px;
  resize: vertical;
}

.create-form textarea { min-height: 72px; }
.create-form input::placeholder,
.create-form textarea::placeholder { color: var(--text-soft); }

.cover-picker { display: block; margin-bottom: 14px; cursor: pointer; }
.cover-preview { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 120px;
}

.pl-pick-list {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pl-pick-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}

.pl-pick-btn .cover-frame { width: 44px; height: 44px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.btn {
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.primary {
  background: rgba(255, 255, 255, 0.92);
  color: #3a3630;
}

.toast {
  position: fixed;
  bottom: calc(var(--dock-h) + var(--safe-b) + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(40, 38, 34, 0.88);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 400;
  font-size: 0.85rem;
  max-width: calc(100% - 32px);
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
}

.gate-card { padding: 28px; max-width: 360px; width: 100%; text-align: center; }
.gate-card h2 { margin-bottom: 10px; }
.gate-card p { color: var(--text-muted); margin-bottom: 20px; }

.gate-card a {
  display: block;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
  color: #3a3630;
  text-decoration: none;
  font-weight: 600;
}

.pl-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  grid-column: 1 / -1;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
