:root {
  /* Dark is the default so a phone in a dim room is not flashed. Light follows
     prefers-color-scheme unless data-theme forces it. */
  --bg: #0b0f17;
  --surface: #131927;
  --surface-2: #1a2235;
  --border: #25304a;
  --text: #e6ecf6;
  --text-muted: #94a3c4;
  --accent: #7c9cff;
  --accent-strong: #a5beff;
  --good: #4ade80;
  --warn: #f5c14b;
  --bad: #f87171;
  --on-fill: #0b0f17;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --tip-delay: 500ms;
}

/* CSS cannot share one declaration block between a media query and an attribute
   selector, so the light palette appears in both rules below. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef2fb;
    --border: #d6def0;
    --text: #15203a;
    --text-muted: #475573;
    --accent: #3955c8;
    --accent-strong: #2a3fa1;
    --good: #13703c;
    --warn: #855c00;
    --bad: #c43b3b;
    --on-fill: #ffffff;
    --shadow: 0 6px 16px rgba(30, 40, 70, 0.08);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2fb;
  --border: #d6def0;
  --text: #15203a;
  --text-muted: #475573;
  --accent: #3955c8;
  --accent-strong: #2a3fa1;
  --good: #13703c;
  --warn: #855c00;
  --bad: #c43b3b;
  --on-fill: #ffffff;
  --shadow: 0 6px 16px rgba(30, 40, 70, 0.08);
}

:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

/* The UA [hidden] rule only matches the HTML namespace, so inline SVGs need their own. */
svg[hidden] { display: none; }

/* Hidden from sight but still read by screen readers and still focusable. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The wake-lock fallback video stays laid out but invisible, since a video the layout drops
   no longer counts as playing video. */
.wake-video {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  min-height: 100svh;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

main {
  width: 100%;
  max-width: 760px;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  width: 100%;
  max-width: 760px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
  border-radius: var(--radius-sm);
  transition: color 150ms;
}
.title-link:hover .title { color: var(--accent); }
.title-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  transition: color 150ms;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.conn-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--warn);
  transition: background 200ms;
  box-shadow: 0 0 0 0 currentColor;
}

.conn[data-state="connected"] .conn-dot { background: var(--good); }
.conn[data-state="connecting"] .conn-dot {
  background: var(--warn);
  animation: pulse 1.4s ease-in-out infinite;
}
.conn[data-state="disconnected"] .conn-dot,
.conn[data-state="evicted"] .conn-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
.conn-label { font-variant-numeric: tabular-nums; }
.conn[data-state="connected"] .conn-label { color: var(--good); }
.conn[data-state="connecting"] .conn-label { color: var(--warn); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.ghost-btn:not(:disabled):hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.ghost-btn:active { transform: translateY(1px); }
.ghost-btn.small { padding: 4px; min-width: 0; }
.ghost-btn[hidden] { display: none; }
.ghost-btn:disabled { opacity: 0.4; cursor: default; }

/* With all five buttons shown, the full-size top bar needs about 540px on one line.
   The connection label is clipped, not removed, so screen readers still hear the live region. */
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .title { font-size: 0.85rem; letter-spacing: 0; white-space: nowrap; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .ghost-btn { padding: 4px; min-width: 32px; min-height: 32px; }
  .conn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* A tip grows rightward from its element's left edge, so on a 360px screen it fits only on
   left-half elements. */
[data-tip] { position: relative; }
/* The top-bar buttons sit at the right edge, so their tips grow leftward. */
.topbar [data-tip]::after { left: auto; right: 0; }
/* The clear button ends the queue header, where a rightward tip would scroll a phone sideways. */
#clear-queue[data-tip]::after { left: auto; right: 0; }
/* The output button ends the volume row, where a rightward tip would scroll a phone sideways. */
#btn-audio-device[data-tip]::after { left: auto; right: 0; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 3;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms, visibility 0s 120ms;
}
/* The delay shows the tip only on a deliberate hover. Touch screens get none,
   because a tap would leave a sticky :hover behind. */
@media (hover: hover) {
  [data-tip]:hover::after {
    opacity: 1;
    visibility: visible;
    transition: opacity 120ms var(--tip-delay), visibility 0s var(--tip-delay);
  }
}
/* A mode-toggle label never takes focus itself, so its tip follows the focused radio. */
[data-tip]:focus-visible::after,
.mode-toggle input:focus-visible + [data-tip]::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 120ms var(--tip-delay), visibility 0s var(--tip-delay);
}

