/* ────────────────────────────────────────────
   Karaoke King — Control Interface Styles
   Dark theme, clean, touch-friendly
   ──────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0d0d;
  --surface:      #1a1a2e;
  --surface2:     #16213e;
  --accent:       #e94560;
  --accent2:      #0f3460;
  --text:         #e8e8e8;
  --text-muted:   #8888aa;
  --border:       #2a2a4a;
  --row-hover:    #1e1e3a;
  --row-active:   #2a1040;
  --row-playing:  #1a0d2e;
  --radius:       8px;
  --shadow:       0 4px 20px rgba(0,0,0,0.5);
}

/* ── Light mode overrides ── */
body.light-mode {
  --bg:          #f4f4f8;
  --surface:     #ffffff;
  --surface2:    #eaeaf2;
  --accent:      #e94560;
  --accent2:     #ccd6f6;
  --text:        #1a1a2e;
  --text-muted:  #5a5a7a;
  --border:      #d0d0e0;
  --row-hover:   #eaeaf4;
  --row-active:  #ddd0f0;
  --row-playing: #ede0f8;
  --shadow:      0 4px 20px rgba(0,0,0,0.12);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  overflow: hidden;
}

/* ── Layout ── */
#app {
  display: grid;
  grid-template-rows: 60px 1fr;
  grid-template-columns: 1fr 320px;
  height: 100vh;
  gap: 0;
}

/* ── Header ── */
#header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

#search-wrap {
  flex: 1;
  max-width: 500px;
  position: relative;
}

#search {
  width: 100%;
  padding: 8px 16px 8px 40px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-muted); }

#search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}


#song-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Song List ── */
#song-list-wrap {
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

#song-list-wrap::-webkit-scrollbar { width: 6px; }
#song-list-wrap::-webkit-scrollbar-track { background: transparent; }
#song-list-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#song-list-wrap::-webkit-scrollbar-thumb:hover { background: var(--accent2); }

#song-list {
  list-style: none;
}

.song-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  min-height: 59px;        /* must match ITEM_HEIGHT in app.js virtual scroll */
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.12s;
  gap: 12px;
}

.song-item:hover  { background: var(--row-hover); }
.song-item:active { background: var(--row-active); }

.song-item.is-playing {
  background: var(--row-playing);
  border-left: 3px solid var(--accent);
}

.song-item.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.song-num {
  font-size: 11px;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.song-info { flex: 1; min-width: 0; }

.song-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.song-status {
  font-size: 18px;
  flex-shrink: 0;
}

.song-item.is-playing .song-status::after  { content: '▶'; color: var(--accent); }
.song-item.is-loading .song-status::after  { content: '⏳'; }

/* ── Right-click flag context menu ───────────────────────────────────────── */
/* ── Venue badge context menu ── */
.venue-ctx-menu {
  background: #1e1e2e;
  border: 1px solid #444466;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 9999;
  min-width: 190px;
}
.venue-ctx-item {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 8px 12px;
  text-align: left;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s;
}
.venue-ctx-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.flag-popup {
  position: fixed;
  background: #1e1e2e;
  border: 1px solid #444466;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 9999;
  min-width: 170px;
}
.flag-popup-title {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px 2px;
}
.flag-option {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 8px 12px;
  text-align: left;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s;
}
.flag-option:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* highlight search matches */
mark {
  background: rgba(233, 69, 96, 0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Side Panel: Now Playing ── */
#side-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface2);
  overflow: hidden;
}

/* Now Playing card */
#now-playing {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

#now-playing h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 12px;
}

#np-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
  min-height: 24px;
}

#np-artist {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

/* Progress bar */
#progress-wrap {
  margin-top: 14px;
}

#progress-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: height 0.15s;
}
#progress-bar-bg:hover {
  height: 7px;
}

#progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s linear;
}

#progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Controls */
#controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.ctrl-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.ctrl-btn:hover  { background: var(--row-hover); border-color: var(--accent); }
.ctrl-btn:active { background: var(--accent2); }

.ctrl-btn.primary {
  width: 52px;
  height: 52px;
  font-size: 20px;
  background: var(--accent);
  border-color: var(--accent);
  position: relative;
  overflow: visible;
  z-index: 0;
}
.ctrl-btn.primary:hover { background: #c93550; }

/* ── Rotating glow when playing ── */
@keyframes spin-glow {
  to { transform: rotate(360deg); }
}

.ctrl-btn.primary.is-playing::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent   0%,
    var(--accent) 25%,
    #ff9ec8       50%,
    var(--accent) 75%,
    transparent   100%
  );
  animation: spin-glow 1.4s linear infinite;
  filter: blur(3px);
  z-index: -1;
}

