/* This must win over any class's own `display` rule (.modal, .layout, .auth-page,
   etc. all set one) regardless of selector specificity or source order, or an
   element toggled via `.hidden = true` in JS stays visible. Bitten by this
   exact bug three times now — global !important instead of patching each
   class that happens to set display. */
[hidden] { display: none !important; }

/* Synthwave/outrun palette: deep purple-navy base, neon cyan + magenta as
   the two accent voices (the classic 80s two-tone neon pairing), amber/pink-
   red kept for warn/danger so status meaning stays intuitive. --on-bright is
   for text sitting on a solid accent/danger button — one shared dark tone
   rather than a separate near-black per button color. --glow-* are reused
   as box-shadow on the handful of elements that should actually glow
   (primary actions, active states, a playhead) — deliberately not applied
   everywhere, or nothing would read as "the important thing." */
:root {
  color-scheme: dark;
  --bg: #120a24;
  --panel: #1c1033;
  --panel-2: #261745;
  --border: #3d2a66;
  --text: #f1ecff;
  --muted: #9c8fc2;
  --accent: #2de2e6;
  --accent-2: #ff2e97;
  --danger: #ff3864;
  --warn: #ffb627;
  --on-bright: #0b0618;
  --glow-accent: 0 0 10px rgba(45,226,230,0.55), 0 0 2px rgba(45,226,230,0.8);
  --glow-accent-2: 0 0 10px rgba(255,46,151,0.55), 0 0 2px rgba(255,46,151,0.8);
  --font-display: "Orbitron", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* A soft neon glow bleeding from the top of the page — subtle and fixed
     in place, so it reads as atmosphere behind the content rather than
     competing with it on any of the app's many text-dense views. */
  background:
    radial-gradient(ellipse 800px 420px at 50% -12%, rgba(255,46,151,0.13), transparent 60%),
    radial-gradient(ellipse 700px 420px at 100% -8%, rgba(45,226,230,0.11), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  /* Belt-and-suspenders: nothing on this page should ever need horizontal
     scroll, so a runaway child (a flex row that won't shrink, a stray wide
     element) clips instead of dragging the whole page wider than the screen. */
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.hamburger-btn {
  display: none;
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.1rem;
  border-radius: 8px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

@media (max-width: 720px) {
  .topbar h1 { font-size: 1.05rem; }
  .hamburger-btn { display: block; }
  .topbar-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    z-index: 80;
  }
  .topbar-controls.open { display: flex; }
  .topbar-controls .view-nav { order: 0; flex-direction: column; }
  .topbar-controls .health { order: 2; }
  .topbar-controls .topbar-user { order: 1; flex-direction: column; align-items: stretch; gap: 8px; }
  .topbar-controls .topbar-user button { width: 100%; }
}

/* Primary navigation — Create / My Songs / My Cover Library. Inline as a
   tab row in the topbar on desktop; stacked inside the hamburger dropdown
   on mobile (see the max-width:720px block above). */
.view-nav {
  display: flex;
  gap: 6px;
}
.view-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}
.view-nav-btn.active {
  background: var(--accent);
  color: var(--on-bright);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: var(--glow-accent);
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin: 0;
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(255,46,151,0.65), 0 0 3px rgba(255,46,151,0.9);
}

.health {
  font-size: 0.8rem;
  color: var(--muted);
}

.health.ready { color: var(--accent-2); }
.health.error { color: var(--danger); }
.health.loading { color: var(--warn); }

.layout[hidden] { display: none; }
.layout {
  display: grid;
  /* One view (Create, My Songs, a song's detail, My Cover Library) is shown
     at a time now instead of the form and the songs list side by side, so
     this is just a centered single column — minmax(0, ...) still matters: a
     bare 1fr track has an implicit auto minimum sized to its content, so one
     wide child (a long song id, an unbroken URL, a canvas) would otherwise
     force the whole grid — and page — wider than the screen instead of that
     child wrapping or scrolling internally. */
  grid-template-columns: minmax(0, 1fr);
  max-width: 760px;
  margin: 0 auto;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

/* A persistent mini-player can be docked at the bottom once a song is loaded
   into it (body.mini-player-active, toggled in JS) — keep the last bit of
   scrollable content from hiding behind it. */
body.mini-player-active .layout {
  padding-bottom: 88px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.panel h2 {
  margin-top: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.hint { color: var(--muted); font-weight: normal; }
p.hint { font-size: 0.78rem; margin: 0 0 8px; }
p.hint code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
p.hint a { color: var(--accent); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}
.chip-row button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.76rem;
  padding: 5px 10px;
  border-radius: 999px;
}
.chip-row button:hover { color: var(--text); border-color: var(--accent); }

input, textarea, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row {
  display: flex;
  gap: 12px;
  min-width: 0;
}
.row label { flex: 1; min-width: 0; }

@media (max-width: 560px) {
  .row { flex-direction: column; }
}
.row input[type="file"] { flex: 1; min-width: 0; }

#cover-source-preview {
  width: 100%;
  margin: 10px 0;
}

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  margin-bottom: 10px !important;
}
.checkbox-label input[type="checkbox"] { width: auto; }

details {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}
details textarea { width: 100%; margin-top: 10px; }
details button { margin-top: 8px; }

.section-defs dl {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
}
.section-defs dt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
}
.section-defs dd {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
@media (max-width: 480px) {
  .section-defs dl { grid-template-columns: 1fr; gap: 2px 0; }
  .section-defs dd { margin-bottom: 8px; }
}

/* abcjs always draws black ink, so notation gets its own "paper" regardless
   of the surrounding dark theme — tinted a faint lavender rather than pure
   white so it still reads as part of the neon palette, not a jarring cutout. */
.abc-notation {
  background: #f3edff;
  border-radius: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  min-height: 60px;
}
.abc-notation svg { max-width: none; }
.abc-empty {
  color: #8a7a9c;
  font-size: 0.8rem;
  padding: 10px 4px;
}
.abc-warnings {
  color: var(--warn);
  font-size: 0.72rem;
  margin-top: 4px;
}

.notation-toggle-wrap { margin-top: 10px; }
.notation-panel {
  margin-top: 8px;
}

/* Karaoke-mode timed lyrics — the current line (matched against playback
   time) is highlighted; everything else stays muted. */
.karaoke-lyrics {
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 2px;
}
.karaoke-lyrics p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.15s ease;
}
.karaoke-lyrics p.active {
  color: var(--accent);
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  background: var(--accent);
  color: var(--on-bright);
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 0 8px rgba(45,226,230,0.35);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
button:hover:not(:disabled) { box-shadow: var(--glow-accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button#reset-btn, button#clear-abc, button#refresh-songs, button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  /* Quiet at rest — only the primary action per screen should glow by
     default, or nothing reads as "the important one." */
  box-shadow: none;
}
button#reset-btn:hover:not(:disabled), button#clear-abc:hover:not(:disabled),
button#refresh-songs:hover:not(:disabled), button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(45,226,230,0.3);
}
button.secondary.active {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-bright);
  box-shadow: 0 0 8px rgba(255,56,100,0.45);
}
button#cancel-job {
  background: var(--danger);
  color: var(--on-bright);
  box-shadow: 0 0 8px rgba(255,56,100,0.35);
}
button#cancel-job:hover:not(:disabled) {
  box-shadow: 0 0 10px rgba(255,56,100,0.55), 0 0 2px rgba(255,56,100,0.8);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.job-status {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.job-stage {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--accent);
}
.job-bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.job-bar-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.songs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.songs-header button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
}