.now-playing-card {
  --card-padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--card-padding);
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 16px;
  align-items: center;
}

@media (max-width: 480px) {
  .now-playing-card {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
}

/* fit-content keeps the info column only as wide as its text, so the visualizer gets the rest. */
.now-playing-card.has-visualizer {
  grid-template-columns: minmax(120px, 160px) fit-content(45%) minmax(0, 1fr);
}

.visualizer {
  position: relative;
  align-self: stretch;
  min-height: 120px;
  margin: calc(-1 * var(--card-padding)) calc(-1 * var(--card-padding)) calc(-1 * var(--card-padding)) 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.visualizer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.visualizer:focus {
  outline: none;
}

/* The visualizer reaches the card's edge, so its outline and its tip sit inside it. */
.visualizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.visualizer[data-tip]::after {
  top: auto;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.visualizer.naming-mode::after {
  opacity: 1;
  visibility: visible;
  transition: none;
}

@media (max-width: 480px) {
  .now-playing-card.has-visualizer {
    grid-template-columns: 1fr;
  }

  .visualizer {
    justify-self: stretch;
    min-height: 72px;
    height: 72px;
    margin: 0 calc(-1 * var(--card-padding)) calc(-1 * var(--card-padding));
  }
}

.cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 200px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--surface-2), var(--accent));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  position: relative;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  width: 40%;
  height: 40%;
  opacity: 0.6;
}

.cover.has-art .cover-placeholder { display: none; }

.track-info {
  min-width: 0; /* A grid item's automatic minimum would grow to fit the no-wrap text. */
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.badge[data-state="playing"] { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge[data-state="paused"]  { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge[data-state="radio"]   { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge[data-state="idle"]    { background: var(--surface-2); color: var(--text-muted); }

.track-title {
  margin: 0 0 4px 0;
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.track-artist, .track-album, .queue-pos {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-album { font-size: 0.88rem; opacity: 0.9; }
.queue-pos { margin-top: 6px; font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.progress-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px 18px 10px;
  box-shadow: var(--shadow);
}

.progress-row { width: 100%; }

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sliders shared by the seek bar and the volume control */
.slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}

.slider:disabled { cursor: default; opacity: 0.5; }

.slider::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--progress, 0%),
    var(--surface-2) var(--progress, 0%),
    var(--surface-2) 100%
  );
  border-radius: 999px;
}
.slider::-moz-range-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
}
.slider::-moz-range-progress {
  background: var(--accent);
  height: 6px;
  border-radius: 999px;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  background: var(--accent-strong);
  border-radius: 50%;
  border: 0;
  margin-top: -6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 100ms;
}
.slider::-moz-range-thumb {
  height: 18px;
  width: 18px;
  background: var(--accent-strong);
  border-radius: 50%;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.slider:hover::-webkit-slider-thumb,
.slider:active::-webkit-slider-thumb { transform: scale(1.15); }

.transport {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  padding: 6px 0;
}

.transport-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 100ms, background 150ms, border-color 150ms;
}

.transport-btn svg {
  width: 28px; height: 28px;
}

.transport-btn:not(:disabled):hover { background: var(--surface-2); border-color: var(--accent); }
.transport-btn:active { transform: scale(0.94); }
.transport-btn:disabled { opacity: 0.4; cursor: default; }

.play-btn {
  background: var(--accent);
  color: var(--on-fill);
  border-color: var(--accent);
  width: 72px;
  height: 72px;
}
.play-btn:not(:disabled):hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.play-btn svg { width: 36px; height: 36px; }
.play-btn svg path { fill: var(--on-fill); }

/* The one action-result notice (messages.js). It hangs from the top edge over the page or the open
   dialog, so no layout reserves space for it. The z-index lifts it over the header and the lyrics view. */
.notice {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 760px;
  max-height: 50dvh;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  line-height: 1.4;
  animation: notice-in 150ms ease-out;
}
.notice[hidden] { display: none; }
/* messages.js hides the notice when this fade ends (FADE_MS). */
.notice[data-leaving] { opacity: 0; transition: opacity 150ms; }
.notice[data-tone="warning"] { border: 1px solid var(--warn); border-top: 0; }
.notice[data-tone="error"] { border: 1px solid var(--bad); border-top: 0; }
/* The text scrolls inside the notice, so a long server text never covers the entire screen. */
.notice-text {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  margin: 0;
  padding-block: 2px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}
.notice[data-tone="success"] {
  --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z'/%3E%3C/svg%3E");
  --notice-icon-color: var(--good);
}
.notice[data-tone="warning"],
.notice[data-tone="error"] {
  --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240Zm40 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Z'/%3E%3C/svg%3E");
  --notice-icon-color: var(--warn);
}
.notice[data-tone="error"] { --notice-icon-color: var(--bad); }
.notice[data-tone="error"] .notice-text { color: var(--bad); }
/* The icon is a mask over the tone color, so one SVG serves both themes and the text stays the notice's only content. */
.notice[data-tone="success"] .notice-text::before,
.notice[data-tone="warning"] .notice-text::before,
.notice[data-tone="error"] .notice-text::before {
  content: '';
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.35em;
  vertical-align: -0.22em;
  background-color: var(--notice-icon-color);
  -webkit-mask: var(--notice-icon) center / contain no-repeat;
  mask: var(--notice-icon) center / contain no-repeat;
}
@keyframes notice-in { from { transform: translateY(-100%); } }
/* messages.js marks a dialog form busy while its save runs, so a second submit cannot start. */
form[aria-busy="true"] { opacity: 0.6; transition: opacity 150ms; }
/* The minimum width fits the longest label, Saving… or Saved, so the row stays still while the label changes. */
.save-btn { min-width: 7rem; }
@media (prefers-reduced-motion: reduce) {
  .notice { animation: none; }
  .notice[data-leaving],
  form[aria-busy="true"] { transition: none; }
}

/* An empty line leaves the flex flow so it adds no gap. It stays in the accessibility tree,
   so the live region still announces the next message. */
[aria-live]:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.output-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.output-banner[hidden] { display: none; }
.output-banner-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--bad);
}
.output-banner-btn { flex: none; }

