/* Sarcastaball 9000 (S9000) — iOS-feel grid of song-buttons */
.full-width { width: 100%; }
:root {
  --bg: #0f0f10;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --text: #f2f2f7;
  --text-dim: #98989f;
  --accent: #1db954; /* Spotify green */
  --border: #38383a;
  --tab-active: #ffffff;

  /* Sarcastaball 9000 palette by songCellColorRaw value (0..10), matched to the colours stored in the source database format. */
  --c-default: #8c8c8c; /* webapp default; overridden by JS from localStorage */
  --c0:  #d8332a; /* Red */
  --c1:  #dd7a2e; /* Orange */
  --c2:  #e8c875; /* Gold */
  --c3:  #4dff4d; /* Green */
  --c4:  #80ffff; /* Light Blue */
  --c5:  #4a86e8; /* Medium Blue */
  --c6:  #0000dd; /* Dark Blue */
  --c7:  #6f1ff7; /* Purple */
  --c8:  #db44f0; /* Violet */
  --c9:  #e84a78; /* Pink */
  --c10: #8c8c8c; /* Gray */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: env(safe-area-inset-top) 12px 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
/* "Track Played" on/off switch in the top bar */
.switch-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--text-dim); user-select: none; white-space: nowrap; }
.switch-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-label input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch { position: relative; width: 34px; height: 18px; background: rgba(255,255,255,0.22); border-radius: 9px; transition: background 0.15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch-label input:checked + .switch { background: var(--accent); }
.switch-label input:checked + .switch::after { transform: translateX(16px); }
.switch-emoji { font-size: 15px; line-height: 1; }
#btn-clear-played { /* uses default .icon-btn sizing — emoji label keeps it narrow */ }
/* The app title gets a slow rainbow shimmer that lives *inside* the letters
   (the gradient is clipped to the text). prefers-reduced-motion users get the
   gradient without the animation. */
#title {
  font-weight: 700; font-size: 26px; letter-spacing: 0.5px;
  background: linear-gradient(90deg,
    #ff5f6d, #ffc371, #f6e05e, #47e891, #4a86e8, #b06ff7, #ff5f6d);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: titleShimmer 8s linear infinite;
}
@keyframes titleShimmer { to { background-position: 200% center; } }
/* Rotate only the centered SVG artwork, not the playhead's positioning or
   shadow. Keeping the animation applied lets pause/resume retain its angle. */
#logo-ball, #np-bar-dot .np-ball {
  display: block; flex: none;
  width: 24px; height: 24px;
  transform-origin: 50% 50%;
  animation: ballSpin 1.1s linear infinite;
  animation-play-state: paused;
}
#logo-ball.spinning, #np-bar-dot.spinning .np-ball { animation-play-state: running; }
@keyframes ballSpin { to { transform: rotate(360deg); } }
.pill {
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 12px;
}
.pill[data-state="ready"] { background: rgba(29,185,84,0.2); color: var(--accent); }
.pill[data-state="error"] { background: rgba(255,69,58,0.2); color: var(--c0); }
.pill[data-state="warn"]  { background: rgba(255,159,10,0.2); color: var(--c1); }

/* The device pill doubles as a button: click it to pick a Spotify device. A red
   outline shouts "no device chosen yet"; a green one means we're connected. */
#device-pill { cursor: pointer; border: 2px solid transparent; user-select: none; }
#device-pill[data-state="none"]  { border-color: #ff453a; color: var(--c0); }
#device-pill[data-state="ready"] { border-color: var(--accent); }
#device-pill:hover { filter: brightness(1.2); }

/* Full-screen confetti canvas for the "Buy Me a Fake Beer" gag. It sits above
   everything and swallows clicks so we can count the two needed to dismiss it. */
#confetti-canvas {
  position: fixed; inset: 0;
  z-index: 9999;
  pointer-events: auto;
  cursor: pointer;
}
/* One-click close button for the confetti gag — sits above the canvas. */
#confetti-close {
  position: fixed; top: 16px; right: 16px;
  z-index: 10000;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 20px; line-height: 1; cursor: pointer;
  color: var(--text);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.4);
}
#confetti-close:hover { background: rgba(0,0,0,0.75); }

/* The tab strip and its scroll affordances. #tabs-wrap is the flexible middle
   column of the top bar; it shrinks (min-width:0) so the tabs scroll instead of
   shoving the right-hand controls off screen. */
