:root {
  --bg: #000;
  --surface: #121214;
  --surface-2: #1c1c1f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: rgba(235, 235, 245, 0.6);
  --faint: rgba(235, 235, 245, 0.32);
  --accent: #7d61ff;
  --accent-soft: rgba(125, 97, 255, 0.18);
  --danger: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px 140px; }

/* ---- Buttons & inputs ------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 650; cursor: pointer;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.white { background: #fff; color: #000; }
.btn.ghost { background: rgba(255, 255, 255, 0.1); }
.btn.small { padding: 9px 16px; font-size: 15px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.08); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--text);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.big svg { width: 30px; height: 30px; }
.icon-btn.round { background: rgba(255, 255, 255, 0.1); }
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

input.field {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; outline: none;
}
input.field:focus { border-color: var(--accent); }

/* ---- Sign in --------------------------------------------------------------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: min(380px, 100%); text-align: center; }
.auth-box .logo { width: 64px; height: 64px; margin: 0 auto 18px; }
.auth-box h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.auth-box p.sub { margin: 6px 0 24px; color: var(--muted); }
.auth-fields { display: flex; flex-direction: column; gap: 10px; }
.auth-error { color: var(--danger); font-size: 14px; text-align: left; margin: 10px 2px 0; min-height: 1em; }
.auth-box .btn.primary { width: 100%; margin-top: 18px; }
.auth-toggle { margin-top: 18px; color: var(--muted); font-size: 15px; background: none; border: 0; cursor: pointer; }
.auth-toggle b { color: var(--accent); font-weight: 600; }
.auth-forgot { align-self: flex-end; margin: 2px 2px -4px; padding: 0; color: var(--muted); font-size: 14px; background: none; border: 0; cursor: pointer; }
.auth-forgot:hover { color: var(--text); }

/* ---- Header ---------------------------------------------------------------- */