.lyrics-transport .output-banner { box-shadow: none; padding: 6px 0; background: transparent; }

.volume-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

.volume-icon {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 6px;
  cursor: pointer;
  display: inline-flex;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
}
.volume-icon:hover { color: var(--text); }
.volume-icon.is-lost,
.volume-icon.is-lost:hover { color: var(--bad); }
.volume-icon svg { width: 22px; height: 22px; }

.volume-slider { flex: 1; }

.volume-label {
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.queue {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 12px 6px 14px;
  box-shadow: var(--shadow);
}

.queue-header {
  padding: 0 14px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.queue-header #clear-queue { margin-left: auto; }

.queue-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.queue-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  padding: 1px 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50svh;
  overflow-y: auto;
}

.queue-list li { border-top: 1px solid var(--border); }

/* The remove button sits beside the row, since a button cannot hold another button. */
.queue-list li.qitem { display: flex; align-items: center; }

.queue-list li:first-child { border-top: 0; }

.queue-list .qrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.queue-list .qrow:hover { background: var(--surface-2); color: var(--text); }

.queue-list .qrow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.queue-list li.current .qrow {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent);
  color: var(--text);
  /* The current row does nothing on click, so it keeps the default cursor. */
  cursor: default;
}

.queue-list li.current .qrow:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
}

