:root {
  --bg: #0d0b1a;
  --bg-soft: #171331;
  --card: #1d1840;
  --card-2: #221c4a;
  --line: #342c63;
  --line-soft: #2a2352;
  --text: #f3f0ff;
  --muted: #a99fd4;
  --accent: #ff2e88;
  --accent-2: #8a5bff;
  --gold: #ffd166;
  --good: #36d399;
  --danger: #ff5d6c;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #2a1d5e 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 80px; }
.wrap.wide { max-width: 980px; }

header.top { text-align: center; padding: 14px 0 10px; }
.brand {
  font-size: 30px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 60%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); margin-top: 4px; font-size: 15px; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.tight { padding: 14px 16px; }

h2 { margin: 0 0 12px; font-size: 19px; }
h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .9px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
a { color: var(--accent); }

input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; font-family: inherit;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); }
input::placeholder, textarea::placeholder { color: #7d74a8; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

button {
  font: inherit; font-weight: 700; cursor: pointer;
  border: none; border-radius: 12px; padding: 13px 16px; font-size: 16px;
  color: #fff; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: transform .05s ease, filter .15s ease, opacity .15s ease;
  white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.full { width: 100%; }
button.big { padding: 18px 20px; font-size: 19px; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.link { background: none; border: none; color: var(--muted); padding: 4px 6px; font-weight: 600; font-size: 14px; text-decoration: underline; }
button.sm { padding: 8px 11px; font-size: 14px; border-radius: 10px; }
button.danger { background: linear-gradient(90deg, #ff5d6c, #d6344e); }
button.good { background: linear-gradient(90deg, #36d399, #1d9e72); }
button.gold { background: linear-gradient(90deg, #ffd166, #f0a93b); color: #2a1d00; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; max-width: none; margin: 0; padding: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800;
  letter-spacing: .6px; text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--good); border-color: rgba(54,211,153,.4); }
.pill.live .dot { animation: pulse 1.6s infinite; }
.pill.paused { color: var(--gold); border-color: rgba(255,209,102,.4); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* Now singing strip */
.nowbar {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid rgba(255,209,102,.45); background: #2a2410; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 16px;
}
.nowbar .lbl { font-size: 11px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase; color: var(--gold); }
.nowbar .who { font-weight: 800; font-size: 17px; }
.nowbar .what { color: #e8dcb0; font-size: 14px; }
.mic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--gold), #f0a93b); color: #2a1d00; font-weight: 900; }

/* Song picker */
.searchbar { position: sticky; top: 0; z-index: 2; background: var(--card); padding-bottom: 8px; }
.results { max-height: 52vh; overflow-y: auto; margin-top: 4px; border-radius: 12px; -webkit-overflow-scrolling: touch; }
.letter { font-size: 12px; font-weight: 800; color: var(--accent-2); letter-spacing: 1px; padding: 10px 4px 4px; }
.song {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--line-soft); border-radius: 12px;
  margin-bottom: 6px; background: var(--bg-soft); cursor: pointer; width: 100%;
  text-align: left; color: var(--text); font-weight: 400;
}
.song:hover { border-color: var(--accent-2); filter: none; }
.song.selected { border-color: var(--accent); background: #2a1442; }
.song .title { font-weight: 700; font-size: 15px; }
.song .artist { color: var(--muted); font-size: 13px; }
.song .meta { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.song .pick { color: var(--accent); font-weight: 700; font-size: 14px; }
.picked {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--accent);
  background: #2a1442; border-radius: 12px; padding: 12px 14px;
}
.picked .title { font-weight: 800; }
.picked .artist { color: var(--muted); font-size: 14px; }
.count-line { font-size: 12px; color: var(--muted); margin: 2px 2px 6px; }

/* Queue list */
.qitem {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 12px;
  margin-bottom: 8px; background: var(--bg-soft);
}
.qitem.me { border-color: var(--accent); background: #2a1442; }
.qitem.performing { border-color: var(--gold); background: #2e2710; box-shadow: 0 0 0 1px var(--gold) inset; }
.qitem.done { opacity: .55; }
.qitem.dragging { opacity: .4; }
.qitem.drop-above { box-shadow: 0 -3px 0 0 var(--accent) ; }
.qitem.drop-below { box-shadow: 0 3px 0 0 var(--accent) ; }
.handle { cursor: grab; color: var(--muted); font-size: 18px; padding: 0 2px; user-select: none; touch-action: none; letter-spacing: -2px; }
.pos {
  flex: 0 0 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff;
}
.qitem.performing .pos { background: linear-gradient(180deg, var(--gold), #f0a93b); color: #2a1d00; }
.qitem.done .pos { background: var(--line); }
.qbody { flex: 1; min-width: 0; }
.qbody .name { font-weight: 700; overflow-wrap: anywhere; }
.qbody .songline { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.qbody .note { font-size: 13px; color: var(--gold); margin-top: 3px; overflow-wrap: anywhere; }
.qactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; vertical-align: 2px; }
.tag.now { background: var(--gold); color: #2a1d00; }
.tag.you { background: var(--accent); color: #fff; }
.tag.soft { background: var(--line); color: var(--text); }

.banner {
  border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--bg-soft);
}
.banner.good { border-color: var(--good); }
.banner.warn { border-color: var(--gold); background: #2a2410; }
.banner.err  { border-color: var(--danger); color: #ffd7dc; }

.big-spot { text-align: center; padding: 6px 0 4px; }
.big-spot .num { font-size: 72px; font-weight: 800; line-height: 1;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.big-spot .lbl { color: var(--text); margin-top: 8px; font-size: 17px; font-weight: 700; }
.big-spot .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.big-spot.up .num { font-size: 40px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--muted); }

/* Host layout */
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }
.qrbox { background: #fff; border-radius: 12px; padding: 12px; display: inline-block; }
.qrbox img, .qrbox canvas { display: block; }
.urlline { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; margin-top: 8px; }
.timer { font-variant-numeric: tabular-nums; }

details.past summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: 14px; }
.pastrow { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.pastrow:last-child { border-bottom: none; }

/* Modal sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(5,3,15,.7); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #fff; color: #1a1240; font-weight: 700; padding: 12px 18px;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 60; opacity: 0;
  transition: opacity .2s ease; pointer-events: none; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }
.toast.err { background: #ffdde1; color: #7a1020; }

.navlinks { text-align: center; margin-top: 8px; }
.navlinks a { color: var(--muted); text-decoration: none; font-size: 13px; margin: 0 8px; }
.navlinks a:hover { color: var(--text); }

.refresh-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: #fff; text-align: center;
  font-size: 13px; font-weight: 700; padding: 6px; z-index: 70; }

/* Song admin table */
.srow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft);
  border-radius: 12px; margin-bottom: 6px; background: var(--bg-soft); }
.srow.hiddensong { opacity: .5; }
.srow input[type=text] { padding: 8px 10px; font-size: 15px; }
.reqs { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }
