/* ROTATOR Mobile UI — Mobile-First, PWA Responsive Dark Theme */
:root {
  --bg:           #0b0f17;
  --bg2:          #131a29;
  --bg3:          #1c2538;
  --bg4:          #26334d;
  --border:       #273349;
  --border-focus: #3b82f6;
  --accent:       #3b82f6;
  --accent-light: #60a5fa;
  --accent-glow:  rgba(59, 130, 246, 0.25);
  --green:        #10b981;
  --green-bg:     rgba(16, 185, 129, 0.15);
  --red:          #ef4444;
  --red-bg:       rgba(239, 68, 68, 0.15);
  --yellow:       #f59e0b;
  --purple:       #a855f7;
  --purple-bg:    rgba(168, 85, 247, 0.15);
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --dim:          #64748b;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-full:  9999px;
  --font:         system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── CABECERA SUPERIOR ──────────────────────────────────────────────── */
#main-header {
  height: 56px;
  min-height: 56px;
  background: rgba(19, 26, 41, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  z-index: 50;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top, 0);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.header-chat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.header-chat-info:hover {
  background: rgba(255, 255, 255, 0.04);
}

.header-chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
@media (min-width: 480px) {
  .header-chat-title { max-width: 260px; }
}

.header-chat-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.meta-pill {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-quotas-compact {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quota-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  background: var(--bg3);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.quota-gemini { color: #38bdf8; }
.quota-claude { color: #c084fc; }

/* Botones Icono */
.btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}
.btn-icon:hover {
  background: var(--bg4);
  border-color: var(--accent);
  color: var(--accent-light);
}
.btn-icon:active {
  transform: scale(0.94);
}
.btn-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-action:hover {
  background: var(--accent-light);
  color: #fff;
}

.icon-hamburger {
  font-size: 20px;
  line-height: 1;
}

/* Barra Gateway Remoto */
.gateway-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e1b4b;
  border-bottom: 1px solid #4338ca;
  padding: 8px 12px;
  font-size: 12px;
  flex-shrink: 0;
}
.gateway-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid #6366f1;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}

/* Barra de Carpeta / Workspace Activo */
.active-folder-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 40;
}
.folder-bar-icon {
  font-size: 13px;
  opacity: 0.85;
}
.folder-bar-text {
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.folder-bar-text .folder-highlight {
  color: var(--accent-light);
  font-weight: 600;
}

/* ── PANTALLA DE CHAT PRINCIPAL ─────────────────────────────────────── */
#chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

/* Welcome Card */
.welcome-msg {
  text-align: center;
  padding: 24px 16px !important;
  margin: auto auto;
  max-width: 380px !important;
  border-radius: 16px !important;
  background: var(--bg2) !important;
  border: 1px solid var(--border) !important;
}
.welcome-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.welcome-msg h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--accent-light);
}
.welcome-msg p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Mensajes */
.msg {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.msg-bot {
  align-self: flex-start;
  background: var(--bg2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.msg-sys {
  align-self: center;
  max-width: 95%;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  text-align: center;
}

.msg-err {
  align-self: center;
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: #fca5a5;
  font-size: 13px;
}

/* Markdown en mensajes bot */
.msg pre {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}
.msg code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Chat Status / Ticker */
.chat-status {
  padding: 4px 16px;
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 500;
  min-height: 20px;
}

/* ── BARRA DE CONTROL DE MODELO Y ROTACIÓN ENCIMA DEL CHAT ── */
.chat-input-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

.quick-model-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.quick-model-icon {
  font-size: 14px;
  opacity: 0.85;
  flex-shrink: 0;
}

.quick-model-select {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}
.quick-model-select:focus {
  border-color: var(--accent);
}

.quick-mode-group {
  flex-shrink: 0;
}

.quick-mode-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.quick-mode-pill:hover {
  background: var(--bg);
  border-color: var(--accent);
}

/* ── INDICADOR DE PENSANDO CON BURBUJA Y PUNTOS ANIMADOS ── */
.msg-typing {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.35);
  animation: pulse-border 2s infinite ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(59, 130, 246, 0.25); }
  50% { border-color: rgba(59, 130, 246, 0.6); }
}

.typing-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent-light);
  font-weight: 500;
}

.typing-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(96, 165, 250, 0.25);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0 2px 22px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent-light);
  border-radius: 50%;
  display: inline-block;
  opacity: 0.4;
  animation: bounce-dot 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce-dot {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.btn-retry {
  margin-top: 8px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-retry:hover {
  background: rgba(239, 68, 68, 0.35);
}

/* Barra de Entrada */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(19, 26, 41, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#chat-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  padding: 0;
}
#chat-input::placeholder {
  color: var(--dim);
}

.btn-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}
.btn-send:hover {
  background: var(--accent-light);
}
.btn-send:active {
  transform: scale(0.92);
}
.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.send-icon {
  font-size: 16px;
  margin-left: 2px;
}

/* ── MENÚ LATERAL DESPLEGABLE (DRAWER) ──────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(85vw, 340px);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-symbol {
  color: var(--accent);
  font-size: 18px;
}

.btn-new-chat-drawer {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-new-chat-drawer:hover {
  background: var(--accent-light);
}

.drawer-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
}
.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  -webkit-overflow-scrolling: touch;
}

/* ÁRBOL DE CARPETAS Y CHATS */
.folder-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.folder-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s;
}
.folder-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.folder-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.folder-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-count {
  font-size: 11px;
  color: var(--dim);
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.btn-new-chat-folder {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--accent-light);
  font-size: 14px;
  font-weight: bold;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-new-chat-folder:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.1);
}
.btn-new-chat-folder:active {
  transform: scale(0.92);
}
.folder-chevron {
  font-size: 10px;
  color: var(--dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.folder-item.is-open .folder-chevron {
  transform: rotate(90deg);
}

.folder-chats {
  display: none;
  flex-direction: column;
  padding: 2px 0 6px 6px;
  gap: 2px;
}
.folder-item.is-open .folder-chats {
  display: flex;
}

/* Chat Item bajo carpeta */
.chat-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, border-left-color 0.15s;
  border-left: 2px solid transparent;
}
.chat-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.chat-item:active {
  background: rgba(59, 130, 246, 0.15);
  transform: scale(0.99);
}
.chat-item.active {
  background: rgba(59, 130, 246, 0.18);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.chat-item-title {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item.active .chat-item-title {
  color: var(--accent-light);
}

/* Pie del Drawer */
.drawer-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-footer-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.drawer-footer-btn:hover {
  background: var(--bg4);
  border-color: var(--accent);
}

.drawer-host-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 4px;
}
.dot-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-err { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ── MODAL CONTEXTUAL (LONG-PRESS ACTION SHEET) ─────────────────────── */
.action-sheet-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 100vw;
  width: 100%;
  margin: auto auto 0 auto;
}
.action-sheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.action-sheet-content {
  background: var(--bg2);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom, 18px));
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.action-sheet-header {
  text-align: center;
  margin-bottom: 14px;
}
.action-sheet-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-sheet-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.action-sheet-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.action-btn:active {
  transform: scale(0.98);
}
.action-danger {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}
.action-cancel {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
}

/* ── MODAL FULLSCREEN DE AJUSTES & PANEL DE CONTROL ────────────────── */
.fullscreen-dialog {
  border: none;
  background: var(--bg);
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  display: none;
  flex-direction: column;
  z-index: 200;
}
.fullscreen-dialog[open] {
  display: flex;
}

.dialog-header {
  height: 56px;
  min-height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top, 0);
}
.dialog-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-title-group h2 {
  font-size: 16px;
  font-weight: 700;
}
.badge-gateway {
  font-size: 11px;
  background: #312e81;
  color: #a5b4fc;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.btn-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.settings-tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  padding: 0 8px;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}
.settings-tabs::-webkit-scrollbar { display: none; }

.s-tab {
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.s-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
}

.stab-content {
  display: none;
  flex-direction: column;
  gap: 14px;
}
.stab-content.active {
  display: flex;
}

/* Tarjetas y Formularios de Ajustes */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card h3 {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}
.card-row:last-child {
  border-bottom: none;
}
.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.select-full {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.form-row {
  display: flex;
  gap: 8px;
}

.mode-switch-large {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mode-btn {
  padding: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s;
}
.mode-btn strong { font-size: 13px; color: var(--text); }
.mode-btn small  { font-size: 11px; color: var(--dim); }
.mode-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
}
.mode-btn.active strong { color: var(--accent-light); }

/* ESTADÍSTICAS DEL MAZO */
.deck-stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num { font-size: 16px; font-weight: 700; color: var(--text); }
.stat-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.stat-gemini .stat-num { color: #38bdf8; }
.stat-claude .stat-num { color: #c084fc; }

.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* LISTADO DEL MAZO (CARDS DE CUENTAS) */
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deck-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s;
}
.deck-card.is-active {
  border-color: var(--green);
  background: rgba(16, 185, 129, 0.05);
}
.deck-card.is-exhausted {
  border-color: var(--yellow);
  opacity: 0.85;
}
.deck-card.is-unlinked {
  border-color: rgba(239, 68, 68, 0.4);
}

.deck-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.deck-card-id {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.deck-card-email {
  font-size: 12px;
  color: var(--text-muted);
}
.deck-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.deck-card-actions {
  display: flex;
  gap: 6px;
}

/* Modales Pequeños */
.deck-modal {
  border: none;
  background: var(--bg2);
  color: var(--text);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  max-width: 90vw;
  width: 440px;
  margin: auto;
}
.deck-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.bulk-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* Utilidades */
.btn-sm {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-light); }
.btn-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon-xs {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.log-box {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: #94a3b8;
}
.audit-table-wrapper {
  overflow-x: auto;
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.audit-table th, .audit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.audit-table th { color: var(--text-muted); }

.dim { color: var(--dim); }
.loading {
  text-align: center;
  padding: 24px 0;
  color: var(--dim);
  font-size: 13px;
}

/* Banners */
.banner {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid transparent;
}
.banner-warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fef3c7;
}
.banner-action-btn {
  margin-top: 6px;
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