#tabs-wrap {
  flex: 1; min-width: 0;
  display: flex; align-items: center; position: relative;
}
/* The ‹ › scroll buttons. Hidden via the global .hidden class until needed. */
.tab-scroll {
  flex: none; background: transparent; border: none;
  color: var(--text-dim); font-size: 20px; line-height: 1;
  padding: 4px 6px; cursor: pointer; border-radius: 8px;
}
.tab-scroll:hover, .tab-scroll:active { background: var(--surface-2); color: var(--text); }
#tabs {
  flex: 1; min-width: 0;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  scroll-behavior: smooth; touch-action: pan-x;
}
#tabs::-webkit-scrollbar { display: none; }
/* While the user is mouse-dragging the strip, show a grabbing cursor and stop
   accidental text selection. */
#tabs.dragging { scroll-behavior: auto; cursor: grabbing; user-select: none; }
.tab {
  padding: 8px 14px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-dim);
  white-space: nowrap; font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--surface-2); color: var(--tab-active); }
.tab-add {
  padding: 8px 12px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-dim);
  font-size: 18px; font-weight: 700; line-height: 1;
  opacity: 0.6;
}
.tab-add:hover, .tab-add:active { background: var(--surface-2); opacity: 1; color: var(--text); }

.icon-btn {
  background: transparent; border: none; padding: 8px;
  border-radius: 8px; font-size: 20px;
}
.icon-btn:active { background: var(--surface-2); }
#btn-fullscreen[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
#btn-fullscreen:disabled { cursor: wait; }
.emoji-icon {
  display: inline-block;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", emoji;
  font-style: normal; font-weight: 400; font-variant-emoji: emoji;
  line-height: 1; vertical-align: middle;
}
/* The Stop ("panic") button is the one control an operator reaches for in a
   hurry, so it's enlarged and tinted red to stand out from the other controls. */
#np-stop {
  font-size: 26px;
  color: #ff5a5a;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.5);
}
#np-stop:hover { background: rgba(255, 90, 90, 0.22); }
#np-stop:active { background: rgba(255, 90, 90, 0.32); }
/* "m:ss left" countdown next to the end time; turns amber in the final seconds. */
#np-remaining {
  margin-left: 8px; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted, #9aa);
}
#np-remaining.ending { color: #ffb340; font-weight: 700; }

/* ---------- Grid ---------- */
#grid-container { height: calc(100dvh - 56px); overflow-y: auto; }
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 12px;
  padding-bottom: 96px;
}

/* ---------- Master volume rail (right edge) ---------- */
/* A vertical fader for the currently-playing song; hidden until a song loads.
   The control is an ordinary horizontal range rotated -90deg, which is the most
   reliable way to render a vertical slider across browsers: 0% sits at the bottom
   and 100% at the top. Releasing the thumb is what applies the volume (see
   app.js), so dragging never floods the Spotify API. */
#vol-rail {
  position: fixed;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
#vol-rail.hidden { display: none; }
#vol-rail-track {
  width: 44px;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#vol-rail-slider {
  width: 400px;            /* becomes the vertical length once rotated */
  flex: none;              /* don't let the narrow track shrink the slider's length */
  height: 6px;
  transform: rotate(-90deg);
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-2);
  border-radius: 3px;
  outline: none;
}
#vol-rail-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}
#vol-rail-slider::-moz-range-thumb {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}
#vol-rail-slider::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--surface-2);
}
/* When the rail sits on the Settings default volume the thumb is grayed out;
   once you move it off the default it turns green to signal a custom level. */
#vol-rail-slider.is-default::-webkit-slider-thumb { background: var(--text-dim); }
#vol-rail-slider.is-default::-moz-range-thumb { background: var(--text-dim); }
#vol-rail-slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
#vol-rail-label {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 36px;
  text-align: center;
}
#vol-save { font-size: 18px; }
#vol-mute { font-size: 18px; }

/* While the rail is visible, reserve a strip on the right so it never covers the
   rightmost tiles. */
body.vol-open #grid { padding-right: 64px; }

.cell {
  position: relative;
  aspect-ratio: 1.4 / 1;
  border-radius: 12px;
  background: var(--c-default);
  padding: 10px;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: left;
  border: none;
  color: white;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: transform 0.08s ease, filter 0.08s ease;
}
.cell:active { transform: scale(0.97); filter: brightness(1.15); }
/* The currently-playing cell gets an animated rainbow ring that matches the
   app-title shimmer (same gradient + titleShimmer keyframes). It's drawn with a
   pseudo-element: a gradient-filled box masked so only the 3px border shows.
   When paused, the ring becomes a steady yellow outline instead. */
