/* ===== Karaokê · Tela de controle ===== */
:root {
  color-scheme: dark;
  --bg: #0b0b12;
  --bg-elevated: #10101a;
  --surface: #151520;
  --surface-2: #1c1c2a;
  --surface-3: #262638;
  --border: #2a2a3d;
  --border-strong: #3a3a52;
  --text: #f3f2f8;
  --text-2: #b4b3c7;
  --text-3: #7d7c93;
  --accent: #ff3d7f;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(255, 61, 127, 0.14);
  --gradient: linear-gradient(135deg, #ff3d7f 0%, #b14bf4 55%, #8b5cf6 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --topbar-h: 76px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: #ff8db5; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.9em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; width: 100%; }
img { display: block; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.stack { display: grid; gap: 16px; }

/* ----- Botões ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .1s, opacity .15s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgba(255, 61, 127, .25); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: #b91c1c; color: #fff; }
.btn.danger:hover { background: #dc2626; }
.btn.chip { min-height: 34px; padding: 0 14px; background: var(--surface-2); border-color: var(--border); font-weight: 500; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: .88rem; }
.btn.sm .icon { width: 18px; height: 18px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.icon-btn.danger-hover:hover { color: var(--danger); background: rgba(248, 113, 113, .12); }
.icon-btn.fav.on { color: var(--warn); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.pill .icon { width: 16px; height: 16px; }
button.pill { font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
button.pill.off:hover { color: var(--text); border-color: var(--border-strong); }
.pill.ok { color: var(--ok); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .08); }
.pill.off { color: var(--text-3); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08); }

.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: .76rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.tag .icon { width: 14px; height: 14px; }
.tag.subtle { background: transparent; border: 1px solid var(--border); font-weight: 500; }
.tag.ok { background: rgba(52, 211, 153, .12); color: var(--ok); }
.tag.warn { background: rgba(251, 191, 36, .12); color: var(--warn); }
.tag.danger { background: rgba(248, 113, 113, .12); color: var(--danger); }
.tag.kind { font-weight: 700; }
.tag.kind-karaoke { background: var(--accent-soft); color: var(--accent); }
.tag.kind-lyrics { background: rgba(139, 92, 246, .16); color: #c4b5fd; }
.card-meta .tag.kind, .queue-meta .tag.kind, .history-meta .tag.kind { padding-block: 1px; }

/* ----- Estrutura ----- */
.app { display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr); height: 100dvh; }

.topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px;
  padding: 0 20px; background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.15rem; text-decoration: none !important; }
.brand img { border-radius: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr) 390px; min-height: 0; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--bg-elevated); }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: var(--text-2); font-weight: 600; text-decoration: none !important; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #fff; }
.nav a.active .icon { color: var(--accent); }
.nav .nav-queue { display: none; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .75rem; display: grid; place-items: center;
}

.content { overflow-y: auto; padding: 28px clamp(16px, 3vw, 40px) 48px; scroll-behavior: smooth; }
.view { display: none; }
.content > .view.active { display: block; animation: fade .2s ease; }
body[data-view="queue"] #view-search { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 22px; display: grid; gap: 6px; }
.view-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.view-head h1 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 800; }
.section-title { font-size: 1.1rem; margin: 30px 0 12px; }
.section-label { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 18px 0 8px; }

