:root {
  --bg: #0a0b10;
  --bg-raised: #14161f;
  --bg-raised-2: #1b1e2b;
  --border: #2a2e40;
  --text: #e8e9f3;
  --text-dim: #8b8fa8;
  --accent-a: #38f2c0;
  --accent-b: #ff4fd8;
  --accent-a-glow: rgba(56, 242, 192, 0.45);
  --accent-b-glow: rgba(255, 79, 216, 0.45);
  --danger: #ff6161;
  --radius: 14px;
  --tabbar-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Several elements below set `display` unconditionally (e.g. `display: flex`
   on .add-track), which — per the cascade — outranks the browser's built-in
   `[hidden] { display: none }` rule (author styles beat user-agent styles
   regardless of specificity). Without this, toggling `.hidden = true` in JS
   silently does nothing. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(60vw 40vh at 10% -10%, rgba(56,242,192,0.08), transparent 60%),
    radial-gradient(60vw 40vh at 90% -10%, rgba(255,79,216,0.08), transparent 60%),
    var(--bg);
  min-height: 100vh;
  /* Nothing in this app is a horizontal-scroll surface; the whole point of
     the tab shell is that each view is a single narrow column. */
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.dep-banner {
  background: #3a1f1f;
  border-bottom: 1px solid #7a3a3a;
  color: #ffd7d7;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.dep-banner__dismiss {
  margin-left: auto;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  line-height: 1;
}

/* ---------- App shell ----------
   One scrolling document (rather than an internal overflow container for the
   views): iOS Safari's collapsing toolbars only behave correctly when the
   page itself is what scrolls. The tab bar is fixed, so the shell just
   reserves its height as bottom padding. */
.app {
  min-height: 100vh;
  /* dvh tracks iOS Safari's collapsing toolbars; 100vh above is the fallback
     for browsers that don't know the unit. */
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 12px);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  /* Deliberately solid rather than a translucent blur: position:sticky +
     backdrop-filter is a known WebKit mis-render trigger on iOS, where the
     sticky element visually glitches whenever anything else on the page
     changes (a toast appearing, a list re-rendering). */
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* The actual flexible element between two fixed-size icons (brand mark,
     logo) — needs both flex:1 (claim the leftover space) and min-width:0
     (flex items refuse to shrink below their own content size otherwise, no
     matter what overflow/text-overflow say) to be the one that truncates
     when space is tight, instead of the icons overflowing the topbar. */
  flex: 1 1 auto;
  min-width: 0;
}
.topbar__action { margin-left: auto; flex-shrink: 0; }

.topbar__logo {
  display: block;
  height: 18px;
  width: auto;
  flex-shrink: 0; /* a logo squishing narrower than its own aspect ratio looks broken, not "compact" */
}

.brand__mark {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

/* ---------- Views ----------
   max-width lives on each .view (not the shared .views wrapper) so the
   Player view can be widened on desktop, independently of the read-focused
   Search/Playlist/Settings columns, without a second layout system. */
.views {
  display: block;
  width: 100%;
}
.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px;
  animation: view-in 0.16s ease-out;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}

/* ---------- Generic card / list primitives ---------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.card__header h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0;
  min-width: 0; /* let a long playlist name actually ellipsis instead of pushing a header button (e.g. Add All) out of the card */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__header .pill-btn { flex-shrink: 0; }

.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  padding: 16px 10px;
  line-height: 1.5;
  text-align: center;
}

.icon-btn {
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--accent-a); }

.pill-btn {
  /* Same look as an active (checked) .toggle-check — bright text on an
     accent-colored border — so these read clearly against the dark
     background instead of the low-contrast dim-grey-on-near-black default. */
  background: var(--bg-raised-2);
  border: 1px solid var(--accent-a);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
}
.pill-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--border); color: var(--text-dim); }
.pill-btn--danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }

/* ---------- Decks ---------- */
.deck {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.deck--a { box-shadow: inset 3px 0 0 var(--accent-a); }
.deck--b { box-shadow: inset 3px 0 0 var(--accent-b); }

.deck__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* A compact square cover rather than the old 16:9 hero frame — two decks
   plus the mixer have to coexist on one phone screen. */
.deck__video-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.deck__video {
  width: 100%;
  height: 100%;
}
.deck__video img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, filter 0.4s ease;
}
/* No video to show motion, so give the cover a subtle pulse while its
   deck is actually playing — purely decorative, no click targets. */