.cell.playing::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 3px;
  background: linear-gradient(90deg,
    #ff5f6d, #ffc371, #f6e05e, #47e891, #4a86e8, #b06ff7, #ff5f6d);
  background-size: 200% auto;
  animation: titleShimmer 8s linear infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}
.cell.playing.paused::after {
  background: #ffd60a;
  animation: none;
}
.cell.focused {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--accent);
  z-index: 1;
}

.cell .title  { font-size: 17px; font-weight: 700; }
.cell .meta   { font-size: 11px; opacity: 0.85; font-weight: 500; }
.cell .start  {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; opacity: 0.85; font-weight: 500;
  background: rgba(0,0,0,0.25); border-radius: 4px; padding: 1px 5px;
}

.cell[data-color="-1"] { background: var(--c-default); }
.cell[data-color="0"]  { background: var(--c0); }
.cell[data-color="1"]  { background: var(--c1); }
.cell[data-color="2"]  { background: var(--c2); color: #1a1a1a; }
.cell[data-color="3"]  { background: var(--c3); color: #1a1a1a; }
.cell[data-color="4"]  { background: var(--c4); color: #1a1a1a; }
.cell[data-color="5"]  { background: var(--c5); }
.cell[data-color="6"]  { background: var(--c6); }
.cell[data-color="7"]  { background: var(--c7); }
.cell[data-color="8"]  { background: var(--c8); }
.cell[data-color="9"]  { background: var(--c9); }
.cell[data-color="10"] { background: var(--c10); }

/* ---------- Empty state ---------- */
#empty-state {
  position: absolute; inset: 56px 0 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-dim);
}
.hidden { display: none !important; }

/* ---------- Now-playing footer ---------- */
#nowplaying {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom)) 14px;
  background: rgba(28,28,30,0.95);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  z-index: 4;
  gap: 6px;
}
#np-row {
  display: flex; align-items: center; justify-content: space-between;
}
#np-progress {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
#np-progress.hidden { display: none; }
#np-bar {
  flex: 1; height: 6px; background: rgba(255,255,255,0.12);
  border-radius: 3px;
  position: relative;
  margin: 12px 0;
  cursor: pointer;
  touch-action: none;
}
#np-bar-fill {
  position: absolute; top: 0; left: 0;
  height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
  pointer-events: none;
}
/* JS sets each marker's `left` as a percentage; translate(-50%, -50%) keeps
   its box centered on that point independently of the artwork inside it. */
#np-bar-dot, #np-bar-caret, #np-bar-stop {
  position: absolute; top: 50%;
  transform: translate(-50%, -50%);
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
  cursor: grab;
  user-select: none;
}
/* Current position — the square SVG sits above the cue markers. */
#np-bar-dot {
  width: 24px; height: 24px;
  z-index: 2;
  transition: transform 0.08s ease;
}
#np-bar-dot:hover { transform: translate(-50%, -50%) scale(1.15); }
#np-bar-dot:active { cursor: grabbing; }
#np-bar-dot.focused { filter: drop-shadow(0 0 3px var(--accent)) drop-shadow(0 1px 1px rgba(0,0,0,0.6)); }
/* Start cue — 🔰 beginner/start marker. */
#np-bar-caret {
  font-size: 20px;
  z-index: 1;
}
#np-bar-caret:active { cursor: grabbing; }
#np-bar-caret.focused {
  filter: drop-shadow(0 0 3px var(--accent)) drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
/* End cue — stop sign. Hidden until an end cue is set (JS toggles display). */
#np-bar-stop {
  font-size: 18.75px;
  z-index: 1;
}
#np-bar-stop:active { cursor: grabbing; }
#np-bar-stop.focused {
  filter: drop-shadow(0 0 3px #ff9f0a) drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
/* Adjustment panel (fine cue + volume), shown only while tweaking a track. */
#np-cue-fine {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums;
  padding: 0 2px 2px;
}
#np-cue-fine.hidden { display: none; }
.np-fine-row { display: flex; align-items: center; gap: 8px; }
#np-cue-fine-label, #np-vol-label { white-space: nowrap; min-width: 118px; }
/* The volume speaker icon is enlarged so it's easy to spot at a glance. */
#np-vol-label .vol-emoji { font-size: 18px; vertical-align: middle; }
#np-cue-fine-slider, #np-vol-slider {
  flex: 1; height: 18px;
  cursor: pointer; touch-action: none;
}
/* The micro-adjustment (fine cue) slider is tinted a deeper green so it reads as
   a clearly darker control than the bright-green main scrobbler bar above it. */
