:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-2: #252542;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --text: #f2f2f7;
  --text-dim: #a0a0b8;
  --border: #2e2e4a;
  --danger: #ff5c5c;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --mini-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Author `display` rules below must not defeat the `hidden` attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

#app { max-width: 560px; margin: 0 auto; padding: 10px 16px calc(var(--mini-h) + env(safe-area-inset-bottom) + 24px); }

/* Top bar */
.top-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 40px; }
.top-bar h1 {
  flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  background: none; border: 0; color: var(--text-dim); font-size: 22px;
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.back-btn { font-size: 30px; line-height: 1; }

.view { animation: fade 0.16s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-title { margin: 4px 0 2px; font-size: 20px; font-weight: 700; }
.view-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-dim); }

.inline-status { font-size: 13px; color: var(--text-dim); padding: 12px 2px; }
.inline-status:empty { display: none; }

/* Search */
.search-section { display: flex; gap: 8px; margin-bottom: 10px; }
.search-section input, .add-section input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.search-section input:focus, .add-section input:focus { border-color: var(--accent); }
.primary-btn {
  padding: 12px 18px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer;
  flex-shrink: 0;
}
.primary-btn:disabled { opacity: 0.55; }
.primary-btn:active:not(:disabled) { transform: scale(0.97); }
#festivalModeBtn {
  padding: 12px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-dim); font-size: 12px; cursor: pointer;
  flex-shrink: 0;
}
#festivalModeBtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#festivalModeBtn:active:not(.active) { opacity: 0.8; }
.secondary-btn {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer;
}

