:root {
  --ink: #15131f;
  --surface: #1f1c2e;
  --surface-2: #29253b;
  --line: #38334f;
  --text: #eeeaf8;
  --muted: #a49dbd;
  --amber: #ffb547;
  --amber-ink: #2a1a00;
  --cyan: #73d2e6;
  --coral: #ff7366;
  --ok: #7be0a5;
  --r-lg: 18px;
  --r-sm: 8px;
  --font: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { display: flex; flex-direction: column; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
b { font-weight: 650; }

/* ---------- barra superior ---------- */
.bar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand svg { width: 22px; height: 22px; color: var(--amber); }
.kick-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted); cursor: default;
}
body.is-admin .kick-pill { cursor: pointer; }
.kick-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.kick-pill[data-s='connected'] .dot { background: var(--ok); }
.kick-pill[data-s='connecting'] .dot { background: var(--amber); animation: blink 1.2s infinite; }
.kick-pill[data-s='error'] .dot { background: var(--coral); }
@keyframes blink { 50% { opacity: .25; } }
.bar-flags { display: flex; gap: 8px; }
.flag { font-size: 13px; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); color: var(--cyan); }
.flag.closed { color: var(--coral); }
.flag.dj { background: var(--amber); color: var(--amber-ink); font-weight: 650; }
.bar-end { margin-left: auto; display: flex; gap: 8px; }

/* ---------- botones ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface-2);
  padding: 8px 14px; border-radius: var(--r-sm); cursor: pointer;
  font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
a.btn { text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--text); color: var(--ink); border-color: var(--text); }
.btn.skip { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--coral); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--coral); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 20px; padding: 20px; flex: 1; min-height: 0;
}
.stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; overflow: auto; }
.side { display: grid; grid-template-rows: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; min-height: 0; }

.screen {
  position: relative; aspect-ratio: 16 / 9; max-height: 46vh;
  border-radius: var(--r-lg); overflow: hidden; background: #000;
}
.screen > #ytPlayer, .screen iframe, .screen > img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.screen-empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  padding: 24px; background: var(--surface); color: var(--muted);
}
.screen-empty .big { font-size: 26px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.screen-empty p { margin: 0; max-width: 44ch; }

/* el elemento protagonista: título de lo que suena */
.now-title {
  margin: 4px 0 6px;
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 1.02; font-weight: 780; letter-spacing: -0.025em;
  font-variation-settings: 'wdth' 78, 'opsz' 96;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-wrap: balance;
}
.now-meta { margin: 0 0 14px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.now-meta .by { color: var(--cyan); }
.audio-badge { font-size: 12.5px; padding: 1px 8px; border-radius: 5px; background: var(--surface-2); color: var(--text); }
.now-meta .by.dj { color: var(--amber); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--amber); transition: width .9s linear; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 6px; font-variant-numeric: tabular-nums; }

.deck { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.vol { display: flex; align-items: center; gap: 10px; margin-left: auto; color: var(--muted); font-size: 13px; }
.vol input { width: 150px; accent-color: var(--amber); }
.vol output { width: 3ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.dj-switches { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface); }
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin: 6px 0; }
.switch input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--cyan); }
.switch.amber input { accent-color: var(--amber); }
.switch small { display: block; color: var(--muted); font-size: 12.5px; }

.add { display: flex; gap: 8px; flex-wrap: wrap; }
.add input { flex: 1 1 220px; }
input[type='text'], input[type='password'], input[type='number'], input:not([type]), select, textarea {
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 12px; min-width: 0;
}
textarea { resize: vertical; width: 100%; }

/* ---------- paneles ---------- */
.panel { background: var(--surface); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.count { display: inline-block; min-width: 24px; padding: 0 7px; margin-left: 4px; border-radius: 999px; background: var(--surface-2); font-size: 13px; text-align: center; }
.q-total { color: var(--muted); font-size: 13px; margin-right: auto; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; padding: 0 12px 6px; }
.tab { border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--surface-2); color: var(--text); }