#np-cue-fine-slider { accent-color: #0e7a38; }
/* Volume gets a completely different hue (blue) so the two sliders in the same
   panel can never be confused for one another. */
#np-vol-slider { accent-color: #3a86ff; }
#np-info { min-width: 0; }
#np-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#np-title:hover { text-decoration: underline; }
#np-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#np-controls { display: flex; gap: 6px; }
/* deletion + edit state */
.cell.pending-delete {
  opacity: 0.35;
  text-decoration: line-through;
  outline: 2px dashed var(--c0);
  outline-offset: -2px;
}
.cell .edited-dot {
  position: absolute; bottom: 6px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); display: none;
}
.cell.pending-edit .edited-dot { display: block; }
/* Hotkey badge — shows the single assigned keyboard letter in the top-right
   corner of a tile. Hidden automatically when no letter is assigned (empty). */
.cell .hotkey-badge {
  position: absolute; top: 6px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 4px; font-size: 11px; font-weight: 700; line-height: 16px;
  text-align: center; color: var(--text);
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.25);
}
.cell .hotkey-badge:empty { display: none; }
/* Played tiles are dimmed to a grayed-out look. The currently-playing tile is
   shown at full strength even if it's been played, so it still stands out. */
.cell.played { opacity: 0.4; filter: grayscale(60%); }
.cell.played.playing { opacity: 1; filter: none; }

/* pending move indicator */
.cell.pending-move {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.cell.pending-move::after {
  content: "→ " attr(data-movetarget);
  position: absolute;
  top: 6px; right: 8px;
  background: rgba(0,0,0,0.55);
  color: var(--accent);
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
  pointer-events: none;
  max-width: 70%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* right-click context menu */
#ctx-menu {
  position: fixed;
  min-width: 200px; max-width: 280px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  padding: 6px 0;
  z-index: 50;
  font-size: 13px;
}
#ctx-menu .ctx-title {
  padding: 6px 12px 4px;
  color: var(--text-dim);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ctx-menu .ctx-header {
  padding: 8px 12px 4px;
  color: var(--text-dim); font-weight: 700;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
#ctx-menu .ctx-item.ctx-disabled {
  color: var(--text-dim); opacity: 0.4; cursor: default;
}
#ctx-menu .ctx-item.ctx-disabled:hover { background: transparent; }
#ctx-menu .ctx-item {
  padding: 8px 16px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ctx-menu .ctx-item:hover { background: rgba(255,255,255,0.08); }
#ctx-menu .ctx-cancel {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  color: var(--c0);
}

/* save button + badge */
.save-btn { position: relative; }
.save-btn.has-changes { color: var(--accent); }
.badge {
  position: absolute; top: 0; right: 0;
  background: var(--c0); color: white;
  border-radius: 999px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  display: none;
}
.save-btn.has-changes .badge { display: inline-block; }

/* color swatches in now-playing footer */
.swatches { display: flex; gap: 4px; align-items: center; }
.swatch {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer;
}
.swatch.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch[data-color="-1"] { background: var(--c-default); }
.swatch[data-color="0"]  { background: var(--c0); }
.swatch[data-color="1"]  { background: var(--c1); }
.swatch[data-color="2"]  { background: var(--c2); }
.swatch[data-color="3"]  { background: var(--c3); }
.swatch[data-color="4"]  { background: var(--c4); }
.swatch[data-color="5"]  { background: var(--c5); }
.swatch[data-color="6"]  { background: var(--c6); }
.swatch[data-color="7"]  { background: var(--c7); }
.swatch[data-color="8"]  { background: var(--c8); }
.swatch[data-color="9"]  { background: var(--c9); }
.swatch[data-color="10"] { background: var(--c10); }

/* ---------- Modal ---------- */
#modal, #logout-modal, #fullscreen-help-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 16px;
}
.modal-card {
  background: var(--surface);
  border-radius: 14px; max-width: 540px; width: 100%;
  max-height: 90dvh; overflow-y: auto;
  padding: 20px;
}
#modal .modal-card {
  max-width: 680px;
  max-height: min(90dvh, calc(100dvh - 32px));
}
#fullscreen-help-modal .modal-card { max-width: 680px; }
#fullscreen-browser-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
#fullscreen-browser-tabs button {
  flex: 1 1 100px; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--text-dim); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