.top {
  display: flex; align-items: center; gap: 10px; padding: 18px 0 14px;
  position: sticky; top: 0; z-index: 5; background: linear-gradient(#000 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 850; font-size: 30px; letter-spacing: -0.03em; }
.brand svg { width: 36px; height: 36px; }
.top .spacer { flex: 1; }
.search {
  min-width: 0;
  width: min(280px, 40vw); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; outline: none;
}
.search:focus { border-color: var(--accent); }
.avatar {
  flex: none;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 0; cursor: pointer; padding: 0;
  background: linear-gradient(#636366, #48484a); display: grid; place-items: center; font-weight: 650;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.menu {
  position: absolute; right: 20px; top: 70px; z-index: 20; min-width: 220px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.menu .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who b { display: block; }
.menu .who span { color: var(--muted); font-size: 14px; }
.menu .plan { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 14px; }
.menu .plan-row { display: flex; justify-content: space-between; gap: 12px; }
.menu .plan-row span { color: var(--muted); font-variant-numeric: tabular-nums; }
.menu .plan-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.menu .plan-bar div { height: 100%; background: var(--accent); border-radius: 4px; }
.menu .plan p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu button:hover { background: rgba(255, 255, 255, 0.08); }
.menu button.danger { color: var(--danger); }

.chips { display: flex; gap: 8px; margin: 4px 0 22px; flex-wrap: wrap; }
.chip {
  border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text);
}
.chip.on { background: var(--accent); color: #fff; }
.chip.link { margin-left: auto; background: transparent; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.chip.link:hover { color: var(--text); }

/* ---- Grid ------------------------------------------------------------------ */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 20px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr 1fr; gap: 24px 14px; } }

.tile { cursor: pointer; }
.tile .art { position: relative; }
.tile .play-fab {
  position: absolute; right: 10px; bottom: 10px; width: 50px; height: 50px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); transition: transform 0.12s ease;
}
.tile .play-fab:hover { transform: scale(1.06); }
.tile .play-fab svg { width: 22px; height: 22px; }
.tile h3 { margin: 12px 0 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile p { margin: 2px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.current h3 { color: var(--accent); }

/* Typeset cover, like the app's. */
.cover { width: 100%; aspect-ratio: 1; border-radius: 7%; overflow: hidden; position: relative; container-type: inline-size; box-shadow: 0 0 0 0.5px rgba(255,255,255,0.08) inset; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .typeset { position: absolute; inset: 0; padding: 8%; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.cover .t { font-weight: 900; letter-spacing: -0.02em; line-height: 1.02; font-size: 12cqw; /* like the app: side × 0.12 */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cover .a { font-size: max(9px, 5cqw); font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30%; }
.cover.small .typeset { padding: 0; justify-content: flex-end; }
.cover.small .t { font-size: 50cqw; padding: 0 0 2cqw 10cqw; }
.cover.mosaic { display: grid; grid-template-columns: 1fr 1fr; }
.cover.mosaic > * { position: relative; aspect-ratio: 1; }

.empty-state { text-align: center; color: var(--muted); padding: 80px 20px; }
.empty-state h2 { color: var(--text); margin: 0 0 6px; }

/* ---- Detail pages ---------------------------------------------------------- */

.back { margin: 18px 0 0; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 0 24px; }
.hero .cover { width: min(300px, 70vw); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.hero .eyebrow { margin: 22px 0 0; font-size: 12px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.hero h1 { margin: 6px 0 2px; font-size: 32px; letter-spacing: -0.02em; line-height: 1.1; }
.hero .by { margin: 0; color: var(--muted); font-size: 17px; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; width: min(520px, 100%); }
.hero .actions .btn { flex: 1 1 110px; }

.rows { list-style: none; margin: 0; padding: 0; border-top: 0.5px solid var(--line); }
.row {
  display: grid; grid-template-columns: 28px 48px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 6px; border-bottom: 0.5px solid var(--line); cursor: pointer; border-radius: 10px;
}
.row:hover { background: rgba(255, 255, 255, 0.04); }
.row .n { color: var(--faint); text-align: center; font-variant-numeric: tabular-nums; }
.row .cover { width: 48px; border-radius: 9px; }
.row .name { min-width: 0; }
.row .name b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name > span { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.row.current .name b { color: var(--accent); }
.row.off { opacity: 0.4; cursor: default; }
.tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 5px; vertical-align: 2px;
  background: rgba(255, 255, 255, 0.1); font-size: 12px; font-weight: 650; color: var(--muted);
}

/* ---- Mini player ------------------------------------------------------------ */

.mini {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 4px;
  background: rgba(36, 36, 40, 0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 8px; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: 0; cursor: pointer; text-align: left; padding: 0; }
.mini-cover { width: 46px; flex: none; }
.mini-cover .cover { border-radius: 10px; }
.mini-text { min-width: 0; }
.mini-text b, .mini-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-text span { color: var(--muted); font-size: 14px; }
.mini-progress { position: absolute; left: 24px; right: 24px; bottom: 3px; height: 2px; background: rgba(255,255,255,0.1); border-radius: 2px; }
.mini-progress div { height: 100%; width: 0; background: var(--accent); border-radius: 2px; }

/* ---- Full player ------------------------------------------------------------ */

.full { position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: #000; }
.full-bg { position: fixed; inset: 0; pointer-events: none; }
.full-inner { position: relative; max-width: 560px; margin: 0 auto; padding: 18px 24px 60px; }
.full-top { display: flex; align-items: center; justify-content: space-between; }
.full-from { text-align: center; }
.full-from span { display: block; font-size: 12px; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.full-from b { font-size: 15px; }
.full-cover { margin: 26px auto 0; width: min(420px, 100%); }
.full-cover .cover { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.full-title { margin-top: 26px; }
.full-title h2 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.full-title p { margin: 2px 0 0; color: var(--muted); font-size: 18px; }
.scrub { margin-top: 18px; }
.scrub canvas { width: 100%; height: 54px; cursor: pointer; touch-action: none; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.full-controls { display: flex; justify-content: center; align-items: center; gap: 30px; margin: 16px 0 6px; }
.play-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer; background: #fff; color: #000;
  display: grid; place-items: center;
}
.play-btn svg { width: 32px; height: 32px; }

.cards { margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.card { background: rgba(255, 255, 255, 0.07); border-radius: 20px; padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 17px; }
.card h3 .count { color: var(--faint); }
.lyrics { max-height: 300px; overflow-y: auto; scroll-behavior: smooth; }
.lyrics p { margin: 0; padding: 4px 0; font-size: 20px; font-weight: 700; color: var(--faint); transition: color 0.2s; cursor: pointer; }
.lyrics p.on { color: var(--text); }
.lyrics.plain p { color: var(--text); font-size: 17px; font-weight: 500; white-space: pre-wrap; cursor: default; }
.comments { list-style: none; margin: 0; padding: 0; }
.comments li { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 9px 0; }
.comments li + li { border-top: 0.5px solid var(--line); }
.comments .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--accent-soft); color: var(--accent); }
.comments .meta { font-size: 14px; color: var(--muted); }
.comments .meta b { color: var(--text); }
.comments .at { border: 0; background: rgba(255,255,255,0.08); border-radius: 6px; padding: 0 6px; margin-left: 4px; color: var(--accent); font-size: 13px; font-weight: 650; cursor: pointer; }
.comments p { margin: 2px 0 0; overflow-wrap: anywhere; }
.empty { color: var(--faint); margin: 0; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input { flex: 1; min-width: 0; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; outline: none; }
.comment-form input:focus { border-color: var(--accent); }

.icon-btn.add { background: var(--accent); flex: none; }
.icon-btn.add:hover { background: var(--accent); filter: brightness(1.1); }

.sheet { border: 0; padding: 0; background: transparent; color: var(--text); width: min(420px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); }
.sheet-body { background: var(--surface-2); border-radius: 24px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; }
.sheet .field { background: rgba(0, 0, 0, 0.3); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.uploads {
  position: fixed; right: 18px; bottom: 96px; z-index: 35; width: min(340px, calc(100vw - 36px));
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.uploads h3 { margin: 0 0 8px; font-size: 15px; }
.uploads ul { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.uploads li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; font-size: 14px; }
.uploads li b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uploads li span { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.uploads li.bad span { color: var(--danger); grid-column: 1 / -1; text-align: left; }
.uploads li.ok span { color: #4cd964; }
.uploads .bar { grid-column: 1 / -1; height: 3px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
.uploads .bar div { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 60;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
