:root {
  --accent: #ED5564;
  --accent-2: #F48FB1;
  --bg: #0E0E12;
  --surface: #1A1A22;
  --surface-2: #24242E;
  --text: #ffffff;
  --text-dim: rgba(255,255,255,.62);
  --text-faint: rgba(255,255,255,.38);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; }
body { overflow: hidden; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
img { display: block; }

#app { height: 100dvh; position: relative; overflow: hidden; }

/* Scrolling content area */
.view {
  position: absolute; inset: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 8px) 0 90px;
}
.view::-webkit-scrollbar { display: none; }

.screen-title { font-size: 32px; font-weight: 800; padding: 12px 16px 4px; letter-spacing: -0.5px; }
.section-title { font-size: 20px; font-weight: 700; padding: 18px 16px 10px; }

/* Horizontal shelves */
.shelf { display: flex; gap: 14px; overflow-x: auto; padding: 0 16px 6px; scroll-snap-type: x mandatory; }
.shelf::-webkit-scrollbar { display: none; }
.card { width: 150px; flex: 0 0 auto; scroll-snap-align: start; }
.card img { width: 150px; height: 150px; border-radius: 14px; object-fit: cover; background: var(--surface-2); }
.card .c-title { font-size: 14px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.round img { border-radius: 50%; width: 110px; height: 110px; margin: 0 auto; }
.card.round { width: 110px; text-align: center; }
.card.round .c-title { text-align: center; white-space: normal; }

/* Song rows */
.rows { padding: 0 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; }
.row:active { background: var(--surface); }
.row img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; }
.row .r-meta { min-width: 0; flex: 1; }
.row .r-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-sub { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.playing .r-title { color: var(--accent); }
.row .r-index { width: 22px; text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 13px; }

/* Search field */
.searchbar { padding: 6px 16px 10px; }
.searchbar input {
  width: 100%; height: 40px; border-radius: 12px; border: none;
  background: var(--surface); color: var(--text); font-size: 16px; padding: 0 14px;
}
.searchbar input::placeholder { color: var(--text-faint); }

/* State messages */
.state { text-align: center; color: var(--text-dim); padding: 60px 24px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--surface-2); border-top-color: var(--accent);
  border-radius: 50%; margin: 40px auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tab bar */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; background: rgba(20,20,26,.86); backdrop-filter: blur(20px);
  border-top: .5px solid rgba(255,255,255,.08);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--text-dim); }
.tab .tab-ico { font-size: 20px; filter: grayscale(1) opacity(.7); }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { filter: none; }

/* Mini player */
.mini-player.hidden { display: none !important; }
.mini-player {
  position: absolute; left: 8px; right: 8px; z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 6px);
  background: rgba(30,30,38,.94); backdrop-filter: blur(20px);
  border-radius: 14px; overflow: hidden; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.mini-progress { height: 2px; background: rgba(255,255,255,.12); }