/* Solid backing so glow doesn't bleed into the button face */
.ctrl-btn.primary.is-playing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  z-index: -1;
}

/* Volume */
#vol-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  margin-top: 16px;
}

#vol-wrap label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

#vol-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ── TV Screen Section ── */
#tv-section {
  padding: 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

#tv-section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#open-screen-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#open-screen-btn:hover { background: #1a4a80; }

#open-queue-screen-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#open-queue-screen-btn:hover { background: #1a4a80; }

#screen-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

#qr-toggle-btn {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  transition: border-color 0.15s, color 0.15s;
}
#qr-toggle-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── Queue ── */
#queue-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

#queue-section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

#queue-list {
  list-style: none;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}

.queue-num  { color: var(--text-muted); font-size: 11px; min-width: 18px; }
.queue-info { flex: 1; min-width: 0; }
.queue-title  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-artist { font-size: 11px; color: var(--text-muted); }
.queue-pitch {
  display: inline-block;
  margin-left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #e94560;
  background: rgba(233,69,96,0.12);
  border: 1px solid rgba(233,69,96,0.35);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: middle;
  letter-spacing: 0.03em;
}

.queue-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.queue-remove:hover { color: var(--accent); background: rgba(233,69,96,0.1); }

#queue-empty {
  padding: 20px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Loading overlay ── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
#loading-overlay.visible { display: flex; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  font-size: 14px;
  color: var(--text-muted);
}

#loading-progress {
  width: 200px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#loading-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

/* ── Queue Header (Up Next + Add Singer button) ── */
#queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 8px;
  position: sticky;
  top: 0;
  background: var(--surface2);
  z-index: 1;
}

#queue-header h2 {
  padding: 0;
  position: static;
  background: none;
}

#add-singer-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
#add-singer-btn:hover { background: #c93550; }

/* Singer name in Now Playing */
#np-singer {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  min-height: 18px;
  margin-bottom: 2px;
}

/* Queue item singer name */
.queue-singer {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

/* Mobile request singer name — slightly different tint to distinguish */
.queue-singer.mobile-request {
  color: #4db8ff;
}

/* ── Singer Modal ── */
#singer-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#singer-modal-backdrop.open { display: flex; }

#singer-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#singer-modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* Roster chips area */
#roster-chips-wrap {
  min-height: 0;
}

#roster-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 4px;
}

.roster-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
  user-select: none;
}
.roster-chip:hover {
  border-color: var(--accent);
  background: rgba(233,64,89,0.12);
}
/* Name button inside chip — clicking just fills the name field */
.chip-name-btn {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.chip-name-btn:hover { text-decoration: underline; }
.chip-name { font-weight: 600; }
.chip-count {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* Singer name input + autocomplete */
#singer-name-wrap {
  position: relative;
}

#name-autocomplete {
  list-style: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  z-index: 20;
  display: none;
  max-height: 160px;
  overflow-y: auto;
}
#name-autocomplete.open { display: block; }

.name-ac-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
.name-ac-item:last-child { border-bottom: none; }
.name-ac-item:hover { background: var(--row-hover); }

#singer-modal label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: -6px;
}

#singer-name-input,
#modal-song-search {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
#singer-name-input:focus,
#modal-song-search:focus { border-color: var(--accent); }

#modal-song-search-wrap {
  position: relative;
}

#modal-song-results {
  list-style: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
#modal-song-results.open { display: block; }

#modal-song-results li {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
#modal-song-results li:last-child { border-bottom: none; }
#modal-song-results li:hover { background: var(--row-hover); }

.msr-title {
  font-size: 14px;
  font-weight: 600;
}
.msr-artist {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

#modal-selected-song {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  min-height: 42px;
  display: flex;
  align-items: center;
  transition: border-color 0.2s, color 0.2s;
}
#modal-selected-song.has-song {
  border-color: var(--accent);
  color: var(--text);
}

#modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

#modal-cancel-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
#modal-cancel-btn:hover { border-color: var(--text-muted); color: var(--text); }

#modal-add-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#modal-add-btn:hover:not(:disabled) { background: #c93550; }
#modal-add-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Refresh bar (sticky bottom of song list) ── */
#refresh-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 20px 16px 12px;
  background: linear-gradient(transparent, var(--bg) 60%);
  pointer-events: none;   /* let clicks pass through the gradient */
}

#library-status {
  pointer-events: none;
  align-self: center;
  margin-right: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#library-status.usb {
  color: #22c55e;
  border-color: #22c55e;
  background: rgba(34,197,94,0.1);
}

#usb-library-btn {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  margin-right: 8px;
}
#usb-library-btn:hover { border-color: var(--accent); color: var(--text); background: var(--surface2); }
#usb-library-btn.active {
  border-color: #22c55e;
  color: #22c55e;
  background: rgba(34,197,94,0.1);
}

