/* MyMusic — dark, artwork-forward player. */
:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --surface-2: #1d2128;
  --line: #262b33;
  --text: #f2f4f7;
  --muted: #9aa3ae;
  --accent: #5ee0b5;
  --accent-ink: #062a1f;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 10px;
  --tabs-h: 58px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .4; cursor: default; }
h1 { font-size: 28px; margin: 8px 0 16px; letter-spacing: -.02em; }
h2 { font-size: 19px; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.error { color: var(--danger); }
.warn-text { color: var(--warn); }
.row { display: flex; gap: 8px; align-items: center; }
.icon { display: block; flex: none; }

/* ---------- boot / login ---------- */
.boot, .login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.boot-logo { font-size: 34px; font-weight: 800; letter-spacing: -.03em; color: var(--accent); }
.boot-sub { color: var(--muted); }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 12px 16px; background: #5a1d1d; z-index: 1000; }
#blazor-error-ui .reload { text-decoration: underline; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.content { padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 24px); max-width: 900px; margin: 0 auto; }
.content.bare { padding: 0; }
.page section { margin-bottom: 8px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: rgba(11, 13, 16, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tab.active { color: var(--accent); }
.tab-icon { position: relative; }
.tab-icon .dot { position: absolute; top: -2px; right: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

/* ---------- mini player ---------- */
.mini {
  position: fixed; left: 8px; right: 8px; z-index: 19;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 6px); height: var(--mini-h);
  display: flex; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--surface-2); border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.mini-progress { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); }
.mini-hit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; height: 100%; }
.mini-text { min-width: 0; display: flex; flex-direction: column; }
.mini-title, .mini-sub, .track-title, .track-sub, .tile-title, .tile-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-title { font-weight: 600; font-size: 15px; }
.mini-sub { font-size: 13px; color: var(--muted); }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 15px; white-space: nowrap; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost.on { color: var(--accent); }
.btn.danger, .icon-btn.danger { color: var(--danger); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text); flex: none; }
.icon-btn.on { color: var(--accent); }
.icon-btn:active, .btn:active { transform: scale(.96); }
.play-round { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.input { width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input.num { width: 90px; text-align: right; }
.title-input { font-size: 22px; font-weight: 700; height: 48px; margin-bottom: 8px; }
.search { position: relative; margin-bottom: 8px; }
.search .icon { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.search .input { padding-left: 40px; }

/* ---------- artwork ---------- */
.art { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.art-placeholder { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, hsl(var(--hue) 35% 26%), hsl(calc(var(--hue) + 40) 30% 14%)); color: hsl(var(--hue) 60% 82%); font-weight: 800; }
.art-placeholder span { font-size: 2.2em; letter-spacing: -.04em; }
.art-xs { width: 40px; height: 40px; border-radius: 4px; flex: none; }
.art-xs span { font-size: 14px; }
.art-sm { width: 48px; height: 48px; border-radius: 6px; flex: none; }
.art-sm span { font-size: 16px; }
.art-md { width: 64px; height: 64px; flex: none; }
.art-md span { font-size: 20px; }
.art-lg { width: 180px; height: 180px; flex: none; }
.art-lg span { font-size: 44px; }
.art-xl { width: min(78vw, 380px); height: min(78vw, 380px); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.art-xl span { font-size: 72px; }

/* ---------- shelves / grids / tiles ---------- */
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 14px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.shelf::-webkit-scrollbar { display: none; }
.shelf .tile { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 14px; margin-bottom: 20px; }
.tile { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .art-placeholder span { font-size: 36px; }
.tile-art { position: relative; display: block; }
.tile-title { font-weight: 600; font-size: 14px; margin-top: 4px; }
.tile-sub { font-size: 12px; color: var(--muted); }
.badge { position: absolute; right: 6px; bottom: 6px; color: var(--accent); background: rgba(0,0,0,.6); border-radius: 50%; padding: 2px; }

/* ---------- album / playlist header ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.crumbs a { color: var(--accent); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); margin-bottom: 8px; }
.album-head { display: flex; gap: 18px; align-items: flex-end; margin-bottom: 16px; }
.album-head h1 { margin: 0 0 4px; font-size: 24px; }
.album-meta { min-width: 0; flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
@media (max-width: 560px) {
  .album-head { flex-direction: column; align-items: center; text-align: center; }
  .album-head .art-lg { width: 62vw; height: 62vw; max-width: 260px; max-height: 260px; }
  .actions { justify-content: center; }
}

/* ---------- track list ---------- */
.tracks, .list, .queue { list-style: none; margin: 0; padding: 0; }
.track, .list > li, .queue > li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); min-height: 56px; }
.track-hit, .list-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 0; text-align: left; }
.track-num { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; flex: none; }
.track-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.track-title { font-size: 15px; }
.track-sub { font-size: 13px; color: var(--muted); }
.track-dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; padding-left: 8px; }
.track.current .track-title, .queue .current .track-title { color: var(--accent); font-weight: 600; }
.eq { display: inline-flex; gap: 2px; height: 14px; align-items: flex-end; }
.eq i { width: 3px; background: var(--accent); animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; }
.eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 14px; } }

.continue { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 12px; padding: 10px; }
.continue-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- full-screen now playing ---------- */
.np {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-t) + 8px) 20px calc(var(--safe-b) + 20px);
  background: linear-gradient(180deg, #1b2a26 0%, var(--bg) 60%); overflow-y: auto;
  animation: slideup .22s ease-out;
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.np-head { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 8px; }
.np-source { flex: 1; text-align: center; min-width: 0; }
.np-source-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-art { margin: 28px 0 24px; }
.np-title { font-size: 22px; font-weight: 700; text-align: center; max-width: 520px; }
.np-sub { color: var(--muted); text-align: center; margin-top: 4px; }
.np-error { color: var(--warn); margin-top: 8px; text-align: center; }
.np-scrub { width: 100%; max-width: 520px; margin-top: 24px; }
.np-scrub input[type=range] { width: 100%; accent-color: var(--accent); }
.np-times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.np-controls { width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.play-big { width: 76px; height: 76px; border-radius: 50%; background: var(--text); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; }
.queue { width: 100%; max-width: 520px; margin-top: 16px; flex: 1; overflow-y: auto; }

/* ---------- overlays ---------- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(var(--safe-t) + 10px) 16px 10px; font-size: 14px; }
.banner.warn { background: #3a2c10; color: #ffe0a8; }
.toast, .download-bar {
  position: fixed; left: 16px; right: 16px; z-index: 30; text-align: center;
  bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 16px);
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
}
.toast { background: var(--text); color: var(--bg); }
.download-bar { background: var(--surface-2); color: var(--text); }
.download-bar + .toast { bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 64px); }
.tap-to-play {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(11,13,16,.92); font-size: 20px; font-weight: 700;
}
.tap-to-play .icon { background: var(--accent); color: var(--accent-ink); border-radius: 50%; padding: 18px; width: 92px; height: 92px; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 70; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-height: 80vh; overflow-y: auto;
  background: var(--surface); border-radius: 16px 16px 0 0; padding: 12px 16px calc(var(--safe-b) + 16px);
  animation: slideup .2s ease-out;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 8px 0; }
.sheet .row { margin: 8px 0 12px; }

/* ---------- offline page ---------- */
.card { background: var(--surface); border-radius: 12px; padding: 14px; margin: 12px 0; }
.card h2 { margin-top: 0; }
.usage { margin-bottom: 12px; }
.usage-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 6px; }
.usage-bar div { height: 100%; background: var(--accent); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.card .btn.ghost { margin-top: 12px; }
.ring { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line) 0); }