.deck__video-wrap.playing img {
  transform: scale(1.05);
  filter: saturate(1.15);
}
.deck__video-wrap.playing::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px var(--accent-a);
  animation: cover-pulse 1.8s ease-in-out infinite;
  pointer-events: none;
}
.deck--b .deck__video-wrap.playing::after { box-shadow: inset 0 0 0 2px var(--accent-b); }
@keyframes cover-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}
.deck__video-placeholder {
  position: absolute;
  inset: 0;
  /* Opaque, not just the letter — otherwise this only draws the "A"/"B"
     text and leaves whatever's underneath (the <img>, including any
     leftover broken-image glyph a browser is slow to repaint away) visible
     through the rest of the box once .has-video is removed. */
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 24px;
  font-weight: 700;
  pointer-events: none;
}
.deck__video-wrap.has-video .deck__video-placeholder { display: none; }

.deck__meta { min-width: 0; flex: 1; }
.deck__badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.deck--a .deck__badge { color: var(--accent-a); }
.deck--b .deck__badge { color: var(--accent-b); }
.deck__title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck__sub {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck__scrubber {
  display: flex;
  align-items: center;
  gap: 8px;
}
.deck__time {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  width: 34px;
  flex-shrink: 0;
}
.deck__scrubber input[type="range"] { flex: 1; min-width: 0; }

.deck__controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.play-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-raised-2);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.play-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.deck--a .play-btn.playing { border-color: var(--accent-a); box-shadow: 0 0 24px var(--accent-a-glow); color: var(--accent-a); }
.deck--b .play-btn.playing { border-color: var(--accent-b); box-shadow: 0 0 24px var(--accent-b-glow); color: var(--accent-b); }

/* Same circle as .play-btn — .cue-btn only adds icon centering, since its
   content is an SVG (which text-align:center alone won't reliably center
   the way it does the play button's single "▶" text glyph) rather than
   text. No unicode media-control character (⏭ etc.) here on purpose: those
   default to full-color emoji presentation on iOS/Safari, breaking the
   monochrome match with the plain-text ▶ this is meant to sit next to. */
.cue-btn { display: flex; align-items: center; justify-content: center; }
.cue-btn svg { width: 22px; height: 22px; fill: currentColor; }

