/* Stage and Crowd base styles.
   Phone first. Light/dark follows the device; the live vote page forces the
   dark "stage" theme (body.stage) so it isn't blinding in a dark room.
   One accent color (stage-light amber); everything else neutral. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1c1b19;
  --text-2: #5f5e5a;
  --text-3: #8a8983;
  --border: rgba(0, 0, 0, .12);
  --accent: #e8962a;
  --accent-strong: #b8701a;
  --accent-bg: #fbecd6;
  --accent-text: #6b3f08;
  --on-accent: #1c1206;
  --live: #d6453d;
  --live-bg: #fbe4e2;
  --ok: #2f7d3a;
  --radius: 10px;
  --chart-bar: #b8701a;   /* validated: >= 3:1 on white, inside the light lightness band */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1c1b19;
    --surface-2: #262522;
    --text: #f1efe8;
    --text-2: #b4b2a9;
    --text-3: #888780;
    --border: rgba(255, 255, 255, .12);
    --accent-bg: #3a2a12;
    --accent-text: #f6c27a;
    --live-bg: #3d1a18;
    --chart-bar: #cf7f24;   /* validated against #1c1b19 (dark band + 3:1) */
  }
}

body.stage {
  --bg: #0d0c0b;
  --surface: #191816;
  --surface-2: #24221f;
  --text: #f4f2ec;
  --text-2: #b9b6ad;
  --text-3: #85827a;
  --border: rgba(255, 255, 255, .12);
  --accent-bg: #3a2a12;
  --accent-text: #f6c27a;
  --live-bg: #3d1a18;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; }
a { color: var(--accent-strong); }
body.stage a, .dark a { color: var(--accent); }
@media (prefers-color-scheme: dark) { a { color: var(--accent); } }
img { max-width: 100%; height: auto; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 18px; margin: 24px 0 8px; font-weight: 700; }
h3 { font-size: 16px; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* Layout */
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 520px; }
main { padding: 20px 0 48px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { font-weight: 800; font-size: 18px; color: var(--text) !important; text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 14px; margin-left: auto; align-items: center; flex-wrap: wrap; }
/* .topbar prefix: must outrank "body.stage a" so nav links stay neutral on dark pages */
.topbar .nav a { color: var(--text-2); text-decoration: none; font-size: 14px; }
.topbar .nav a:hover, .topbar .nav a.on { color: var(--text); }

/* Cards and rows */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.card.feature { border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pills, badges, avatars */
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--accent-bg); color: var(--accent-text); }
.badge-live { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--live-bg); color: var(--live); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar.lg { width: 84px; height: 84px; font-size: 28px; border: 3px solid var(--surface); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.banner { height: 160px; border-radius: 14px; background: var(--surface-2); background-size: cover; background-position: center; }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text) !important; font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent) !important; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.block { width: 100%; }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 110px; }
.msg { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; }
.msg.err { background: var(--live-bg); color: var(--live); }
.msg.ok { background: var(--accent-bg); color: var(--accent-text); }