/* ----- Tocando agora (topo) ----- */
.now-playing {
  display: grid; grid-template-columns: 52px minmax(120px, 1fr) auto auto; align-items: center; gap: 16px;
  max-width: 980px; width: 100%; justify-self: center; padding: 8px 14px 8px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.np-art { width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: var(--surface-3); }
.np-art img { width: 100%; height: 100%; object-fit: cover; }
.np-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--text-3); }
.np-main-col { min-width: 0; display: grid; gap: 6px; }
.np-text { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.np-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .98rem; }
.np-singer { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.np-singer .icon { width: 16px; height: 16px; }
.now-playing.is-empty .np-singer { color: var(--text-3); font-weight: 500; }
.np-progress { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.np-time { font-size: .76rem; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 34px; }
.np-time:last-child { text-align: right; }
.np-bar { height: 6px; border-radius: 999px; background: var(--surface-3); cursor: pointer; overflow: hidden; }
.np-fill { height: 100%; width: 0; background: var(--gradient); border-radius: inherit; transition: width .5s linear; }
.np-controls { display: flex; align-items: center; gap: 2px; }
.np-controls .np-main { width: 46px; height: 46px; background: var(--text); color: var(--bg); }
.np-controls .np-main:hover { background: #fff; color: var(--bg); transform: scale(1.04); }
.np-volume-wrap { display: flex; align-items: center; gap: 4px; }
.np-volume { width: 96px; accent-color: var(--accent); }

/* ----- Busca ----- */
.search-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-input {
  flex: 1 1 320px; display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-3);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 1rem; color: var(--text); }
.search-bar > .btn { height: 50px; padding: 0 22px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); cursor: pointer; user-select: none; color: var(--text-2); font-weight: 600;
}
.chip-toggle input { accent-color: var(--accent); width: 18px; height: 18px; }
.chip-toggle:has(input:checked) { border-color: var(--accent); color: #fff; background: var(--accent-soft); }
.paste-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 12px; margin-right: -8px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; transition: color .15s, border-color .15s;
}
.paste-link:hover, .paste-link:focus-visible { color: #fff; border-color: var(--accent); outline: 0; }
.paste-link .icon { width: 18px; height: 18px; }
.search-input.flash { animation: paste-flash .9s ease-out; }
@keyframes paste-flash {
  0% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(255, 61, 127, .55); background: var(--accent-soft); }
  60% { border-color: var(--accent); box-shadow: 0 0 0 10px rgba(255, 61, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 61, 127, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .search-input.flash { animation-duration: .01s; }
}
.search-mode {
  height: 50px; padding: 0 38px 0 16px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent-soft); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.search-mode:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--accent-soft); }
.search-mode option { background: var(--surface); color: var(--text); }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-bottom: 16px;
  border-radius: var(--radius); background: rgba(139, 92, 246, .1); border: 1px solid rgba(139, 92, 246, .35); color: var(--text);
}
.notice .icon { color: var(--accent-2); margin-top: 1px; }
.results-status { min-height: 1.4em; margin-bottom: 10px; font-size: .9rem; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.video-card { display: flex; flex-direction: column; overflow: hidden; transition: border-color .15s, transform .15s; }
.video-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: var(--surface-3); cursor: pointer; overflow: hidden; }
.thumb img, .song-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-hover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(11, 11, 18, .55); opacity: 0; transition: opacity .15s; color: #fff; font-weight: 700; font-size: .85rem;
}
.thumb-hover .icon { width: 44px; height: 44px; padding: 8px; border-radius: 50%; background: var(--gradient); }
.thumb:hover .thumb-hover, .thumb:focus-visible .thumb-hover,
.song-thumb:hover .thumb-hover, .song-thumb:focus-visible .thumb-hover { opacity: 1; }
.song-thumb .thumb-hover .icon { width: 34px; height: 34px; padding: 6px; border-radius: 50%; background: var(--gradient); }
.badge {
  position: absolute; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px;
  border-radius: 6px; font-size: .75rem; font-weight: 700; background: rgba(0, 0, 0, .78); color: #fff;
}
.badge .icon { width: 14px; height: 14px; }
.badge.duration { right: 8px; bottom: 8px; font-variant-numeric: tabular-nums; }
.badge.lib { left: 8px; top: 8px; background: rgba(139, 92, 246, .92); }
.card-body { padding: 12px 14px 6px; display: grid; gap: 4px; flex: 1; }
.card-title { font-size: .96rem; font-weight: 650; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: .82rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; align-items: center; gap: 2px; padding: 6px 8px 10px 14px; }
.card-actions .btn { margin-right: auto; }
.card.skeleton { aspect-ratio: 4 / 4; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 300% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
img.broken { opacity: 0; }
.more-row { display: flex; justify-content: center; margin-top: 22px; }

.empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--text-2); }
.empty-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.empty-icon .icon { width: 34px; height: 34px; }
.empty h3 { color: var(--text); font-size: 1.15rem; }
.empty p { max-width: 460px; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

/* ----- Fila ----- */
.queue-panel { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 22px 18px 40px; border-left: 1px solid var(--border); background: var(--bg-elevated); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 1.3rem; font-weight: 800; }
.queue-summary { font-size: .85rem; }
.queue-now { margin-bottom: 4px; }
.now-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; padding: 12px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(255, 61, 127, .18), rgba(139, 92, 246, .14)); border: 1px solid rgba(255, 61, 127, .3); }
.now-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: var(--surface-3); }
.now-thumb img { width: 100%; height: 100%; object-fit: cover; }
.live-dot { position: absolute; top: 6px; left: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(0, 0, 0, .4); }
.live-dot.on { background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 61, 127, 0); } 0% { box-shadow: 0 0 0 0 rgba(255, 61, 127, .6); } }
.now-info { display: grid; gap: 4px; align-content: center; min-width: 0; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.now-title { font-size: 1rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.singer { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text); }
.singer .icon { width: 16px; height: 16px; color: var(--accent); }
.now-hint { display: grid; gap: 8px; justify-items: start; margin-top: 6px; font-size: .84rem; }
.now-empty { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); border: 1px dashed var(--border-strong); }
.now-empty > .icon { width: 30px; height: 30px; color: var(--text-3); }