.mini-progress-fill { height: 100%; width: 0; background: var(--accent); }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.mini-art { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.mini-meta { flex: 1; min-width: 0; }
.mini-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-artist { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 18px; padding: 6px; color: var(--text); }
.icon-btn.big { font-size: 24px; }

/* Full player */
.player, .lyrics, .sheet {
  position: absolute; inset: 0; z-index: 40; transition: transform .35s cubic-bezier(.3,.7,.2,1);
}
.player.hidden, .lyrics.hidden, .sheet.hidden { transform: translateY(100%); pointer-events: none; }
.player-bg { position: absolute; inset: 0; background: var(--surface);
  transition: background .6s ease; }
.player-bg::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.15), var(--bg)); }
.player-content { position: relative; height: 100%; display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 6px) 24px calc(var(--safe-bottom) + 20px); }
.player-header { display: flex; align-items: center; justify-content: space-between; }
.player-heading { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.player-art { width: 100%; max-width: 360px; aspect-ratio: 1; align-self: center; margin: auto 0;
  border-radius: 16px; object-fit: cover; background: var(--surface-2); box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.player-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.player-title { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 16px; color: var(--text-dim); }
.icon-btn.like.on { color: var(--accent); }
.seek, .times { margin-top: 16px; }
.seek { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.2); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.transport { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.play-fab { width: 68px; height: 68px; border-radius: 50%; background: #fff; color: #000; font-size: 26px; }
.secondary { display: flex; justify-content: center; margin-top: 18px; }
.text-btn { color: var(--text-dim); font-size: 15px; padding: 8px 14px; }

/* Lyrics */
.lyrics { background: var(--bg); }
.lyrics-header { display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px 8px; }
.lyrics-song { font-size: 18px; font-weight: 700; }
.lyrics-body { height: 100%; overflow-y: auto; padding: 20px 24px 200px; }
.lyric-line { font-size: 24px; font-weight: 800; padding: 8px 0; color: rgba(255,255,255,.35);
  transition: color .25s, transform .25s; transform-origin: left; }
.lyric-line.active { color: #fff; }
.lyric-line.plain { color: rgba(255,255,255,.85); font-size: 18px; font-weight: 600; }

/* Sheet (queue) */
.sheet { background: var(--bg); }
.sheet-header { display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 20px 8px; font-size: 18px; font-weight: 700; }
.sheet-body { height: 100%; overflow-y: auto; padding: 8px 8px 120px; }

.hidden-vis { display: none !important; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--surface);
  border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600; }
.play-pill { background: var(--accent); color: #fff; }
.header-block { text-align: center; padding: 12px 24px 4px; }
.header-block img { width: 200px; height: 200px; border-radius: 16px; object-fit: cover; margin: 8px auto; }
.header-block.round img { border-radius: 50%; width: 150px; height: 150px; }
.header-actions { display: flex; gap: 12px; justify-content: center; padding: 12px 16px; }
.settings-list { padding: 8px 16px; }
.settings-group { background: var(--surface); border-radius: 14px; margin: 12px 0; overflow: hidden; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border-bottom: .5px solid rgba(255,255,255,.06); font-size: 15px; }
.settings-row:last-child { border-bottom: none; }
.settings-row .val { color: var(--text-dim); }
.settings-label { font-size: 13px; color: var(--text-dim); padding: 4px 16px; text-transform: uppercase; letter-spacing: .5px; }

/* Row ⋯ menu button */
.row-menu { color: var(--text-dim); font-size: 22px; line-height: 1; padding: 6px 6px 10px; flex: 0 0 auto; }
.row-menu:active { color: var(--text); }

/* Offline download indicators */
.dl-badge { color: var(--accent); font-size: 13px; flex: 0 0 auto; opacity: .9; }
.dl-count { font-size: 12px; font-weight: 500; color: var(--text-dim); margin-left: 8px; }

/* Playlist cards */
.pl-new { color: var(--accent); font-size: 22px; font-weight: 700; padding: 0 6px; vertical-align: middle; }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.pl-card .pl-art { width: 150px; height: 150px; border-radius: 14px; background: linear-gradient(135deg, var(--surface-2), var(--surface)); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.pl-card .pl-art img { width: 100%; height: 100%; object-fit: cover; }
.pl-card .pl-badge { position: absolute; font-size: 40px; color: #fff; opacity: .92; }

/* Action sheet */
.action-sheet { position: absolute; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; }
.action-sheet.show .sheet-backdrop { opacity: 1; }
.sheet-card { position: absolute; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px);
  background: var(--surface-2); border-radius: 18px; padding: 8px; transform: translateY(120%);
  transition: transform .3s cubic-bezier(.3,.7,.2,1); }
.action-sheet.show .sheet-card { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin: 4px auto 8px; }
.sheet-title { font-size: 13px; color: var(--text-dim); text-align: center; padding: 2px 12px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  font-size: 17px; padding: 15px 16px; border-radius: 12px; color: var(--text); }
.sheet-item:active { background: var(--surface); }
.sheet-item.cancel { justify-content: center; color: var(--accent); font-weight: 600; margin-top: 4px; }
.sheet-item .sheet-sub { margin-left: auto; color: var(--text-faint); font-size: 14px; }
.sheet-empty { text-align: center; color: var(--text-dim); padding: 16px; }

/* Toast */
#toast { position: absolute; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 80px); z-index: 70;
  background: rgba(40,40,48,.96); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
