:root {
  --bg: #15172b;
  --surface: #20233f;
  --surface-2: #2a2e52;
  --line: #363a63;
  --text: #f6f2e9;
  --muted: #a3a6c4;
  --amber: #f5b942;
  --amber-ink: #2a1d00;
  --live: #ff6b5c;
  --ok: #6fd39a;
  --radius: 14px;
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; line-height: 1.35; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; background: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
input[type=search], input[type=text], input[type=password], input[type=number] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; -webkit-appearance: none;
}
input::placeholder { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.brand { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; }

/* ---------- vote meter ---------- */
.meter { margin-top: 10px; }
.meter-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.meter-bar span { display: block; height: 100%; transition: flex-basis .3s; }
.meter-bar .placed { background: var(--amber); }
.meter-bar .used { background: var(--muted); }
.meter-text { margin-top: 6px; font-size: 14px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.meter-text b { color: var(--text); }
.meter-text .available b { color: var(--amber); }

/* ---------- banner ---------- */
.banner { margin: 12px 16px 0; padding: 12px 16px; border-radius: var(--radius); background: var(--live); color: #2b0d09; font-weight: 600; }
.banner .label { font-size: 12px; opacity: .8; display: block; }
.banner-closed { background: var(--surface-2); color: var(--text); font-weight: 500; }

/* ---------- song list (audience) ---------- */
.search { padding: 12px 16px; }
.songs { list-style: none; margin: 0; padding: 0 16px 40px; }
.song { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.song-text { flex: 1; min-width: 0; }
.song-title { font-size: 17px; font-weight: 600; }
.song-artist { font-size: 14px; color: var(--muted); }
.vote { flex: none; width: 88px; height: 44px; border-radius: 22px; border: 2px solid var(--amber); color: var(--amber); font-weight: 700; font-size: 15px; transition: transform .1s; }
.vote:active { transform: scale(.95); }
.vote.on { background: var(--amber); color: var(--amber-ink); }
.vote:disabled { opacity: .35; cursor: default; }
.song.playing .vote { border-color: var(--live); color: var(--live); opacity: 1; }
.song.playing .vote.on { background: var(--live); color: #2b0d09; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 22px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--live); color: #2b0d09; text-align: center; font-size: 13px; padding: 4px; z-index: 10; }

/* ---------- performer ---------- */
.doffe { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr; height: 100vh; overflow: hidden; }
.doffe-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.doffe-head .brand { font-size: 20px; }
.doffe-head .stats { color: var(--muted); font-size: 14px; }
.doffe-head .grow { flex: 1; }
.pill { padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 600; background: var(--surface-2); }
.pill.open { background: var(--ok); color: #05301a; }
.pill.closed { background: var(--surface-2); color: var(--muted); }
.main { overflow-y: auto; padding: 16px 20px 40px; }
.side { overflow-y: auto; border-left: 1px solid var(--line); padding: 16px; background: var(--surface); }
h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 8px 0 10px; }

.top10 { list-style: none; margin: 0; padding: 0; }
.top10 li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank { font-size: 28px; font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.top10 .song-title { font-size: 22px; }
.top10 .song-artist { font-size: 16px; }
.count { display: inline-block; margin-top: 2px; font-size: 14px; color: var(--amber); font-weight: 600; }
.play { height: 64px; padding: 0 22px; border-radius: 32px; background: var(--amber); color: var(--amber-ink); font-size: 17px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.play:active { transform: scale(.97); }
.play:disabled { opacity: .35; cursor: default; }

.nowcard { border: 3px solid var(--live); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 20px; }
.nowcard .label { font-size: 13px; color: var(--live); font-weight: 700; }
.nowcard .song-title { font-size: 26px; }
.countdown { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; }
.undo { height: 64px; padding: 0 26px; border-radius: 32px; background: var(--live); color: #2b0d09; font-size: 17px; font-weight: 800; }
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.results .song-title { font-size: 17px; }
.results .status { font-size: 13px; color: var(--muted); }
.results .play { height: 48px; padding: 0 16px; font-size: 14px; }
.admin { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.btn { height: 46px; padding: 0 16px; border-radius: 23px; background: var(--surface-2); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--ok); color: #05301a; }
.btn.danger { background: transparent; border: 2px solid var(--live); color: var(--live); }
.admin input[type=number] { width: 90px; padding: 10px 12px; text-align: center; }
.admin .note { font-size: 13px; color: var(--muted); }
.login { max-width: 360px; margin: 18vh auto; padding: 0 20px; }
.login h1 { font-size: 24px; margin-bottom: 6px; }
.login p { color: var(--muted); margin-top: 0; }
.login .btn { width: 100%; margin-top: 12px; }
.err { color: var(--live); font-size: 14px; margin-top: 8px; }

@media (max-width: 900px) {
  .doffe { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- catalogue management ---------- */
.tabs { display: flex; gap: 4px; margin-left: 12px; padding: 4px; background: var(--surface); border-radius: 24px; }
.tab { height: 38px; padding: 0 18px; border-radius: 19px; font-weight: 600; font-size: 15px; color: var(--muted); }
.tab.active { background: var(--amber); color: var(--amber-ink); }
.add-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 14px; max-width: 900px; }
.catalogue { list-style: none; margin: 12px 0 0; padding: 0; max-width: 900px; }
.catalogue li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.catalogue .song-title { font-size: 18px; }
.catalogue .song-artist { font-size: 14px; }
#view-catalogue input[type=search] { max-width: 900px; }
.del { flex: none; height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600; }
.del:active { border-color: var(--live); color: var(--live); }
@media (max-width: 600px) { .add-form { grid-template-columns: 1fr; } }

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; max-width: 900px; }
.history li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.history .song-title { font-size: 20px; }
.history .meta { text-align: right; }
.history .time { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history .status { font-size: 13px; color: var(--muted); }
.history li.now .time, .history li.now .status { color: var(--live); }