.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.queue-item {
  display: grid; grid-template-columns: 18px 22px 72px minmax(0, 1fr); align-items: center; gap: 4px 10px;
  padding: 8px 6px 8px 4px; border-radius: 12px; border: 1px solid transparent; background: var(--surface);
  transition: background .15s, border-color .15s, opacity .15s;
}
.queue-item:hover { border-color: var(--border-strong); }
.queue-item.dragging { opacity: .4; }
.queue-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.queue-item.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.drag-handle { color: var(--text-3); cursor: grab; display: grid; place-items: center; }
.drag-handle .icon { width: 18px; height: 18px; }
.queue-index { font-weight: 800; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.queue-item:first-child .queue-index { color: var(--accent); }
.queue-thumb { width: 72px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 7px; background: var(--surface-3); }
.queue-info { min-width: 0; display: grid; gap: 2px; }
.queue-title { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; }
/* Ações numa linha própria: o título da música usa toda a largura do painel. */
.queue-actions { grid-column: 3 / -1; display: flex; justify-content: flex-end; margin-top: -4px; opacity: .55; transition: opacity .15s; }
.queue-actions:empty { display: none; }
.now-info .tag.kind { justify-self: start; }
.now-actions { display: flex; gap: 2px; margin-top: 2px; }
.now-actions .icon-btn { width: 32px; height: 32px; }
.now-actions .icon { width: 18px; height: 18px; }
.queue-item:hover .queue-actions, .queue-item:focus-within .queue-actions { opacity: 1; }
.queue-actions .icon-btn { width: 32px; height: 32px; }
.queue-actions .icon { width: 18px; height: 18px; }
.queue-empty .empty { padding: 28px 8px; }
.queue-empty .empty-icon { width: 56px; height: 56px; }

/* ----- Catálogo ----- */
.catalog-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.catalog-side { position: sticky; top: 0; display: grid; gap: 16px; }
.catalog-nav { display: grid; gap: 2px; max-height: 52vh; overflow-y: auto; }
.catalog-nav .section-label { margin: 14px 10px 6px; }
.catalog-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-weight: 600; text-align: left; cursor: pointer;
}
.catalog-link:hover { background: var(--surface-2); color: var(--text); }
.catalog-link.active { background: var(--accent-soft); color: #fff; }
.catalog-link.active .icon { color: var(--accent); }
.catalog-link-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-link .count { font-size: .78rem; color: var(--text-3); }
.catalog-side-actions { display: grid; gap: 8px; }
.catalog-side-actions .btn { justify-content: flex-start; }
.catalog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.catalog-heading h2 { font-size: 1.35rem; }
.heading-actions { display: flex; align-items: center; gap: 4px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search-input { height: 44px; flex: 1 1 260px; }
.toolbar select, .field input, .field select, .field textarea, .inline-form input {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.field textarea { padding: 10px 14px; resize: vertical; }
.toolbar select:focus, .field input:focus, .field textarea:focus, .inline-form input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.song-list { display: grid; gap: 8px; }
.song-row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.song-row.blocked { opacity: .7; }
.song-thumb { position: relative; padding: 0; border: 0; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: var(--surface-3); cursor: pointer; }
.song-info { min-width: 0; display: grid; gap: 3px; }
.song-title { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-meta { font-size: .84rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.song-actions { display: flex; align-items: center; gap: 2px; }
.song-actions .btn { margin-right: 6px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }

/* ----- Histórico ----- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat-icon { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat strong { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .muted { font-size: .84rem; }
.rankings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.ranking { padding: 16px 18px; }
.ranking h3 { font-size: 1rem; margin-bottom: 10px; }
.ranking ol { margin: 0; padding: 0; list-style: none; counter-reset: rank; display: grid; gap: 4px; }
.ranking li { counter-increment: rank; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 36px; }
.ranking li::before { content: counter(rank); font-weight: 800; color: var(--text-3); text-align: center; }
.ranking li:nth-child(-n + 3)::before { color: var(--accent); }
.rank-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-count { font-size: .8rem; color: var(--text-3); }
.ranking .icon-btn { width: 32px; height: 32px; }
.history-list { display: grid; gap: 6px; }
.history-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; background: var(--surface); }
.history-thumb { width: 80px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 7px; background: var(--surface-3); }
.history-info { min-width: 0; display: grid; gap: 2px; }
.history-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .94rem; }
.history-info .muted { font-size: .82rem; }
.history-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-meta > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-actions { display: flex; align-items: center; gap: 2px; }
.history-row .song-thumb { width: 80px; }

/* ----- Ajustes ----- */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.settings-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 16px; min-width: 0; }
.settings-form fieldset:disabled .card { opacity: .7; }
.settings-card { padding: 20px; display: grid; gap: 16px; }
.settings-card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-card h2 { font-size: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; }
.field-label { font-weight: 600; font-size: .92rem; }
.field-hint { font-size: .82rem; color: var(--text-3); }
.help summary { cursor: pointer; color: #ff8db5; font-weight: 600; }
.help ol { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; }
.form-actions { display: flex; justify-content: flex-end; }
.connect-card { position: sticky; top: 0; padding: 20px; display: grid; gap: 10px; justify-items: start; }
.connect-card .qr { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 6px; }
.big-link { font-size: 1.1rem; font-weight: 700; word-break: break-all; }

.toggle { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .15s; margin-top: 1px; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .18s, background .18s; }
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: #fff; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text { display: grid; gap: 2px; }
.toggle-text span { font-weight: 600; }
.toggle-text small { color: var(--text-3); font-size: .82rem; }

/* ----- Entrada (código do evento) ----- */
.gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at top, #2a0f2f, var(--bg) 70%);
}
.gate-card {
  width: min(400px, 100%); display: grid; justify-items: center; gap: 14px; padding: 32px 24px;
  border-radius: 22px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); text-align: center;
}
.gate-card img { border-radius: 18px; box-shadow: 0 10px 30px rgba(255, 61, 127, .35); }
.gate-card h1 { font-size: 1.5rem; }
.gate-card input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--bg-elevated); color: var(--text); font-size: 1.1rem; text-align: center; letter-spacing: .04em;
}
.gate-card input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.gate-card .btn { width: 100%; min-height: 48px; }
.gate-card .form-error { width: 100%; margin: 0; }
.link-btn { border: 0; background: none; color: #ff8db5; font-weight: 600; cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }
.admin-host:not(:empty) { margin-bottom: 18px; max-width: 760px; }

/* ----- Diálogos ----- */
.modal {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border-strong);
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal.wide { width: min(720px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(5, 5, 10, .7); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: inherit; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 12px 8px 22px; }
.modal-head h2 { font-size: 1.2rem; }
.modal-body { padding: 8px 22px 6px; overflow-y: auto; }
.modal-subject { font-weight: 600; color: var(--text-2); padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex-wrap: wrap; }
.modal-foot-extra { margin-right: auto; }
.modal-foot:empty { display: none; }

/* ----- Prévia ----- */
.modal.wide:has(.preview) { width: min(960px, calc(100vw - 32px)); }
.preview { display: grid; gap: 14px; padding-bottom: 18px; }
.preview-frame { aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-info { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.preview-text { min-width: 0; display: grid; gap: 2px; }
.preview-title { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta { font-size: .86rem; color: var(--text-3); }
.preview-pager { display: flex; align-items: center; gap: 4px; flex: none; }
.preview-counter { font-size: .84rem; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 56px; text-align: center; }
.preview-nav { border: 1px solid var(--border-strong); }
.preview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.preview-actions .icon-btn { margin-left: auto; }
.preview-hint { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-3); }
.preview-hint .icon { width: 16px; height: 16px; }
.form-error { margin-top: 12px; padding: 10px 12px; border-radius: 10px; color: #fecaca; background: rgba(248, 113, 113, .12); border: 1px solid rgba(248, 113, 113, .35); }
.confirm-text { color: var(--text-2); }
.check-list { display: grid; gap: 2px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.check-row span { flex: 1; }
.check-row small { color: var(--text-3); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

/* ----- Avisos ----- */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; pointer-events: auto;
  background: #23233a; border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.success .icon { color: var(--ok); }
.toast.error { border-color: rgba(248, 113, 113, .5); }
.toast.error .icon, .toast.warning .icon { color: var(--danger); }
.toast-text { flex: 1; }
.toast-action { border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }

.offline-banner {
  position: fixed; z-index: 60; top: 0; left: 0; right: 0; padding: 8px 16px; text-align: center; font-weight: 600;
  background: #b45309; color: #fff; transform: translateY(-100%); transition: transform .25s;
}
body.offline .offline-banner { transform: none; }

/* ----- Sala: nome no topo e papel ----- */
.brand-text { display: grid; line-height: 1.1; min-width: 0; }
.brand-room { font-size: .78rem; font-weight: 600; color: var(--text-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-room:empty { display: none; }
.who { display: inline-flex; align-items: center; }
.who .pill { max-width: 180px; }
.who .pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.pill:disabled { cursor: default; }
.topbar .pill { white-space: nowrap; }
.queue-item.mine { border-color: rgba(255, 61, 127, .35); }
.queue-item.readonly .queue-actions { opacity: 1; }
body.gated .app { filter: blur(3px); pointer-events: none; }

/* ----- Conta e convite (/entrar, /convite) ----- */
.auth-page { min-height: 100dvh; background: radial-gradient(ellipse at top, #2a0f2f, var(--bg) 70%); }
.auth { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 18px; padding: 32px 16px calc(32px + env(safe-area-inset-bottom)); }
.auth-brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 800; font-size: 1.3rem; text-decoration: none !important; }
.auth-brand img { border-radius: 16px; box-shadow: 0 10px 30px rgba(255, 61, 127, .35); }
.auth-card {
  width: min(420px, 100%); display: grid; gap: 14px; padding: 28px 24px;
  border-radius: 22px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; }
.auth-card .notice { margin: 0; }
.auth-card .form-error { margin: 0; }
.auth-form { display: grid; gap: 14px; }
.auth-form .field input { min-height: 46px; font-size: 1rem; }
.btn.block { width: 100%; min-height: 46px; }
.auth-links { text-align: right; font-size: .9rem; }
.auth-switch { text-align: center; color: var(--text-2); font-size: .92rem; }
.auth-providers { display: grid; gap: 10px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: .85rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-foot { width: min(420px, 100%); text-align: center; }
.legal-note { font-size: .78rem; color: var(--text-3); }

/* ----- Minhas salas ----- */
.rooms-page { min-height: 100dvh; }
.rooms-topbar { position: sticky; top: 0; z-index: 5; grid-template-columns: auto 1fr; height: var(--topbar-h); }
.rooms-topbar .topbar-actions { justify-self: end; }
.rooms-topbar .btn span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.rooms-main { width: min(1180px, 100%); margin: 0 auto; padding: 28px clamp(16px, 3vw, 40px) 48px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.room-card { padding: 18px; display: grid; gap: 10px; align-content: start; }
.room-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.room-card-title { display: grid; gap: 2px; min-width: 0; }
.room-card-title h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.room-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; margin-bottom: 10px; }
.back-link .icon { width: 18px; height: 18px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.host-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.host-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.host-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient); color: #fff; font-weight: 800; }
.host-info { display: grid; min-width: 0; }
.host-info strong, .host-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-card { border-color: rgba(248, 113, 113, .35); }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-code { font-family: Consolas, "Cascadia Mono", monospace; letter-spacing: .08em; }
.copy-input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-elevated); }
.inline-form .btn { flex: none; }

@media (max-width: 1100px) {
  .rooms-aside { order: -1; }
}

@media (max-width: 900px) {
  .brand-room { max-width: 40vw; }
  .who-rooms { width: 36px; padding: 0; }
  .who-rooms span { display: none; }
  .rooms-topbar { height: auto; grid-template-areas: none; grid-template-columns: auto 1fr; }
  .rooms-main { padding: 20px 16px 32px; }
}

@media (max-width: 520px) {
  .brand > .brand-text > span:first-child { display: none; }
  .brand-room { font-size: .95rem; color: var(--text); }
  .room-grid { grid-template-columns: 1fr; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { flex-basis: 100%; }
  .auth-card { padding: 22px 18px; }
}

/* ----- Responsivo ----- */
@media (max-width: 1360px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr) 360px; }
  .nav a { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: .72rem; text-align: center; }
  .nav-badge { position: absolute; top: 4px; right: 10px; }
  .np-volume-wrap { display: none; }
}

@media (max-width: 1100px) {
  .settings-layout { grid-template-columns: 1fr; }
  .connect-card { position: static; }
  .catalog-layout { grid-template-columns: 1fr; }
  .catalog-side { position: static; }
  .catalog-nav { display: flex; overflow-x: auto; max-height: none; gap: 6px; padding-bottom: 4px; }
  .catalog-nav .section-label { display: none; }
  .catalog-link { width: auto; flex: none; border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; }
  .catalog-side-actions { display: flex; flex-wrap: wrap; }
}

@media (max-width: 900px) {
  :root { --topbar-h: 64px; }
  .app { grid-template-rows: auto minmax(0, 1fr); }
  .topbar { grid-template-columns: auto 1fr; grid-template-areas: "brand actions" "np np"; gap: 10px 12px; padding: 10px 14px; }
  .brand { grid-area: brand; }
  .topbar-actions { grid-area: actions; justify-self: end; }
  .now-playing { grid-area: np; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; padding: 6px 8px 6px 6px; }
  .np-art { width: 44px; height: 44px; }
  /* No celular ficam só anterior, tocar/pausar e próxima. */
  .np-controls .icon-btn:not(.np-main):not(:nth-child(1)):not(:nth-child(4)) { display: none; }
  .np-controls .np-main { width: 40px; height: 40px; }
  .np-text { flex-direction: column; gap: 0; }
  .np-text > * { max-width: 100%; }
  .hide-sm { display: none; }
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .nav {
    order: 2; flex-direction: row; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .nav a { flex: 1; padding: 8px 2px; }
  .nav .nav-queue { display: flex; }
  .content { order: 1; padding: 20px 16px 32px; }
  .queue-panel { order: 1; display: none; border-left: 0; padding: 20px 16px 32px; }
  body[data-view="queue"] .content { display: none; }
  body[data-view="queue"] .queue-panel { display: flex; }
  body[data-view="queue"] #view-search { display: none; }
  .queue-actions { opacity: 1; }
  .results { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .search-bar > .btn span { display: none; }
  .search-bar > .btn { width: 50px; padding: 0; }
  .song-row { grid-template-columns: 96px minmax(0, 1fr); }
  .song-actions { grid-column: 1 / -1; justify-content: flex-end; flex-wrap: wrap; }
  .history-row { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .history-row .history-outcome { display: none; }
  .history-row { grid-template-columns: 64px minmax(0, 1fr); row-gap: 2px; }
  .history-actions { grid-column: 2; justify-content: flex-end; margin-top: -6px; }
  .history-thumb, .history-row .song-thumb { width: 64px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .search-input { flex-basis: 100%; }
  .chip-toggle, .search-mode { flex: 1; justify-content: center; }
  .paste-link span { display: none; }
  .paste-link { width: 34px; padding: 0; justify-content: center; }
  .search-bar > .btn { flex: 1; }
  .search-bar > .btn span { display: inline; }
  .queue-item { grid-template-columns: 22px 60px minmax(0, 1fr); }
  .queue-item .drag-handle { display: none; }
  .queue-thumb { width: 60px; }
  .queue-actions { grid-column: 1 / -1; }
  .card-actions .btn span { display: none; }
  .now-card { grid-template-columns: 96px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
