:root {
  --bg: #0e1015;
  --surface: #161920;
  --surface-2: #1d2129;
  --border: #2a2f3a;
  --text: #e9ecf2;
  --muted: #8b93a3;
  --accent: #6d7cff;
  --accent-hover: #8290ff;
  --live: #ff4d6d;
  --ok: #3ecf8e;
  --warn: #f5b546;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; }
a { color: var(--accent-hover); }
kbd {
  font: 12px var(--font);
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
}
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.82rem; }

/* ---------- Componentes básicos ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: 500 0.9rem var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a4150; background: #232833; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: transparent; border-color: #5a2a35; color: #ff8fa3; }
.btn.danger:hover { background: #3a1820; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 3px 8px; font-size: 0.8rem; }
.btn.big { padding: 12px 18px; font-size: 1rem; width: 100%; }
.btn.link {
  background: none; border: none; padding: 0; margin-top: 10px;
  color: var(--muted); font-size: 0.82rem; text-decoration: underline; white-space: normal; text-align: left;
}
.btn.link:hover { color: var(--text); background: none; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 0.85rem; color: var(--muted); }
input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: 0.92rem var(--font);
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.form-error { color: #ff8fa3; font-size: 0.88rem; margin: 10px 0 0; min-height: 1em; }
.form-error:empty { display: none; }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.01em;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.2);
  flex: none;
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill[data-state="live"] { color: var(--ok); border-color: rgba(62, 207, 142, 0.35); }
.pill[data-state="offline"], .pill[data-state="warn"] { color: var(--warn); border-color: rgba(245, 181, 70, 0.35); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #262b36;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { border-color: #6b2a38; color: #ffb3c1; }

/* ---------- Escenario (compartido anfitrión / invitado) ---------- */

.stage {
  --stage-bg: #0b0d12;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--stage-bg);
  overflow: hidden;
  container-type: inline-size;
  user-select: none;
  transition: background 0.3s;
}
.slot {
  position: absolute;
  transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease, opacity 0.3s, visibility 0.3s;
}
.stage.is-dragging .slot { transition: none; }
.slot-media {
  position: absolute; inset: 0;
  overflow: hidden;
  background: #000;
  transition: border-radius 0.3s, box-shadow 0.3s;
}
.slot[data-slot="screen"] .slot-media { background: transparent; }
.slot video { width: 100%; height: 100%; display: block; }
.slot[data-slot="screen"] video { object-fit: contain; }
.slot[data-slot="camera"] video { object-fit: cover; }
.slot.is-mirror video { transform: scaleX(-1); }
.slot[data-shape="rounded"] .slot-media { border-radius: 2.2cqw; }
.slot[data-shape="circle"] .slot-media { border-radius: 50%; }
.slot.has-border .slot-media {
  box-shadow: 0 0 0 0.35cqw rgba(255, 255, 255, 0.92), 0 0.8cqw 2.4cqw rgba(0, 0, 0, 0.5);
}
.slot.is-hidden { opacity: 0; visibility: hidden; }

.stage { background-position: center; background-repeat: no-repeat; }
/* Oscurece la imagen de fondo para que resalte lo que va encima. */
.stage::before {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background: rgba(0, 0, 0, var(--bg-dim, 0));
  pointer-events: none;
}
.stage.is-blank.has-bg-image .stage-blank-msg { display: none; }
.stage.editor.has-bg-image .slot.is-empty .slot-media { background: rgba(20, 24, 32, 0.35); }

.stage-blank-msg { z-index: 2;
  position: absolute; inset: 0; margin: 0;
  display: none; align-items: center; justify-content: center;
  color: var(--muted); font-size: clamp(13px, 1.8cqw, 20px); text-align: center; padding: 20px;
}
.stage.is-blank .stage-blank-msg { display: flex; }

/* ---------- Vista del anfitrión ---------- */

