:root {
  --bg: #14161c;
  --card: #1d2029;
  --card2: #252936;
  --line: #2f3443;
  --text: #eceef3;
  --dim: #9aa1b2;
  --accent: #f4a340;      /* valve-radio amber */
  --accent2: #ffd08a;
  --ok: #6fcf8e;
  --warn: #f0b35a;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; white-space: nowrap;
         display: flex; align-items: baseline; gap: 9px; }
.brand .sq { width: 15px; height: 15px; border-radius: 4px; background: var(--accent); flex-shrink: 0; }
.brand span { color: var(--accent); }
.mood select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font: inherit; max-width: 48vw;
}

.searchbar { position: sticky; top: 0; z-index: 10; padding: 8px 16px 12px; background: var(--bg); }
.searchbar input {
  width: 100%; padding: 12px 16px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; outline: none;
}
.searchbar input:focus { border-color: var(--accent); }
.results {
  position: absolute; left: 16px; right: 16px; top: calc(100% - 4px);
  background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: 70vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.result { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.result .grow { flex: 1; min-width: 0; }
.result .btns { display: flex; gap: 6px; flex-shrink: 0; }

main {
  display: grid; gap: 14px; padding: 0 16px 24px; max-width: 1100px; margin: 0 auto;
}
@media (min-width: 900px) {
  main { grid-template-columns: 1.1fr 1fr; align-items: start; }
  main .now { grid-row: span 2; position: sticky; top: 76px; }
}
.card { background: var(--card); border-radius: var(--radius); padding: 16px; min-width: 0; }
.now { position: relative; overflow: hidden; isolation: isolate; }
.now::before {
  content: ""; position: absolute; inset: -60px; z-index: -1; opacity: 0;
  background: var(--backdrop) center / cover no-repeat;
  filter: blur(40px) brightness(.4) saturate(1.3);
  transition: opacity .8s ease;
}
.now.has-backdrop::before { opacity: 1; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.head h2 { margin: 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }

.empty { text-align: center; padding: 40px 12px; color: var(--dim); }
.empty .big { font-size: 1.4rem; color: var(--text); margin: 0 0 6px; }

.art { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1; margin: 0 auto 16px; }
.art img, .noart {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.noart {
  display: flex; align-items: center; justify-content: center; font-size: 4rem; font-weight: 700;
  color: rgba(255,255,255,.85); background: linear-gradient(135deg, #3a2a5d, #b5642a);
}
.artist { margin: 0; color: var(--accent2); font-weight: 600; }
.artist a, .album a { color: inherit; text-decoration: none; }
.artist a:hover, .album a[href]:hover { text-decoration: underline; }
.title { margin: 2px 0 4px; font-size: 1.6rem; line-height: 1.2; overflow-wrap: anywhere; }
.titlerow { display: flex; align-items: baseline; gap: 12px; }
.titlerow .title { flex: 1; min-width: 0; }
.format { font-size: .75rem; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.album { margin: 0 0 10px; color: var(--dim); overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chips:empty { display: none; }
.drawer { margin: -4px 0 14px; }
.drawer summary { display: inline-block; cursor: pointer; list-style: none; font-size: .8rem; color: var(--dim);
  padding: 2px 0; user-select: none; }
.drawer summary::-webkit-details-marker { display: none; }
.drawer summary::after { content: "▸"; display: inline-block; margin-left: 5px; transition: transform .15s; }
.drawer[open] summary::after { transform: rotate(90deg); }
.drawer summary:hover { color: var(--text); }
.drawer[open] summary { margin-bottom: 8px; }
.chip { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--card2); color: var(--dim); }

.progress .bar { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.progress .bar div { height: 100%; width: 0; background: var(--accent); transition: width .9s linear; }
.times { display: flex; justify-content: space-between; font-size: .8rem; color: var(--dim);
  margin-top: 4px; font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 12px; }
.round {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--card2);
  display: inline-flex; align-items: center; justify-content: center;
}
.round svg { width: 22px; height: 22px; fill: currentColor; }
.round.main { width: 64px; height: 64px; background: var(--accent); color: #1b1206; }
.round.main svg { width: 28px; height: 28px; }
.pill {
  border: 1px solid var(--line); background: var(--card2); border-radius: 999px;
  padding: 8px 14px; white-space: nowrap;
}
.pill.quiet { background: transparent; }
.pill.go { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: 600; }
.pill.small { padding: 5px 11px; font-size: .85rem; }
button:active { transform: scale(.96); }
button:disabled { opacity: .4; }

/* Where it plays: the desk amp, the outside Pi, or this phone (the last two via the stream). */
.outputs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card2); }
.seg button { border: 0; background: transparent; padding: 7px 16px; color: var(--dim); font-size: .9rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #1b1206; font-weight: 600; }
.seg button:active { transform: none; }
.heard { font-size: .78rem; color: var(--dim); }
.listening #listen { background: var(--card2); border-color: var(--line); color: var(--text); font-weight: 400; }
.listening .heard::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 6px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* How much of the library has been heard, as an old radio's tuning dial. */
.dial { --heard: 0%; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.dial .counts { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dial .counts b { color: var(--text); font-size: 1rem; }
.dial .scale, .volume .scale { position: relative; height: 22px; border-radius: 4px; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.28) 0 1px, transparent 1px 25%) 0 0 / 100% 100%,
    repeating-linear-gradient(90deg, rgba(255,255,255,.14) 0 1px, transparent 1px 2.5%) 0 100% / 100% 45% no-repeat,
    var(--card2); }
.dial .glow { position: absolute; inset: 0 auto 0 0; width: var(--heard); transition: width 1s ease;
  background: linear-gradient(90deg, rgba(244,163,64,.05), rgba(244,163,64,.35)); }
.dial .needle { position: absolute; top: 0; bottom: 0; left: var(--heard); width: 2px; margin-left: -1px;
  background: var(--accent); box-shadow: 0 0 8px 2px rgba(244,163,64,.6); transition: left 1s ease; }
.dial .dialnums, .volume .dialnums { position: relative; height: 1.2em; font-size: .7rem; margin-top: 3px; opacity: .7; }
.dial .dialnums span, .volume .dialnums span { position: absolute; transform: translateX(-50%); }
.dial .dialnums span:first-child { transform: none; }
.dial .dialnums span:last-child { right: 0; transform: none; }
.dial .dialcap { margin: 6px 0 0; text-align: center; }
.dial .dialcap b { color: var(--accent2); }

/* Volume: three stops (80, 100, 130) on a 60-140 scale, so 100 sits in the middle. */
.volume { --vol: 50%; margin: 4px 0 0; font-size: .8rem; color: var(--dim); font-variant-numeric: tabular-nums;
  outline: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.volume .scale { cursor: pointer; overflow: visible;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.14) 0 1px, transparent 1px 2.5%) 0 100% / 100% 45% no-repeat,
    var(--card2); }
.volume:focus-visible .scale { box-shadow: 0 0 0 1px var(--accent); }
.volume .glow { position: absolute; inset: 0 auto 0 0; width: var(--vol); border-radius: 4px 0 0 4px;
  transition: width .25s ease; background: linear-gradient(90deg, rgba(244,163,64,.05), rgba(244,163,64,.35)); }
.volume.loud .glow { background: linear-gradient(90deg, rgba(244,163,64,.08), rgba(244,163,64,.55)); }
.volume .stop { position: absolute; top: 0; bottom: 0; left: var(--at); width: 1px; background: rgba(255,255,255,.45); }
.volume .knob { position: absolute; top: -3px; bottom: -3px; left: var(--vol); width: 14px; margin-left: -7px;
  border-radius: 3px; transition: left .25s ease;
  background:
    repeating-linear-gradient(0deg, transparent 0 4px, rgba(27,18,6,.45) 4px 5px) center / 8px 15px no-repeat,
    linear-gradient(180deg, var(--accent2), var(--accent) 55%, #c97a22);
  box-shadow: 0 0 8px 2px rgba(244,163,64,.45), inset 0 0 0 1px rgba(27,18,6,.5); }
.volume .dialnums span { cursor: pointer; }
.volume .dialnums span.on { color: var(--accent2); font-weight: 700; }

.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; }
.track + .track { border-top: 1px solid var(--line); }
.track.tap { cursor: pointer; }
.track.tap:hover { background: var(--card2); }
.track.first { background: rgba(244,163,64,.08); }
.thumb { width: 44px; height: 44px; border-radius: 6px; flex-shrink: 0; object-fit: cover;
  background: linear-gradient(135deg, #3a2a5d, #b5642a); }
.track .grow { flex: 1; min-width: 0; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name b, .name .who { font-weight: 600; }
.who { color: inherit; text-decoration: none; }
.who:hover { color: var(--accent2); text-decoration: underline; }
.result.tap { cursor: pointer; }
.result.tap:hover { background: var(--card); }
.kind { font-size: .75rem; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; flex-shrink: 0; }
.meta { font-size: .8rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.why { font-size: .78rem; color: var(--accent2); opacity: .85; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.nowwhy { margin: 0 0 8px; font-size: .85rem; }
.nowwhy:empty { display: none; }
.nowwhy .why { font-size: inherit; white-space: normal; }
.num { width: 1.4em; text-align: center; color: var(--dim); font-weight: 700; flex-shrink: 0; }
.first .num { color: var(--accent); }
.tick { color: var(--ok); width: 1.2em; flex-shrink: 0; text-align: center; }

.foot { text-align: center; color: var(--dim); font-size: .8rem; padding: 0 16px 24px; }
.foot span { display: block; margin-bottom: 8px; }
.linkish { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  color: var(--dim); font-size: .8rem; }
.linkish:hover { color: var(--text); border-color: var(--accent); }

.toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); z-index: 50; pointer-events: none; }
.toast { background: var(--card2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: in .2s ease-out; overflow-wrap: anywhere; }
.toast.warning { border-left-color: var(--warn); }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }
.offline .brand::after { content: " · reconnecting…"; color: var(--warn); font-weight: 400; font-size: .85rem; }
@media (min-width: 1132px) {
  .top, .searchbar { max-width: 1100px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
}

/* ---- login --------------------------------------------------------------------- */
.login { display: flex; flex-direction: column; gap: 12px; max-width: 420px; margin: 24px auto 0; }
.login h2 { margin: 0; }
.login label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: .85rem; }
.login input { padding: 11px 14px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; outline: none; }
.login input:focus { border-color: var(--accent); }
.login .pill { align-self: flex-start; margin-top: 6px; }
.login .err { margin: 0; color: var(--warn); }

/* ---- settings ------------------------------------------------------------------ */
.top .mood { margin-left: auto; }
.gear { color: var(--dim); text-decoration: none; font-size: 1.4rem; line-height: 1; padding: 4px; }
.gear:hover { color: var(--accent); }
a.brand { color: inherit; text-decoration: none; }
a.pill { text-decoration: none; color: var(--text); }
main.narrow { max-width: 760px; grid-template-columns: 1fr; }
.hint { color: var(--dim); font-size: .85rem; margin: 12px 0 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--dim); }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 12px; margin: 0;
  background: var(--card2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--dim); transition: transform .2s, background .2s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: #1b1206; }

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.presets select, .save-as input {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .9rem;
}
.save-as { display: flex; gap: 6px; margin-left: auto; }
.save-as input { width: 11em; outline: none; }
.save-as input:focus { border-color: var(--accent); }

input[type=range] { accent-color: var(--accent); }
.eq { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; transition: opacity .2s; }
.eq.off { opacity: .35; }
.band { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  font-variant-numeric: tabular-nums; }
.band output { font-size: .75rem; color: var(--dim); }
.band .freq { font-size: .8rem; color: var(--dim); }
.band input { writing-mode: vertical-lr; direction: rtl; height: 180px; width: 28px; margin: 0; }
.band.pre { border-right: 1px solid var(--line); padding-right: 4px; }
.band.pre .freq { color: var(--accent2); }

@media (max-width: 560px) {
  .eq { grid-template-columns: 1fr; gap: 2px; }
  .band { display: grid; grid-template-columns: 3em 1fr 3.2em; align-items: center; }
  .band .freq { order: -1; }
  .band output { order: 2; text-align: right; }
  .band input { writing-mode: horizontal-tb; direction: ltr; height: 32px; width: 100%; }
  .band.pre { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 6px; margin-bottom: 4px; }
  .save-as { margin-left: 0; width: 100%; }
  .save-as input { flex: 1; }
}
.row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.row > span { flex-shrink: 0; }
.row input[type=range] { flex: 1; min-width: 0; }
.row output { width: 3.5em; text-align: right; color: var(--accent2); font-variant-numeric: tabular-nums; }
.switch.row span { color: var(--text); flex-shrink: 1; }
.switch.row input { flex-shrink: 0; }
@media (max-width: 480px) {
  .top { gap: 8px; }
  .mood select { max-width: 36vw; }
}

/* ---- artist and album pages ------------------------------------------------------ */
.browsing #nextcard, .browsing #tonightcard, .browsing .now:has(#playing[hidden]) { display: none; }
.browsing:has(#playing[hidden]) main { grid-template-columns: 1fr; max-width: 760px; }
.backbar { margin: -4px 0 12px; }
.hero { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.hero .grow { min-width: 0; }
.hero .title { font-size: 1.5rem; }
.hero .meta { white-space: normal; margin: 0 0 12px; }
.heroart { width: 140px; height: 140px; border-radius: 10px; flex-shrink: 0; object-fit: cover;
  background: linear-gradient(135deg, #3a2a5d, #b5642a); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.heroart.round { width: 110px; height: 110px; border-radius: 50%; }
.sub { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 18px 0 10px; }
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.albumcard { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.albumcard .cover { display: block; aspect-ratio: 1; }
.albumcard .cover .thumb { width: 100%; height: 100%; border-radius: 8px; }
.albumcard .atitle { color: var(--text); text-decoration: none; font-weight: 600; margin-top: 4px;
  overflow-wrap: anywhere; }
.albumcard .atitle:hover { color: var(--accent2); }
.albumcard .pill { align-self: flex-start; margin-top: 4px; }
.browse .track .btns { display: flex; gap: 6px; flex-shrink: 0; }
.browse .track.playing { background: rgba(244,163,64,.12); }
.browse .track.playing .num, .browse .track.playing .name { color: var(--accent); }

/* On a phone, Now Playing shrinks to a bar above the page, so pause and skip stay in reach. */
@media (max-width: 899px) {
  .browsing .now { padding: 10px 12px; position: sticky; top: 72px; z-index: 5; }
  .browsing .playing { display: flex; align-items: center; gap: 12px; }
  .browsing .now .art { width: 56px; margin: 0; flex-shrink: 0; }
  .browsing .now .noart { font-size: 1.1rem; }
  .browsing .now .art img, .browsing .now .noart { border-radius: 6px; box-shadow: none; }
  .browsing .now .info { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; }
  .browsing .now .artist { order: 1; width: 100%; font-size: .85rem; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .browsing .now .titlerow { order: 2; flex: 1; min-width: 0; }
  .browsing .now .title { font-size: 1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .browsing .now .controls { order: 3; margin: 0; gap: 6px; }
  .browsing .now .round { width: 38px; height: 38px; }
  .browsing .now .round svg { width: 16px; height: 16px; }
  .browsing .now .album, .browsing .now .format, .browsing .now .drawer, .browsing .now .volume,
  .browsing .now .progress, .browsing .now .controls .pill, .browsing .now .dial, .browsing .now .outputs { display: none; }
}
@media (max-width: 480px) {
  .heroart { width: 104px; height: 104px; }
  .heroart.round { width: 84px; height: 84px; }
  .hero .title { font-size: 1.25rem; }
  .albums { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .browse .track .btns .pill:last-child:not(:first-child) { display: none; }
}
