:root {
  --bg-0: #08090a;
  --bg-1: #0f1011;
  --bg-2: #191a1b;
  --bg-3: #28282c;
  --brand: #40f2fe;
  --accent: #40f2fe;
  --accent-hi: #80f7fe;
  --accent-deep: #0fa8b5;
  --text: #f7f8f8;
  --text-2: #d0d6e0;
  --text-3: #8a8f98;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.10);
  --twitch: #9146ff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --sidebar-w: 220px;
  --bottom-nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }

html { background: var(--bg-0); }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg-0); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  font-weight: 500; letter-spacing: -0.005em;
  overscroll-behavior: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
body {
  padding-top: var(--safe-top);
  background: var(--bg-0);
}

/* View routing */
.view { display: none; }
body[data-view="loading"] .view-loading { display: flex; align-items: center; justify-content: center; height: 100vh; }
body[data-view="login"]   .view-login   { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
body[data-view="main"]    .view-main    { display: grid; height: 100vh; height: 100dvh; }

.spinner { width: 36px; height: 36px; border-radius: 50%; border: 2.5px solid var(--border-2); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Login ===== */
.login-card { display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; max-width: 340px; padding: 36px 28px; border-radius: 20px; background: var(--bg-1); border: 1px solid var(--border-2); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); }
.brand-mark { width: 72px; height: 72px; border-radius: 18px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand-mark-small { width: 32px; height: 32px; border-radius: 9px; }
.brand-rx { font-size: 30px; font-weight: 800; letter-spacing: 0.02em; color: var(--bg-0); }
.brand-mark-small .brand-rx { font-size: 13px; }
.login-title { font-size: 22px; font-weight: 590; margin: 0; color: var(--text); }
.login-sub { font-size: 14px; font-weight: 400; margin: 0; color: var(--text-3); line-height: 1.55; }
.login-foot { font-size: 11px; font-weight: 400; margin: 0; color: var(--text-3); }
.login-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px 20px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.12); background: linear-gradient(160deg, #a070ff 0%, #9146ff 60%, #6c2bcf 100%); color: var(--text); font: inherit; font-size: 15px; font-weight: 590; text-decoration: none; box-shadow: 0 12px 28px -12px rgba(145, 70, 255, 0.55), 0 2px 6px rgba(0, 0, 0, 0.45); transition: transform 110ms ease, filter 200ms ease; }
.login-btn:active { transform: scale(0.98); filter: brightness(1.10); }

/* ===== Main shell ===== */
.view-main { grid-template-columns: 1fr; grid-template-rows: 1fr; }

/* SIDEBAR (desktop only) */
.sidebar { display: none; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 8px; }
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; color: var(--text); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 18px 16px; border-bottom: 1px solid var(--border); }
.avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--bg-2); object-fit: cover; }
.user-name { font-size: 13px; font-weight: 510; color: var(--text-2); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; padding: 12px 10px; flex: 1; min-height: 0; }
.sidebar-nav .nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--text-3); text-decoration: none; font-size: 13px; font-weight: 510; transition: background .12s, color .12s; }
.sidebar-nav .nav-item:hover { color: var(--text-2); background: rgba(255,255,255,0.03); }
.sidebar-nav .nav-item.active { color: var(--accent); background: rgba(64,242,254,0.08); }
.sidebar-nav .nav-item.active svg { color: var(--accent); }
.sidebar-footer { padding: 14px 10px; border-top: 1px solid var(--border); }
.sidebar-footer .icon-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13px; }
.sidebar-footer .icon-btn span { font-weight: 510; }