.songs-search {
  width: 100%;
  margin-top: 10px;
}

.songs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.songs-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* My Songs' compact list row — full song controls live on the detail screen
   (tap the row) instead of being crammed in here; the play button loads
   straight into the persistent mini-player without leaving the list. */
.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  cursor: pointer;
}
.song-row:hover { border-color: var(--accent); }
.song-row-play {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.song-row-info { flex: 1; min-width: 0; }
.song-row-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song-row-meta {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.song-row-chevron {
  flex: none;
  color: var(--muted);
  font-size: 1.1rem;
}

.back-btn { margin-bottom: 14px; }

/* Persistent mini-player, docked at the bottom once a song is loaded into it
   (see body.mini-player-active in the .layout rule above) — visible across
   every view, with prev/next to browse without leaving whatever you're
   doing. */
.mini-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.mini-player button {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.mini-player-info { flex: 1; min-width: 0; }
.mini-player-title {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-player-wave {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: 4px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: none;
}
.mini-player-time {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: var(--muted);
}
@media (max-width: 480px) {
  /* Keeps the bar from getting cramped on narrow phones — title + controls
     stay legible, the exact elapsed/total readout isn't essential there. */
  .mini-player-time { display: none; }
}

.song-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
}

.song-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 8px;
  margin-bottom: 6px;
}

.song-id {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  min-width: 0;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.complete { background: rgba(255,46,151,0.15); color: var(--accent-2); }
.badge.failed { background: rgba(255,56,100,0.15); color: var(--danger); }
.badge.running, .badge.queued { background: rgba(255,182,39,0.15); color: var(--warn); }
.badge.incomplete { background: rgba(156,143,194,0.15); color: var(--muted); }
.badge.trimmed { background: rgba(45,226,230,0.15); color: var(--accent); }
.badge.voiced { background: rgba(45,226,230,0.15); color: var(--accent); }
.badge.chipmunk { background: rgba(45,226,230,0.15); color: var(--accent); }

.id-row {
  display: flex;
  gap: 6px;
}
.id-row input { flex: 1; }
.id-row button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
}

.downloads {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}
.dl-line { margin-bottom: 4px; }
.dl-bar {
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.dl-bar-fill {
  height: 100%;
  background: var(--accent-2);
}
.dl-file {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 2px 0;
}
.dl-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

.dl-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Download format picker — one button instead of four separate format
   links cluttering the actions row. */
.dl-dropdown { position: relative; display: inline-block; }
.dl-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.dl-dropdown-menu .dl-link {
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
}
.dl-dropdown-menu .dl-link:hover {
  background: var(--panel);
  color: var(--accent);
}

/* The mini-player is docked at the very bottom of the screen, so its "more
   actions" menu has to open upward and hug the right edge — the default
   dropdown (opens below, left-aligned) would run off-screen here. */
.mini-player-menu-wrap { position: relative; }
.mini-player-menu {
  top: auto;
  bottom: calc(100% + 8px);
  left: auto;
  right: 0;
  /* Deliberately a plain fixed width, not width:max-content/min-width — that
     combination on an absolutely-positioned element with 100%-width children
     was producing a too-narrow box that clipped the start of every label
     (worse the longer the label). A fixed width plus normal wrapping has no
     such ambiguity. */
  width: 230px;
  max-width: calc(100vw - 28px);
  box-sizing: border-box;
  max-height: 60vh;
  overflow-x: hidden;
  overflow-y: auto;
}
/* Plain text menu rows — .dl-link (designed for <a> download links) left the
   global button style (filled accent pill, glow, centered) showing through
   when reused on a <button> here, which is what made these look broken. */
.mini-player-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 11px 12px;
  font-weight: 500;
  font-size: 0.88rem;
  box-shadow: none;
  white-space: normal;
}
.mini-player-menu-item:hover:not(:disabled),
.mini-player-menu-item:active:not(:disabled) {
  background: var(--panel);
  color: var(--accent);
  box-shadow: none;
  transform: none;
}

.lyrics-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.lyrics-tools input[type="text"] {
  flex: 1 1 220px;
  min-width: 0;
}
.lyrics-tools button.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* Trim modal */
.modal[hidden] {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8,3,20,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h3 {
  margin-top: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
}
.modal-box audio {
  width: 100%;
  margin: 12px 0;
}
.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.modal-box .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lyrics-modal-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  max-height: 50vh;
  overflow-y: auto;
  margin: 0 0 14px;
}
textarea.lyrics-modal-text {
  width: 100%;
  box-sizing: border-box;
  max-height: none;
  height: 40vh;
  resize: vertical;
}

.waveform-wrap {
  position: relative;
  height: 120px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  touch-action: none;
  user-select: none;
}
.waveform-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.trim-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(45,226,230,0.18);
  border-left: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  pointer-events: none;
}
.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  margin-left: -6px;
  background: var(--accent);
  border-radius: 4px;
  cursor: ew-resize;
}
.trim-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.song-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.player audio { display: none; }
.player-play {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.player-wave {
  flex: 1;
  width: 100%;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
}
.player-time {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 82px;
  text-align: right;
}

.song-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.song-actions button {
  font-size: 0.78rem;
  padding: 6px 10px;
}
button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  box-shadow: none;
}
button.danger:hover:not(:disabled) {
  box-shadow: 0 0 8px rgba(255,56,100,0.4);
}

.empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 0;
  text-align: center;
}

/* Auth screens (login/signup gate, and the standalone set-password page) */
.auth-page[hidden] { display: none; }
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-panel {
  width: min(400px, 100%);
}
.auth-panel h1 {
  font-size: 1.2rem;
  margin: 0 0 4px;
}
.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
}
.auth-switch {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}
.auth-switch a { color: var(--accent); cursor: pointer; }
.auth-setup-link {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  word-break: break-all;
}
.auth-setup-link a { color: var(--accent-2); }

/* Top bar user/account controls */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.topbar-user button {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Scope tabs above the songs list */
.scope-tabs {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.scope-tabs button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 0.8rem;
}
.scope-tabs button.active {
  background: var(--accent);
  color: var(--on-bright);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: var(--glow-accent);
}

.owner-badge {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

/* Admin panel + playlists modal reuse .modal styling from the trim modal */
.admin-section { margin-bottom: 18px; }
.admin-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
@media (max-width: 480px) {
  .admin-row { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 0; }
  .admin-row button { width: 100%; }
}
.admin-row:last-child { border-bottom: none; }
.admin-row .muted { color: var(--muted); font-size: 0.78rem; }

.help-box { width: min(680px, 100%); }
.help-section { margin-bottom: 18px; }
.help-section:last-of-type { margin-bottom: 0; }
.help-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 6px;
}
.help-section dl {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
}
.help-section dt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
}
.help-section dd {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
@media (max-width: 480px) {
  .help-section dl { grid-template-columns: 1fr; gap: 2px 0; }
  .help-section dd { margin-bottom: 8px; }
}

.playlists-panel { margin-top: 20px; }
.playlist-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  margin-bottom: 12px;
}
.playlist-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.playlist-card-head .song-id { font-size: 0.95rem; }
.playlist-songs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.playlist-song-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  gap: 8px;
}
.playlist-song-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Beat Maker: a 16-step grid per voice. Cells are flex-basis-0 (never a
   fixed pixel width) so the whole grid shrinks to fit a phone screen
   instead of forcing horizontal scroll. */