.trim {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.trim input { flex: 1; min-width: 0; }

.deck__status {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 15px;
}
.deck__status.error { color: var(--danger); }
.deck__status.busy { color: #ffcf5c; }

/* ---------- Mixer console ---------- */
.mixer-console {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.crossfader-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.crossfader-labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}
.crossfader-labels span:first-child { color: var(--accent-a); }
.crossfader-labels span:last-child { color: var(--accent-b); }
.crossfader-hint {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.master-volume {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.master-volume__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.master-volume__label output {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.master-volume input[type="range"] { width: 100%; }

.auto-crossfade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.auto-crossfade__btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border: none;
  color: #0a0b10;
  font-weight: 700;
  font-size: 17px;
  padding: 15px 14px;
  border-radius: 12px;
  letter-spacing: 0.02em;
}
.auto-crossfade__btn:hover { filter: brightness(1.08); }
.auto-crossfade__btn:disabled { opacity: 0.55; }

.auto-crossfade__status {
  min-height: 14px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}
.auto-crossfade__status.busy { color: #ffcf5c; }

.auto-crossfade__toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}
.toggle-check {
  /* A basis rather than bare 1 so a third toggle can wrap onto its own row
     on the narrowest phones instead of three squeezing onto one and
     clipping/wrapping their label text mid-word. */
  flex: 1 1 100px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  cursor: pointer;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised-2);
}
.toggle-check input[type="checkbox"] {
  accent-color: var(--accent-a);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-check:has(input:checked) {
  color: var(--text);
  border-color: var(--accent-a);
}

/* A plain `background` on the input box itself (the old approach) reads as
   almost invisible here: --bg-raised-2 and the --bg-raised card it sits on
   are both near-black, so the "track" and its surroundings were only a
   couple of luminance steps apart — on plenty of screens, not distinguishable
   at all. --track is deliberately much lighter than either, with its own
   border, so the groove reads as a groove regardless of what's behind it.
   Set explicitly on the ::track pseudo-elements (not just the input's own
   background) because that's the only way Firefox reliably paints it. */
input[type="range"] {
  --track: #4a5170;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  /* Sliders sit inside a vertically-scrolling page on touch devices: without
     this, a horizontal drag that starts slightly off-axis gets stolen by the
     page scroll instead of moving the fader. */
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  background: var(--track);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 6px;
}
input[type="range"]::-moz-range-track {
  background: var(--track);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 6px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border: 2px solid #fff2;
  cursor: pointer;
  /* Webkit measures the thumb's vertical position against the *input's* box,
     not the (shorter) track pseudo-element, so it needs a manual nudge to
     stay centered on a 6px track instead of sitting at its top edge. */
  margin-top: -7px;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border: 2px solid #fff2;
  cursor: pointer;
}

#crossfader::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  opacity: 0.9;
  height: 8px;
}
#crossfader::-moz-range-track {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  opacity: 0.9;
  height: 8px;
}

/* ---------- Playback queue ---------- */
.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.queue-list__empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 14px;
  text-align: center;
}

.queue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  cursor: grab;
  min-width: 0;
}
.queue-row.dragging { opacity: 0.4; }
.queue-row.drag-over { border-color: var(--accent-a); box-shadow: 0 0 0 1px var(--accent-a); }
.queue-row__handle {
  color: var(--text-dim);
  font-size: 15px;
  flex-shrink: 0;
  cursor: grab;
}
.queue-row img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  flex-shrink: 0;
}
.queue-row__meta { min-width: 0; flex: 1; }
.queue-row__title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-row__sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-row__order {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.queue-row__order button {
  width: 28px;
  height: 22px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  font-size: 10px;
  line-height: 1;
}
.queue-row__order button:disabled { opacity: 0.3; }
.queue-row__remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 6px 4px;
}
.queue-row__remove:hover { color: var(--danger); }

/* The Player tab only ever shows a short preview of the queue now (next
   couple of tracks + a "+N more" count) — the full editable list lives
   exclusively in the overlay below, so there's no long, ever-growing list
   eating into the space decks/mixer need. Fixed at a couple of lines
   regardless of queue length, unlike the old list it replaced. */
.queue-summary__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.queue-summary__empty,
.queue-summary__more {
  color: var(--text-dim);
  font-size: 13px;
}
.queue-summary__item {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-summary__item::before {
  content: '▸ ';
  color: var(--text-dim);
}

/* ---------- Full-screen queue editor ---------- */
.queue-overlay {
  position: fixed;
  inset: 0;
  z-index: 45; /* above .tabbar (40) so it fully replaces it while open, below .toast-stack (50) so a toast (e.g. "Added to queue") still surfaces on top */
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: view-in 0.16s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .queue-overlay { animation: none; }
}
.queue-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-shrink: 0;
}
.queue-overlay__header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.queue-overlay__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The list itself reuses .queue-list (same #queue-list element, same JS) —
   just given more breathing room and bigger touch targets here, since making
   dragging to reorder easier is the whole point of this view. */
.queue-list--overlay {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  gap: 10px;
}
.queue-list--overlay .queue-row { padding: 12px; }
.queue-list--overlay .queue-row img { width: 52px; height: 52px; }
.queue-list--overlay .queue-row__order button { width: 32px; height: 26px; }

/* ---------- Search view ---------- */
.add-track-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 12px;
}
.add-track-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 999px;
}
.add-track-tab.active {
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.add-track {
  display: flex;
  gap: 8px;
  min-width: 0;
}
.add-track input {
  flex: 1;
  min-width: 0;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  /* 16px keeps iOS Safari from auto-zooming the whole page on focus. */
  font-size: 16px;
  outline: none;
}
.add-track input:focus {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px var(--accent-a-glow);
}
.add-track button {
  background: linear-gradient(135deg, var(--accent-a), #1fbf95);
  border: none;
  color: #06251c;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  flex-shrink: 0;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.search-results__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 32px 20px;
  text-align: center;
}
.loading-disc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: repeating-radial-gradient(
    circle at center,
    var(--bg-raised-2) 0px, var(--bg-raised-2) 3px,
    var(--bg) 3px, var(--bg) 6px
  );
  border: 1px solid var(--border);
  position: relative;
  animation: loading-disc-spin 1.1s linear infinite;
}
/* A ring pattern is radially symmetric and a dead-center dot never moves —
   rotating either alone looks completely static despite the animation
   genuinely running. This off-center mark is what actually makes the spin
   visible, the way a real vinyl label's print does. */
.loading-disc::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--text-dim);
}
.loading-disc::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent-a);
}
@keyframes loading-disc-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-disc { animation: none; }
}
/* Two rows: identity (cover + meta) on top, the destination picker and
   queue shortcuts below, full width — same reasoning as .track-row. A single
   line was fine back when the only action was one "+" button; now there's a
   playlist choice plus two queue actions, which need room of their own. */
