:root {
  --bg: #dfe9e6;
  --panel: #cfdcd8;
  --ink: #16302d;
  --muted: #587370;
  --accent: #2a44d4;
  --on-accent: #fff;
  --line: #b6c8c3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12201f;
    --panel: #1a2d2b;
    --ink: #e2eeeb;
    --muted: #8fa9a5;
    --accent: #7c93ff;
    --on-accent: #0d1330;
    --line: #2a403d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { background: var(--bg); color: var(--ink); }
body {
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
  min-height: 100vh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Login */
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
#login-form { width: min(100%, 340px); display: grid; gap: 12px; }
#login-form h1 { font-size: 3rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 8px; }
#login-form label { font-size: .9rem; color: var(--muted); }
#login-form input {
  font: inherit; padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px;
  background: transparent; color: inherit;
}
#login-form button {
  padding: 12px; border: 0; border-radius: 10px; background: var(--accent);
  color: var(--on-accent); font-weight: 600;
}
#login-err { min-height: 1.4em; color: #c0392b; font-size: .9rem; }

/* Player */
#app { max-width: 720px; margin: 0 auto; }
.now {
  position: sticky; top: 0; z-index: 5;
  padding: calc(20px + env(safe-area-inset-top, 0)) 20px 16px;
  margin-top: calc(-1 * env(safe-area-inset-top, 0));
  background: var(--bg); border-bottom: 2px solid var(--line);
}
.now h2 {
  font-size: clamp(1.6rem, 6.5vw, 2.6rem); font-weight: 800; line-height: 1.05;
  letter-spacing: -0.025em; min-height: 2.1em; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

#seek { width: 100%; margin: 14px 0 4px; accent-color: var(--accent); height: 22px; }
.times { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted);
  font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.controls button {
  position: relative; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; color: var(--muted);
}
.controls button svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2;
  fill: none; stroke-linecap: round; stroke-linejoin: round; }
.controls button svg.fill { fill: currentColor; stroke: none; }
.controls #prev, .controls #next { color: var(--ink); }
.controls button[aria-pressed="true"], .controls button.on { color: var(--accent); }
.controls .primary { width: 64px; height: 64px; background: var(--accent); color: var(--on-accent); }
.controls .primary svg { width: 28px; height: 28px; }
#repeat b { position: absolute; font-size: .6rem; right: 10px; top: 8px; }

/* Library */
.library { padding: 16px 20px 40px; }
#search {
  width: 100%; font: inherit; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 10px; background: transparent; color: inherit;
}
#count { margin: 10px 2px 6px; font-size: .85rem; color: var(--muted); }
#list { list-style: none; padding: 0; }
#list button {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 14px 10px; border-bottom: 1px solid var(--line); font-size: 1rem; line-height: 1.3;
}
#list button:hover { background: var(--panel); }
#list button[aria-current="true"] {
  font-weight: 600; color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); padding-left: 16px;
}
.empty { padding: 24px 4px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
