/* CSS custom properties */
:root {
  --accent:   #e50914;
  --bg:       #121212;
  --surface:  #181818;
  --surface2: #282828;
  --surface3: #3E3E3E;
  --text:     #FFFFFF;
  --muted:    #B3B3B3;
  --nav-h:    64px;
  --mini-h:   72px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Circular', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { background: none; border: none; cursor: pointer; color: inherit; }
input  { outline: none; border: none; background: none; color: inherit; font: inherit; }
img    { display: block; }
a      { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 100;
}
.login-wrap { width: 100%; max-width: 340px; padding: 0 32px; text-align: center; }
.login-logo {
  font-size: 52px; font-weight: 900; letter-spacing: -3px;
  color: var(--accent); margin-bottom: 6px;
}
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 48px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  background: var(--surface2); border-radius: 4px; padding: 15px 18px;
  font-size: 15px; color: var(--text); border: 1px solid transparent;
  transition: border-color .2s;
}
#login-form input:focus { border-color: var(--text); }
#login-form input::placeholder { color: var(--muted); }
#login-form button {
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
  padding: 15px; border-radius: 500px; margin-top: 8px;
  letter-spacing: .5px; transition: transform .1s, opacity .1s;
}
#login-form button:active { transform: scale(.97); opacity: .9; }
#login-error { color: #f15e6c; font-size: 13px; min-height: 18px; }

/* ── App layout ────────────────────────────────────────── */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#panels { flex: 1; overflow: hidden; position: relative; }
.panel {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mini-h) + var(--nav-h) + var(--safe-b) + 16px);
  display: none;
}
.panel.active { display: block; }

/* ── Bottom nav ────────────────────────────────────────── */
#bottom-nav {
  display: flex; background: #000;
  border-top: 1px solid #282828;
  padding-bottom: var(--safe-b);
  height: calc(var(--nav-h) + var(--safe-b));
  flex-shrink: 0;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 10px; font-weight: 600; color: var(--muted); padding: 6px 0;
  transition: color .15s; letter-spacing: .2px;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--text); }
.nav-btn.active svg { /* slight scale for active */ }

/* ── Mini player ───────────────────────────────────────── */
#mini-player {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2);
  border-radius: 8px; margin: 0 8px;
  height: calc(var(--mini-h) - 8px); padding: 0 12px;
  flex-shrink: 0; cursor: pointer;
  box-shadow: 0 -1px 0 #282828;
}
#mini-art {
  width: 48px; height: 48px; border-radius: 4px;
  object-fit: cover; background: var(--surface3); flex-shrink: 0;
}
#mini-info { flex: 1; overflow: hidden; }
#mini-title  {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mini-artist {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
#mini-play, #mini-next {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#mini-play { background: var(--text); color: #000; }
#mini-play svg, #mini-next svg { width: 20px; height: 20px; }
#mini-next svg { fill: var(--muted); }
#mini-next:active { opacity: .7; }
#mini-play:active { transform: scale(.93); }

/* Mini player progress line */
#mini-progress {
  position: absolute; bottom: 0; left: 8px; right: 8px; height: 2px;
  background: var(--surface3); border-radius: 0 0 8px 8px; overflow: hidden;
}
#mini-progress-fill { height: 100%; background: var(--text); width: 0%; transition: width .5s linear; }

/* ── Home ──────────────────────────────────────────────── */
#home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 8px;
}
#home-greeting { font-size: 22px; font-weight: 800; }
#settings-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border-radius: 50%; color: var(--muted);
}
#settings-btn svg { width: 18px; height: 18px; }

