:root {
  --bg: #0d0b14;
  --bg2: #16131f;
  --card: #1d1929;
  --line: #2e2840;
  --text: #f2eff8;
  --muted: #a39cb5;
  --accent: #c04bff;
  --accent2: #ff4f9a;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5d6c;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { font-size: .85rem; word-break: break-all; color: var(--muted); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 12px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: #4a4163; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; }
.btn.small { padding: 8px 12px; font-size: .88rem; border-radius: 10px; }
.btn.danger { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
input, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #c04bff33; }

/* ------------------------------------------------------------- guest ---- */
.guest .wrap { max-width: 520px; margin: 0 auto; padding: 22px 16px 60px; }
.g-head { text-align: center; padding: 10px 0 18px; }
.logo {
  width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center;
  font-size: 30px; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 8px 30px #c04bff55;
}
.g-head h1 { font-size: 1.6rem; }
.sub { color: var(--muted); margin: 6px 0 14px; }
.note {
  margin: 14px auto 0; max-width: 34ch; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px;
  font-size: .85rem; color: var(--muted); line-height: 1.4;
}
.quota { display: inline-flex; align-items: center; gap: 10px; font-size: .92rem; color: var(--muted); }
.dots { display: inline-flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.dot.used { background: var(--line); }

.search { position: sticky; top: 0; z-index: 2; display: block; padding: 6px 0 10px; background: var(--bg); }
.search input { padding-left: 42px; background: var(--bg2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23a39cb5' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m17 17-4.5-4.5'/%3E%3C/svg%3E") 14px 50% no-repeat; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.results button {
  width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: inherit; cursor: pointer; display: flex; align-items: center; gap: 12px;
}
.results button:active { background: #2a2340; }
.results .t { font-weight: 600; }
.results .a { color: var(--muted); font-size: .9rem; }
.results .plus { margin-left: auto; color: var(--accent); font-size: 1.4rem; font-weight: 300; }
.hint { color: var(--muted); text-align: center; padding: 18px 0; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.form .btn { margin-top: 4px; }

.done { text-align: center; padding: 30px 18px; }
.done .big { font-size: 44px; }
.done h2 { font-size: 1.3rem; margin: 8px 0 6px; }

#mine { margin-top: 28px; }
#mine h2 { margin-bottom: 10px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mine li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--bg2); }
.mine .song { min-width: 0; }
.mine .song div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine .a { color: var(--muted); font-size: .85rem; }
.status { margin-left: auto; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.status.active { background: #c04bff22; color: var(--accent); }
.status.played { background: #3ddc9722; color: var(--ok); }
.status.dismissed { background: #ffffff10; color: var(--muted); }

.sheet { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; justify-content: center; z-index: 10; animation: fade .15s; }
.sheet-card { width: 100%; max-width: 520px; background: var(--card); border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet-title { font-size: 1.3rem; font-weight: 700; margin-top: 6px; }
.sheet-artist { color: var(--muted); margin-bottom: 20px; }
.row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  background: #fff; color: #111; font-weight: 600; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px #0008; animation: up .2s;
}
.toast.err { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translate(var(--tx, 0), 20px); opacity: 0; } }
.toast { --tx: -50%; }

/* --------------------------------------------------------- dashboard ---- */
.dj-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 22px; background: #0d0b14ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; margin: 0; font-size: 18px; border-radius: 10px; box-shadow: none; }
.mode-toggle { display: flex; align-items: center; gap: 10px; margin-left: auto; font-weight: 600; }
.mode-toggle span { color: var(--muted); transition: color .15s; }
.mode-toggle span.on { color: var(--text); }
.switch { position: relative; width: 58px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; border-radius: 99px; background: linear-gradient(135deg, var(--accent), var(--accent2)); transition: .2s; }
.slider::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: linear-gradient(135deg, #ffb547, #ff7a3d); }
.switch input:checked + .slider::after { transform: translateX(26px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px #fff6; }
.bar-right { display: flex; align-items: center; gap: 12px; }
.live { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.live.on::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.dj-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; padding: 22px; max-width: 1300px; margin: 0 auto; }
@media (max-width: 900px) { .dj-main { grid-template-columns: 1fr; } .mode-toggle { margin-left: 0; } }
.feed-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.feed-head h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.count { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 99px; padding: 1px 10px; font-size: .95rem; }
.seg { margin-left: auto; display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-size: .85rem; color: var(--muted); background: none; border: 0; padding: 6px 11px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); }

.feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.req {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); transition: opacity .25s, transform .25s;
}
.req.fresh { animation: flash 2.5s ease-out; }
.req.leaving { opacity: 0; transform: translateX(30px); }
@keyframes flash { 0% { border-color: var(--accent); box-shadow: 0 0 0 3px #c04bff55; } 100% { border-color: var(--line); box-shadow: none; } }
.req-main { min-width: 0; flex: 1; }
.req-title { font-size: 1.15rem; font-weight: 700; }
.req-artist { color: var(--muted); }
.req-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: .78rem; color: var(--muted); align-items: center; }
.badge { padding: 2px 8px; border-radius: 99px; background: #ffffff0d; font-weight: 600; }
.badge.votes { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.badge.lib { background: #3ddc9720; color: var(--ok); }
.badge.nolib { background: #ffb54720; color: var(--warn); }
.badge.free { background: #ffffff12; }
.req-actions { display: flex; gap: 8px; flex: none; }
.btn.played { background: #3ddc9722; border-color: #3ddc9755; color: var(--ok); }
.btn.played:hover { background: #3ddc9738; }
.btn.dismiss { color: var(--muted); }
.btn.dismiss:hover { color: var(--bad); border-color: #ff5d6c66; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

.side { display: grid; gap: 16px; align-content: start; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 1.4rem; }
.stats span { font-size: .75rem; color: var(--muted); }
.reach { margin: 0 0 10px; font-size: .85rem; font-weight: 600; }
.reach.ok { color: var(--ok); }
.reach.warn { color: var(--warn); }
.qr-small {background: #fff; border-radius: 10px; padding: 8px; width: 150px; margin-bottom: 10px; }
.qr-small img { display: block; width: 100%; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 320px; overflow: auto; }
.history li { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 6px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history .song { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .undo { font-size: .78rem; padding: 4px 8px; }
.stack { display: grid; gap: 8px; }

.locked { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; padding: 20px; text-align: center; }

/* ----------------------------------------------------------- QR page ---- */
.qr-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; text-align: center; }
.qr-page h1 { font-size: clamp(2rem, 6vw, 3.6rem); }
.qr-page .sub { font-size: 1.2rem; }
.qr-box { background: #fff; border-radius: 26px; padding: 22px; width: min(78vw, 420px); margin: 24px auto; box-shadow: 0 20px 60px #c04bff44; }
.qr-box img { display: block; width: 100%; }
.qr-url { font-size: 1.1rem; color: var(--muted); }
.qr-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; }
@media print {
  body { background: #fff; color: #000; }
  .qr-page .sub, .qr-url { color: #333; }
  .qr-box { box-shadow: none; border: 2px solid #000; }
  .qr-actions { display: none; }
}