/* CONTENT */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: 0.02em; flex-shrink: 0; }
.topbar-stats {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-2); letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 600; min-width: 0; overflow-x: auto; overflow-y: hidden; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  scrollbar-width: none;
}
.topbar-stats::-webkit-scrollbar { width: 0; height: 0; }
.topbar-stats > span { display: inline-flex; align-items: center; gap: 4px; }
.topbar-stats .ic { flex-shrink: 0; opacity: 0.75; }
.topbar-stats .live .ic, .topbar-stats .rec .ic, .topbar-stats .foll .ic { opacity: 1; }
.topbar-stats .foll .ic { color: #ff7ab8; }
.topbar-stats .ts-slot.dim { color: var(--text-3); }
.topbar-stats .ts-slot.dim .ic { color: var(--text-3); opacity: 0.55; }
/* Slots fijos: cada uno ancho mínimo para evitar movimiento al cambiar valores */
.topbar-stats .ts-slot { justify-content: center; flex-shrink: 0; }
.topbar-stats .ts-status { min-width: 78px; justify-content: flex-start; }
.topbar-stats .ts-uptime { min-width: 62px; }
.topbar-stats .ts-viewers { min-width: 56px; }
.topbar-stats .ts-foll { min-width: 52px; }
.topbar-stats .ts-rec { min-width: 60px; }
.topbar-stats .ts-fps { min-width: 60px; }
.topbar-stats .ts-cpu { min-width: 68px; }
.topbar-stats .rec-off { opacity: 0.25; }
.topbar-stats .rec-off .ic { color: var(--text-3); }
/* Scroll horizontal silencioso si no cabe (mobile). Mantenemos fps/cpu/rec visibles. */
.topbar-stats { overflow-x: auto; scrollbar-width: none; }
.topbar-stats::-webkit-scrollbar { display: none; }
@media (max-width: 720px) {
  .topbar-stats { gap: 8px; font-size: 11px; }
  .topbar { padding: 10px 12px; }
  .topbar-title { display: none; }
}

/* ===== MOBILE: scroll en HTML (document scroll, no nested overflow) ===== */
@media (max-width: 720px) {
  /* iOS PWA standalone scrollea fiable cuando el scroll es del DOCUMENTO entero,
     no overflow internos. Quitar overflow:hidden del html/body, dejar que el
     contenido del body fluya y haga document scroll natural. */
  html { overflow-x: hidden !important; overflow-y: auto !important; height: auto !important; min-height: 100%; }
  body { overflow: visible !important; height: auto !important; min-height: 100lvh; padding-top: calc(var(--safe-top) + 58px); padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 40px); }
  body[data-view="main"] .view-main { display: block !important; height: auto !important; min-height: 0 !important; }
  .content { display: block !important; height: auto !important; min-height: 0 !important; }
  .topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: var(--bg-0); border-bottom: 1px solid var(--border); padding-top: calc(var(--safe-top) + 10px); }
  .page { flex: none !important; height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; padding: 12px 16px !important; }
  .bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 200; }
  /* iOS Safari default touch-action en <button> = manipulation (bloquea scroll
     cuando arrastras en un botón). Forzar pan-y en TODOS los elementos. */
  html, body, * { touch-action: pan-y !important; }
  /* Excepciones: scrollers horizontales */
  .topbar-stats, .stream-subtabs, .vis-chips, .scenes-grid, .topbar-stats *, .stream-subtabs *, .scenes-grid *, .vis-chips * { touch-action: pan-x pan-y !important; }
}
.topbar-stats { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; }
.topbar-stats .k { color: rgba(247,248,248,0.45); margin-right: 3px; font-weight: 500; }
.topbar-stats .live { color: #ff5a72; font-weight: 800; text-shadow: 0 0 8px rgba(255,90,114,0.35); }
.topbar-stats .rec { color: #fbbf24; font-weight: 800; }
.topbar-stats .foll { color: #ff7ab8; font-weight: 800; text-shadow: 0 0 6px rgba(255,122,184,0.3); }
.topbar-stats .sep { opacity: 0.35; }

.icon-btn { display: flex; align-items: center; justify-content: center; width: auto; min-width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--text-3); cursor: pointer; flex-shrink: 0; transition: color 200ms ease, background 200ms ease, border-color 200ms ease; }
.icon-btn:active { color: var(--text); background: rgba(255, 255, 255, 0.04); border-color: var(--border-2); }

/* PAGES */
.page { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px); display: flex; flex-direction: column; gap: 14px; }
.page::-webkit-scrollbar { width: 0; }
.page[hidden] { display: none; }

/* Cards & blocks */
.card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.card-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; }

/* Dashboard stat grid */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }

/* Chart */
.chart-card { gap: 8px; }
.chart-legend { display: flex; gap: 12px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.leg-msgs { color: var(--accent); }
.leg-cmds { color: #fbbf24; }
.leg-users { color: #a070ff; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 140px; padding-top: 8px; }
.chart-bar { display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; }
.chart-bar .bars { display: flex; align-items: end; gap: 2px; flex: 1; width: 100%; min-height: 4px; }
.chart-bar .bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s ease; }
.chart-bar .bar-msgs { background: var(--accent); }
.chart-bar .bar-cmds { background: #fbbf24; }
.chart-bar .bar-users { background: #a070ff; }
.chart-bar .label { font-size: 9px; color: var(--text-3); text-transform: uppercase; }

/* Two-col layout for dashboard tables */
.two-col { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* Leaderboard */
.lb { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; background: rgba(255,255,255,0.02); }
.lb-row .pos { color: var(--text-3); font-weight: 700; font-size: 11px; min-width: 22px; }
.lb-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.lb-row .value { color: var(--accent-hi); font-weight: 600; font-size: 11px; }
.lb-row.gold .pos { color: #ffd166; }
.lb-row.silver .pos { color: #c0c5d0; }
.lb-row.bronze .pos { color: #cd7f32; }

/* Bottom nav (mobile) — separación del home indicator + bordes curvos iPhone */
.bottom-nav {
  display: flex; align-items: stretch; gap: 4px;
  background: var(--bg-1); border-top: 1px solid var(--border-2);
  flex-shrink: 0;
  padding-top: 4px;
  padding-bottom: max(8px, calc(var(--safe-bottom) - 16px));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  height: auto;
}
.bottom-nav .nav-item { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; color: #5a5f6a !important; text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; transition: color .12s, opacity .12s, background .15s; padding: 5px 4px; border-radius: 10px; }
.bottom-nav .nav-item svg { opacity: 0.55; transition: opacity .12s; stroke: currentColor !important; }
.bottom-nav .nav-item span { display: none; }
.bottom-nav .nav-item.active { color: var(--accent) !important; font-weight: 700; background: rgba(64,242,254,0.08); }
.bottom-nav .nav-item.active svg { opacity: 1; }
.bottom-nav .nav-item.active span { display: inline; }
.bottom-nav .nav-item:active { transform: scale(0.96); }

/* ===== Streamdeck page (existing controls) ===== */
.action-btn {
  position: relative;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 12px;
  width: 100%; height: 64px; flex-shrink: 0;
  border-radius: 18px;
  border: 1px solid var(--border-2);
  background: linear-gradient(160deg, rgba(64, 242, 254, 0.16) 0%, rgba(64, 242, 254, 0.06) 60%, rgba(15, 168, 181, 0.03) 100%), var(--bg-2);
  color: var(--text); font: inherit; letter-spacing: 0.16em;
  box-shadow: 0 14px 34px -14px rgba(64, 242, 254, 0.32), 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -1px 0 rgba(0, 0, 0, 0.40);
  cursor: pointer; overflow: hidden;
  transition: transform 110ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 140ms, filter 240ms;
}
.action-btn::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(120% 80% at 50% 0%, rgba(64, 242, 254, 0.18) 0%, transparent 60%); }
.action-btn .icon { display: flex; color: var(--accent); }
.action-btn .label { font-size: 20px; font-weight: 590; letter-spacing: 0.22em; }
.action-btn:active { transform: scale(0.97); filter: brightness(1.18); }
.action-btn[disabled] { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.action-btn.firing { animation: pulse 520ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.action-btn.firing .icon { color: var(--accent-hi); transform: scale(1.08); }
.action-btn.success { border-color: rgba(64, 242, 254, 0.55); box-shadow: 0 0 0 4px rgba(64, 242, 254, 0.18), 0 14px 34px -14px rgba(64, 242, 254, 0.55), 0 4px 14px rgba(0, 0, 0, 0.55); }
.action-btn.error { border-color: rgba(255, 98, 117, 0.55); }
@keyframes pulse { 0%{transform:scale(0.97);} 35%{transform:scale(1.03);} 100%{transform:scale(1);} }

.status { font-size: 11px; font-weight: 510; letter-spacing: 0.06em; color: var(--text-3); text-align: center; text-transform: uppercase; flex-shrink: 0; min-height: 0; line-height: 1.2; transition: color 200ms ease; }
.status:empty { display: none; }
.status.ok { color: var(--accent-hi); }
.status.warn { color: #ffc857; }
.status.err { color: #ff6275; }
.last-clip { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); flex-shrink: 0; }
.last-clip[hidden] { display: none !important; }
.last-clip a { font-size: 12px; font-weight: 510; color: var(--accent); text-decoration: none; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-clip a:active { color: var(--accent-hi); }
.copy-btn { font: inherit; font-size: 10px; font-weight: 510; letter-spacing: 0.06em; text-transform: uppercase; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); cursor: pointer; flex-shrink: 0; }
.copy-btn:active { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.copy-btn.copied { color: var(--accent-hi); border-color: rgba(64, 242, 254, 0.55); }

.block { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; min-height: 0; }
.block-head { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; }
.block-head .muted { font-size: 10px; color: var(--text-3); letter-spacing: 0; text-transform: none; }
.block-head .muted.small { font-size: 9px; }
.agent-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; border: 1.5px solid #ef4444; flex-shrink: 0; transition: background 150ms, border-color 150ms; }
.agent-dot[data-state="online"] { background: var(--accent); border-color: var(--accent); }
.agent-dot[data-state="connecting"] { background: transparent; border-color: #fbbf24; }

.audio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.audio-btn { background: rgba(255,255,255,0.05); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 7px; min-height: 38px; cursor: pointer; text-align: left; }
.audio-btn:active { transform: scale(0.97); }
.audio-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; transition: background 150ms; }
.audio-btn.muted { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.40); }
.audio-btn.muted .dot { background: #ef4444; }
.audio-btn .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scenes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.scene-btn { background: rgba(255,255,255,0.05); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 8px; font: inherit; font-size: 11px; font-weight: 600; line-height: 1.2; min-height: 42px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.scene-btn:active { transform: scale(0.96); background: rgba(64,242,254,0.12); }
.scene-btn.active { background: var(--accent); color: #04141a; border-color: var(--accent); }
.scene-btn.pending { opacity: 0.6; pointer-events: none; }
.scene-btn.placeholder { opacity: 0.30; cursor: default; color: var(--text-3); }
.audio-btn.placeholder, .vis-chip.placeholder { opacity: 0.30; cursor: default; color: var(--text-3); }
.audio-btn.placeholder .dot { background: var(--text-3); }

.vis-chips { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.vis-chips::-webkit-scrollbar { height: 0; }
.vis-chip { flex-shrink: 0; background: rgba(255,255,255,0.04); color: var(--text-3); border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.vis-chip:active { transform: scale(0.95); }
.vis-chip.on { background: rgba(64,242,254,0.14); border-color: rgba(64,242,254,0.55); color: var(--accent-hi); }
.vis-chip.off { opacity: 0.55; }

.block-chat { min-height: 200px; }
.chat-feed { height: 280px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.35; display: flex; flex-direction: column; gap: 3px; user-select: text; }
@media (min-width: 900px) {
  .chat-feed { height: 360px; }
}
.chat-feed::-webkit-scrollbar { width: 0; }
.chat-feed-wrap { position: relative; }
.chat-scroll-bottom { position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(64,242,254,0.15); border: 1px solid rgba(64,242,254,0.4); color: var(--accent-hi); display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity 180ms ease, transform 180ms ease; transform: scale(0.85); pointer-events: none; }
.chat-scroll-bottom.show { opacity: 1; transform: scale(1); pointer-events: auto; }
.chat-scroll-bottom:active { transform: scale(0.92); background: rgba(64,242,254,0.30); }
.chat-scroll-bottom .unread-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid var(--bg-1); }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px 0; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { width: 0; height: 0; }
.chat-quick-btn { padding: 6px 11px; border-radius: 999px; background: rgba(64,242,254,0.08); border: 1px solid var(--border); color: var(--fg); font-size: 11px; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: background 120ms; }
.chat-quick-btn:active { transform: scale(0.96); background: rgba(64,242,254,0.20); }
.chat-quick-btn.editing { background: rgba(255,180,40,0.18); border-color: rgba(255,180,40,0.5); }
.chat-custom { display: flex; gap: 6px; margin-top: 4px; align-items: stretch; }
.chat-custom-input.sd-input { flex: 1 1 auto; width: auto; margin-bottom: 0; font-size: 13px; padding: 9px 12px; }
.chat-custom-send.sd-btn { flex: 0 0 auto; width: auto; min-width: 56px; padding: 0 18px; font-size: 20px; margin-top: 0; }
/* Nada de docking ni modal. iOS auto-scrollea el input arriba del teclado naturalmente. */
.chat-line { word-break: break-word; }
.cbadge { display: inline-flex; align-items: center; justify-content: center; height: 13px; padding: 0 4px; border-radius: 3px; font-size: 8px; font-weight: 800; letter-spacing: 0.04em; margin-right: 3px; vertical-align: middle; line-height: 1; }
.cbadge-broadcaster { background: rgba(255, 60, 60, 0.22); color: #ff7070; }
.cbadge-mod { background: rgba(0, 173, 3, 0.22); color: #4ed94d; }
.cbadge-vip { background: rgba(225, 0, 152, 0.22); color: #ff5fc1; }
.cbadge-sub { background: rgba(145, 70, 255, 0.22); color: #b594ff; }
.cbadge-staff { background: rgba(255, 217, 0, 0.22); color: #ffd900; }
.cbadge-admin { background: rgba(220, 30, 30, 0.30); color: #ff8a8a; }
.cbadge-partner { background: rgba(145, 70, 255, 0.22); color: #b594ff; padding: 0 3px; }
.cbadge-turbo { background: rgba(64, 242, 254, 0.18); color: var(--accent-hi); padding: 0 3px; }
.cbadge-bits { background: rgba(255, 200, 0, 0.22); color: #ffcc33; }
.chat-line .chat-user { font-weight: 700; margin-right: 6px; cursor: pointer; }
.chat-line .chat-user:active { opacity: 0.6; }
.mod-panel {
  position: fixed; width: 270px; max-width: calc(100vw - 16px);
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 10px; z-index: 500;
  opacity: 0; transform: scale(0.95) translateY(-4px); pointer-events: none;
  transition: opacity 150ms, transform 150ms;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  display: flex; flex-direction: column;
  max-height: 70vh; max-height: 70svh;
  overflow: hidden;
}
.mod-panel-actions { flex: 0 0 auto; }
.mod-panel.show { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.mod-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mod-panel-user { font-weight: 700; color: var(--accent-hi); font-size: 13px; }
.mod-panel-close { background: none; border: none; color: var(--text-3); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 6px; }
.mod-panel-actions { display: flex; flex-direction: column; gap: 4px; }
.mod-panel-actions button { background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; text-align: left; }
.mod-panel-actions button:active { background: rgba(64,242,254,0.10); }
.mod-panel-actions button[data-mod-act="ban"] { color: #ff6b6b; }
.mod-panel-actions button[data-mod-act="timeout"] { color: #fbbf24; }
.mod-panel-self { font-size: 11px; color: var(--text-3); padding: 8px 6px; line-height: 1.4; }
.mod-panel-body { margin-top: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mod-panel-body::-webkit-scrollbar { width: 0; }
.mod-history-line { font-size: 11px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.mod-history-time { color: var(--text-3); margin-right: 6px; font-variant-numeric: tabular-nums; }
.mod-history-text { color: var(--text-2); word-break: break-word; }
.chat-line .chat-text { color: var(--text-2); }
.chat-empty { color: var(--text-3); font-size: 11px; text-align: center; padding: 8px 8px; }

/* Twitch panel siempre visible */
.tw-bar { flex-shrink: 0; border: 1px solid var(--border); border-bottom: none; background: var(--bg-1); border-radius: 12px 12px 0 0; margin: 0 -16px -16px; overflow: hidden; }
.tw-bar-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: transparent; border: none; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.tw-bar-head:active { background: rgba(255,255,255,0.03); }
.tw-icon { color: #9146ff; flex-shrink: 0; }
.tw-mini { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tw-title-mini { font-size: 12px; font-weight: 510; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-cat-mini { font-size: 10px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-cat-mini:empty { display: none; }
.chevron { color: var(--text-3); flex-shrink: 0; transition: transform 220ms ease; }
.tw-bar.expanded .chevron { transform: rotate(180deg); }
.tw-bar-body { max-height: 0; overflow: hidden; transition: max-height 280ms cubic-bezier(0.2, 0.8, 0.2, 1); padding: 0 14px; }
.tw-bar.expanded .tw-bar-body { max-height: 50dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 14px 16px; border-top: 1px solid var(--border); }
.tw-bar.expanded .tw-bar-body::-webkit-scrollbar { width: 0; }

.sd-input { width: 100%; background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 13px; margin-bottom: 8px; }
.sd-input:focus { outline: none; border-color: var(--accent); }
.sd-btn { width: 100%; background: var(--accent); color: #04141a; border: none; border-radius: 11px; padding: 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; margin-top: 4px; }
.sd-btn:active { transform: scale(0.98); }
.sd-btn:disabled { opacity: 0.4; }
.sd-btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-2); margin-top: 10px; }
.sd-btn-ghost:active { background: rgba(255,255,255,0.04); }

.ch-cat { position: relative; }
#ch-cat-results { background: #0d141a; border: 1px solid var(--border); border-radius: 10px; max-height: 200px; overflow: auto; margin-bottom: 8px; display: none; }
#ch-cat-results.show { display: block; }
.ch-cat-item { padding: 9px 12px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ch-cat-item:last-child { border-bottom: none; }
.ch-cat-item:active { background: rgba(64,242,254,0.1); }
#ch-cat-current { font-size: 11px; margin-bottom: 8px; color: var(--text-3); }
#ch-msg { font-size: 11px; margin-top: 8px; color: var(--text-3); }
#ch-msg.err { color: #ef4444; }
#ch-msg.ok { color: #22c55e; }

.title-presets { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.preset-chip { background: rgba(64,242,254,0.06); border: 1px solid rgba(64,242,254,0.22); color: var(--accent-hi); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 11px; font-weight: 500; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .12s, border-color .12s, transform .08s; }
.preset-chip:active { transform: scale(0.985); background: rgba(64,242,254,0.14); }
.preset-chip.editing { background: rgba(255,180,40,0.15); border-color: rgba(255,180,40,0.45); }
.preset-chip-ai { display: flex; flex-direction: column; gap: 3px; white-space: normal; text-align: left; padding: 9px 11px; background: rgba(64,242,254,0.10); border-color: rgba(64,242,254,0.32); }
.preset-chip-ai .preset-meta { font-size: 9px; color: rgba(64,242,254,0.75); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.preset-chip-ai .preset-text { color: var(--text); font-size: 11px; font-weight: 500; line-height: 1.35; }
.title-gen-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.title-gen-actions .sd-btn { flex: 1; min-width: 130px; margin-top: 0; padding: 10px 12px; font-size: 12px; }
.title-intent { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.title-intent-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.title-intent-label .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }
.title-intent textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-family: inherit; font-size: 13px;
  resize: vertical; min-height: 44px; line-height: 1.4;
  outline: none; transition: border-color 0.15s;
}
.title-intent textarea:focus { border-color: var(--accent); }
.title-intent textarea::placeholder { color: var(--text-3); font-style: italic; }
.title-intent-counter { font-size: 10px; color: var(--text-3); text-align: right; }

/* Merge button inside each chip — appears only when intent textarea has content */
.preset-chip { position: relative; }
.preset-merge-btn {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
  background: rgba(64, 242, 254, 0.15);
  border: 1px solid rgba(64, 242, 254, 0.4);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
.preset-merge-btn:hover { background: rgba(64, 242, 254, 0.35); transform: scale(1.08); }
.preset-merge-btn:active { transform: scale(0.95); }
.preset-chip-merge {
  border-color: rgba(64, 242, 254, 0.55) !important;
  background: linear-gradient(135deg, rgba(64,242,254,0.06), rgba(64,242,254,0.02)) !important;
}
.preset-chip-merge .preset-meta { color: rgba(64,242,254,0.95) !important; }
.profile-form { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 10px 0; }
.profile-label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.profile-label .sd-input { margin-bottom: 0; font-size: 13px; }
.automsg-form { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 10px 0; }
.automsg-msgs { display: flex; flex-direction: column; gap: 6px; }
.automsg-row { display: flex; gap: 6px; align-items: stretch; }
.automsg-row .automsg-input { flex: 1; margin-bottom: 0; font-size: 12px; padding: 8px 10px; }
.automsg-del { flex: 0 0 auto; width: 36px; background: rgba(255,255,255,0.04); color: var(--text-3); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 14px; }
.automsg-del:active { background: rgba(255,90,90,0.15); color: #ff6b6b; }
.settings-btn.settings-btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-2); margin-top: 8px; }
.preset-chip .preset-num { color: rgba(64,242,254,0.55); font-weight: 700; margin-right: 6px; }

/* Sugerencias de título (top streamers EN VIVO de la categoría) */
.title-gen { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
#title-generate { margin-top: 0; }
#title-gen-msg { font-size: 10px; margin-top: 0; }
#title-gen-msg.ok { color: #22c55e; }
#title-gen-msg.err { color: #ef4444; }
#title-gen-msg.warn { color: #ffc857; }
.preset-chip-real { display: flex; flex-direction: column; gap: 2px; white-space: normal; text-align: left; padding: 8px 10px; }
.preset-chip-real .preset-meta { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.preset-chip-real .preset-text { font-size: 11px; color: var(--accent-hi); font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Bot commands editor */
.bot-cmds-list { display: flex; flex-direction: column; gap: 5px; padding-right: 2px; }
.bot-cmd-row { display: flex; align-items: center; gap: 5px; padding: 0; }
.bot-cmd-row .name { color: var(--accent); font-size: 11px; font-weight: 700; min-width: 64px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-cmd-row .text { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 11px; color: var(--text-2); min-width: 0; }
.bot-cmd-row .text:focus { outline: none; border-color: var(--accent); color: var(--text); }
.bot-cmd-row button { background: transparent; border: none; padding: 4px 6px; cursor: pointer; color: var(--text-3); font-size: 13px; flex-shrink: 0; line-height: 1; }
.bot-cmd-row button:active { color: var(--text); transform: scale(0.92); }
.bot-cmd-row .save.dirty { color: var(--accent-hi); }
.bot-cmds-add { display: flex; gap: 5px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); align-items: center; flex-wrap: wrap; }
.bot-cmds-add .sd-input { margin-bottom: 0; font-size: 12px; padding: 8px 10px; }
.bot-cmds-add #bot-cmd-name { flex: 0 0 100px; }
.bot-cmds-add #bot-cmd-text { flex: 1; min-width: 100px; }
.bot-cmds-add #bot-cmd-add { width: auto; padding: 8px 14px; font-size: 12px; margin-top: 0; }
#bot-cmd-msg { font-size: 10px; margin-top: 6px; }
#bot-cmd-msg.ok { color: #22c55e; }
#bot-cmd-msg.err { color: #ef4444; }

/* Watchtime page */
.wt-totals { font-size: 11px; color: var(--text-3); }
.wt-totals strong { color: var(--text); font-weight: 700; font-size: 13px; }

.muted { color: var(--text-3); font-size: 10px; }
.muted.small { font-size: 9px; }

/* ===== DESKTOP layout >=900px ===== */
@media (min-width: 900px) {
  body[data-view="main"] .view-main {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr;
  }
  .sidebar {
    display: flex; flex-direction: column;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    height: 100%;
    min-height: 0;
  }
  .bottom-nav { display: none; }
  .page { padding: 22px 28px; padding-bottom: 22px; max-width: 1200px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 16px 28px; }
  .stat-card { padding: 16px 18px; }
  .stat-value { font-size: 32px; }

  /* En desktop el panel Twitch deja de pegarse a los bordes */
  .tw-bar { margin: 16px 0 0; border-radius: 12px; border-bottom: 1px solid var(--border); }
}

/* Texto info cuando hay más escenas en OBS que no se muestran (cap 6) */
.scenes-hidden-hint { grid-column: 1 / -1; font-size: 10px; color: var(--text-3); text-align: center; padding: 4px 0 0; font-style: italic; }

/* Canal page: header con titulo+cat actual */
.tw-current-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 12px; line-height: 1.4; padding: 4px 0 6px; }
.tw-current-title-text { color: var(--text); font-weight: 600; }
.tw-current-cat-text { color: var(--accent); font-weight: 600; }

/* Subtítulo dentro de un .block (ej. "Fuentes" debajo de Escenas) */
.block-sub { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: 0.05em; text-transform: uppercase; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ===== Engagement block (polls + predictions) ===== */
.engage-active { display: flex; flex-direction: column; gap: 8px; min-height: 12px; font-size: 12px; color: var(--text-3); }
.engage-empty { padding: 8px; text-align: center; color: var(--text-3); font-size: 11px; }
.engage-timer { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 8px; background: rgba(64,242,254,0.08); border-radius: 6px; margin-bottom: 8px; display: inline-block; font-variant-numeric: tabular-nums; }
.engage-timer.expired { color: var(--text-3); background: rgba(255,255,255,0.04); }
.engage-card.resolved { opacity: 0.85; background: rgba(255,255,255,0.03); border-color: var(--border-2); }
.engage-card.resolved .engage-card-status.resolved { background: rgba(64,242,254,0.12); color: var(--accent-hi); }
.engage-card.resolved .engage-card-status.canceled { background: rgba(220,30,30,0.15); color: #ff6b6b; }
.engage-winner { font-size: 12px; font-weight: 600; color: var(--text); padding: 6px 0 0 0; }
.last-clip-text { cursor: pointer; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 510; color: var(--accent); }
.last-clip-text:active { color: var(--accent-hi); }
.engage-card { background: rgba(145,70,255,0.06); border: 1px solid rgba(145,70,255,0.25); border-radius: 10px; padding: 10px 12px; }
.engage-card.pred { background: rgba(255,90,150,0.06); border-color: rgba(255,90,150,0.25); }
.engage-card-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.engage-card-status { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(145,70,255,0.2); color: #b594ff; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; flex-shrink: 0; }
.engage-card-status.locked { background: rgba(251,191,36,0.2); color: #fbbf24; }
.engage-choices { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.engage-choice { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; background: rgba(0,0,0,0.25); border-radius: 6px; font-size: 11px; }
.engage-choice-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engage-choice-votes { color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 600; }
.engage-card-actions { display: flex; gap: 6px; margin-top: 8px; }
.engage-card-actions button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border-2); background: rgba(255,255,255,0.04); color: var(--text-2); font-size: 11px; font-weight: 700; cursor: pointer; }
.engage-card-actions button:active { transform: scale(0.97); background: rgba(255,255,255,0.08); }
.engage-card-actions .danger { border-color: rgba(220,30,30,0.4); color: #ff6b6b; }
.engage-actions { display: flex; gap: 8px; margin-top: 6px; }
.engage-actions .sd-btn { flex: 1; }

/* ===== Modal prompt (input variants) ===== */
.app-modal-input {
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.app-modal-input:focus { outline: none; border-color: var(--accent); }
.app-modal-input.textarea { min-height: 80px; }

/* ===== Modal custom (reemplaza confirm/alert nativos del browser) ===== */
.app-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  display: none;
  align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-bottom));
  opacity: 0; transition: opacity 0.18s ease, padding-bottom 0.18s ease, align-items 0.18s ease;
}
/* Cuando teclado iOS está abierto, modal anclado arriba del accessory bar (^ v ✓ ~45-50px) */
.app-modal-overlay.kb-open {
  align-items: flex-end !important;
  padding-bottom: 90px !important;
}
.app-modal-overlay.show { display: flex; opacity: 1; }
.app-modal {
  background: linear-gradient(180deg, #1c1d20 0%, #14151a 100%);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  max-width: 380px; width: 100%;
  box-shadow: 0 24px 56px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), opacity 0.20s ease;
  overflow: hidden;
}
.app-modal-overlay.show .app-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.app-modal-icon {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px;
  margin: 24px auto 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-2);
  color: var(--text-2);
}
.app-modal-icon.danger { background: rgba(220,30,30,0.12); border-color: rgba(220,30,30,0.4); color: #ff6b6b; }
.app-modal-icon.warn { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.4); color: #fbbf24; }
.app-modal-icon.success { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.4); color: #22c55e; }
.app-modal-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  text-align: center; padding: 0 24px;
  letter-spacing: 0.01em;
}
.app-modal-body {
  font-size: 14px; color: var(--text-2);
  text-align: center; padding: 8px 24px 20px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.app-modal-actions {
  display: flex; gap: 8px;
  padding: 0 16px 16px;
}
.app-modal-btn {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  border: none;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.app-modal-btn:active { transform: scale(0.97); }
.app-modal-btn-cancel {
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.app-modal-btn-cancel:active { background: rgba(255,255,255,0.1); }
.app-modal-btn-confirm {
  background: linear-gradient(135deg, #9146ff 0%, #6441a5 100%);
  color: #fff;
}
.app-modal-btn-confirm.danger {
  background: linear-gradient(135deg, #ff3b3b 0%, #c80000 100%);
}
.app-modal-btn-confirm.warn {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #1c1d20;
}
.app-modal-btn-confirm.success {
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
}

/* ===== Settings page ===== */
.settings-row { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.settings-row .avatar { width: 48px; height: 48px; border-radius: 50%; }
.settings-user { flex: 1; min-width: 0; }
.settings-name { font-size: 15px; font-weight: 700; color: var(--text); }
.settings-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.settings-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #9146ff 0%, #6441a5 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.03em;
  cursor: pointer; text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.settings-btn:active { transform: scale(0.98); }
.settings-btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-2);
}
.settings-btn-ghost:active { background: rgba(255,255,255,0.04); }
.settings-twitch { padding: 4px 0 12px; font-size: 13px; color: var(--text-2); }
.settings-hint { margin: 8px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.4; text-align: center; }
.card-danger {
  border: 1px solid rgba(220,30,30,0.30) !important;
  background: var(--bg-1) !important;
}
.card-danger .card-head { color: #ff6b6b; }

/* ===== Emergency Kill block (legacy if reused inside stream) ===== */
.block-danger {
  border: 1px solid rgba(220,30,30,0.30) !important;
  background: var(--bg-1);
}
.block-danger .block-head { color: #ff6b6b; }
.kill-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px;
  background: #c8202c;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.kill-btn:active { transform: scale(0.98); background: #a51823; }
.kill-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.kill-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
  text-align: center;
}

/* ===== Panic Mute Mic FAB ===== */
.panic-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 70px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1f8a4d;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.25s ease, background 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.panic-fab:active { transform: scale(0.92); }
.panic-fab { transition: opacity 180ms ease, transform 180ms ease; }
.panic-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.6); }
.panic-fab .icon-mic-off { display: none; }
.panic-fab.active {
  background: #c8202c;
  box-shadow: 0 0 0 2px rgba(220,30,30,0.25), 0 4px 14px rgba(0,0,0,0.5);
}
.panic-fab.active .icon-mic-on { display: none; }
.panic-fab.active .icon-mic-off { display: block; }
@keyframes panic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@media (min-width: 900px) {
  .panic-fab { bottom: 24px; right: 24px; width: 64px; height: 64px; }
}

/* Toast notificación post-panic */
.panic-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 175px);
  transform: translateX(-50%);
  background: rgba(0,0,0,0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
.panic-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) {
  .panic-toast { bottom: 100px; }
}

/* ===== Directo (10-oct, sabodeck-movil-9oct): estado arriba, CLIP y MIC grandes, escenas de OBS ===== */
.live-card { background: var(--bg-1); border: 1px solid var(--border-2); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.live-card[data-live="on"] { border-color: rgba(255, 90, 114, 0.55); box-shadow: 0 0 0 3px rgba(255, 90, 114, 0.10); }
.live-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.live-pill { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; padding: 5px 10px; border-radius: 8px; background: var(--bg-3); color: var(--text-3); flex-shrink: 0; }
.live-card[data-live="on"] .live-pill { background: #e5384f; color: #fff; }
.live-time { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; font-size: 15px; font-weight: 700; color: var(--text); }
.live-viewers { font-size: 12px; color: var(--text-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-row .agent-dot { margin-left: auto; width: 9px; height: 9px; }
.live-metrics { display: grid; grid-template-columns: 1.3fr 0.9fr 1.2fr 0.6fr; gap: 8px; }
.lm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lm-k { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.lm-v { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; font-size: 13px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-scene .lm-v { font-family: inherit; color: var(--accent-hi); }
.lm-v.warn { color: #ffc857; }
.live-warn { font-size: 12px; line-height: 1.35; color: #ffc857; background: rgba(255, 200, 87, 0.08); border: 1px solid rgba(255, 200, 87, 0.30); border-radius: 10px; padding: 8px 10px; }
.live-warn[hidden] { display: none; }

.deck-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex-shrink: 0; }
.deck-btn { height: 112px; flex-direction: column; gap: 8px; }
.deck-btn .label { font-size: 17px; letter-spacing: 0.16em; }
.mic-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; border-radius: 18px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); font: inherit; cursor: pointer; transition: transform 110ms cubic-bezier(0.2, 0.8, 0.2, 1), background 160ms, border-color 160ms; }
.mic-btn .icon { display: flex; }
.mic-btn .label { font-weight: 700; }
.mic-btn .icon-mic-off { display: none; }
.mic-btn[data-state="on"] { background: linear-gradient(160deg, rgba(34, 197, 94, 0.22), rgba(34, 197, 94, 0.06)), var(--bg-2); border-color: rgba(34, 197, 94, 0.55); }
.mic-btn[data-state="on"] .icon { color: #4ade80; }
.mic-btn[data-state="off"] { background: #c62a3f; border-color: #ff6275; }
.mic-btn[data-state="off"] .icon-mic-on { display: none; }
.mic-btn[data-state="off"] .icon-mic-off { display: block; }
.mic-btn[data-state="unknown"] { opacity: 0.6; }
.mic-btn:active { transform: scale(0.97); }
.mic-btn.pending { opacity: 0.6; pointer-events: none; }

.page-stream .scenes-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
.page-stream .scene-btn { min-height: 58px; font-size: 15px; font-weight: 700; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; white-space: normal; }
.page-stream .scene-btn .scene-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.page-stream .scene-btn.active { background: rgba(229, 56, 79, 0.16); color: #fff; border: 2px solid #e5384f; }
.page-stream .scene-btn .scene-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.1em; color: #ff8a9a; }
.page-stream .scene-btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.scenes-empty { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); text-align: center; padding: 18px 8px; border: 1px dashed var(--border-2); border-radius: 12px; }

.tg-card { display: flex; align-items: center; gap: 10px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.tg-card:active { background: var(--bg-2); }
.tg-box { width: 26px; height: 36px; border-radius: 4px; background: var(--bg-3); flex-shrink: 0; overflow: hidden; }
.tg-box img { display: block; width: 26px; height: 36px; }
.tg-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tg-title { font-size: 12px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tg-game { font-size: 11px; color: var(--text-3); }
.tg-go { font-size: 11px; font-weight: 700; color: var(--accent); flex-shrink: 0; }

body[data-page="stream"] .panic-fab { display: none; }

/* Título y buscador de juego (Canal) */
.ch-title-wrap { position: relative; }
.ch-title-wrap .sd-input { padding-right: 62px; }
.ch-count { position: absolute; right: 10px; top: 12px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--text-3); pointer-events: none; }
.ch-count.warn { color: #ffc857; }
.ch-cat-chosen { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin-bottom: 8px; border-radius: 10px; background: rgba(64, 242, 254, 0.07); border: 1px solid rgba(64, 242, 254, 0.30); }
.ch-cat-chosen[hidden] { display: none; }
.ch-cat-chosen img, .ch-cat-item img { width: 26px; height: 36px; border-radius: 3px; flex-shrink: 0; background: var(--bg-3); }
.ch-cat-chosen .cc-name { font-size: 13px; font-weight: 700; flex: 1; min-width: 0; }
.ch-cat-chosen .cc-tag { font-size: 10px; color: var(--text-3); flex-shrink: 0; }
#ch-cat-results { max-height: 300px; margin-top: -4px; }
.ch-cat-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; font-size: 13px; }
.ch-cat-item.sel { background: rgba(64, 242, 254, 0.12); }
.ch-cat-none { padding: 10px 12px; font-size: 12px; color: var(--text-3); }

/* Clips: alargar o recortar (11-oct) */
.clips-list { display: flex; flex-direction: column; gap: 8px; }
.clips-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 14px 8px; border: 1px dashed var(--border-2); border-radius: 12px; }
.clip-row { background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.clip-top { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; }
.clip-when { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; color: var(--text); flex-shrink: 0; }
.clip-game { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.clip-dur { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent-hi); flex-shrink: 0; }
.clip-st { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 6px; flex-shrink: 0; }
.clip-st.ok { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.clip-st.pend { background: rgba(255, 200, 87, 0.12); color: #ffc857; }
.clip-st.err { background: rgba(255, 98, 117, 0.14); color: #ff6275; }
.clip-lado { display: grid; grid-template-columns: 64px 44px 1fr 44px; align-items: center; gap: 8px; }
.clip-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.clip-step { height: 40px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); font: inherit; font-size: 20px; font-weight: 700; cursor: pointer; }
.clip-step:active { transform: scale(0.95); background: rgba(64, 242, 254, 0.12); }
.clip-step[disabled] { opacity: 0.3; pointer-events: none; }
.clip-v { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-3); }
.clip-v.on { color: var(--text); }