/* Quick access grid (top of home — 2-col) */
.quick-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; padding: 4px 16px 16px;
}
.quick-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: 4px;
  overflow: hidden; cursor: pointer; height: 56px;
  transition: background .15s;
}
.quick-card:active { background: var(--surface3); }
.quick-card-art { width: 56px; height: 56px; object-fit: cover; flex-shrink: 0; }
.quick-card-title { font-size: 13px; font-weight: 700; line-height: 1.2; padding-right: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Section labels */
.section-label {
  padding: 16px 16px 8px;
  font-size: 22px; font-weight: 800;
}
.section-sublabel {
  padding: 4px 16px 10px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}

/* Horizontal scroll row */
.h-scroll {
  display: flex; gap: 16px; overflow-x: auto;
  padding: 0 16px 16px; -webkit-overflow-scrolling: touch;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-card { flex-shrink: 0; width: 148px; cursor: pointer; }
.h-card:active .h-card-art { opacity: .8; }
.h-card-art {
  width: 148px; height: 148px; border-radius: 4px;
  object-fit: cover; background: var(--surface2);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.h-card-title {
  font-size: 13px; font-weight: 600; margin-top: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.h-card-artist {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Album grid ────────────────────────────────────────── */
.album-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 16px; padding: 0 16px 16px;
}
.album-card {
  cursor: pointer; border-radius: 6px; overflow: hidden;
  background: var(--surface); padding-bottom: 12px;
  transition: background .15s;
}
.album-card:active { background: var(--surface2); }
.album-art {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  background: var(--surface2); border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.album-info { padding: 8px 8px 0; }
.album-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.album-artist {
  font-size: 12px; color: var(--muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal;
}

/* ── Track list ────────────────────────────────────────── */
.track-list { padding: 0 0 8px; }
.track-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; cursor: pointer; border-radius: 4px;
  transition: background .1s;
}
.track-item:active { background: var(--surface2); }
.track-num {
  width: 20px; text-align: center; font-size: 14px;
  color: var(--muted); flex-shrink: 0;
}
.track-num.playing { color: var(--accent); }
.track-art {
  width: 40px; height: 40px; border-radius: 2px;
  object-fit: cover; background: var(--surface2); flex-shrink: 0;
}
.track-info { flex: 1; overflow: hidden; }
.track-title {
  font-size: 14px; font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-title.playing { color: var(--accent); }
.track-artist {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-dur { font-size: 13px; color: var(--muted); flex-shrink: 0; }

/* ── Artist list ───────────────────────────────────────── */
.artist-list { padding: 0 16px 8px; }
.artist-item {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 0; cursor: pointer; border-radius: 4px;
}
.artist-item:active { background: var(--surface2); }
.artist-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; background: var(--surface2); flex-shrink: 0;
}
.artist-name { font-size: 15px; font-weight: 600; }
.artist-type { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Library chips ─────────────────────────────────────── */
.lib-chips {
  display: flex; gap: 8px; padding: 12px 16px 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.lib-chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--surface2); border-radius: 500px; padding: 6px 16px;
  font-size: 13px; font-weight: 700; white-space: nowrap; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.chip.active { background: var(--text); color: #000; }

/* ── Search ────────────────────────────────────────────── */
.search-bar-wrap {
  padding: 16px 16px 8px; position: sticky; top: 0;
  background: var(--bg); z-index: 10;
}
#search-input {
  width: 100%; background: var(--text); color: #000;
  border-radius: 4px; padding: 12px 16px; font-size: 14px; font-weight: 500;
}
#search-input::placeholder { color: #757575; }
.search-empty-state { padding: 24px 16px; }
.search-empty-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.search-empty-sub   { font-size: 14px; color: var(--muted); }

/* ── Full player ───────────────────────────────────────── */
#full-player {
  padding: 0 24px 32px; display: flex; flex-direction: column;
  align-items: center; min-height: 100%;
  background: linear-gradient(180deg, #3a0a0a 0%, #121212 40%);
}
#fp-topbar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 16px 0 8px;
}
#fp-topbar-title { font-size: 12px; font-weight: 700; text-align: center; flex: 1; letter-spacing: .5px; color: var(--muted); }
#fp-close-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
#fp-close-btn svg { width: 20px; height: 20px; }
#fp-art {
  width: min(78vw, 300px); height: min(78vw, 300px);
  border-radius: 4px; object-fit: cover; background: var(--surface2);
  margin: 24px 0 32px;
  box-shadow: 0 16px 56px rgba(0,0,0,.6);
}
.fp-info-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; margin-bottom: 24px;
}
#fp-title  { font-size: 22px; font-weight: 800; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fp-artist { font-size: 14px; color: var(--muted); margin-top: 4px; }
.fp-info-left { flex: 1; overflow: hidden; }
#fp-like-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
#fp-like-btn svg { width: 24px; height: 24px; }

/* Progress */
#fp-progress { width: 100%; margin-bottom: 4px; }
#fp-seek {
  width: 100%; height: 4px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: var(--surface3); border-radius: 2px; outline: none;
}
#fp-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  border-radius: 50%; background: var(--text); cursor: pointer;
}
#fp-seek::-webkit-slider-runnable-track { border-radius: 2px; }
.fp-times {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-bottom: 24px; width: 100%;
  letter-spacing: .3px;
}

/* Controls */
.fp-controls {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; margin-bottom: 24px; padding: 0 4px;
}
.fp-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.fp-btn svg { width: 28px; height: 28px; }
#fp-play-btn {
  width: 56px; height: 56px; background: var(--text);
  border-radius: 50%; color: #000;
}
#fp-play-btn svg { width: 28px; height: 28px; }
#fp-play-btn:active { transform: scale(.95); }

/* Extras */
.fp-extras {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0 4px;
}
.fp-ext-btn {
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
}
.fp-ext-btn svg { width: 20px; height: 20px; }
.fp-ext-btn.on { color: var(--text); }

/* ── Queue panel ───────────────────────────────────────── */
#queue-panel {
  position: fixed; inset: 0; background: var(--surface); z-index: 200;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; padding-bottom: calc(var(--safe-b) + 20px);
}
#queue-panel.open { transform: translateY(0); }
.queue-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 12px; font-size: 18px; font-weight: 800;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}