#fullscreen-browser-tabs button:hover { border-color: var(--text); }
#fullscreen-browser-tabs button:active { background: var(--bg); }
#fullscreen-browser-tabs button[aria-selected="true"] {
  background: var(--accent); color: #000; border-color: var(--accent);
}
.fullscreen-guide { width: 100%; border-collapse: collapse; table-layout: fixed; }
.fullscreen-guide caption { text-align: left; margin: 8px 0; font-weight: 600; }
.fullscreen-guide th, .fullscreen-guide td {
  padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: top; overflow-wrap: anywhere; font-size: 14px;
}
.fullscreen-guide th:first-child { width: 30%; }
.fullscreen-guide th small { display: block; margin-top: 4px; font-weight: 400; }
.modal-card h2 { margin: 0 0 12px 0; }
.modal-card h3 { margin: 18px 0 8px 0; font-size: 15px; }
.modal-card section { padding: 8px 0; border-top: 1px solid var(--border); }
.modal-card section:first-of-type { border-top: none; }
.modal-card label { display: block; margin: 8px 0; font-size: 13px; color: var(--text-dim); }
.modal-card input[type="text"] {
  width: 100%; margin-top: 4px;
  padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 14px;
}
.modal-card input[type="file"] { margin: 8px 0; color: var(--text-dim); }
.modal-card .hint { font-size: 12px; color: var(--text-dim); margin: 4px 0; }
#modal .hint a[href],
#modal .hint a[href]:visited {
  color: #9acbff;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
#modal .hint a[href]:hover,
#modal .hint a[href]:focus-visible { color: #c7e1ff; }
#modal .hint a[href]:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}
#modal .hint a[href]:active { color: var(--text); }
.modal-card .status { font-size: 12px; margin-top: 6px; min-height: 16px; }
.modal-card .status.ok { color: var(--accent); }
.modal-card .status.err { color: var(--c0); }
.redirect-uri {
  display: block;
  margin: 6px 0 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
}
.modal-card button.primary {
  background: var(--accent); color: #000; border: none;
  padding: 10px 16px; border-radius: 8px; font-weight: 700;
}
.modal-card button.secondary {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; margin-top: 12px;
}
#btn-logout-spotify:not(:disabled):hover,
#btn-logout-spotify:not(:disabled):focus-visible {
  background: #38383a; color: var(--text); border-color: var(--text-dim);
}
#btn-logout-spotify:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
#btn-logout-spotify:disabled {
  background: var(--surface); color: var(--text-dim);
  border-color: var(--border); cursor: not-allowed;
}
/* "Refresh devices" button — themed to match the app instead of the bare
   browser-gray default it would otherwise show. */
#btn-refresh-devices {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; margin-top: 8px; font-weight: 600;
}
#btn-refresh-devices:hover, #btn-refresh-devices:active { border-color: var(--accent); }

.device-list .device {
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  margin: 6px 0; display: flex; justify-content: space-between; align-items: center;
}
.device-list .device.active { border-color: var(--accent); }
.device-list .device button {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; color: var(--text);
}

/* The standalone device picker overlay mirrors the Settings modal overlay. */
#device-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 16px;
}
#btn-refresh-devices-picker {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; margin-top: 8px; font-weight: 600;
}
#btn-refresh-devices-picker:hover, #btn-refresh-devices-picker:active { border-color: var(--accent); }