.beat-inline-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.beat-inline-label input { width: 64px; }
.beat-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 14px 0;
  user-select: none;
  -webkit-user-select: none;
}
.beat-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.beat-row-label {
  flex: 0 0 34px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.beat-cells {
  display: flex;
  gap: 3px;
  flex: 1;
  touch-action: none;
}
.beat-cell {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
}
.beat-cells > .beat-cell:nth-child(4n+1) { margin-left: 6px; }
.beat-cells > .beat-cell:nth-child(1) { margin-left: 0; }
.beat-cell.on { background: var(--accent); border-color: var(--accent); box-shadow: var(--glow-accent); }
.beat-cell.playhead { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.beat-cell[data-state="1"] { background: var(--accent); border-color: var(--accent); box-shadow: var(--glow-accent); }
.beat-cell[data-state="2"] { background: var(--accent-2); border-color: var(--accent-2); box-shadow: var(--glow-accent-2); }
.beat-cell[data-state="3"] {
  background: #fff8ff;
  border-color: #fff8ff;
  box-shadow: 0 0 10px rgba(255,255,255,0.7), 0 0 2px rgba(255,255,255,0.9);
}

/* Lightweight "here's what just happened" confirmation for actions that
   don't otherwise show an obvious result (a derived song created quietly in
   the background, lyrics copied into a form below the fold) — not a blocking
   alert(), just a brief top-anchored banner that fades on its own. */
.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  max-width: min(92vw, 480px);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  text-align: center;
  box-shadow: var(--glow-accent), 0 8px 24px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

.ambient-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ambient-row:last-child { border-bottom: none; }
.ambient-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.ambient-row-name { font-weight: 600; }
.ambient-row .actions { flex-wrap: wrap; }
.ambient-row-pending {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}
.ambient-row-pending .ambient-row-name { flex: 1; color: var(--warn); font-weight: 500; }