/* ── Settings panel ────────────────────────────────────── */
#settings-panel {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  padding: 0; overflow-y: auto;
}
#settings-panel.open { transform: translateY(0); }
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 16px; font-size: 22px; font-weight: 800;
  position: sticky; top: 0; background: var(--bg); z-index: 1;
  border-bottom: 1px solid var(--surface2);
}
.settings-body { padding: 8px 16px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--surface2);
}
.settings-label { font-size: 15px; font-weight: 500; }
.settings-value { font-size: 14px; color: var(--muted); }
#accent-picker {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--surface3); cursor: pointer; padding: 0;
}

/* ── Detail overlay ────────────────────────────────────── */
.detail-back {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 14px 16px;
  font-size: 14px; font-weight: 600; color: var(--text);
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.detail-back svg { width: 20px; height: 20px; }

.detail-hero {
  position: relative; padding: 0 16px 24px;
  background: linear-gradient(180deg, #3a0a0a 0%, var(--bg) 100%);
}
.detail-hero-art {
  width: 180px; height: 180px; border-radius: 4px; object-fit: cover;
  background: var(--surface2); margin: 0 auto 16px; display: block;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.detail-hero-title  { font-size: 22px; font-weight: 800; text-align: center; }
.detail-hero-sub    { font-size: 14px; color: var(--muted); text-align: center; margin-top: 6px; }
.detail-hero-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 16px 0 0;
}
.play-all-btn {
  width: 56px; height: 56px; background: var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 16px rgba(229,9,20,.4); flex-shrink: 0;
}
.play-all-btn svg { width: 24px; height: 24px; fill: #fff; margin-left: 3px; }

/* ── Spinner / empty ───────────────────────────────────── */
.spinner { text-align: center; padding: 48px; color: var(--muted); font-size: 14px; }
.empty   { text-align: center; padding: 64px 24px; color: var(--muted); font-size: 14px; }
.empty-title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
