/* MONKbot radio: near-black player, one electric purple. The artwork's own colour washes the top of the player. */
@property --tint {
  syntax: "<color>";
  inherits: true;
  initial-value: #3b2a5c;
}

:root {
  --bg: #121212;
  --surface: #181818;
  --elevated: #282828;
  --hover: #1f1f1f;
  --press: #2a2a2a;
  --line: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --muted: #a7a7a7;
  --faint: #6a6a6a;
  --brand: #8b46ff;          /* fills: white on it is 4.7:1 */
  --brand-hover: #9a5cff;
  --brand-text: #bb8fff;     /* purple text or icons on near-black: 7:1 */
  --danger: #f15e6c;
  --danger-text: #ff8a94;

  --font: -apple-system, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Inter, "Helvetica Neue", sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --top-h: 56px;
  --tab-h: 60px;
  --mini-h: 56px;
  --ease: cubic-bezier(0.3, 0.7, 0.2, 1);

  --tint: #3b2a5c;
  transition: --tint 900ms ease;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
button:disabled { cursor: default; }
svg { display: block; fill: currentColor; }
img { display: block; }
h1, h2, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 6px; }

/* ---------- Brand tile: the cowl glyph on purple ---------- */
.tile {
  display: inline-block;
  flex: none;
  width: 28px; height: 28px;
  border-radius: 22%;
  background: var(--brand);
  color: #fff;
  overflow: hidden;
}
.tile svg { width: 100%; height: 100%; }
.tile-sm { width: 28px; height: 28px; }
.tile-xl { width: 112px; height: 112px; box-shadow: 0 18px 50px rgba(139, 70, 255, 0.35); }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px;
  border-radius: 999px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.005em;
  text-decoration: none; color: var(--text);
  transition: transform 120ms var(--ease), background-color 150ms, border-color 150ms;
}
.pill:active { transform: scale(0.97); }
.pill-brand { background: var(--brand); color: #fff; }
.pill-brand:hover { background: var(--brand-hover); }
.pill-light { background: #fff; color: #121212; }
.pill-light:hover { background: #ececec; }
.pill-outline { border: 1px solid rgba(255, 255, 255, 0.4); }
.pill-outline:hover { border-color: #fff; }
.pill-ghost { color: var(--text); }
.pill-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.pill-danger { background: var(--danger); color: #1a0306; }
.pill-danger:hover { background: #f47784; }
.pill-lg { min-height: 52px; padding: 0 34px; font-size: 16px; }

/* ---------- Boot ---------- */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
}
.mark-boot { width: 72px; height: 72px; animation: breathe 1.4s var(--ease) infinite alternate; }
@keyframes breathe { from { opacity: 0.35; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b));
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139, 70, 255, 0.55), rgba(139, 70, 255, 0) 70%),
    var(--bg);
}
.login-inner { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 340px; }
.login-title { margin-top: 28px; font-size: 34px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; }
.login-copy { margin: 12px 0 32px; color: var(--muted); font-size: 16px; }

/* ---------- App frame ---------- */
.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 24px);
}
.app.has-mini { padding-bottom: calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 32px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) calc(12px + var(--safe-r)) 0 calc(16px + var(--safe-l));
  transition: background-color 200ms;
}
.topbar.is-solid { background: color-mix(in srgb, var(--tint) 45%, var(--bg)); }
.app[data-view="search"] .topbar { background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 4px; }

.conn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 12px; font-weight: 600; color: #ffd38a;
  white-space: nowrap;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: #ffb547; animation: blink 1.2s infinite alternate; }
@keyframes blink { from { opacity: 0.3; } to { opacity: 1; } }

