:root {
  --bg: #0b0a12;
  --panel: rgba(22, 19, 31, 0.62);
  --panel2: rgba(30, 26, 46, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f2ff;
  --muted: #9a94b8;
  --pink: #ff2e88;
  --violet: #8a5cff;
  --cyan: #00e5cc;
  --gold: #ffc857;
  --danger: #ff5c5c;
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { -webkit-tap-highlight-color: transparent; }

/* ---------- thanh tab trên mobile ---------- */
#mobileTabs { display: none; }

html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(138, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 650px at -10% 110%, rgba(0, 229, 204, 0.12), transparent 60%),
    radial-gradient(700px 500px at 50% 115%, rgba(255, 71, 160, 0.10), transparent 65%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: rgba(11, 10, 18, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; }
.logo span {
  background: linear-gradient(90deg, var(--pink), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.head-right { display: flex; align-items: center; gap: 12px; }
.chip {
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.chip.on { color: var(--cyan); border-color: rgba(0, 229, 204, 0.4); }
.name-input {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 12px; width: 150px; font-size: 13.5px; outline: none;
}
.name-input:focus { border-color: var(--violet); }

/* ---------- layout ---------- */
main {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 18px; padding: 18px 22px 60px; max-width: 1500px; margin: 0 auto;
}
@media (max-width: 1050px) { main { grid-template-columns: minmax(0, 1fr); } }
.right { display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
h2 { margin: 0 0 14px; font-size: 17px; }
h2 .count { font-size: 13px; color: var(--muted); font-weight: 500; }
.queue-mode { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--cyan); vertical-align: middle; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 14px 6px; line-height: 1.6; }

/* ---------- search ---------- */
.search-bar { display: flex; gap: 10px; }
.search-bar input {
  flex: 1; background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 14.5px; outline: none;
}
.search-bar input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 46, 136, 0.15); }
.examples { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ex {
  background: rgba(138, 92, 255, 0.12); border: 1px solid rgba(138, 92, 255, 0.3);
  color: #cfc3ff; border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer;
}
.ex:hover { background: rgba(138, 92, 255, 0.25); }

.parsed {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 229, 204, 0.07); border: 1px solid rgba(0, 229, 204, 0.25);
  font-size: 13px; line-height: 1.7;
}
.parsed .tag {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 9px; border-radius: 999px;
  background: rgba(0, 229, 204, 0.12); border: 1px solid rgba(0, 229, 204, 0.3); color: #9df2e7;
  font-size: 12px;
}

.results {
  margin-top: 14px; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
}
.card {
  background: #0f0d1a; border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(255, 46, 136, 0.45); }
.thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur, .fit {
  position: absolute; border-radius: 7px; font-size: 11.5px; font-weight: 700; padding: 2px 7px;
}
.dur { right: 6px; bottom: 6px; background: rgba(0, 0, 0, 0.78); color: #fff; }
.fit { right: 6px; top: 6px; color: #0b0a12; }
.fit.hi { background: linear-gradient(90deg, #4ade80, var(--cyan)); }
.fit.mid { background: linear-gradient(90deg, var(--gold), #ffa94d); }
.fit.low { background: #b9b3d0; }
.qbadge {
  position: absolute; left: 6px; top: 6px; border-radius: 7px;
  font-size: 11px; font-weight: 800; padding: 2px 7px; color: #04201c;
  background: #b9b3d0; box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.qbadge.q4k { background: linear-gradient(90deg, var(--gold), #ff9d4d); color: #1c1204; }
.qbadge.qfhd { background: linear-gradient(90deg, #00b8a2, var(--cyan)); }
.qbadge.qhd { background: linear-gradient(90deg, #7dd3fc, #38bdf8); }
.qbadge.qsd { color: #1c1a26; }
.meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.title {
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 38px;
}
.channel { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(138, 92, 255, 0.15); border: 1px solid rgba(138, 92, 255, 0.35); color: #d6c9ff;
}
.badge.reason { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; margin-top: auto; }
.why { font-size: 12px; color: var(--muted); font-style: italic; }
.addrow { display: flex; gap: 8px; }
.addrow input {
  flex: 1; min-width: 0; background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 7px 10px; font-size: 13px; outline: none;
}
.prio-toggle { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--gold); cursor: pointer; user-select: none; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 11px; padding: 10px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer; color: var(--text); background: #2a2540; transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.primary { background: linear-gradient(90deg, var(--pink), var(--violet)); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn:disabled, .ibtn:disabled { opacity: 0.35; cursor: not-allowed; }
.actions .btn.ghost.small { padding: 7px 9px; }

/* chọn tone + meta đang phát */
.search-filters { margin-top: 8px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tone-label { font-size: 12.5px; color: var(--muted); }
.tone-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tone-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  font-family: inherit; line-height: 1.4; outline: none;
}
.tone-chip:hover { border-color: var(--cyan); }
.tone-chip.active { background: rgba(94, 190, 183, 0.18); border-color: var(--cyan); color: #fff; font-weight: 600; }
.tone-select {
  background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; outline: none; cursor: pointer;
}
.tone-select:focus { border-color: var(--violet); }
.np-meta { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; align-items: center; }
.np-meta .chip { font-size: 12px; }
.link-chip { cursor: pointer; color: #cfc3ff; border-color: rgba(138, 92, 255, 0.35); }
.link-chip:hover { background: rgba(138, 92, 255, 0.2); }
.admin-chip { cursor: pointer; font-size: 14px; }
.qbtns .ibtn { font-size: 14px; padding: 4px 3px; }

/* banner người hát tiếp theo */
.nextup {
  margin-top: 10px; padding: 9px 13px; border-radius: 11px; font-size: 13px;
  background: rgba(255, 200, 87, 0.08); border: 1px dashed rgba(255, 200, 87, 0.4); color: #ffe3a3;
}

/* cài đặt phòng hát */
.settings { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.settings summary { cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 700; }
.settings[open] summary { margin-bottom: 8px; }
.set-grid { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.set-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.slider-row { display: flex; align-items: center; gap: 9px; padding-left: 4px; }
.slider-row span { width: 58px; flex: none; color: var(--muted); font-size: 12.5px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--pink); }
.slider-row b { width: 32px; text-align: right; font-size: 12px; color: var(--cyan); }
.fx-block { border-top: 1px dashed var(--line); padding-top: 9px; display: flex; flex-direction: column; gap: 7px; }

/* 🔥 bài hát hot */
.hot-wrap { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.hot-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.hot-title { font-weight: 800; font-size: 14.5px; }
.hot-head select {
  background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; outline: none;
}
.hot-prefs { margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.hot-hint { font-size: 12px; color: var(--gold); margin-bottom: 8px; }
.hot-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow: auto; }
.hotrow {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 11px; background: #0f0d1a; border: 1px solid var(--line);
}
.hotrow.boosted { border-color: rgba(255, 200, 87, 0.45); background: rgba(255, 200, 87, 0.05); }
.hotmeta { flex: 1; min-width: 0; }
.hotname { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hotsub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.hotbtns { display: flex; gap: 6px; flex: none; }
.btn.voice { padding: 10px 13px; font-size: 17px; background: rgba(138, 92, 255, 0.15); border: 1px solid rgba(138, 92, 255, 0.35); }
.btn.voice:hover { background: rgba(138, 92, 255, 0.3); }
.btn.voice.listening {
  background: var(--danger); border-color: transparent; color: #fff;
  animation: mic-pulse 1.1s infinite;
}
.btn.voice.busy { opacity: .72; cursor: progress; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.55); }
  60% { box-shadow: 0 0 0 12px rgba(255, 92, 92, 0); }
}
.btn.mic { background: linear-gradient(90deg, #00b8a2, var(--cyan)); color: #04201c; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.ibtn { background: transparent; border: none; cursor: pointer; font-size: 15px; padding: 4px; border-radius: 7px; opacity: 0.75; }
.ibtn:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }

/* ---------- now playing ---------- */
.now-info { margin-bottom: 10px; font-size: 14px; line-height: 1.55; min-height: 22px; }
.now-info b { font-size: 15px; }
.player-wrap {
  position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden;
  background: #000; border: 1px solid var(--line);
}
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px;
}
#playerSlot:empty::after {
  content: "📺 Video đang ở chế độ hình trong hình (PiP) — đóng cửa sổ PiP để đưa về đây";
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16/9; border-radius: 12px; background: #000;
  border: 1px dashed rgba(0, 229, 204, 0.4); color: var(--cyan); font-size: 13.5px;
  padding: 0 20px; text-align: center;
}
.btn.active { background: linear-gradient(90deg, var(--pink), var(--violet)); color: #fff; border-color: transparent; }

.now-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.fx-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.fx-btn {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.fx-btn:hover { transform: scale(1.15); border-color: var(--cyan); background: rgba(94,190,183,0.12); }
.fx-btn:active { transform: scale(0.92); }
.fx-icon { width: 21px; height: 21px; display: block; object-fit: contain; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.fx-emoji {
  position: absolute; line-height: 1; will-change: transform, opacity;
  animation: fx-float 1.6s ease-out forwards;
}
.fx-emoji.fx-artwork { width: var(--fx-size, 40px); height: var(--fx-size, 40px); }
.fx-emoji.fx-artwork img { width: 100%; height: 100%; display: block; object-fit: contain; }
.fx-emoji.fx-firework { animation-name: fx-firework; }
@keyframes fx-float {
  0% { transform: translate(0,0) scale(0.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; }
}
@keyframes fx-firework {
  0% { transform: translate(0,0) scale(0.3); opacity: 0; }
  20% { opacity: 1; transform: translate(calc(var(--dx)*0.3), calc(var(--dy)*0.3)) scale(1.4); }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}
.meter-wrap { margin-top: 12px; }
.meter-head { font-size: 13px; color: var(--muted); margin-bottom: 7px; display: flex; align-items: center; gap: 7px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
#noteNow { color: var(--cyan); font-weight: 700; }
#meter { width: 100%; height: 44px; border-radius: 10px; background: #0e0c17; border: 1px solid var(--line); }

/* ---------- queue ---------- */
.queue-list { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow: auto; }
.qrow {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 12px; background: #0f0d1a; border: 1px solid var(--line);
}
.qrow.priority { border-left: 3px solid var(--gold); }
.qrow.current-next { border-left: 3px solid var(--cyan); }
.qidx { width: 22px; text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; flex: none; }
.qthumb { width: 62px; height: 35px; object-fit: cover; border-radius: 7px; flex: none; }
.qmeta { flex: 1; min-width: 0; }
.qtitle {
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qsub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.qbtns { display: flex; align-items: center; gap: 2px; flex: none; }
.star { font-size: 13px; }

/* ---------- bảng vàng ---------- */
.gold-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow: auto; }
.grow {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 12px; background: rgba(255, 200, 87, 0.05); border: 1px solid rgba(255, 200, 87, 0.18);
}
.gscore {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #0b0a12;
  background: linear-gradient(135deg, var(--gold), #ff9d4d);
}
.gscore.mid { background: linear-gradient(135deg, #7dd3fc, var(--cyan)); }
.gscore.low { background: #b9b3d0; }
.gmeta { flex: 1; min-width: 0; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(5, 4, 10, 0.72);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: linear-gradient(180deg, #241f38, var(--panel));
  border: 1px solid var(--line); border-radius: 20px; padding: 24px;
  width: min(560px, 100%); max-height: 88vh; overflow: auto; position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 20px; cursor: pointer;
}
.score-big {
  font-size: 64px; font-weight: 900; text-align: center; line-height: 1;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.score-grade { text-align: center; font-size: 20px; font-weight: 700; margin: 6px 0 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar-label { width: 130px; flex: none; color: var(--muted); }
.bar-track { flex: 1; height: 10px; border-radius: 999px; background: #0e0c17; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--pink)); }
.bar-val { width: 52px; text-align: right; flex: none; font-weight: 700; }
.fb {
  margin-top: 16px; padding: 13px 15px; border-radius: 12px; line-height: 1.65; font-size: 14px;
  background: rgba(0, 229, 204, 0.07); border: 1px solid rgba(0, 229, 204, 0.25);
}
.fb-title { font-size: 12px; color: var(--cyan); font-weight: 700; margin-bottom: 5px; letter-spacing: 0.4px; }
.desc { white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; color: #cfcadd; max-height: 300px; overflow: auto; }
.lyrics-wrap { margin: 10px 0 12px; }
.lyrics-title { font-size: 12px; color: var(--cyan); font-weight: 700; margin-bottom: 6px; letter-spacing: 0.4px; }
.lyrics { max-height: 240px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,0.2); }
.lyrics.empty { color: #8b86a3; font-size: 13px; }
.lyrics .lrow { padding: 3px 6px; border-radius: 6px; font-size: 14px; line-height: 1.6; color: #cfcadd; transition: color 0.2s, background 0.2s; }
.lyrics .lrow.active { color: #fff; background: rgba(94, 190, 183, 0.18); font-weight: 700; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: #2a2540; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: pop 0.2s ease;
}
.toast.error { border-color: rgba(255, 92, 92, 0.5); color: #ffb3b3; }
.toast.ok { border-color: rgba(74, 222, 128, 0.5); color: #b8f5c9; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }

.loading { text-align: center; color: var(--muted); padding: 30px; grid-column: 1/-1; font-size: 14px; }
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--muted); border-top-color: var(--pink); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ---------- 🔐 đăng nhập & 🏠 phòng ---------- */
.auth-card { width: min(360px, 92vw); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.auth-tabs button {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-weight: 700; cursor: pointer;
}
.auth-tabs button.active { background: linear-gradient(90deg, var(--pink), var(--violet)); color: #fff; border-color: transparent; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.auth-card input {
  width: 100%; margin-top: 8px; background: #0e0c17; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 12px; font-size: 16px; outline: none;
}
.auth-card input:focus { border-color: var(--violet); }

#roomBar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 22px; border-bottom: 1px solid var(--line);
  background: rgba(11, 10, 18, 0.9); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 45; font-size: 13.5px;
}
#roomBar[hidden] { display: none !important; }
@media (max-width: 1050px) {
  #roomBar { padding: 7px 12px; top: 0; }
  header { position: static; }
}

/* room picker */
.rp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.rp-room {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #0f0d1a; color: var(--text); cursor: pointer; text-align: left;
}
.rp-room:hover { border-color: var(--pink); }
.rp-room.owner { border-color: rgba(255, 200, 87, 0.45); }
.rp-code { color: var(--muted); font-size: 12px; }
.rp-actions { display: flex; gap: 8px; margin-top: 10px; }
.rp-actions input {
  flex: 1; background: #0e0c17; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; outline: none;
}

/* ---------- 📊 thống kê ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 9px; }
.stat-card {
  background: #0f0d1a; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; text-align: center;
}
.stat-val { font-size: 22px; font-weight: 900; color: var(--gold); }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.srow {
  display: flex; justify-content: space-between; gap: 10px; font-size: 13px;
  padding: 7px 10px; border-radius: 9px; background: rgba(255,255,255,0.03); margin-top: 5px;
}
#panelStats h3 { margin: 12px 0 6px; font-size: 14px; color: #d6c9ff; }

/* ---------- hiệu ứng nền động (aurora, kiểu build.nvidia.com) ---------- */
.bg-blob {
  position: fixed; z-index: -1; pointer-events: none;
  border-radius: 50%; filter: blur(90px); opacity: 0.55;
  will-change: transform;
}
.bg-blob.b1 {
  width: 55vw; height: 55vw; left: -12vw; top: -14vw;
  background: radial-gradient(circle at 30% 30%, rgba(138, 92, 255, 0.55), transparent 70%);
  animation: bg-drift1 22s ease-in-out infinite alternate;
}
.bg-blob.b2 {
  width: 48vw; height: 48vw; right: -10vw; top: 4vh;
  background: radial-gradient(circle at 60% 40%, rgba(0, 229, 204, 0.4), transparent 70%);
  animation: bg-drift2 26s ease-in-out infinite alternate;
}
.bg-blob.b3 {
  width: 50vw; height: 50vw; left: 18vw; bottom: -18vw;
  background: radial-gradient(circle at 50% 50%, rgba(255, 71, 160, 0.32), transparent 70%);
  animation: bg-drift3 30s ease-in-out infinite alternate;
}
.bg-blob.b4 {
  width: 34vw; height: 34vw; right: 16vw; bottom: 6vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 200, 60, 0.22), transparent 70%);
  animation: bg-drift1 35s ease-in-out infinite alternate-reverse;
}
.bg-blob.b5 {
  width: 46vw; height: 40vw; left: 50%; top: -18vw; transform: translateX(-50%);
  background: radial-gradient(circle at 50% 40%, rgba(124, 215, 254, 0.4), transparent 70%);
  animation: bg-drift2 28s ease-in-out infinite alternate;
}
@keyframes bg-drift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(8vw, 6vh) scale(1.15); }
}
@keyframes bg-drift2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-7vw, 9vh) scale(1.1); }
}
@keyframes bg-drift3 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(5vw, -8vh) scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  .bg-blob { animation: none !important; }
}

/* ---------- canvas particle nền (kiểu build.nvidia.com) ---------- */
.bg-canvas {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  width: 100vw; height: 100vh; opacity: 0.6;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: 28px; padding: 22px 18px calc(26px + env(safe-area-inset-bottom));
  text-align: center; border-top: 1px solid var(--line);
  background: radial-gradient(640px 240px at 50% 0%, rgba(138, 92, 255, 0.12), transparent 70%);
}
.footer-inner { max-width: 980px; margin: 0 auto; }
.footer-brand { font-size: 15px; font-weight: 800; margin-bottom: 8px; }
.footer-brand span { background: linear-gradient(90deg, var(--pink), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.footer-text { font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.footer-text strong { color: var(--text); }
.footer-note { margin-top: 8px; font-size: 13px; color: var(--cyan); font-weight: 600; }

/* ---------- overlay đếm ngược trước bài kế tiếp ---------- */
.gap-overlay {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px);
}
.gap-box { text-align: center; }
.gap-title { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.gap-song { font-size: 17px; font-weight: 700; color: #fff; margin-bottom: 2px; padding: 0 16px; }
.gap-singer { font-size: 14px; color: var(--cyan); margin-bottom: 10px; }
.gap-count { font-size: 56px; font-weight: 900; color: #fff; line-height: 1; margin-bottom: 14px; }
.gap-box .btn { font-size: 15px; padding: 10px 22px; }


@media (max-width: 1050px) {
  main { grid-template-columns: minmax(0, 1fr); }

  /* header gọn, không chiếm chỗ khi cuộn */
  header { position: static; padding: 10px 14px; gap: 8px; }
  .logo { font-size: 17px; white-space: nowrap; }
  .head-right { gap: 6px; min-width: 0; }
  .head-right .chip { max-width: 34vw; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .name-input { width: 108px; padding: 7px 9px; font-size: 13px; }

  #mobileTabs {
    display: flex; gap: 6px; padding: 8px 12px;
    position: sticky; top: 0; z-index: 40;
    background: rgba(11, 10, 18, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .mtab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
    min-height: 40px; border-radius: 11px; border: 1px solid var(--line);
    background: var(--panel); color: var(--muted);
    font-size: 13px; font-weight: 700; cursor: pointer; position: relative;
  }
  .mtab.active {
    color: #fff; border-color: transparent;
    background: linear-gradient(90deg, var(--pink), var(--violet));
  }
  .mtab .dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
    display: none;
  }
  .mtab .dot.on { display: inline-block; animation: blink 1.2s infinite; }
  .tabcount {
    background: var(--gold); color: #1c1204; border-radius: 999px;
    font-size: 11px; font-weight: 800; padding: 1px 7px;
  }
  .tabcount:empty { display: none; }

  /* mỗi tab chỉ hiện đúng mục của nó */
  body[data-view="search"] .right { display: none; }
  body[data-view="now"] .left,
  body[data-view="now"] #panelQueue,
  body[data-view="now"] #panelFav,
  body[data-view="now"] #panelGold { display: none; }
  body[data-view="queue"] .left,
  body[data-view="queue"] #panelNow,
  body[data-view="queue"] #panelFav,
  body[data-view="queue"] #panelGold { display: none; }
  body[data-view="fav"] .left,
  body[data-view="fav"] #panelNow,
  body[data-view="fav"] #panelQueue,
  body[data-view="fav"] #panelGold { display: none; }
  body[data-view="gold"] .left,
  body[data-view="gold"] #panelNow,
  body[data-view="gold"] #panelQueue,
  body[data-view="gold"] #panelFav { display: none; }
  body[data-view="stats"] .left,
  body[data-view="stats"] #panelNow,
  body[data-view="stats"] #panelQueue,
  body[data-view="stats"] #panelFav,
  body[data-view="stats"] #panelGold { display: none; }

  main { padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); gap: 12px; }
  .panel { padding: 14px; border-radius: 14px; }
  h2 { font-size: 15.5px; }

  /* chống iOS tự zoom khi focus (cần >= 16px) */
  .search-bar input, .name-input, .addrow input, .tone-select { font-size: 16px; }
  .search-bar { flex-wrap: wrap; }
  .search-bar input { flex: 1 1 100%; padding: 13px 14px; }
  .search-bar .btn.voice { flex: 0 0 58px; min-height: 46px; }
  .search-bar .btn.primary { flex: 1 1 auto; min-height: 46px; }

  .btn { min-height: 44px; padding: 10px 16px; }
  .btn.small { min-height: 40px; }
  .ibtn { font-size: 19px; padding: 9px; }
  .qthumb { width: 72px; height: 41px; border-radius: 8px; }
  .qrow { padding: 9px 10px; }
  .qrow .qbtns { gap: 0; }

  .now-actions .btn { flex: 1 1 45%; }
  .head-right .chip { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .examples { font-size: 12px; }

  #toasts { width: 100%; padding: 0 12px; padding-bottom: env(safe-area-inset-bottom); }
  .toast { max-width: 100%; text-align: center; }
  .bar-label { width: 108px; font-size: 12px; }
  .modal-card { padding: 18px 16px; }
  .desc { max-height: 45vh; }
}

@media (max-width: 400px) {
  .results { grid-template-columns: 1fr 1fr; gap: 9px; }
  .title { font-size: 12.5px; }
  .channel { font-size: 11px; }
  .logo { font-size: 18px; }
}