.queue-list .qnum {
  flex: 0 0 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.queue-list .qmain {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.queue-list .qtitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.queue-list .qartist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.queue-list .qdur {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.queue-list .qicon {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  color: var(--accent);
  visibility: hidden;
}
.queue-list .qicon svg { display: block; width: 100%; height: 100%; }
.queue-list li.current .qicon { visibility: visible; }

.queue-list .qremove { flex: none; margin-right: 10px; padding: 4px; }
.queue-list .qremove-icon { width: 18px; height: 18px; }

.queue-list .empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 0;
}

.modal {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: min(440px, 90vw);
  width: 100%;
}

.modal::backdrop,
.lyrics-backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -6px -8px -6px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.modal-close[hidden] { display: none; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-close svg { width: 22px; height: 22px; }

.modal-help, .modal-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.modal-hint { font-size: 0.82rem; }

.network-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

.network-list li {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.network-list .iface {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.network-list a {
  color: var(--accent);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  word-break: break-all;
}
.network-list a:hover { text-decoration: underline; }

.audio-device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* .btn-secondary comes later and sets its own display, so the pair outranks it. */
.btn-secondary.audio-device-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.audio-device-note {
  flex: none;
  font-size: 0.78rem;
  color: var(--bad);
}

.primary-btn {
  background: var(--accent);
  color: var(--on-fill);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 40px;
}
.primary-btn:hover { background: var(--accent-strong); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border, var(--surface-2));
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 40px;
}
.btn-secondary:not(:disabled):hover { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: default; }
.btn-secondary.danger:not(:disabled):hover { color: var(--on-fill); background: var(--bad); border-color: var(--bad); }
.primary-btn,
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary-btn[hidden],
.btn-secondary[hidden] { display: none; }
.primary-btn svg,
.btn-secondary svg { flex: none; width: 18px; height: 18px; }
.primary-btn.danger { background: var(--bad); }
.primary-btn.danger:not(:disabled):hover { filter: brightness(1.1); }
.btn-secondary.small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; gap: 6px; }
.btn-secondary.small svg { width: 16px; height: 16px; }
/* Equal tiles with the icon over the label, so a row of actions fits one line even at phone width. */
.action-tiles { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.action-tiles .btn-secondary { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: 0.82rem; line-height: 1.2; text-align: center; }
.action-tiles .btn-secondary svg { width: 20px; height: 20px; }
/* Settings modal checkbox rows */
.modal-content label.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.92rem;
  cursor: pointer;
}
.modal-content label.check input { margin-top: 3px; accent-color: var(--accent); }
/* :not([hidden]) keeps this display from overriding the hidden attribute on a conditional hint. */
.modal-content label.check .modal-hint:not([hidden]) { display: block; margin-top: 2px; }

.settings-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.settings-group[hidden] { display: none; }
.settings-group + .settings-group { margin-top: 10px; }
.settings-heading { padding: 0; }
.theme-toggle { justify-self: start; }

/* A mode with a login shows only the login card until an admin session exists. */
body.login-required main,
body.login-required .topbar-actions { display: none; }
.login-view {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 32px 16px;
}
.login-view[hidden],
.login-card [hidden] { display: none; }
.login-card {
  width: min(440px, 100%);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.login-card h2 {
  margin: 0;
  font-size: 1.1rem;
}
.login-status {
  margin: 0;
  color: var(--bad);
  font-size: 0.88rem;
}
.login-status:empty { display: none; }

body.player-stopped main,
body.player-stopped .topbar-actions .ghost-btn,
body.stream-evicted main { opacity: 0.45; }
body.player-stopped::after,
body.stream-evicted::after {
  display: block;
  position: fixed;
  inset: auto 0 0 0;
  padding: 12px 16px;
  text-align: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.9rem;
}
body.player-stopped::after {
  content: 'Player stopped. Run navidrome-mcp jukebox again or restart the MCP server to use it again.';
}
/* The connection label is hidden at phone width, so this bar names the cause. It sits above the lyrics overlay. */
body.stream-evicted::after {
  content: 'This page closed because it is open in other tabs or windows on this device. Reload it to use it here.';
  z-index: 30;
}

/* One row that scrolls sideways, so the tabs never wrap on a narrow phone. */
.modal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border, var(--surface-2));
  overflow-x: auto;
}
.modal-tab {
  flex: none;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 40px;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.modal-pane[hidden] { display: none; }

/* Long lists take the full height below the top bar (--modal-top), in dvh so a collapsing URL bar
   keeps the bottom on screen. The 760px cap matches the player column. */
.modal.modal-full,
.lyrics-view.is-window {
  --modal-gutter: 16px;
  width: calc(100% - 2 * var(--modal-gutter));
  max-width: 760px;
  max-height: none;
  height: calc(100dvh - var(--modal-top, 0px) - var(--modal-gutter));
  margin: var(--modal-top, 0px) auto auto;
}
.modal-full .modal-content { height: 100%; }
.modal-full .modal-header,
.modal-full .modal-tabs,
.modal-full .play-toolbar { flex: none; }
/* Only the active pane scrolls, so the header, tabs and toolbar stay put. */
.modal-full .modal-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

@media (max-width: 480px) {
  .modal.modal-full,
  .lyrics-view.is-window {
    --modal-gutter: 8px;
    border-radius: var(--radius-md);
  }
  .modal-full .modal-content { padding: 14px 12px; }
}

/* :not([hidden]) keeps `.modal-pane[hidden]` in charge of hiding the pane. */
#play-pane-search:not([hidden]),
#play-pane-playlists:not([hidden]),
#play-pane-favorites:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Only the lists scroll, so the search row, captions and status lines stay pinned. */
#lib-results,
#playlists-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
#lib-caption { overflow-wrap: anywhere; }

.lib-search {
  display: flex;
  gap: 8px;
}
/* 1rem keeps iOS from zooming the page when the field takes focus. */
.lib-search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.lib-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
}
.lib-search .primary-btn { flex: none; }

/* The eye button sits inside the field, so the field leaves room for it. */
.reveal {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}
.reveal input { padding-right: 44px; }
.reveal-btn {
  position: absolute;
  inset: 0 0 0 auto;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.reveal-btn:hover { color: var(--text); }
.reveal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }

/* Sits above the panes, so every tab plays with one queue mode and one pair of shuffle settings. */
.play-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* The labels act as the buttons, so the native radios keep arrow-key selection and change
   events. */
.mode-toggle {
  position: relative;
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
}
.mode-toggle-btn,
.shuffle-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 40px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.mode-toggle-btn:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.mode-toggle-btn:not(:first-of-type) { margin-left: -1px; }
.mode-toggle-btn:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.theme-toggle .mode-toggle-btn,
.text-toggle .mode-toggle-btn {
  width: auto;
  min-width: 76px;
  padding: 0 14px;
  font-size: 0.9rem;
}
.shuffle-toggle {
  padding: 0;
  border-radius: var(--radius-sm);
}
.mode-toggle-btn svg,
.shuffle-toggle svg { width: 22px; height: 22px; }
.mode-toggle-btn:hover,
.shuffle-toggle:hover { color: var(--text); background: var(--surface-2); }
.mode-toggle input:disabled + .mode-toggle-btn { opacity: 0.4; pointer-events: none; }
/* z-index lifts the selected button so its accent border draws over the shared edge. */
.mode-toggle input:checked + .mode-toggle-btn,
.shuffle-toggle[aria-pressed="true"],
.audio-device-btn[aria-pressed="true"] {
  z-index: 1;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent-strong);
}
.mode-toggle input:focus-visible + .mode-toggle-btn,
.shuffle-toggle:focus-visible {
  z-index: 2;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lib-group + .lib-group { margin-top: 14px; }
.lib-group-title,
.settings-heading {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 4px 6px 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.lib-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lib-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lib-name, .lib-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-name { font-size: 0.95rem; font-weight: 600; }
.lib-meta { font-size: 0.78rem; color: var(--text-muted); }

.lib-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface);
}
/* The child combinator keeps an artist's nested album covers square. */
.lib-node[data-kind="artist"] > .lib-row .lib-thumb { border-radius: 50%; }
.lib-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.lib-thumb-glyph { width: 20px; height: 20px; opacity: 0.6; }

.lib-action,
.lib-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
}
.lib-action svg,
.lib-toggle svg { width: 22px; height: 22px; }
.lib-icon-play { display: none; }
#play-dialog[data-mode="replace"] .lib-icon-add { display: none; }
#play-dialog[data-mode="replace"] .lib-icon-play { display: block; }