/* Live vote page */
.now { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.vote-list .row { min-height: 60px; }
.rank { width: 22px; color: var(--text-3); font-size: 14px; text-align: center; flex: none; }
.vote-btn { flex: none; min-width: 60px; min-height: 52px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.vote-btn .arrow { font-size: 14px; }
.vote-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.vote-btn:disabled { opacity: .5; cursor: default; }
.votes-left { text-align: center; color: var(--text-2); font-size: 14px; margin-top: 12px; }

/* Show recap + homepage code box */
.recap-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.vbar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.vbar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.code-form { display: flex; gap: 8px; margin-top: 8px; }
.code-form input[type=text] { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .08em; font-family: Consolas, Menlo, monospace; }

/* Band cast */
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 12px; }
.cast-item { text-align: center; }
.cast-item .avatar { margin: 0 auto 6px; }
.cast-name { font-weight: 700; overflow-wrap: anywhere; }
.lineup-row input[type=text] { width: 42%; flex: none; min-height: 38px; padding: 6px 10px; }

/* Charts + directories */
.chart-cols { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 860px) { .chart-cols { grid-template-columns: 1fr 1fr; } }
.dir-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); margin-bottom: 0; }
.dir-card:hover { border-color: var(--accent); }
.dir-card .grow { flex: 1; min-width: 0; }
.dir-name { font-weight: 700; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pick { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }

/* Install-the-app bar (footer) */
.install-box { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; color: var(--text); }
.install-box > div { flex: 1; min-width: 0; }
.install-box[hidden], .install-box [hidden] { display: none; }
/* Installed app: keep the footer clear of the phone's home bar */
@media (display-mode: standalone) {
  footer { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}

/* Follow, phone alerts, run-page request alert, legal pages */
.follow-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.push-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--radius); padding: 8px 12px; margin: 6px 0 10px; }
.push-box > span { flex: 1 1 200px; }
.push-box[hidden], .push-box [hidden], .req-alert[hidden] { display: none; }
.req-alert { display: block; text-decoration: none; font-weight: 700; }
.confirm-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 12px; }
.confirm-box > div { flex: 1 1 220px; }
.ml-row, .verified-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.ml-row > span, .verified-row > span { flex: 1 1 200px; }
.verified-row { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.verified-note { border-color: var(--accent); }
.genre-pick { border: 0; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; }
.genre-pick legend { font-size: 14px; font-weight: 600; margin-bottom: 4px; padding: 0; }
.legal { line-height: 1.6; }
.legal h2 { font-size: 18px; margin-top: 24px; }
.report-link { margin-top: 24px; }

/* Band links + videos */
.band-links { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.vid { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; margin: 6px 0; }
.vid iframe, .vid-play { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vid-play { background-size: cover; background-position: center; cursor: pointer; padding: 0; }
.vid-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 44px; border-radius: 12px; background: rgba(0,0,0,.72); color: #fff; font-size: 20px; }
.vid-play:hover .vid-icon, .vid-play:focus .vid-icon { background: var(--accent); color: var(--on-accent); }
.vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.vid-thumb-sm { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); }

/* Tip links */
.tips-head { font-weight: 700; margin-bottom: 8px; }
.tips-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.tip-btn { flex: 1 1 140px; }

/* Admin trends: one small single-series bar chart per metric (small multiples) */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.trend-card { margin-bottom: 0; }
.trend-card h3 { margin: 0; font-size: 15px; }
.trend-num { font-size: 28px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.trend-chg { font-size: 13px; color: var(--text-2); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 84px; margin-top: 12px; border-bottom: 1px solid var(--border); }
.spark .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; outline: none; cursor: default; }
.spark .bar { width: 100%; max-width: 24px; background: var(--chart-bar); border-radius: 4px 4px 0 0; }
/* The week in progress: same hue, hatched, so it never reads as a real drop */
.spark .bar.partial { background: repeating-linear-gradient(45deg, var(--chart-bar) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--chart-bar); }
.spark .col:hover .bar, .spark .col:focus .bar { filter: brightness(1.15); }
.spark .col:hover::after, .spark .col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none; }
.spark .col:nth-child(-n+3):hover::after, .spark .col:nth-child(-n+3):focus::after { left: 0; transform: none; }
.spark .col:nth-last-child(-n+3):hover::after, .spark .col:nth-last-child(-n+3):focus::after { left: auto; right: 0; transform: none; }
.spark-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.trend-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trend-table th, .trend-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.trend-table th:first-child, .trend-table td:first-child { text-align: left; }
.table-scroll { overflow-x: auto; }

/* Band stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 4px; }
.stat-grid .card { margin-bottom: 0; }

/* Playlists */
.spotify-embed { display: block; width: 100%; border: 0; border-radius: 12px; margin: 10px 0 12px; }
.pl-icon { width: 44px; height: 44px; border-radius: var(--radius); background: var(--accent-bg); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.code-form select { flex: 1; min-width: 0; }
.code-form .btn, .code-form form { flex: none; }

/* Manager pages */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 16px; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2) !important; text-decoration: none; font-size: 14px; }
.tab.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-text) !important; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
label.check input { width: 20px; height: 20px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: var(--live) !important; }
.inline { display: inline; margin: 0; }
details.edit summary { cursor: pointer; color: var(--accent-strong); font-size: 13px; list-style: none; }
details.edit[open] { width: 100%; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; flex: none; }
.code { font-family: Consolas, Menlo, monospace; font-size: 20px; font-weight: 700; letter-spacing: .08em; }
.stat { font-size: 26px; font-weight: 800; }

/* Footer */
footer { border-top: 1px solid var(--border); padding: 20px 0 32px; color: var(--text-3); font-size: 13px; }
footer a { color: var(--text-2); }

@media (max-width: 560px) {
  h1 { font-size: 21px; }
  .nav { gap: 10px; }
  .nav .hide-sm { display: none; }
}