.avatar-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.avatar {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #5b3a91; color: #fff;
  font-size: 14px; font-weight: 800;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.3);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-btn:hover .avatar { transform: scale(1.05); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 50px; z-index: 30;
  min-width: 232px; padding: 4px;
  background: var(--elevated);
  border-radius: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: pop 140ms var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.menu-user img { width: 28px; height: 28px; border-radius: 50%; }
.menu-item {
  display: block; width: 100%; min-height: 44px; padding: 0 12px;
  text-align: left; font-size: 15px; font-weight: 500;
  border-radius: 3px;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(255, 255, 255, 0.1); }
.menu-item.danger { color: var(--danger-text); }

/* ---------- Now playing ---------- */
.now {
  position: relative;
  margin-top: calc(-1 * (var(--top-h) + var(--safe-t)));
  padding: calc(var(--top-h) + var(--safe-t) + 4px) calc(24px + var(--safe-r)) 28px calc(24px + var(--safe-l));
  background: linear-gradient(180deg, #3b2a5c 0%, var(--bg) 100%);
  background: linear-gradient(180deg,
    var(--tint) 0%,
    color-mix(in srgb, var(--tint) 55%, var(--bg)) 45%,
    var(--bg) 100%);
}
.now-inner { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: center;
  max-width: 100%;
  height: 32px; padding: 0 14px 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 13px; font-weight: 600;
  margin-bottom: 18px;
}
.chip svg { width: 16px; height: 16px; flex: none; color: var(--brand-text); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.art {
  position: relative;
  width: 100%;
  max-width: min(100%, 52dvh);
  align-self: center;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--elevated);
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade 300ms ease; }
.art img.is-lb, .thumb img.is-lb { transform: scale(1.34); }
@keyframes fade { from { opacity: 0; } }
.art-placeholder { position: absolute; inset: 0; color: #3a3a3a; }
/* The cowl rises from the bottom edge, like a bust. */
.art-placeholder svg { position: absolute; bottom: 0; left: 50%; translate: -50% 0; width: 58%; height: 58%; }
.now.is-idle .art-placeholder { color: #353535; }

.now-meta { margin-top: 24px; min-width: 0; }
.now-title {
  font-size: 24px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.18;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.now-sub { margin-top: 4px; color: rgba(255, 255, 255, 0.7); font-size: 15px; }
.now.is-idle .now-meta { text-align: center; }
.now.is-idle .now-sub { max-width: 30ch; margin-inline: auto; }
.now-cta { align-self: center; margin-top: 24px; }

.progress { margin-top: 18px; }
.bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.24); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: #fff; border-radius: inherit; transition: width 500ms linear; }
.progress.is-paused .bar-fill { background: rgba(255, 255, 255, 0.7); }
.times {
  display: flex; justify-content: space-between;
  margin-top: 8px;
  font-size: 12px; color: rgba(255, 255, 255, 0.65);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex; align-items: center; justify-content: center; gap: 28px;
  margin-top: 10px;
}
.ctl {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.85);
  transition: color 150ms, transform 120ms var(--ease);
}
.ctl svg { width: 28px; height: 28px; }
#stop-ctl svg { width: 22px; height: 22px; }
.ctl:hover:not(:disabled) { color: #fff; transform: scale(1.06); }
.ctl:active:not(:disabled) { transform: scale(0.92); }
.ctl:disabled { color: rgba(255, 255, 255, 0.3); }

.play-btn {
  width: 68px; height: 68px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 120ms var(--ease), background-color 150ms;
}
.play-btn svg { width: 30px; height: 30px; }
.play-btn:hover:not(:disabled) { background: var(--brand-hover); transform: scale(1.05); }
.play-btn:active:not(:disabled) { transform: scale(0.94); }
.play-btn:disabled { background: #4a3a63; color: rgba(255, 255, 255, 0.5); box-shadow: none; }
.play-btn .i-play, .mini-play .i-play { display: none; }
.play-btn.is-paused .i-play, .mini-play.is-paused .i-play { display: block; }
.play-btn.is-paused .i-pause, .mini-play.is-paused .i-pause { display: none; }

/* ---------- Section heads ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 4px 10px;
}
.section-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.025em; }
.queue-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.queue-count.is-full { color: var(--danger-text); font-weight: 600; }

/* ---------- Queue ---------- */
.side { min-width: 0; }
.queue { padding: 8px calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l)); }
/* Leave room for the Queue tab to bring "Next up" to the top even when the list is short. */
@media (max-width: 899.98px) {
  .queue { min-height: calc(100dvh - var(--top-h) - var(--safe-t) - var(--tab-h) - var(--safe-b) - 40px); }
}

.row { position: relative; border-radius: 6px; overflow: hidden; }
.row-behind {
  position: absolute; inset: 0;
  display: none; justify-content: flex-end;
  background: var(--danger);
  border-radius: 6px;
}
.row.show-behind .row-behind { display: flex; }
.row-behind button { width: 92px; height: 100%; color: #1a0306; font-weight: 700; font-size: 14px; }

.row-main, .result {
  position: relative;
  display: grid; align-items: center;
  grid-template-columns: 48px minmax(0, 1fr) 44px 44px;
  column-gap: 12px;
  min-height: 64px;
  padding: 8px 0 8px 8px;
  border-radius: 6px;
  background: var(--bg);
  transition: transform 240ms var(--ease), background-color 120ms;
  touch-action: pan-y;
}
.row-main.is-swiping { transition: none; }
.row-main:hover { background: var(--hover); }
.row-main:active { background: var(--press); }

.thumb {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--elevated);
  display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-glyph { position: absolute; bottom: 0; left: 50%; translate: -50% 0; width: 72%; height: 72%; color: #444; }

.row-text { min-width: 0; }
.row-title {
  font-size: 15px; font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px; min-width: 0;
  font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.row-sub > * { flex: none; }
.row-sub .who, .row-sub .chan { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-sub > * + *::before { content: "•"; margin-right: 6px; color: var(--faint); }
.row-sub .dur { font-variant-numeric: tabular-nums; }

/* Requester avatar */
.who { display: inline-flex; align-items: center; gap: 6px; }
.row-sub .who { flex: 0 0 auto; max-width: 55%; }
.row-sub .status { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.who-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av {
  position: relative; flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center;
  overflow: hidden;
  background: #5b3a91; color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1;
}
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.now-sub.has-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.now-sub .av { width: 24px; height: 24px; font-size: 12px; }
.now.is-idle .now-sub.has-who { justify-content: center; }
.mini-sub { display: flex; align-items: center; gap: 5px; }
.mini-sub .av { width: 16px; height: 16px; font-size: 9px; }
.row-err {
  margin-top: 2px;
  font-size: 12px; color: var(--danger-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.status .spinner { flex: none; }
.status-dl { color: var(--brand-text); }
.status-failed { color: var(--danger-text); }
.spinner {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row.is-downloading .thumb img { opacity: 0.5; }
.row.is-downloading .row-title { color: rgba(255, 255, 255, 0.75); }
.row.is-failed .thumb { opacity: 0.45; }
.row.is-failed .row-title { color: var(--muted); }

.row-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: color 120ms;
}
.row-btn svg { width: 20px; height: 20px; }
.remove-btn svg { width: 18px; height: 18px; }
.row-btn:hover { color: #fff; }
.handle { cursor: grab; touch-action: none; }
.handle:active { cursor: grabbing; }

/* Sortable states */
.drag-ghost { opacity: 0.25; }
.drag-ghost .row-main { background: var(--elevated); }
.drag-chosen .row-main { background: var(--elevated); }
.drag-active {
  opacity: 1 !important;
  border-radius: 6px;
  background: var(--elevated);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
}
.drag-active .row-main { background: var(--elevated); }

/* When the player is idle its own "Find a song" button already covers this. */
.now.is-idle ~ .side .queue-empty .pill { display: none; }
.queue-empty {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 28px 16px 12px;
  text-align: center; color: var(--muted); font-size: 15px;
}

/* ---------- Search ---------- */
.search { padding: 0 calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l)); }
.search-top {
  position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 5;
  padding: 4px 0 12px;
  background: var(--bg);
}
.search-title { font-size: 30px; font-weight: 800; letter-spacing: -0.035em; margin-bottom: 14px; }
.search-form { position: relative; }
.search-icon {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 22px; height: 22px; color: #121212; pointer-events: none;
}
.search-input {
  width: 100%; height: 48px;
  padding: 0 16px 0 46px;
  border: 0; border-radius: 8px;
  background: #fff; color: #121212;
  font: 600 16px var(--font);
  -webkit-appearance: none; appearance: none;
}
.search-input::placeholder { color: #5f5f5f; font-weight: 500; }
.search-input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.search-input::-webkit-search-cancel-button { filter: grayscale(1); }

.search-status { color: var(--muted); font-size: 14px; padding: 4px 4px 8px; }
.search-status:empty { display: none; }
.search-idle { text-align: center; padding: 56px 16px 24px; }
.search-idle-title { color: var(--text); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }

.results { margin: 0 -8px; }
.result { grid-template-columns: 48px minmax(0, 1fr) 48px; padding-right: 4px; animation: fade 200ms ease both; }
.result:hover { background: var(--hover); }
.result-link .row-title { font-weight: 700; }
.thumb-link { background: var(--brand); color: #fff; }
.thumb-link svg { width: 24px; height: 24px; }

.add-btn {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: color 120ms, transform 120ms var(--ease);
}
.add-btn svg { width: 26px; height: 26px; }
.add-btn:hover:not(:disabled) { color: #fff; transform: scale(1.06); }
.add-btn:active:not(:disabled) { transform: scale(0.9); }
.add-btn:disabled:not(.is-added) { opacity: 0.5; }
.add-btn.is-added { color: var(--brand-text); animation: pop 200ms var(--ease); }

/* ---------- Mini player ---------- */
.mini {
  position: fixed; z-index: 25;
  left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r));
  bottom: calc(var(--tab-h) + var(--safe-b) + 4px);
  height: var(--mini-h);
  display: flex; align-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: #2a1f3d;
  background: color-mix(in srgb, var(--tint) 62%, #000);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: rise 220ms var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.mini-line { position: absolute; left: 8px; right: 8px; top: 0; height: 2px; background: rgba(255, 255, 255, 0.2); border-radius: 1px; overflow: hidden; }
.mini-fill { height: 100%; width: 0; background: #fff; transition: width 500ms linear; }
.mini-open {
  flex: 1; min-width: 0; height: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px 0 8px;
  text-align: left;
}
.mini-thumb { width: 40px; height: 40px; flex: none; }
.mini-text { min-width: 0; display: flex; flex-direction: column; }
.mini-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: rgba(255, 255, 255, 0.7); white-space: nowrap; overflow: hidden; min-width: 0; }
.mini-play { width: 52px; height: 100%; flex: none; display: grid; place-items: center; }
.mini-play svg { width: 24px; height: 24px; }
.mini-play:active { transform: scale(0.9); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 24; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b) + 28px);
  padding: 28px var(--safe-r) var(--safe-b) var(--safe-l);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0.82) 30px, #000 100%);
  pointer-events: none;
}
.tab {
  pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px;
  color: var(--muted);
  font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
  transition: color 150ms;
}
.tab svg { width: 24px; height: 24px; transition: transform 160ms var(--ease); }
.tab:active svg { transform: scale(0.88); }
.tab[aria-current="page"] { color: #fff; font-weight: 700; }
.tab[aria-current="page"] svg { color: var(--brand-text); }
.tab:focus-visible { outline-offset: -4px; border-radius: 10px; }

.seg { display: none; }

/* ---------- Confirm ---------- */
.confirm {
  width: min(92vw, 400px);
  padding: 0; border: 0; border-radius: 12px;
  background: var(--elevated); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.confirm::backdrop { background: rgba(0, 0, 0, 0.7); }
.confirm[open] { animation: pop 180ms var(--ease); }
.confirm-inner { padding: 24px; }
.confirm h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.confirm p { margin-top: 8px; color: var(--muted); font-size: 15px; }
.confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 40;
  left: 50%; translate: -50% 0;
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: min(calc(100vw - 24px), 420px);
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  pointer-events: none;
}
.app.has-mini ~ .toasts { bottom: calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 16px); }
.toast {
  padding: 12px 16px;
  border-radius: 8px;
  background: #f3effa; color: #121212;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: rise 220ms var(--ease);
  transition: opacity 250ms, transform 250ms;
  overflow-wrap: anywhere;
}
.toast.is-error { background: var(--danger); color: #1a0306; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }

/* ---------- Phone: search replaces home ---------- */
@media (max-width: 899.98px) {
  .app[data-view="search"] .now { display: none; }
}

/* ---------- Short phones: keep the controls on screen ---------- */
@media (max-width: 899.98px) and (max-height: 700px) {
  .art { max-width: min(100%, 44dvh); }
  .now-meta { margin-top: 16px; }
  .now-title { font-size: 21px; }
}

/* ---------- Desktop: player left, queue or search right ---------- */
@media (min-width: 900px) {
  body { background: #000; }
  .app { padding: 0 8px 8px; }
  .app.has-mini { padding-bottom: 8px; }
  .topbar { background: #000 !important; padding: 0 8px 0 12px; height: 64px; }
  .tabbar, .mini { display: none !important; }
  .toasts, .app.has-mini ~ .toasts { bottom: 24px; }

  .layout {
    display: grid;
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    gap: 8px;
    max-width: 1400px; margin: 0 auto;
    align-items: start;
  }
  .now {
    position: sticky; top: 64px;
    margin: 0;
    min-height: calc(100dvh - 72px);
    padding: 28px 32px;
    border-radius: 8px;
    display: flex; align-items: center;
  }
  .now-inner { width: 100%; }
  .art { max-width: min(100%, 50dvh); }
  .now-title { font-size: 28px; }

  .side {
    min-height: calc(100dvh - 72px);
    border-radius: 8px;
    background: var(--bg);
    padding: 16px 16px 24px;
  }
  .seg { display: flex; gap: 8px; padding: 0 4px 20px; }
  .seg-btn {
    min-height: 44px; padding: 0 20px;
    border-radius: 999px;
    background: var(--elevated);
    font-size: 14px; font-weight: 600;
    transition: background-color 150ms;
  }
  .seg-btn:hover { background: #333; }
  .seg-btn[aria-current="page"] { background: var(--brand); color: #fff; }
  .queue, .search { padding: 0; }
  .search-top { top: 64px; padding-top: 0; }
  .search-title { display: none; }
  .search-input { max-width: 520px; }
  .results { max-width: 760px; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { animation: none; border-right-color: currentColor; opacity: 0.6; }
}