.search-result-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  grid-template-areas:
    "cover meta"
    "actions actions";
  gap: 8px 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  min-width: 0;
}
.search-result-row img {
  grid-area: cover;
  width: 72px;
  height: 41px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}
.search-result-row__meta {
  grid-area: meta;
  min-width: 0;
  align-self: center;
}
.search-result-row__title {
  font-size: 13px;
  font-weight: 600;
  /* Two lines, then ellipsis: search titles are long and a single nowrap
     line on a phone cuts most of them off before they say anything. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-row__sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.search-result-row__actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.search-result-row__playlist {
  flex: 1 1 120px;
  min-width: 0;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0 8px;
  height: 32px;
  font-size: 12px;
}
.search-result-row__playlist:focus { outline: none; border-color: var(--accent-a); }
.search-result-row__add,
.search-result-row__queue {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg-raised-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 0 12px;
  height: 32px;
  border-radius: 8px;
  white-space: nowrap;
}
.search-result-row__add { color: var(--accent-a); border-color: var(--accent-a); }
.search-result-row__add:disabled,
.search-result-row__queue:disabled { opacity: 0.5; }

/* ---------- Playlist view ---------- */
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* A dropdown, not a list of rows — a list keeps growing every time a
   playlist is added, which pushed the actual track list further down the
   tab with every one you created. This stays exactly one control tall
   regardless of how many playlists exist. */
.playlist-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.playlist-picker__select {
  flex: 1;
  min-width: 0;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  /* 16px keeps iOS Safari from auto-zooming the whole page on focus. */
  font-size: 16px;
}
.playlist-picker__select:focus { outline: none; border-color: var(--accent-a); }
.playlist-picker__select:disabled { opacity: 0.6; }

.track-list__empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 16px 10px;
  line-height: 1.5;
  text-align: center;
}

/* Track rows carry 5 controls, which no longer fit on one phone-width line
   next to a thumbnail. Two rows instead: identity on top, actions below. */
.track-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas:
    "cover meta remove"
    "actions actions actions";
  align-items: center;
  gap: 8px 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  min-width: 0;
}
.track-row img {
  grid-area: cover;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}
.track-row__meta {
  grid-area: meta;
  min-width: 0;
}
.track-row__title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row__sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row__actions {
  grid-area: actions;
  display: grid;
  /* minmax(0, 1fr), not bare 1fr: a `1fr` track's default minimum is
     content-based (`auto`), so it does NOT actually cap at a quarter of the
     row — it grows the track (and the whole grid) to fit its widest button.
     minmax(0, 1fr) is what makes "1fr" mean "at most this share". */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.track-row__actions button {
  /* Same accent-bordered look as the playback queue's pill buttons
     (Shuffle/Clear/Open) — an accent-colored border instead of the dim
     --border grey reads much more clearly here too. */
  border: 1px solid var(--accent-a);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 9px 4px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-row__actions button.load-a { color: var(--accent-a); border-color: var(--accent-a); }
.track-row__actions button.load-b { color: var(--accent-b); border-color: var(--accent-b); }
.track-row__remove {
  grid-area: remove;
  align-self: start;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 4px 6px;
}
.track-row__remove:hover { color: var(--danger); }

/* ---------- Settings view ---------- */
.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting:last-of-type { border-bottom: none; }
.setting__label {
  font-size: 13px;
  font-weight: 600;
}
.setting__control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.setting__control input[type="range"] { flex: 1; min-width: 0; }
.setting__control--tight { justify-content: flex-start; }
.setting__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
}
.setting__control input[type="number"] {
  width: 90px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  text-align: center;
}
.setting__control input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-a);
}
.setting__value {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  flex-shrink: 0;
}
.setting__link {
  margin-top: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}