/* Quick-find overlay mirrors the other modal overlays. */
#search-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 10; padding: 64px 16px 16px;
}
/* Add-song overlay mirrors the quick-find overlay. */
#add-song-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 10; padding: 48px 16px 16px;
}
.search-results {
  margin: 12px 0; max-height: 55dvh; overflow-y: auto;
}
.search-row {
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  margin: 6px 0; cursor: pointer;
}
.search-row:hover { border-color: var(--accent); background: var(--surface-2); }
.search-row.disabled { opacity: 0.5; cursor: default; }
.search-row .search-main { font-weight: 600; color: var(--text); }
.search-row .search-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Add-song modal: segmented Search / From-playlist switch. */
.seg { display: flex; gap: 6px; margin: 6px 0 10px 0; }
.seg-btn {
  flex: 1; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); font-size: 13px; font-weight: 600;
}
.seg-btn.active { color: #000; background: var(--accent); border-color: var(--accent); }
/* "🤬 Explicit" marker on search/playlist results. */
.explicit-badge {
  display: inline-block; margin-right: 6px;
  font-size: 13px; vertical-align: middle;
}
.search-row.explicit { border-color: color-mix(in srgb, var(--c0) 45%, var(--border)); }
/* "Load more" / status footer inside a results list. */
.load-more {
  width: 100%; margin: 6px 0 2px 0; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.load-more:hover { border-color: var(--accent); }
.load-more:disabled { opacity: 0.6; cursor: default; }
#add-playlist-back { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
#add-playlist-back .hint { margin: 0; }

/* Transient bottom banner used for playback errors and device changes. */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; font-size: 14px; max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 12000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body { display: flex; flex-direction: column; }
#transport-status { flex: none; padding: 8px; max-height: 25dvh; overflow-y: auto; background: var(--surface-2); color: var(--text); border-bottom: 2px solid var(--c1); }
#transport-status button {
  margin-left: 8px; padding: 6px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--text-dim); border-radius: 6px;
  font-weight: 600;
}
#transport-status button:hover,
#transport-status button:focus-visible {
  background: #38383a; border-color: var(--text);
}
#transport-status button:active { background: var(--bg); }
#transport-status button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
#topbar { flex: none; flex-wrap: wrap; }
.topbar-left, .topbar-right { min-width: 0; flex-wrap: wrap; }
#title { overflow-wrap: anywhere; }
#grid-container { flex: 1; min-height: 0; height: auto; position: relative; }
#grid { padding-bottom: 12px; }
#empty-state { position: relative; inset: auto; min-height: 100%; padding: 16px; text-align: center; }
#nowplaying { position: relative; flex: none; max-height: 45dvh; overflow-y: auto; }
#np-row, #np-controls, .swatches { flex-wrap: wrap; gap: 8px; }
#np-info { flex: 1; }
#np-title { display: block; max-width: 100%; background: none; border: 0; padding: 0; text-align: left; }
#np-controls { justify-content: flex-end; max-width: 100%; }
.swatches { padding: 4px; }
.swatch { flex: none; }
.search-row { display: block; width: 100%; text-align: left; }
.search-main, .search-sub { display: block; }
#ctx-menu { max-height: calc(100dvh - 16px); overflow-y: auto; }
#ctx-menu .ctx-item { display: block; width: 100%; border: 0; background: none; text-align: left; font: inherit; }
.modal-card { overflow-wrap: anywhere; }
.modal-card input[type="file"] { max-width: 100%; }
.device { flex-wrap: wrap; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
#vol-rail-track { height: clamp(60px, calc(100dvh - 300px), 400px); }
#vol-rail-slider { width: clamp(60px, calc(100dvh - 300px), 400px); }
body:has(#vol-rail:not(.hidden)) #grid { padding-right: 86px; }

@media (max-width: 1100px) {
  #tabs-wrap { order: 3; flex-basis: 100%; }
  .topbar-right { margin-left: auto; }
}
@media (max-width: 700px), (max-height: 500px) {
  #title { font-size: 20px; }
  #topbar { gap: 4px; padding: 4px 8px; max-height: 42dvh; overflow-y: auto; }
  .topbar-left { justify-content: space-between; flex: 1 1 100%; gap: 4px; }
  .topbar-right { justify-content: center; margin: 0; flex: 1 1 100%; gap: 2px; }
  .icon-btn { padding: 6px; font-size: 18px; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); padding: 8px; }
  body:has(#vol-rail:not(.hidden)) #grid { padding-right: 8px; }
  #nowplaying { padding: 6px 8px; }
  #np-info { flex-basis: 100%; }
  #np-controls { flex: 1; justify-content: space-between; }
  #np-controls .swatches { flex: 1 1 100%; }
  #np-progress { flex-wrap: wrap; }
  #np-bar { min-width: 100px; }
  #np-remaining { margin-left: 0; }
  .np-fine-row { flex-wrap: wrap; }
  .np-fine-row input { min-width: 100px; }
  #vol-rail { position: relative; top: auto; right: auto; transform: none; flex: none; flex-direction: row; margin: 4px 8px; padding: 4px; gap: 4px; }
  #vol-rail-track { flex: 1; width: auto; height: 32px; min-width: 40px; }
  #vol-rail-slider { transform: none; width: 100%; }
  .modal-card { padding: 12px; max-height: calc(100dvh - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  #title, .cell.playing::after, #logo-ball, #np-bar-dot .np-ball { animation: none; }
}