#my-library-btn {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  margin-right: 8px;
}
#my-library-btn:hover { border-color: var(--accent); color: var(--text); background: var(--surface2); }
#my-library-btn.active {
  border-color: #3b82f6;
  color: #3b82f6;
  background: rgba(59,130,246,0.1);
}

/* ── My Library Settings Modal ── */
#lib-settings-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}
#lib-settings-modal.open { display: flex; }
#lib-settings-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 24px;
  width: min(480px, 92vw);
  position: relative;
}
#lib-settings-box h2 { margin: 0 0 10px; font-size: 17px; }
#lib-settings-box p  { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
#lib-folder-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
#lib-folder-input:focus { outline: none; border-color: var(--accent); }
#lib-settings-error {
  color: #ef4444;
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 12px;
}
#lib-settings-actions { display: flex; justify-content: flex-end; gap: 10px; }
#lib-settings-save {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#lib-settings-save:disabled { opacity: 0.6; cursor: not-allowed; }
#lib-settings-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
#lib-settings-close:hover { color: var(--text); }

#refresh-btn {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#refresh-btn:hover  { border-color: var(--accent); color: var(--text); background: var(--surface2); }
#refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }

#refresh-btn.spinning {
  animation: pulse-refresh 1s ease-in-out infinite;
  border-color: var(--accent);
  color: var(--accent);
}
@keyframes pulse-refresh {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Sort bar ── */
#sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.sort-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 2px;
}

.sort-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sort-btn:hover  { border-color: var(--accent); color: var(--text); }
.sort-btn.active {
  background: var(--accent2);
  border-color: var(--accent);
  color: #fff;
}

/* ── Fade button ── */
#fade-wrap {
  padding: 8px 20px 0;
}

#btn-fade {
  width: 100%;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  height: 32px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#btn-fade:hover { border-color: var(--accent); color: var(--text); }
#btn-fade.fading {
  background: var(--accent2);
  border-color: var(--accent);
  color: #fff;
  animation: pulse-fade 1s ease-in-out infinite;
}
@keyframes pulse-fade {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Pitch Control ── */
#pitch-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px 0;
}
.pitch-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 2px;
}
.pitch-step {
  width: 28px;
  height: 28px;
  font-size: 15px;
  font-weight: 700;
  padding: 0;
  flex-shrink: 0;
}
#pitch-display {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
}
#pitch-display.pitch-active {
  color: var(--accent);
}

/* ── KJ badge in header ── */
#kj-badge {
  background: rgba(100,160,255,0.12);
  border: 1px solid rgba(100,160,255,0.35);
  color: var(--text);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#kj-badge:hover {
  border-color: #64a0ff;
  background: rgba(100,160,255,0.22);
}

/* ── Combined login modal (KJ → PIN → Venue) ── */
/* ── Singer History Modal ────────────────────────────────────────────────── */
#singer-history-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 600;
  align-items: center;
  justify-content: center;
}
#singer-history-backdrop.open { display: flex; }

#singer-history-modal {
  background: var(--bg-panel);
  border-radius: 12px;
  width: min(520px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

#singer-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#singer-history-header h3 { margin: 0; font-size: 17px; }
#singer-history-close {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  line-height: 1;
}
#singer-history-close:hover { color: #fff; }

#singer-history-meta {
  padding: 8px 20px;
  font-size: 12px;
  color: #888;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#singer-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.sh-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.sh-item:hover { background: var(--row-hover); }

.sh-info { flex: 1; min-width: 0; }
.sh-title  { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-meta   { font-size: 12px; color: #aaa; margin-top: 2px; }

.sh-select-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sh-select-btn:hover { opacity: 0.85; }

.sh-delete-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 8px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sh-delete-btn:hover { border-color: #e74c3c; color: #e74c3c; }

#singer-history-empty {
  padding: 40px;
  text-align: center;
  color: #888;
}

#singer-history-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
#singer-history-select-only {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
  padding: 8px 14px;
  transition: all 0.15s;
}
#singer-history-select-only:hover { border-color: var(--accent); color: #fff; }

#login-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
#login-modal-backdrop.open { display: flex; }

#login-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 400px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#login-modal h3 {
  font-size: 20px;
  font-weight: 700;
}

/* KJ + Venue lists */
#kj-list,
#venue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.kj-empty,
.venue-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 0 8px;
}

/* KJ profile buttons */
.kj-item {
  display: flex;
  gap: 6px;
  align-items: center;
}
.kj-item .kj-select-btn {
  flex: 1;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.kj-item .kj-select-btn:hover {
  border-color: #64a0ff;
  background: rgba(100,160,255,0.08);
}
.kj-item .kj-delete-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.kj-item .kj-delete-btn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
  background: rgba(231,76,60,0.08);
}