.setting__link:hover { border-color: var(--accent-a); }

/* ---------- Account (login/register) ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-form input {
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 16px;
  outline: none;
}
.auth-form input:focus {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px var(--accent-a-glow);
}
.auth-form .pill-btn { align-self: flex-start; }
.auth-msg:empty { display: none; }
.auth-link-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
  margin-top: -4px;
}
.auth-link-btn:hover { color: var(--text); }

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
/* A hint immediately before or after an actions row — "Logged in as…"
   above the Log out/Manage users row, and the Sync buttons' explainer
   below theirs — both want more breathing room than the 4px base above. */
.setting__hint + .account-actions,
.account-actions + .setting__hint {
  margin-top: 10px;
}
/* Same idea, reversed — a lone pill-btn (e.g. Nextcloud's Disconnect)
   directly under its status text, e.g. "Connected to … as …". */
.setting__hint + .pill-btn {
  margin-top: 10px;
}
.account-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------- Manage users (admin) ---------- */
.users-list {
  list-style: none;
  margin: 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.users-list__empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 14px;
  text-align: center;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  min-width: 0;
}
.user-row__meta { min-width: 0; flex: 1; }
.user-row__email {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-row__sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-row--deleted { opacity: 0.55; }
.user-row .pill-btn { flex-shrink: 0; }
.user-row__count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-a);
  white-space: nowrap;
}

/* ---------- Standalone activation page (activate.php) ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
}
.auth-card {
  max-width: 360px;
  width: 100%;
}
.auth-card__logo {
  display: block;
  height: 28px;
  width: auto;
  margin: 0 auto 16px;
}
.auth-error { color: var(--danger); font-size: 13px; }
.auth-success { color: var(--text); font-size: 14px; line-height: 1.5; margin-bottom: 14px; }
.auth-card a.pill-btn { display: inline-block; text-decoration: none; }

.dep-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dep-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.dep-list__item.ok span { color: var(--accent-a); }
.dep-list__item.bad span { color: var(--danger); }

.about-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tabbar-height);
  min-width: 0;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 2px;
}
.tabbar__btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar__btn span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabbar__btn.active {
  color: var(--accent-a);
  border-top-color: var(--accent-a);
  background: linear-gradient(180deg, rgba(56,242,192,0.10), transparent 70%);
}

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  /* Clear of the tab bar, which is what the thumb is resting on. */
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--bg-raised-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  overflow-wrap: break-word; /* a long track title with no spaces (a URL-like
    token, etc.) must never be able to push this — or anything else —
    wider than its bounded container */
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-color: var(--danger); color: #ffd7d7; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Wider screens ----------
   The tab shell stays the single source of layout truth on every width — the
   Search/Playlist/Settings tabs just get a comfortable centered column and a
   little more breathing room, same layout as mobile, not a second one to
   maintain. Player is the one exception: side-by-side decks are how a mixer
   actually reads once there's room for them, so it alone switches to a grid
   and gets a wider column. Deck/button sizing is left as-is rather than
   scaled up — going wide is not the same as going big. */
@media (min-width: 700px) {
  .view { padding: 20px; gap: 18px; }
  .topbar__title { font-size: 18px; }
}

@media (min-width: 860px) {
  #view-player {
    max-width: 1080px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.7fr) minmax(0, 1fr);
    grid-template-areas:
      "deckA mixer deckB"
      "queue queue queue";
    align-items: start;
    gap: 18px;
  }
  #deck-a { grid-area: deckA; }
  .mixer-console { grid-area: mixer; }
  #deck-b { grid-area: deckB; }
  .queue-summary { grid-area: queue; }

  /* Side by side, each deck has its own column instead of the full view
     width — a 72px cover reads as small there, so drop the head back to a
     vertical layout (cover above title) rather than stretching the cover
     to fill the freed-up horizontal space. */
  .deck__head { flex-direction: column; align-items: stretch; }
  .deck__video-wrap { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .deck__meta { text-align: center; }
}