.list { list-style: none; margin: 0; padding: 4px 8px 12px; overflow: auto; flex: 1; counter-reset: q; }
.item { position: relative; display: grid; grid-template-columns: 22px 64px minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 8px; border-radius: 10px; }
.item:hover { background: var(--surface-2); }
.item .pos { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.item img { width: 64px; height: 36px; object-fit: cover; border-radius: 5px; background: var(--ink); }
.item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.item .m { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .m .u { color: var(--cyan); }
.item .m .u.dj { color: var(--amber); }
.item .acts {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface-2);
  opacity: 0; pointer-events: none;
}
.item:hover .acts, .item:focus-within .acts { opacity: 1; pointer-events: auto; }
.empty-list { color: var(--muted); padding: 18px 10px; text-align: center; }

.feed { list-style: none; margin: 0; padding: 0 16px 14px; overflow: auto; flex: 1; font-size: 13.5px; }
.feed li { padding: 5px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 42px 1fr; gap: 8px; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .u { font-weight: 650; color: var(--cyan); }
.feed .dj .u { color: var(--amber); }
.feed .error { color: var(--coral); }
.feed .error .u { color: var(--coral); }
.feed .warn { color: var(--muted); }

/* ---------- visibilidad por rol ---------- */
body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- diálogos ---------- */
.dlg {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  padding: 22px 24px; width: min(440px, calc(100vw - 32px));
}
.dlg.wide { width: min(760px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10, 8, 18, .7); }
.dlg h2 { margin: 0 0 8px; font-size: 22px; font-weight: 750; letter-spacing: -0.015em; }
.dlg p { margin: 0 0 12px; max-width: 70ch; }
.dlg .muted, .muted { color: var(--muted); font-size: 13.5px; }
.dlg input#pin { width: 100%; font-size: 22px; letter-spacing: .3em; text-align: center; }
.err { color: var(--coral); min-height: 1.4em; font-size: 14px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.dlg-actions .spacer { flex: 1; }
.copy-row { display: flex; gap: 8px; margin-bottom: 12px; }
.copy-row input { flex: 1; }
.mono-list { margin: 0 0 8px; padding-left: 18px; }

.settings-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.settings-head h2 { margin: 0; }
.settings-head .tabs { padding: 0; }
.stab { min-height: 330px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.row-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.switch.stack { margin-top: 26px; }
.test-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px 12px; margin: 16px 0 0; }
.test-box legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.diag { margin-top: 16px; }
.diag summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.diag pre { max-height: 220px; overflow: auto; background: var(--ink); padding: 10px; border-radius: var(--r-sm); font-size: 12px; white-space: pre-wrap; word-break: break-all; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--ink); padding: 10px 14px; border-radius: var(--r-sm); font-weight: 550; max-width: 360px; animation: in .18s ease-out; }
.toast.error { background: var(--coral); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; flex: none; }
  .side { grid-template-rows: auto auto; }
  .panel { max-height: 70vh; }
  .bar { flex-wrap: wrap; }
  .bar-flags { order: 3; }
  .grid2 { grid-template-columns: 1fr; }
  .item .acts { opacity: 1; }
  .vol { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- moderadores ---------- */
.banner { padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.banner.warn { background: var(--amber); color: var(--amber-ink); font-weight: 600; }
.banner a { color: inherit; }
.cloud-who { display: flex; align-items: center; gap: 10px; }
.cloud-who .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.cloud-who .dot.online { background: var(--ok); }
.cloud-who .dot.connecting { background: var(--amber); }
.cloud-who .btn { margin-left: auto; }
.invite-card { margin-top: 12px; }
.invite-code { font-size: 34px; font-weight: 780; letter-spacing: .08em; font-variation-settings: 'wdth' 85; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
h3.sub { font-size: 15px; margin: 18px 0 6px; }
.mods { list-style: none; margin: 0; padding: 0; }
.mods li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.mods li:last-child { border-bottom: 0; }
.mods .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.mods .dot.on { background: var(--ok); }
.mods .meta { color: var(--muted); font-size: 13px; }
.mods .btn { margin-left: auto; }
.mods .empty { color: var(--muted); }
body.is-remote #btnOverlay, body.is-remote #btnModerate { display: none; }

/* ---------- pantalla de cuenta ---------- */
.gate { position: fixed; inset: 0; z-index: 40; background: var(--ink); display: grid; place-items: center; padding: 24px 16px; overflow: auto; }
.gate-card { width: min(420px, 100%); }
.gate-title { font-size: clamp(30px, 5vw, 40px); line-height: 1.04; font-weight: 780; letter-spacing: -0.025em; font-variation-settings: 'wdth' 80, 'opsz' 96; margin: 22px 0 8px; text-wrap: balance; }
.gate-card > .muted { margin: 0 0 20px; }
.gate .tabs { padding: 0 0 14px; }
.gate .field input { width: 100%; }
.btn.wide { width: 100%; padding: 11px 14px; }
.gate-adv { margin-top: 18px; color: var(--muted); font-size: 13.5px; }
.gate-adv summary { cursor: pointer; }
.gate-adv input { width: 100%; margin-top: 8px; }
body.gated > :not(.gate):not(.toasts):not(script) { visibility: hidden; }