/* Cached setlist card (mirrors the Android app's last-opened cache) */
.cached-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px;
}
.cached-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 6px; }
.cached-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; padding: 0; color: inherit; text-align: left;
  font: inherit; cursor: pointer;
}
.cached-btn:active { opacity: 0.8; }
.cached-info { flex: 1; min-width: 0; }
.cached-artist { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cached-meta { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.link-add { margin-bottom: 16px; }
.link-add summary { font-size: 13px; color: var(--text-dim); cursor: pointer; padding: 6px 2px; outline: none; }
.add-section { display: flex; gap: 8px; margin-top: 8px; }

/* Setlist / artist lists */
.setlist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.setlist-item {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  background: var(--surface); border-radius: var(--radius); cursor: pointer;
}
.setlist-item:active { background: var(--surface-2); }
.sl-info { flex: 1; min-width: 0; }
.sl-title { font-size: 15px; font-weight: 600; line-height: 1.25; }
.sl-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.sl-tour { font-size: 11px; color: var(--accent); margin-top: 3px; }
.sl-support { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.chev { color: var(--text-dim); font-size: 22px; flex-shrink: 0; }

/* Setlist screen */
.setlist-header { padding: 4px 2px 14px; }
.setlist-artist { font-size: 22px; font-weight: 700; line-height: 1.15; }
.setlist-support { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.toggle-btn {
  margin-top: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; align-self: start;
}
.toggle-btn:active { background: var(--surface-2); }
.setlist-venue { font-size: 15px; color: var(--text); margin-top: 4px; }
.setlist-meta { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.setlist-tour { font-size: 12px; color: var(--accent); margin-top: 3px; }
.play-all-btn { width: 100%; margin-bottom: 10px; }
.banner {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; font-size: 12px; color: var(--text-dim);
}
.banner-btn {
  border: 0; background: var(--accent); color: #fff; padding: 7px 12px;
  border-radius: 8px; font-weight: 600; font-size: 12px; flex-shrink: 0; cursor: pointer;
}

.songs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.set-header {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); padding: 18px 2px 6px;
}
.night-band { color: var(--accent); font-weight: 600; }
.song-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.song-item:active { background: var(--surface); }
.song-item.tape { color: var(--text-dim); cursor: default; }
.song-num { width: 24px; text-align: right; font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
.song-name { flex: 1; font-size: 15px; line-height: 1.25; }
.song-tag { font-size: 10px; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.song-play { color: var(--accent); font-size: 14px; flex-shrink: 0; }

/* Queue */
.queue-section { margin-top: 8px; }
.queue-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.queue-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.queue-count { font-weight: 400; color: var(--text-dim); font-size: 14px; }
.text-btn { background: none; border: 0; color: var(--text-dim); font-size: 13px; cursor: pointer; padding: 6px 4px; }
.text-btn:active { color: var(--text); }

.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--surface); border-radius: 10px; cursor: pointer; }
.queue-item.playing { background: var(--surface-2); outline: 1px solid var(--accent); }
.queue-item img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.queue-item .qi-info { flex: 1; min-width: 0; }
.queue-item .qi-title { font-size: 13px; font-weight: 500; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.queue-item .qi-channel { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.queue-item .qi-remove { background: none; border: 0; color: var(--text-dim); font-size: 18px; padding: 4px 6px; cursor: pointer; }
.queue-item .qi-remove:active { color: var(--danger); }

.empty-state { text-align: center; padding: 28px 12px; color: var(--text-dim); }
.empty-state p { margin: 6px 0; font-size: 14px; }
.empty-state .hint { font-size: 12px; opacity: 0.7; }

/* Mini player */
.mini-player {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--mini-h) + env(safe-area-inset-bottom));
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(26, 26, 46, 0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; z-index: 60;
}
.mini-open {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0; background: none; border: 0; padding: 0;
  color: inherit; text-align: left; font: inherit; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.mini-open:active { opacity: 0.8; }
.mini-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.mini-info { flex: 1; min-width: 0; }
.mini-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-channel { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-progress { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.mini-progress .progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s linear; }
.mini-btn { background: none; border: 0; color: var(--text); font-size: 14px; width: 36px; height: 36px; flex-shrink: 0; cursor: pointer; }
.mini-btn:active { color: var(--accent); }
.mini-play { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 15px; }

/* Full player / playlist screen — opens when the mini player is tapped */
.player-screen {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 60%);
  z-index: 85; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 24px);
  animation: playerUp 0.18s ease;
}
@keyframes playerUp { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }

.player-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.player-top-title { font-size: 12px; color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; }
.player-close { transform: rotate(-90deg); font-size: 26px; }
#playerShuffle.active { color: var(--accent); }

.player-art {
  display: block; width: min(74vw, 300px); aspect-ratio: 1 / 1;
  object-fit: cover; border-radius: 18px; margin: 8px auto 18px;
  box-shadow: var(--shadow); background: var(--surface-2);
}
.player-meta { text-align: center; }
.player-title { font-size: 20px; font-weight: 700; line-height: 1.2; padding: 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.player-channel { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.player-progress { margin-top: 16px; }
.seek-bar { width: 100%; -webkit-appearance: none; appearance: none; height: 5px;
  border-radius: 3px; background: var(--surface-2); outline: none; cursor: pointer; }
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45); cursor: pointer;
}
.seek-bar::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff; }
.player-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-top: 6px; }

.player-controls { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 20px; }
.ctrl-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--surface);
  color: var(--text); font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ctrl-btn:active { transform: scale(0.95); }
.play-btn { width: 68px; height: 68px; background: var(--accent); color: #fff; font-size: 24px; }

.player-queue-title { font-size: 13px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 24px 0 10px; }
.player-queue-list { padding-bottom: 8px; }

/* Hidden YouTube host - off-screen, NOT display:none, so playback works */
.yt-player-host { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 90;
}
.modal-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow);
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.inline-row { display: flex; gap: 8px; align-items: stretch; }
.inline-row input { flex: 1; min-width: 0; }
.inline-row .secondary-btn { flex-shrink: 0; }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }
.modal-card input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.field-hint { font-size: 11px; color: var(--text-dim); margin: 6px 0 0; line-height: 1.4; }
.modal-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.modal-actions .primary-btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--mini-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); padding: 10px 16px;
  border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center; z-index: 100;
}
.toast.error { background: var(--danger); }

/* Install banner */
.install-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; z-index: 80; font-size: 13px;
}
.install-banner button { padding: 8px 14px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.install-banner .dismiss { background: transparent; color: var(--text-dim); }

/* Netlify injects an owner-only HUD iframe that floats over the mini player.
   Hide it completely so it can neither be seen nor intercept taps. */
#nl-hud-frame,
iframe[title="Netlify"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
}