:root {
  --bg: #0e141d; --panel: #141c28; --line: #243042; --text: #e8edf4; --muted: #8493a8;
  --gold: #fbbf24; --gold-ink: #1d1500; --teal: #2dd4bf; --red: #f0614a;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hidden { display: none !important; }

/* auth */
#auth { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.logo { font-size: 30px; font-weight: 800; letter-spacing: 1px; color: var(--gold); margin: 0 0 4px; }
.tag { color: var(--muted); margin: 0 0 20px; }

/* app shell */
#app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 52px 1fr auto; height: 100%; }
header { grid-column: 1 / 3; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
header .logo { font-size: 22px; margin: 0; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
nav { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; }
nav h4 { margin: 14px 8px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
nav button { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--muted); cursor: pointer; }
nav button:hover { color: var(--text); background: #1b2535; }
nav button.on { background: var(--gold); color: var(--gold-ink); font-weight: 600; }
main { overflow-y: auto; padding: 28px 32px; }
main h1 { margin: 0 0 4px; font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }
#banner { background: #3a1812; color: #ffb4a6; border-bottom: 1px solid #6b2a1f; padding: 8px 18px; grid-column: 1 / 3; }
#player { grid-column: 1 / 3; display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--panel); }
#seek { flex: 1; max-width: 420px; accent-color: var(--gold); }
#player .time { width: auto; }
#player .sep { color: var(--muted); }
#nowplaying { min-width: 160px; color: var(--muted); }

/* controls */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.btn { background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 700; cursor: pointer; }
.btn.ghost { background: none; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.play { width: 32px; height: 32px; border-radius: 8px; border: 0; background: var(--gold); color: var(--gold-ink); cursor: pointer; font-size: 13px; }
.link { background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn { flex: 0 0 auto; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 16px; }
.item { display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .main small { color: var(--muted); }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #12332f; color: var(--teal); }
.chip.red { background: #3a1812; color: #ffb4a6; }
.time { color: var(--muted); font-variant-numeric: tabular-nums; width: 44px; text-align: right; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-top: 16px; }
.album { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cover { height: 120px; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: rgba(0,0,0,.65); }
.album .meta { padding: 12px 14px; }
.album .meta small { color: var(--muted); display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; max-width: 560px; margin-top: 16px; }
.msg { margin-top: 10px; min-height: 20px; color: var(--teal); }
.msg.err { color: #ffb4a6; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 280px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
#toast { position: fixed; bottom: 76px; right: 18px; background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 52px auto 1fr auto; }
  header, #banner, #player { grid-column: 1; }
  nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  nav h4 { display: none; }
  nav button { white-space: nowrap; width: auto; }
  main { padding: 18px; }
  #nowplaying { display: none; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