.lib-toggle svg { transition: transform 150ms ease; }
.lib-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.lib-node:is([data-kind="artist"], [data-kind="album"]) > .lib-row > .lib-main { cursor: pointer; }
.lib-node.is-expanded > .lib-row {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  box-shadow: inset 3px 0 0 var(--accent);
}
.lib-children {
  list-style: none;
  margin: 4px 0 0 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  /* Mixed into --surface-2, since the same tint over the dialog surface comes out close to the
     rows' own fill. */
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.lib-children .lib-children { background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
/* The display rule above would otherwise override the hidden attribute. */
.lib-children[hidden] { display: none; }
.lib-children .lib-row {
  min-height: 44px;
  padding: 2px 2px 2px 6px;
  gap: 8px;
  background: transparent;
}
.lib-children .lib-main { gap: 8px; }
.lib-children .lib-name { font-size: 0.88rem; }
.lib-children .lib-meta { font-size: 0.74rem; }
.lib-children .lib-thumb { width: 32px; height: 32px; }
.lib-children .lib-action,
.lib-children .lib-toggle { width: 36px; height: 36px; }
.lib-children .lib-action svg,
.lib-children .lib-toggle svg { width: 20px; height: 20px; }
.lib-notice {
  padding: 8px 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .lib-toggle svg { transition: none; }
}

/* Sized in dvh, never vh, so the transport stays on screen while the mobile URL bar shows. */
.lyrics-view {
  position: fixed;
  inset: 0 0 auto 0;
  height: 100dvh;
  z-index: 20;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "lyrics-head"
    "lyrics-body"
    "lyrics-foot";
}
.lyrics-view[hidden] { display: none; }

.lyrics-header {
  grid-area: lyrics-head;
  display: flex;
  align-items: center;
  gap: 12px;
  /* A grid item's automatic minimum would grow to the no-wrap title and push the stepper off
     a phone screen. */
  min-width: 0;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}

.lyrics-heading { flex: 1 1 auto; min-width: 0; }

.lyrics-title, .lyrics-artist {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lyrics-title { font-size: 1rem; font-weight: 600; }
.lyrics-artist { font-size: 0.85rem; color: var(--text-muted); }

.lyrics-header-actions { display: flex; align-items: center; gap: 8px; }
.lyrics-slot { display: flex; align-items: center; gap: 6px; }

.lyric-size-btn { padding: 4px 8px; }
.lyric-size-glyph { font-weight: 700; line-height: 1; }
.lyric-size-glyph.is-small { font-size: 0.8rem; }
.lyric-size-glyph.is-large { font-size: 1.15rem; }

.lyrics-offset-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lyrics-offset-value {
  flex: 1 1 auto;
  text-align: center;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.lyrics-aside {
  grid-area: lyrics-aside;
  /* A phone viewport has no room for the art beside the words. */
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lyrics-scroll {
  grid-area: lyrics-body;
  overflow-y: auto;
  /* A scroll gesture stays inside the overlay, so the page behind never moves. */
  overscroll-behavior: contain;
  padding: 24px 20px 32px;
  cursor: pointer;
}

.lyrics-status {
  margin: 0;
  padding: 24px 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.lyrics-placard-head {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.lyrics-placard-note { display: block; margin-top: 6px; }

.lyrics-lines {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  font-size: var(--lyric-size);
  max-width: 42ch;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lyric-line {
  margin: 0;
  font-size: var(--lyric-size);
  line-height: 1.35;
  font-weight: 600;
  color: var(--text-muted);
}
/* Blank lines in plain lyrics mark stanza breaks, so they keep a line of height. */
.lyric-line:empty { min-height: 0.9em; }
.lyric-seek {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: inherit;
}
.lyric-seek:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lyrics-transport {
  grid-area: lyrics-foot;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 18px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.lyrics-seek-line {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--progress, 0%),
    var(--surface-2) var(--progress, 0%),
    var(--surface-2) 100%
  );
}

.lyrics-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.lyrics-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding-top: 2px;
}
.lyrics-buttons .transport-btn { width: 44px; height: 44px; }
.lyrics-buttons .transport-btn svg { width: 22px; height: 22px; }
.lyrics-buttons .play-btn { width: 54px; height: 54px; }
.lyrics-buttons .play-btn svg { width: 28px; height: 28px; }

.lyrics-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
}
.lyrics-view.is-window {
  inset: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.lyrics-view.is-window .lyrics-header { padding-top: 12px; }
/* The full view shows the art beside the words on a wide screen, so only the window view puts it
   in the header. */
.lyrics-thumb { display: none; }
.lyrics-view.is-window .lyrics-thumb {
  display: flex;
  flex: none;
  width: 44px;
  border-radius: var(--radius-sm);
}
/* The header's right edge holds the toggle and the X, so their tips grow leftward. */
.lyrics-header [data-tip]::after { left: auto; right: 0; }

.lyrics-view.is-immersive .lyrics-header { display: none; }
.lyrics-view.is-immersive .lyrics-times { display: none; }
.lyrics-view.is-immersive .lyrics-transport {
  gap: 3px;
  padding-top: 4px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.lyrics-view.is-immersive .lyrics-buttons { gap: 20px; }
.lyrics-view.is-immersive .lyrics-buttons .transport-btn { width: 34px; height: 34px; }
.lyrics-view.is-immersive .lyrics-buttons .transport-btn svg { width: 18px; height: 18px; }
.lyrics-view.is-immersive .lyrics-buttons .play-btn { width: 42px; height: 42px; }
.lyrics-view.is-immersive .lyrics-buttons .play-btn svg { width: 22px; height: 22px; }

/* Room above the first line and below the last so either can reach the centre.
   Only a timed set follows the player, so plain text keeps its ordinary box. */
.lyrics-lines.is-synced { padding-block: 38dvh; }
.lyrics-lines.is-synced .lyric-line { cursor: pointer; }

.lyric-line { transition: color 180ms ease, opacity 180ms ease; }
.lyric-line.is-active { color: var(--text); }
/* During an instrumental break the last sung line stays marked but dims, since it is no longer
   the line to read. */
.lyric-line.is-interlude { opacity: 0.5; }

/* Stands in for the words during a break so a long gap does not look frozen. */
.lyric-interlude {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.lyric-interlude span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: lyric-interlude-pulse 1.4s ease-in-out infinite;
}
.lyric-interlude span:nth-child(2) { animation-delay: 0.18s; }
.lyric-interlude span:nth-child(3) { animation-delay: 0.36s; }
@keyframes lyric-interlude-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* Placed in the words area, so it stays clear of the transport. */
.lyrics-follow-pill {
  grid-area: lyrics-body;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 8px 22px rgb(0 0 0 / 35%);
}
.lyrics-follow-pill:hover { border-color: var(--accent); }
.lyrics-follow-pill[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .lyric-line { transition: none; }
  .lyric-interlude span { animation: none; opacity: 0.6; }
}

@media (min-width: 900px) {
  .lyrics-view:not(.is-window) {
    grid-template-columns: minmax(260px, 340px) 1fr;
    grid-template-areas:
      "lyrics-head  lyrics-head"
      "lyrics-aside lyrics-body"
      "lyrics-foot  lyrics-body";
  }
  .lyrics-view:not(.is-window) .lyrics-aside { display: flex; }
  .lyrics-view:not(.is-window) .lyrics-scroll { padding: 40px 48px 56px; border-left: 1px solid var(--border); }
  /* ch resolves against the lines' own font size, so the cap scales with the text stepper. */
  .lyrics-view:not(.is-window) .lyrics-lines { max-width: 48ch; }
  .lyrics-view:not(.is-window) .lyrics-transport { background: transparent; border-top: 0; }
  .lyrics-view:not(.is-window) .lyrics-follow-pill { left: auto; right: 32px; bottom: 32px; transform: none; }
}

/* Jukebox dialog */
.jukebox-select {
  justify-self: start;
  min-height: 40px;
  padding: 6px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.jukebox-warn { color: var(--warn); }
.jukebox-state,
.jukebox-confirm { display: grid; gap: 14px; }
.jukebox-lifetime-field { display: grid; gap: 6px; }
.jukebox-warn[hidden],
.jukebox-state[hidden],
.jukebox-confirm[hidden],
.mode-toggle[hidden] { display: none; }
.jukebox-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.jukebox-manage { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.jukebox-confirm {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.text-toggle { justify-self: start; }
/* A QR code reads only dark on light, so its white surround stays in either theme. */
.jukebox-qr {
  width: min(240px, 100%);
  height: auto;
  background: #ffffff;
  border-radius: var(--radius-sm);
}
.jukebox-qr-large { width: min(320px, 100%); justify-self: center; }
.jukebox-url { overflow-wrap: anywhere; font-size: 0.8rem; color: var(--text-muted); }

/* Full screen QR: a plain light surround in either theme, so a phone camera reads it from across a room. */
.jukebox-fullscreen {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 24px;
  background: #ffffff;
  color: #111111;
  cursor: pointer;
}
.jukebox-fullscreen[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.jukebox-fullscreen .jukebox-qr {
  width: min(90vw, calc(100dvh - 120px));
  border-radius: 0;
}
/* A class, not a p selector, since messages.js moves the notice and its live region into this dialog. */
.jukebox-fullscreen-caption { margin: 0; font-size: 1.25rem; text-align: center; }

/* Guests dialog: the guests and banned sections */
#guest-list li,
#ban-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 12px;
  padding: 10px 0;
  background: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}
#guest-list li:last-child,
#ban-list li:last-child { border-bottom: 0; }
.guest-info { min-width: 0; display: grid; gap: 2px; }
.guest-row-actions { display: flex; gap: 8px; }
/* At phone width the details need the full row, so the actions move under them. */
@media (max-width: 480px) {
  #guest-list li,
  #ban-list li { grid-template-columns: minmax(0, 1fr); }
  .guest-row-actions { justify-self: end; }
}
.guest-ban {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.guest-limit-row input { flex: 0 0 6rem; }
.guest-ban[hidden],
#guest-list:empty,
#ban-list:empty { display: none; }
.guest-head { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.guest-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}
.guest-dot.is-online { background: var(--accent); }
.guest-songs { margin: 4px 0 0; padding-left: 18px; font-size: 0.85rem; overflow-wrap: anywhere; }

/* Guest page */
.guest-page .title { margin: 0; }
.guest-progress {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--progress, 0%), var(--surface-2) var(--progress, 0%));
}
.guest-jukebox { margin: 0; padding: 0 4px; font-size: 0.88rem; color: var(--text-muted); }
.guest-name [hidden] { display: none; }
.guest-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.guest-who .guest-jukebox { flex: 1 1 14rem; }
.guest-name-form { padding: 4px 4px 0; }
/* The welcome opens with no click, so focus goes to its title, where it shows no ring and a screen reader reads it first. */
#guest-welcome-title:focus { outline: none; }
.nickname-fields { display: grid; gap: 6px; }
.nickname-fields label .modal-hint { display: block; margin-top: 2px; }
.guest-name-form .btn-secondary { flex: none; }
.guest-host-banner {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 0.9rem;
}
.guest-host-banner[hidden] { display: none; }
.guest-host-banner a { color: var(--accent); }
.guest-qrow { cursor: default; }
.guest-queue-more { margin: 8px 14px 0; }
.guest-lyrics-toggle { margin-left: auto; }
.guest-lyrics-status { margin: 0; padding: 4px 14px; font-size: 0.9rem; color: var(--text-muted); }
.guest-lyrics-lines {
  list-style: none;
  margin: 0;
  padding: 0 14px;
  max-height: 40svh;
  overflow-y: auto;
  position: relative;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.guest-lyrics-lines.is-synced li { color: var(--text-muted); transition: color 160ms; }
.guest-lyrics-lines.is-synced li.active { color: var(--text); font-weight: 600; }
/* The shared `main { display: flex; }` rule outranks the user-agent [hidden] rule. */
.guest-page main[hidden] { display: none; }
.guest-add[hidden] { display: none; }
.guest-slots { margin-left: auto; font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.guest-search { padding: 0 14px 6px; }
.guest-add-status { margin: 0; padding: 4px 14px; font-size: 0.9rem; color: var(--text-muted); }
.guest-results { max-height: 40svh; }
/* The minimum width fits the longest label, so the row stays still while the label changes. */
.guest-add-btn { flex: none; min-width: 8.5rem; padding-inline: 12px; }
.guest-add-btn[data-state="pending"],
.guest-add-btn[data-state="added"],
.guest-add-btn[data-state="removing"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.guest-add-btn[data-state="pending"]:disabled,
.guest-add-btn[data-state="removing"]:disabled { opacity: 0.7; cursor: progress; }
/* guest-add.js keeps Add songs in place by hand, so the browser's own anchoring must not shift it twice. */
.guest-page { overflow-anchor: none; }
.queue-list li.mine .qtitle { color: var(--accent); }
.queue-list .qguest {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.queue-list .qguest:empty { display: none; }
