:root {
  --bg: #0b0c0f;
  --panel: #16181d;
  --panel-2: #1e2128;
  --line: #2a2e37;
  --text: #eceef2;
  --muted: #9aa1ae;
  --accent: #6c8cff;
  --danger: #ff6b6b;
  --scrim: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,0));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.stage { position: fixed; inset: 0; background: #000; overflow: hidden; }
/* Pinned to the frame (not a grid item, whose % height can fall back to the video's
   native size); object-fit letterboxes/pillarboxes so the aspect ratio is kept. */
video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
video::cue { background: rgba(0,0,0,.7); font-size: clamp(14px, 3.2vh, 28px); }

.topbar, .controls { position: absolute; left: 0; right: 0; padding: 12px 16px; z-index: 2;
  transition: opacity .25s ease; }
.topbar { top: 0; display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,.8), rgba(0,0,0,0)); }
.controls { bottom: 0; background: var(--scrim); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.stage.idle.has-media .topbar, .stage.idle.has-media .controls { opacity: 0; pointer-events: none; }
.stage.idle.has-media { cursor: none; }

.np { flex: 1; min-width: 0; }
.np-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seek-row { display: flex; align-items: center; gap: 10px; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 44px; }
.time:last-child { text-align: right; }
.btn-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.spacer { flex: 1; }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 20px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), rgba(255,255,255,.25) var(--fill, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: #fff; border: 0; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
input[type=range]:disabled { cursor: default; }
.seek { flex: 1; }
.volume { width: 90px; }

.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.big { width: 44px; height: 44px; }
/* Phosphor icons: inline SVGs sized by font-size, colored by currentColor. */
.ph { display: inline-grid; place-items: center; width: 1em; height: 1em; flex: none; line-height: 0; }
.ph svg { width: 100%; height: 100%; }
.icon-btn .ph { font-size: 22px; }
.icon-btn.big .ph { font-size: 28px; }

.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  background: rgba(22,24,29,.8); border-radius: 999px; padding: 4px 10px; font-size: 12px;
  cursor: pointer; white-space: nowrap; }
.chip .ph { font-size: 14px; }
.chip.active { border-color: var(--accent); color: var(--accent); }
.chip:hover { border-color: var(--muted); }
.chip.danger { color: var(--danger); }
.select-wrap { display: inline-flex; align-items: center; gap: 6px; }
.select-wrap .ph { font-size: 20px; }
.select { background: rgba(22,24,29,.8); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px;
  font-size: 12px; max-width: 140px; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55);
  z-index: 1; padding: 16px; }
.overlay-card { text-align: center; max-width: 420px; }
.overlay-title { font-size: 17px; font-weight: 600; margin: 12px 0 4px; }
.overlay-sub { color: var(--muted); margin: 0 0 12px; }
.spinner { font-size: 38px; margin: 0 auto; color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.big-btn .ph { font-size: 18px; }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 3; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 16px; flex: 1; }
.panel-actions { display: flex; gap: 6px; }
.search { position: relative; padding: 0 16px 8px; }
.search > .ph { position: absolute; left: 27px; top: 10px; font-size: 16px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px 8px 34px; outline: none; }
.search input:focus { border-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; }
#queue { flex: 1; }
.results:not(:empty) { max-height: 60%; border-bottom: 1px solid var(--line); margin-bottom: 6px; padding-bottom: 6px; }
.row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; }
.row:hover { background: var(--panel-2); }
.row.current { background: rgba(108,140,255,.14); }
.row .n { color: var(--muted); font-size: 12px; min-width: 22px; display: inline-flex; justify-content: flex-end;
  font-variant-numeric: tabular-nums; }
.row .n .now { color: var(--accent); font-size: 14px; }
.row > .kind { font-size: 18px; color: var(--muted); }
.row .meta { flex: 1; min-width: 0; cursor: pointer; }
.row .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .x { width: 28px; height: 28px; }
.row .x .ph { font-size: 16px; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.results-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px 6px; position: sticky; top: 0;
  background: var(--panel); z-index: 1; }
.results-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.back { width: 30px; height: 30px; }
.icon-btn.back .ph { font-size: 18px; }
.row > .go { font-size: 16px; color: var(--muted); }
.row .chip { flex: none; }
.chip.armed { background: var(--danger); border-color: var(--danger); color: #fff; }

body.listener .dj-only { display: none !important; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; z-index: 4; max-width: calc(100% - 32px); }

@media (max-width: 520px) {
  .volume { display: none; }
  .topbar, .controls { padding-left: 12px; padding-right: 12px; }
}
