/* Layout: one narrow column, like a radio's front panel. The "now playing" card is the dial. */
:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #17202b;
  --muted: #5b6878;
  --line: #d6dde5;
  --accent: #e2591f;      /* on-air lamp */
  --accent-ink: #ffffff;
  --signal: #1f6f8b;      /* links, focus */
  --soft: #f6f8fa;
  --danger: #b4232c;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151c; --panel: #17202a; --ink: #e8edf2; --muted: #93a1b0; --line: #2a3644;
    --accent: #ff7a3d; --accent-ink: #1a0d05; --signal: #6cc3df; --soft: #1c2733; --danger: #ff6b72;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* so el.hidden works on elements that set their own display */
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 760px; margin: 0 auto; padding-block: 20px 60px; display: grid; gap: 20px; }
.wrap.wide { max-width: 1100px; }
h1, h2 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-family: var(--body); font-weight: 600; }
a { color: var(--signal); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.lamp {
  font: 700 11px/1 var(--mono); letter-spacing: 0.12em; padding: 6px 8px; border-radius: 4px;
  border: 1.5px solid var(--line); color: var(--muted);
}
.lamp.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent); }
.conn { font-size: 13px; color: var(--muted); }
.conn.off { color: var(--danger); }

.me { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.me input { width: 150px; }

input[type=text], input[type=url], input[type=search], input[type=password] {
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0;
}
input:focus { border-color: var(--signal); outline: none; }

.btn {
  border: 1.5px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px;
  cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.link { border-color: transparent; background: transparent; color: var(--signal); padding-inline: 6px; }

/* Now playing */
.dial { background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 14px; }
.np { display: grid; grid-template-columns: 168px 1fr; gap: 16px; align-items: start; }
.np img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--soft); display: block; }
.np .meta { min-width: 0; display: grid; gap: 4px; }
.np .title { font: 600 19px/1.3 var(--display); overflow-wrap: anywhere; }
.np .sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }
.times { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.empty { color: var(--muted); padding: 8px 0; }

/* Add a song */
.add { display: grid; gap: 10px; }
.add form { display: flex; gap: 8px; }
.add form input { flex: 1; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.results { display: grid; gap: 6px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.item { display: grid; grid-template-columns: 28px 72px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; }
.item:hover { background: var(--panel); }
.item.mine { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.item .n { font: 13px var(--mono); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.item img { width: 72px; aspect-ratio: 16/9; object-fit: cover; border-radius: 5px; background: var(--soft); display: block; }
.item .t { min-width: 0; }
.item .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t span { font-size: 13px; color: var(--muted); }
.results .item { grid-template-columns: 72px 1fr auto; background: var(--panel); border: 1px solid var(--line); }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary h2::after { content: " ▸"; }
details[open] summary h2::after { content: " ▾"; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

/* Speaker page */
.stage { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.player { aspect-ratio: 16/9; width: 100%; background: #000; border-radius: 12px; overflow: hidden; position: relative; }
.player iframe, .player > #yt { width: 100%; height: 100%; display: block; }
.cover { position: absolute; inset: 0; display: grid; place-items: center; background: #10161d center / cover no-repeat; }
.cover span { background: rgba(0, 0, 0, 0.72); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; }
.gate { background: var(--panel); border: 1.5px dashed var(--accent); border-radius: 12px; padding: 18px; display: grid; gap: 10px; }
.join { font: 600 20px var(--mono); overflow-wrap: anywhere; }
.notice { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--soft); font-size: 14px; }
.notice.warn { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .np { grid-template-columns: 1fr; }
  .item { grid-template-columns: 22px 56px 1fr auto; gap: 8px; }
  .item img { width: 56px; }
  .me input { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