/* Venue list items */
.venue-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.venue-select-btn {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.venue-select-btn:hover {
  border-color: var(--accent);
  background: rgba(233,69,96,0.08);
}
.venue-item-name { font-size: 14px; font-weight: 600; }
.venue-item-meta { font-size: 11px; color: var(--text-muted); }
.venue-item-actions { display: flex; gap: 4px; }
.venue-rename-btn,
.venue-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 6px 7px;
  border-radius: var(--radius);
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
}
.venue-rename-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.venue-delete-btn:hover { opacity: 1; background: rgba(233,69,96,0.15); }

/* Section divider label */
.login-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}

/* New KJ / new venue input rows */
#kj-new-wrap,
#venue-new-wrap {
  display: flex;
  gap: 8px;
}

#kj-new-name,
#venue-new-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
#kj-new-name:focus    { border-color: #64a0ff; }
#venue-new-input:focus { border-color: var(--accent); }
#kj-new-name::placeholder,
#venue-new-input::placeholder { color: var(--text-muted); }

#kj-new-next {
  background: #64a0ff;
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
#kj-new-next:hover { background: #4d8ae8; }

#venue-new-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
#venue-new-btn:hover { background: #c93550; }

/* PIN step */
#login-step-pin {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: color 0.15s;
  align-self: flex-start;
}
.login-back-btn:hover { color: var(--text); }

.login-sub-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -4px;
}

#kj-pin-input,
#kj-pin-confirm {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
#kj-pin-input:focus,
#kj-pin-confirm:focus { border-color: #64a0ff; }

.login-error-text {
  font-size: 13px;
  color: var(--accent);
  min-height: 18px;
}

#kj-pin-submit {
  background: #64a0ff;
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#kj-pin-submit:hover { background: #4d8ae8; }

/* ── Theme toggle button ── */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(233,69,96,0.08);
}

/* ── Venue badge in header ── */
#venue-badge {
  background: rgba(233,69,96,0.12);
  border: 1px solid rgba(233,69,96,0.35);
  color: var(--text);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#venue-badge:hover {
  border-color: var(--accent);
  background: rgba(233,69,96,0.22);
}


/* ── Chip wrapper (needed for dropdown positioning) ── */
.chip-wrap {
  position: relative;
  display: inline-block;
}

/* ── Singer history dropdown (on chip hover) ── */
.chip-history-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  z-index: 50;
  overflow: hidden;
}
.chip-history-dropdown.visible { display: block; }

.chd-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.chd-song {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
.chd-song:hover { background: var(--row-hover); }

.chd-song-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chd-song-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.chd-delete-singer {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.chd-delete-singer:hover { background: rgba(233,69,96,0.12); color: var(--accent); }

/* ── Error toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #c0392b;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  transition: transform 0.3s;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── Admin button ────────────────────────────────────────────────────────── */
#admin-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  padding: 5px 10px;
  transition: background 0.15s;
}
#admin-btn:hover { background: rgba(255,80,80,0.25); }

/* ── Admin modal ─────────────────────────────────────────────────────────── */
#admin-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
#admin-modal-backdrop.open { display: flex; }

#admin-modal {
  background: var(--bg-panel);
  border-radius: 12px;
  width: min(680px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
#admin-modal-header h2 { font-size: 18px; margin: 0; }
#admin-modal-close {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
}
#admin-modal-close:hover { color: #fff; }

#admin-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: #aaa;
  cursor: pointer;
  font-size: 13px;
  padding: 5px 14px;
  transition: all 0.15s;
}
.admin-tab:hover  { border-color: var(--accent); color: #fff; }
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

#admin-flag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.admin-flag-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-flag-item:hover { background: var(--row-hover); }

.admin-flag-info { flex: 1; min-width: 0; }
.admin-flag-title  { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-flag-artist { font-size: 12px; color: #aaa; margin-top: 2px; }
.admin-flag-meta   { font-size: 11px; color: #888; margin-top: 4px; }

.admin-flag-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-flag-badge.duplicate   { background: rgba(52,152,219,0.2); color: #5dade2; }
.admin-flag-badge.bad-quality { background: rgba(231,76,60,0.2);  color: #e74c3c; }

.admin-remove-btn {
  background: none;
  border: 1px solid rgba(231,76,60,0.4);
  border-radius: 6px;
  color: #e74c3c;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.admin-remove-btn:hover { background: rgba(231,76,60,0.15); border-color: #e74c3c; }

.admin-dismiss-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #aaa;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.admin-dismiss-btn:hover { border-color: #aaa; color: #fff; }

#admin-empty {
  padding: 40px;
  text-align: center;
  color: #888;
}