body.host { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.room-title {
  font-size: 1rem; font-weight: 600;
  flex: 1; min-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.host-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
.stage-area { min-width: 0; }
.stage.editor {
  border-radius: 10px;
  border: 1px solid var(--border);
  touch-action: none;
}
.stage.editor .slot { cursor: grab; }
.stage.editor .slot.is-active { cursor: grabbing; }
.stage.editor .slot::after {
  content: "";
  position: absolute; inset: 0;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.stage.editor .slot[data-shape="rounded"]::after { border-radius: 2.2cqw; }
.stage.editor .slot[data-shape="circle"]::after { border-radius: 50%; }
.stage.editor .slot:hover::after,
.stage.editor .slot.is-active::after { border: 1.5px solid var(--accent); }
.stage.editor .slot.is-empty .slot-media {
  background: repeating-linear-gradient(135deg, #1b1f28 0 12px, #20242e 12px 24px);
}
.stage.editor .slot.is-disabled { opacity: 0.35; }

.slot-label {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 3px 9px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 12px; color: #cfd5e1;
  pointer-events: none;
  white-space: nowrap;
  display: none;
}
.slot.is-empty .slot-label, .slot.is-disabled .slot-label { display: block; }
.slot.is-disabled .slot-label::after { content: " · oculta"; }

.handle {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s;
}
.stage.editor .slot:hover .handle,
.stage.editor .slot.is-active .handle { opacity: 1; }
@media (hover: none) { .stage.editor .handle { opacity: 1; } }
.handle[data-handle="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.handle[data-handle="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.handle[data-handle="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.handle[data-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.source-bar { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.source-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.92rem var(--font);
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s;
}
.source-btn:hover { background: var(--surface-2); }
.source-btn[aria-pressed="true"] {
  background: rgba(109, 124, 255, 0.14);
  border-color: var(--accent);
}
.source-icon { font-size: 1.05rem; }
.meter {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: transparent;
}
.meter > span {
  display: block; height: 100%;
  background: var(--ok);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.06s linear;
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }

/* --- Al aire / fuera del aire --- */
.live-btn { background: var(--live); border-color: var(--live); color: #fff; font-weight: 700; }
.live-btn:hover { background: #ff6b85; border-color: #ff6b85; }
.live-btn.is-live { background: transparent; color: #ff8fa3; border-color: #5a2a35; }
.live-btn.is-live:hover { background: #3a1820; }
.live-pill { font-weight: 700; letter-spacing: 0.02em; color: var(--muted); }
.live-pill[data-live="true"] { background: var(--live); border-color: var(--live); color: #fff; }
.offline-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px dashed #4a5163; border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted); font-size: 0.88rem;
}
.offline-banner strong { color: var(--text); }

/* --- Grabación --- */
.rec-btn[aria-pressed="true"] { background: rgba(255, 77, 109, 0.14); border-color: var(--live); }
.rec-btn[aria-pressed="true"] .source-icon { animation: rec-blink 1.2s steps(2, start) infinite; }
@keyframes rec-blink { to { visibility: hidden; } }
.source-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.recordings-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.recordings-list li {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
  font-size: 0.86rem;
}
.recordings-list .rec-info { display: grid; gap: 2px; min-width: 0; }
.recordings-list .rec-meta { color: var(--muted); font-size: 0.78rem; }
.blocker-card .recordings-list { width: 100%; text-align: left; }

.panel { display: grid; gap: 14px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { font-size: 0.82rem; }

.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.preset {
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.preset:hover { border-color: #444c5c; }
.preset.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb {
  position: relative; display: block;
  aspect-ratio: 16 / 9;
  background: #0b0d12;
  border-radius: 3px;
  overflow: hidden;
}
.thumb i { position: absolute; border-radius: 1.5px; }
.thumb-screen { background: #3b4254; }
.thumb-camera { background: var(--accent); outline: 1px solid #0b0d12; }

.control { display: grid; gap: 6px; margin-bottom: 14px; }
.control-label { font-size: 0.85rem; color: var(--muted); }
.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.segmented button {
  flex: 1;
  padding: 6px 4px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 500 0.84rem var(--font);
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-selected { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.color-control { grid-template-columns: 1fr auto; align-items: center; margin-bottom: 0; }
.bg-picker { display: flex; align-items: center; gap: 12px; }
.bg-thumb {
  width: 96px; aspect-ratio: 16 / 9; flex: none;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg) center / cover no-repeat;
  display: grid; place-items: center;
  color: var(--muted); font-size: 0.72rem;
}
.bg-thumb.has-image { color: transparent; }
.bg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bg-options { display: grid; gap: 10px; margin-top: 10px; }
.range-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--muted); }
.range-row input { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 44px; height: 30px; padding: 2px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); cursor: pointer;
}

.viewer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.viewer-list li {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
}
.viewer-list li:hover { background: var(--surface-2); }
.viewer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state-dot[data-state="connected"] { background: var(--ok); }
.state-dot[data-state="disconnected"], .state-dot[data-state="failed"] { background: var(--warn); }

.blocker {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(8, 9, 12, 0.85);
  backdrop-filter: blur(4px);
}
.blocker-card { max-width: 420px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.blocker-card p { margin: 0; color: var(--muted); }

@media (max-width: 1000px) {
  .host-main { grid-template-columns: 1fr; padding: 16px; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .preset-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .toggles { grid-template-columns: 1fr; }
  .source-btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- Vista del invitado ---------- */

body.watch { background: #000; overflow: hidden; }

.viewer { position: fixed; inset: 0; display: flex; background: #000; }
.viewer-main { position: relative; flex: 1; min-width: 0; container-type: size; }
.stage-fit {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.stage-fit .stage {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: auto;
}

.status-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  text-align: center;
}
.status-overlay p { margin: 0; font-size: 1.05rem; max-width: 420px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.unmute-btn { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 12; }

.viewer-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11;
  display: flex; align-items: center; gap: 12px;
  padding: 28px 18px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  transition: opacity 0.3s;
}
.viewer.is-idle .viewer-bar { opacity: 0; }
.viewer.is-idle .viewer-main { cursor: none; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--muted);
}
.live-badge .rec-dot { background: var(--muted); box-shadow: none; }
.live-badge.is-live { background: var(--live); color: #fff; }
.live-badge.is-live .rec-dot { background: #fff; }
.viewer-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 1.05rem;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.icon-btn { position: relative; }
.icon-btn.small { width: 28px; height: 28px; font-size: 0.8rem; background: transparent; color: var(--muted); }
.icon-btn.small:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.22); }
.unread-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
}
input[type="range"] { width: 110px; accent-color: #fff; }
@media (max-width: 480px) {
  input[type="range"] { display: none; }
}

.join-screen {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at top, #1a1d2b, #000 70%);
}
.join-card { width: min(420px, 100%); display: grid; gap: 4px; }
.join-card h1 { font-size: 1.5rem; margin-bottom: 18px; overflow-wrap: anywhere; }
.join-card .brand { margin-bottom: 20px; }
.join-card .muted.small { margin: 12px 0 0; text-align: center; }

/* ---------- Chat ---------- */

.chat-panel {
  width: 340px; flex: none;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.viewer.chat-hidden .chat-panel { display: none; }
.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--border);
}
.chat-header .icon-btn { margin-left: auto; }
.chat-mode { font-size: 0.75rem; color: var(--warn); }

.chat-list {
  list-style: none; margin: 0;
  padding: 8px 6px;
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-list:empty::before {
  content: "Todavía no hay mensajes.";
  display: block; padding: 24px 12px;
  text-align: center; color: var(--muted); font-size: 0.88rem;
}
.chat-msg {
  position: relative;
  display: flex; gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
}
.chat-msg:hover { background: var(--surface-2); }
.chat-msg.is-host { background: rgba(255, 77, 109, 0.07); }
.chat-avatar {
  width: 28px; height: 28px; flex: none;
  border-radius: 50%; object-fit: cover;
  background: #2a2f3a;
}
.chat-avatar-empty { display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.chat-body { flex: 1; min-width: 0; }
.chat-meta { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.chat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { margin-left: auto; flex: none; color: var(--muted); font-size: 0.72rem; }
.chat-text { margin: 2px 0 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.chat-badge {
  flex: none;
  padding: 1px 5px; border-radius: 4px;
  background: #2a2f3a; color: var(--muted);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em;
  vertical-align: middle;
}
.chat-badge[data-provider="twitch"] { background: rgba(145, 70, 255, 0.2); color: #c29dff; }
.chat-badge[data-provider="kick"] { background: rgba(83, 252, 24, 0.14); color: #7dff4f; }
.chat-badge[data-provider="host"] { background: rgba(255, 77, 109, 0.18); color: #ff8fa3; }
.chat-badge[data-provider="bot"] { background: rgba(109, 124, 255, 0.2); color: #aab4ff; }
.role-badge {
  display: inline-flex; align-items: center;
  flex: none;
  padding: 1px 5px; border-radius: 4px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.03em;
  color: #fff;
  vertical-align: middle;
}
.role-badge[data-role="mod"] { background: #00a33b; }
.role-badge[data-role="vip"] { background: #d4169f; }
button.chat-name, button.viewer-name {
  padding: 0; border: 0; background: none;
  color: inherit; font: inherit; font-weight: 600;
  cursor: pointer; text-align: left;
}
button.chat-name:hover, button.viewer-name:hover { text-decoration: underline; }
.chat-msg.is-bot { background: rgba(109, 124, 255, 0.06); }
.chat-msg.is-private { border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; }
.chat-private-note { display: block; margin-top: 2px; color: var(--muted); font-size: 0.72rem; font-style: italic; }

.mod-hint { font-size: 0.8rem; color: var(--muted); }
.mod-hint summary { cursor: pointer; color: #5fd68a; font-weight: 600; }
.mod-hint p { margin: 6px 0 4px; }
.mod-hint ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }

.user-card {
  position: absolute; z-index: 60;
  width: 230px;
  display: grid; gap: 6px;
  padding: 12px;
  background: #1f232c;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.user-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.user-card-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.user-card-head span { display: inline-flex; gap: 4px; }
.user-card .btn { width: 100%; }

.team-list, .command-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.team-list:empty, .command-list:empty { display: none; }
.team-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.88rem; }
.team-name { display: inline-flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.command-form { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; }
.command-name-field { position: relative; }
.command-name-field span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.command-name-field input { padding-left: 20px; }
.command-list li {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px;
  padding: 4px 0;
  font-size: 0.86rem;
}
.command-response { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
#commandError:not(:empty) { margin-top: 8px; }
@media (max-width: 560px) {
  .command-form { grid-template-columns: 1fr; }
}

.chat-actions {
  position: absolute; top: 4px; right: 6px;
  display: none; gap: 4px;
}
.chat-msg:hover .chat-actions, .chat-msg:focus-within .chat-actions { display: flex; }
.chat-msg:hover .chat-time { visibility: hidden; }
.chat-actions button {
  padding: 2px 7px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text);
  font: 500 0.72rem var(--font);
  cursor: pointer;
}
.chat-actions button:hover { border-color: #ff8fa3; color: #ff8fa3; }
@media (hover: none) {
  .chat-actions { display: flex; position: static; align-self: center; }
}

.chat-footer { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-error { margin: 0; color: #ff8fa3; font-size: 0.8rem; }
.chat-error:empty { display: none; }
.chat-notice { margin: 0; color: var(--muted); font-size: 0.85rem; text-align: center; }
.chat-login { display: grid; gap: 8px; }
.chat-login p { margin: 0; }
.chat-login-buttons { display: grid; gap: 6px; }
.btn.twitch { background: #9146ff; border-color: #9146ff; color: #fff; }
.btn.twitch:hover { background: #a46bff; border-color: #a46bff; }
.btn.kick { background: #53fc18; border-color: #53fc18; color: #0b0e0f; }
.btn.kick:hover { background: #79ff4a; border-color: #79ff4a; }
.chat-me { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.chat-me strong { color: var(--text); }
.chat-me .btn.link { margin: 0 0 0 auto; }

.chat-card .chat-settings { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.inline-select { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.inline-select select { width: auto; padding: 5px 8px; }
.host-chat {
  height: 280px; flex: none;
  margin: 12px 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
}
.chat-card .chat-error { margin-top: 8px; }
.banned-box summary { margin-top: 12px; cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.banned-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.banned-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.88rem; }
.viewer-name .chat-badge { margin-left: 2px; }

@media (max-width: 800px) {
  .viewer { flex-direction: column; }
  .viewer-main { flex: none; height: min(56.25vw, 55dvh); }
  .viewer.chat-hidden .viewer-main { flex: 1; height: auto; }
  .chat-panel { width: auto; flex: 1; border-left: 0; border-top: 1px solid var(--border); }
}

body.auth-done { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-done-card { max-width: 400px; text-align: center; display: grid; gap: 10px; }
.auth-done-card h1 { font-size: 1.3rem; }
.auth-done-card p { margin: 0; }

/* ---------- Inicio ---------- */

body.home {
  background: radial-gradient(ellipse at top, #1a1d2b, var(--bg) 60%) fixed;
}
.home-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 56px 16px 40px;
  display: grid; gap: 20px;
}
.home-hero { display: grid; gap: 14px; }
.home-hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.3rem); letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 0; font-size: 1.05rem; }
.create-card h2, .home-main .card h2 { font-size: 1.05rem; }
.recent-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.recent-list li { display: flex; justify-content: space-between; gap: 12px; }
.btn.patreon { background: #ff424d; border-color: #ff424d; color: #fff; }
.btn.patreon:hover { background: #ff5c66; border-color: #ff5c66; }
.gate-card { display: grid; gap: 12px; }
.gate-card h2 { margin: 0; }
.gate-card p { margin: 0; }
.notice {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #6b2a38;
  background: rgba(255, 77, 109, 0.08);
  color: #ffb3c1;
  font-size: 0.9rem;
}
.account-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.account-info { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.account-info > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code { font-size: 0.85em; padding: 1px 5px; border-radius: 4px; background: var(--bg); }

.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding-top: 8px; }
.site-footer a, .legal-links a { color: var(--muted); }
.site-footer a:hover, .legal-links a:hover { color: var(--text); }
.join-card .legal-links { margin-top: 4px; }

/* ---------- Páginas legales ---------- */

body.legal-page { background: var(--bg); }
.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 16px 64px;
  line-height: 1.65;
}
.legal .brand { margin-bottom: 28px; }
.legal h1 { font-size: clamp(1.6rem, 4vw, 2rem); margin-bottom: 6px; }
.legal h1 + .muted { margin-top: 0; }
.legal h2 { font-size: 1.12rem; margin: 32px 0 10px; }
.legal h3 { font-size: 0.98rem; margin: 18px 0 6px; }
.legal p, .legal li { color: #c9ceda; }
.legal ul { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal strong { color: var(--text); }
.legal-footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }

.mode-picker { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.mode-picker legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.mode-option {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}
.mode-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mode-option input { accent-color: var(--accent); margin-top: 3px; }
.mode-option > span { display: grid; gap: 2px; }
.pill:empty { display: none; }
.mode-option.is-disabled { opacity: 0.55; cursor: not-allowed; }
.mode-note:not(:empty) { color: var(--warn); font-size: 0.8rem; }
.plan-box {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
  display: grid; gap: 8px;
}
.plan-head { display: flex; align-items: baseline; gap: 6px; }
.plan-box p { margin: 0; }
.plan-usage { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.88rem; }
.plan-usage li.is-off { color: var(--muted); }
.usage-bar { display: block; height: 5px; margin-top: 4px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.usage-bar > span { display: block; height: 100%; background: var(--accent); }
.mode-pill { color: #c9ceff; border-color: rgba(109, 124, 255, 0.4); }

.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: var(--muted); font-size: 0.92rem; }
.features strong { color: var(--text); font-weight: 600; }
