@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600&display=swap');
:root {
  --bg-app: #020008; --bg-chat: #0b0814; --bg-solid: #0c0a16;
  --border: rgba(255,255,255,0.08); --text: #ECECEC; --text-muted: #9aa0b3;
  --ai-from: #818cf8; --ai-mid: #c084fc; --ai-to: #f472b6;
  --ai-gradient: linear-gradient(135deg, #818cf8 0%, #c084fc 50%, #f472b6 100%);
  --ai-gradient-btn: linear-gradient(90deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --glass: rgba(255,255,255,0.045); --glass-strong: rgba(255,255,255,0.07); --glass-border: rgba(255,255,255,0.10);
  --glow: 0 0 25px rgba(139,92,246,0.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg-app); color: var(--text); height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
::selection { background: rgba(129,140,248,0.30); }

/* ── Aura cósmica de marca (sin filter:blur; solo gradientes + transform) ── */
.aura { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #020008; pointer-events: none; }
.aura-blob { position: absolute; border-radius: 50%; will-change: transform; }
.aura-blob-1 { top: -20%; left: -10%; width: 75vw; height: 75vw; transform-origin: 40% 60%; background: radial-gradient(circle at center, rgba(124,58,237,0.45) 0%, rgba(124,58,237,0.15) 30%, transparent 70%); animation: auraDrift1 16s linear infinite; }
.aura-blob-2 { bottom: -20%; right: -10%; width: 85vw; height: 85vw; transform-origin: 60% 40%; background: radial-gradient(circle at center, rgba(99,102,241,0.35) 0%, rgba(99,102,241,0.10) 35%, transparent 70%); animation: auraDrift2 20s linear infinite; }
.aura-blob-3 { top: 8%; left: 14%; width: 62vw; height: 62vw; transform-origin: 50% 50%; background: radial-gradient(circle at center, rgba(236,72,153,0.32) 0%, rgba(236,72,153,0.05) 40%, transparent 70%); animation: auraDrift3 13s linear infinite; }
.aura-grid { position: absolute; inset: 0; opacity: 0.25; background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCI+PHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTAgNDBoNDBNNDAgMHY0MCIgc3Ryb2tlPSJyZ2JhKDI1NSwyNTUsMjU1LDAuMDMpIiBzdHJva2Utd2lkdGg9IjEiLz48L3N2Zz4="); }
/* Variante sutil/estática para dashboard y tablero (no compite con los datos). */
.aura--subtle { opacity: 0.5; }
.aura--subtle .aura-blob { animation: none; }
.aura--subtle .aura-grid { opacity: 0.12; }
@keyframes auraDrift1 { 0% { transform: translate(-5%,-5%) scale(1) rotate(0deg); } 33% { transform: translate(10%,15%) scale(1.3) rotate(120deg); } 66% { transform: translate(-10%,-5%) scale(0.9) rotate(240deg); } 100% { transform: translate(-5%,-5%) scale(1) rotate(360deg); } }
@keyframes auraDrift2 { 0% { transform: translate(10%,10%) scale(1) rotate(360deg); } 50% { transform: translate(-10%,-5%) scale(1.2) rotate(180deg); } 100% { transform: translate(10%,10%) scale(1) rotate(0deg); } }
@keyframes auraDrift3 { 0% { transform: translate(-10%,0%) scale(1) rotate(0deg); } 33% { transform: translate(15%,10%) scale(1.4) rotate(-120deg); } 66% { transform: translate(-5%,-15%) scale(0.85) rotate(-240deg); } 100% { transform: translate(-10%,0%) scale(1) rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) {
  .aura-blob { animation: none !important; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Header */
#top-bar { height: 52px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; position: relative; z-index: 10; }
.logo { display: flex; align-items: center; gap: 0.55em; }
.brand-text { font-weight: 300; color: rgba(255,255,255,0.92); font-size: 1.3rem; letter-spacing: -0.05em; display: inline-flex; align-items: baseline; user-select: none; }
.brand-ai { font-weight: 500; background: var(--ai-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--ai-from); letter-spacing: -0.05em; }
/* Solo los botones-ícono DIRECTOS de la barra (no los del menú de cuenta anidado). */
.actions > button { background: transparent; border: none; color: rgba(255,255,255,0.72); font-size: 1.2rem; cursor: pointer; margin-left: 15px; transition: color 0.2s; }
.actions > button:hover { color: var(--text); }
.topbar-left { display: flex; align-items: center; gap: 10px; z-index: 1; flex-shrink: 0; }
.btn-back { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass); color: var(--text-muted); text-decoration: none; transition: all 0.2s ease; flex-shrink: 0; }
body[data-authed] .btn-back { display: inline-flex; } /* el server revela "volver" solo si hay sesión */
.btn-back:hover { color: var(--text); border-color: rgba(129,140,248,0.5); transform: translateX(-1px); }
.btn-back i { font-size: 1.05rem; line-height: 1; }
/* "MovAI Boards" alineado idéntico al dashboard (baseline + mismo gap). */
#top-bar .logo { gap: 0.5em; align-items: baseline; }
/* 3 zonas flex: el título es un item central que TRUNCA (ya no se encima con el logo). */
.topbar-center { flex: 1; min-width: 0; text-align: center; padding: 0 10px; }
#board-title { color: var(--text); font-size: 0.92rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 100%; vertical-align: middle; }
.actions { display: flex; align-items: center; z-index: 1; flex-shrink: 0; }
.board-user { display: none; align-items: center; gap: 10px; margin-left: 15px; }
body[data-owner] .board-user { display: flex; }
.board-user .avatar-wrap:hover { transform: translateY(-1px); }
/* Bottom sheet móvil: handle y backdrop ocultos en desktop (se activan en @media). */
#sheet-handle, #sheet-backdrop { display: none; }

/* Layout */
#app-body { display: flex; flex: 1; overflow: hidden; position: relative; z-index: 1; }
#dashboard-area { flex: 1; background: transparent; display: flex; flex-direction: column; position: relative; }
#iframe-container { flex: 1; background: #ffffff; position: relative; overflow: hidden; transition: box-shadow 0.5s ease; }
iframe { width: 100%; height: 100%; border: none; }
/* Cargador: dos orbes de la paleta de marca que derivan sobre un fondo oscuro. Sutil (no invasivo) y vivo. */
#aura-loader { position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, #0a0716 0%, #050310 72%); z-index: 5; pointer-events: none; overflow: hidden; transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1); opacity: 0; }
#aura-loader::before, #aura-loader::after { content: ''; position: absolute; border-radius: 50%; filter: blur(46px); opacity: 0.5; will-change: transform; }
#aura-loader::before { width: 56%; height: 56%; top: 8%; left: 6%; background: radial-gradient(circle, var(--ai-from) 0%, transparent 66%); animation: loaderOrbA 9s ease-in-out infinite; }
#aura-loader::after { width: 62%; height: 62%; bottom: 4%; right: 4%; background: radial-gradient(circle, var(--ai-to) 0%, transparent 66%); animation: loaderOrbB 11s ease-in-out infinite; }
#iframe-container.loading #aura-loader { opacity: 1; pointer-events: all; }
@keyframes loaderOrbA { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(20%, 14%) scale(1.18); } }
@keyframes loaderOrbB { 0%, 100% { transform: translate(0, 0) scale(1.06); } 50% { transform: translate(-16%, -12%) scale(0.88); } }
@media (prefers-reduced-motion: reduce) { #aura-loader::before, #aura-loader::after { animation: none; } }

/* El aura de carga del contenedor (marca MovAI) */
#iframe-container.loading {
  box-shadow: 
    0 0 0 3px rgba(129, 140, 248, 0.45),
    0 0 30px rgba(192, 132, 252, 0.35);
  animation: loading-pulse 2s infinite alternate ease-in-out;
}

@keyframes loading-pulse {
  0% {
    box-shadow: 
      0 0 0 3px rgba(129, 140, 248, 0.45),
      0 0 25px rgba(192, 132, 252, 0.25);
  }
  100% {
    box-shadow: 
      0 0 0 4px rgba(192, 132, 252, 0.65),
      0 0 40px rgba(129, 140, 248, 0.5);
  }
}

/* El aura de procesamiento/pensamiento del tablero (Contenedor Externo) */
#iframe-container.thinking {
  box-shadow:
    0 0 40px rgba(129, 140, 248, 0.55),
    0 0 70px rgba(192, 132, 252, 0.45);
}

/* El aura superpuesta sobre los bordes del tablero (Por encima del iframe).
   El borde/glow está SIEMPRE definido pero invisible (opacity:0); la entrada y la salida
   se hacen con un fade de opacidad suave, en vez de saltar el grosor del borde de golpe. */
#board-aura-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none; /* Crucial para no bloquear clicks en el iframe */
  z-index: 4; /* Encima del iframe, debajo del cargador negro inicial */
  border: 8px solid rgba(129, 140, 248, 0.85);
  box-shadow:
    inset 0 0 35px rgba(129, 140, 248, 0.7),
    inset 0 0 70px rgba(192, 132, 252, 0.65),
    inset 0 0 100px rgba(129, 140, 248, 0.55);
  opacity: 0;
  transition: opacity 0.5s ease;
  animation: overlay-glow 1.5s infinite alternate ease-in-out;
  animation-play-state: paused; /* el pulso solo corre cuando está visible */
}

#iframe-container.thinking #board-aura-overlay {
  opacity: 1;
  animation-play-state: running;
}

@keyframes overlay-glow {
  0% {
    border-color: rgba(129, 140, 248, 0.75);
    box-shadow: 
      inset 0 0 25px rgba(129, 140, 248, 0.6),
      inset 0 0 50px rgba(192, 132, 252, 0.5),
      inset 0 0 80px rgba(129, 140, 248, 0.4);
  }
  100% {
    border-color: rgba(192, 132, 252, 0.95);
    box-shadow: 
      inset 0 0 45px rgba(192, 132, 252, 0.85),
      inset 0 0 90px rgba(129, 140, 248, 0.8),
      inset 0 0 120px rgba(192, 132, 252, 0.7);
  }
}


/* Indicador de carga en el chat (Bouncing Dots) */
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 6px 10px; }
.typing-indicator span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; display: inline-block; animation: typing-bounce 1.4s infinite ease-in-out both; }
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}
#chat-sidebar { width: 400px; background: var(--glass); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); display: flex; flex-direction: column; border-left: 1px solid var(--glass-border); transition: transform 0.3s ease, width 0.3s ease; flex-shrink: 0; overflow: hidden; position: relative; z-index: 20; }
#chat-sidebar.collapsed { width: 0 !important; border-left: none !important; }
#chat-sidebar.resizing { transition: none !important; }

#chat-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 100;
  background: transparent;
  transition: background-color 0.2s ease;
}
#chat-resize-handle:hover,
#chat-resize-handle.resizing {
  background-color: rgba(255, 255, 255, 0.18);
}

/* Fixed Status Panel */
#status-panel {
  padding: 16px 20px;
  background: transparent;
  border-bottom: 1px solid var(--glass-border);
}

/* Chat Messages */
#messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; }
#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
#messages::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }
.msg-wrap { display: flex; flex-direction: column; line-height: 1.6; font-size: 0.95rem; }
.msg-wrap.bot { color: #D1D5DB; }
.msg-wrap.user { align-items: flex-end; }
.bubble {
  word-break: break-word;
  overflow-wrap: break-word;
}
.user .bubble {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  padding: 10px 16px;
  border-radius: 16px;
  max-width: 85%;
  white-space: pre-wrap; /* Mantiene saltos de línea del usuario */
}
.bot .bubble {
  max-width: 90%;
  color: #D1D5DB;
}
.bot .bubble strong { color: #FFF; }

/* Estilos para el parseador de Markdown en el Chat */
.bot .bubble h1, .bot .bubble h2, .bot .bubble h3 {
  color: #FFF;
  margin-top: 14px;
  margin-bottom: 6px;
  font-weight: 600;
}
.bot .bubble h1 { font-size: 1.25rem; }
.bot .bubble h2 { font-size: 1.1rem; }
.bot .bubble h3 { font-size: 0.95rem; }

.bot .bubble ul {
  margin-left: 20px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding-left: 0;
}
.bot .bubble li {
  margin-bottom: 4px;
  line-height: 1.5;
}

/* Tablas Markdown renderizadas en el chat */
.bot .bubble .table-wrap {
  margin: 10px 0;
  overflow-x: auto;
}
.bot .bubble table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
}
.bot .bubble th,
.bot .bubble td {
  border: 1px solid rgba(129, 140, 248, 0.22);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.bot .bubble thead th {
  background: rgba(129, 140, 248, 0.12);
  color: #fff;
  font-weight: 600;
}
.bot .bubble tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

/* Scrollbar fino del tema para los contenedores con scroll horizontal del chat
   (mismo diseño que la barra vertical de #messages). */
.bot .bubble .table-wrap,
.bot .bubble pre.code-block {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}
.bot .bubble .table-wrap::-webkit-scrollbar,
.bot .bubble pre.code-block::-webkit-scrollbar { height: 5px; width: 5px; }
.bot .bubble .table-wrap::-webkit-scrollbar-track,
.bot .bubble pre.code-block::-webkit-scrollbar-track { background: transparent; }
.bot .bubble .table-wrap::-webkit-scrollbar-thumb,
.bot .bubble pre.code-block::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
.bot .bubble .table-wrap::-webkit-scrollbar-thumb:hover,
.bot .bubble pre.code-block::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

/* Gráficos renderizados por la IA (Chart.js sobre canvas). */
.bot .bubble .chart-block {
  position: relative; /* Chart.js mide este contenedor */
  height: 220px;
  margin: 12px 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(129, 140, 248, 0.18);
  border-radius: 8px;
}
.bot .bubble .chart-fallback-caption {
  text-align: left;
  color: #fff;
  padding: 4px 0;
  font-weight: 600;
}

.bot .bubble code.inline-code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: #c084fc; /* Color morado suave a juego con el tema */
}

.bot .bubble pre.code-block {
  background: #0D0D0D;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
}
.bot .bubble pre.code-block code {
  font-family: monospace;
  font-size: 0.85rem;
  color: #ECECEC;
  line-height: 1.4;
  display: block;
}

.system-notification {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  margin: 10px auto;
  width: max-content;
  max-width: 90%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.system-notification strong {
  color: #FFF;
}

/* Input Area */
#input-area { padding: 20px; }
.input-wrapper {
  background: var(--glass-strong);
  border-radius: 14px;
  display: flex;
  align-items: flex-end; /* Alinear abajo al expandirse */
  padding: 8px 8px 8px 16px;
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  transition: all 0.2s ease;
  position: relative;
}
.input-wrapper:focus-within { border-color: rgba(129,140,248,0.5); background: rgba(255,255,255,0.09); box-shadow: 0 0 25px rgba(139,92,246,0.15); }
#chat-input { 
  flex: 1; 
  background: transparent; 
  border: none; 
  color: white; 
  font-size: 0.95rem; 
  font-family: 'Inter', sans-serif; 
  outline: none; 
  resize: none; 
  height: 22px; 
  max-height: 120px; 
  overflow: hidden !important; 
  line-height: 1.4;
  padding: 3px 36px 3px 0; /* Deja espacio para el botón de enviar en normal */
  margin: 0;
  position: relative;
  z-index: 2;
}
#chat-input {
  scrollbar-width: none !important; /* Firefox */
  -ms-overflow-style: none !important; /* IE/Edge */
}
#chat-input::-webkit-scrollbar {
  display: none !important; /* Chrome, Safari, Opera */
  width: 0 !important;
  height: 0 !important;
}
#chat-input.is-previewing {
  color: transparent !important;
  caret-color: transparent !important;
  padding-right: 0px !important;
  padding-bottom: 28px !important;
}
#chat-input-ghost {
  position: absolute;
  left: 16px;
  right: 8px;
  top: 8px; /* Coincide con wrapper padding + input top padding: 8px + 3px = 11px */
  bottom: 8px;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  padding: 3px 36px 3px 0;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  z-index: 1;
  display: none;
}
#chat-input.is-previewing ~ #chat-input-ghost {
  padding-right: 0px !important;
  padding-bottom: 28px !important;
}
.input-actions-wrapper {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  z-index: 3;
}
.input-actions-wrapper > * {
  pointer-events: auto;
}
#chat-input-hint,
#chat-input-arrow-up,
#chat-input-arrow-down,
#chat-input-esc {
  display: none;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(129, 140, 248, 0.9);
  background: rgba(129, 140, 248, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px; /* Alineación al bottom con baseline del texto */
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  z-index: 3;
  align-self: flex-end;
  transition: all 0.12s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#chat-input-arrow-up,
#chat-input-arrow-down,
#chat-input-esc {
  margin-left: 4px;
}
#chat-input-arrow-up,
#chat-input-arrow-down {
  padding: 2px 5px; /* Ligeramente más angosto al ser un solo carácter */
}
#chat-input-hint.active,
#chat-input-arrow-up.active,
#chat-input-arrow-down.active,
#chat-input-esc.active {
  background: rgba(129, 140, 248, 0.35) !important;
  border-color: rgba(129, 140, 248, 0.85) !important;
  color: #ffffff !important;
  transform: scale(0.94);
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.15);
}
#btn-send.active {
  color: #ffffff !important;
  transform: scale(0.94) !important;
  text-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}
#btn-send { 
  display: none; 
  background: transparent; 
  border: none; 
  color: rgba(129, 140, 248, 0.9); 
  outline: none;
  box-shadow: none;
  padding: 0; 
  cursor: pointer; 
  transition: color 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1); 
  flex-shrink: 0; 
  position: relative;
  z-index: 2;
  margin-bottom: 4px; /* Alineación al bottom con baseline a juego con los otros */
  margin-left: 6px;
  align-self: flex-end;
  font-size: 1.15rem; /* Proporcional a la altura de los badges */
  line-height: 1;
  align-items: center;
  justify-content: center;
  user-select: none;
}
#btn-send.show {
  display: inline-flex;
}
#btn-send.show:hover {
  color: rgba(129, 140, 248, 1);
}

/* Modal BYOK */
.hidden { display: none !important; }
#settings-modal { position: fixed; inset: 0; background: rgba(2,0,8,0.6); backdrop-filter: blur(6px); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 20px; width: min(90vw, 350px); padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,0.6); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.1rem; font-weight: 500; }
.modal-header button { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-body label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 10px; }
.modal-body select, .modal-body input { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: white; padding: 11px; border-radius: 10px; font-family: 'Inter', sans-serif; outline: none; }
.modal-body select:focus, .modal-body input:focus { border-color: rgba(192,132,252,0.5); }
#btn-save-settings { margin-top: 15px; background: var(--ai-gradient-btn); color: white; border: none; padding: 11px; border-radius: 999px; cursor: pointer; font-weight: 600; transition: transform 0.12s ease, box-shadow 0.2s; }
#btn-save-settings:hover { transform: scale(1.02); box-shadow: var(--glow); }

/* Animación de carga mágica en el Chat */
.magic-loading-text {
  background: linear-gradient(90deg, #818cf8 0%, #c084fc 50%, #818cf8 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: magic-text-shimmer 2s linear infinite;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.25);
  display: inline-block;
}

@keyframes magic-text-shimmer {
  0% { background-position: 0% center; }
  100% { background-position: -200% center; }
}

.magic-dot {
  display: inline-block;
  animation: magic-dot-pulse 1.4s infinite ease-in-out;
  opacity: 0.3;
  font-weight: 800;
  color: #818cf8;
}
.magic-dot:nth-child(2) { animation-delay: 0.2s; }
.magic-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes magic-dot-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(0) scale(1); }
  50% { opacity: 1; transform: translateY(-3px) scale(1.3); color: #c084fc; text-shadow: 0 0 6px #c084fc; }
}

/* Animación de carga exitosa en el Chat (Verde) */
.magic-success-text {
  background: linear-gradient(90deg, #10b981 0%, #34d399 50%, #10b981 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: magic-text-shimmer 2s linear infinite;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.25);
  display: inline-block;
}

.magic-dot-green {
  display: inline-block;
  animation: magic-dot-pulse-green 1.4s infinite ease-in-out;
  opacity: 0.3;
  font-weight: 800;
  color: #10b981;
}
.magic-dot-green:nth-child(2) { animation-delay: 0.2s; }
.magic-dot-green:nth-child(3) { animation-delay: 0.4s; }

@keyframes magic-dot-pulse-green {
  0%, 100% { opacity: 0.3; transform: translateY(0) scale(1); }
  50% { opacity: 1; transform: translateY(-3px) scale(1.3); color: #34d399; text-shadow: 0 0 6px #34d399; }
}

/* Active Filters UI */
#active-filters-container {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.filter-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 14px;
  background: rgba(129, 140, 248, 0.04);
  border: 1px solid rgba(129, 140, 248, 0.12);
}

.filter-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  user-select: none;
  margin-right: 2px;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(129, 140, 248, 0.08);
  border: 1px solid rgba(129, 140, 248, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.filter-badge:hover {
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(129, 140, 248, 0.12);
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.1);
}

.filter-text {
  user-select: none;
}

.filter-text strong {
  color: #FFF;
  font-weight: 600;
}

.filter-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  padding: 1px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.filter-remove-btn:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.12);
}

.settings-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 4px 0 10px;
}
.settings-hint code {
  background: rgba(129, 140, 248, 0.12);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ── Responsividad ──
   En móvil / tablet-portrait el portal se APILA: tablero arriba, chat abajo. Solo CSS, sin tocar JS:
   reusa el botón de toggle y la clase .collapsed (que aquí colapsa en VERTICAL). El `!important` vence
   el width inline que el JS de resize/localStorage pone en el sidebar. Data Studio (dentro del iframe) ya es
   responsivo; el contenedor flexible lo deja acomodarse. */
@media (max-width: 768px) {
  #app-body { flex-direction: column; position: relative; }
  #dashboard-area { flex: 1; min-height: 0; }
  /* Chat = bottom sheet. Fondo SÓLIDO cósmico para que se vea igual que el panel de desktop. */
  #chat-sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100% !important;
    height: 85dvh;
    background: var(--bg-solid);
    backdrop-filter: none; -webkit-backdrop-filter: none;
    border-left: none;
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.55);
    transform: translateY(0);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 40;
  }
  /* Cerrado: asoma 52px (el handle) para arrastrar hacia arriba y abrir. */
  #chat-sidebar.collapsed { transform: translateY(calc(100% - 52px)); width: 100% !important; }
  #chat-resize-handle { display: none; }
  #btn-toggle-chat { display: none; } /* en móvil el chat se controla desde el sheet */
  /* Handle superior del sheet: arrastrar para abrir/cerrar, o tap. */
  #sheet-handle { display: flex; align-items: center; justify-content: center; height: 52px; cursor: grab; flex-shrink: 0; touch-action: none; }
  #sheet-handle::before { content: ''; width: 42px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); }
  /* Backdrop que oscurece el tablero cuando el sheet está abierto. */
  #sheet-backdrop { display: block; position: fixed; inset: 0; background: rgba(2, 0, 8, 0.5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
  #chat-sidebar:not(.collapsed) ~ #sheet-backdrop { opacity: 1; pointer-events: auto; }
  #input-area { padding: 12px; }
  #top-bar { padding: 0 12px; z-index: 50; }
  /* Móvil: "MovAI Boards" ocupa demasiado → se oculta y el nombre del tablero toma su lugar (ya trunca). */
  #top-bar .logo { display: none; }
  #top-bar .topbar-center { text-align: left; padding-left: 2px; }
  /* Móvil: el badge de plan se oculta (el avatar/menú se mantiene). */
  #top-bar #plan-badge { display: none; }
}

/* ── Páginas de autenticación (login) ── */
body.auth-page { align-items: center; justify-content: center; padding: 24px; }
.auth-card { position: relative; z-index: 1; width: min(92vw, 400px); background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-radius: 28px; padding: 40px 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); text-align: center; }
.auth-brand { font-size: 2.4rem; display: flex; align-items: baseline; justify-content: center; gap: 0.4em; letter-spacing: -0.05em; }
.auth-sub { font-size: 0.7rem; color: rgba(255,255,255,0.5); letter-spacing: 0.35em; text-transform: uppercase; font-weight: 500; }
.auth-tagline { color: rgba(255,255,255,0.7); font-size: 0.95rem; font-weight: 300; margin: 14px 0 30px; }
.auth-actions { display: flex; flex-direction: column; gap: 10px; }
.auth-btn { width: 100%; padding: 13px 16px; border-radius: 999px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06); color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.auth-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(129,140,248,0.5); }
.auth-btn:active { transform: scale(0.98); }
.auth-btn svg { width: 18px; height: 18px; }
.auth-status { min-height: 1.2em; margin-top: 16px; font-size: 0.85rem; color: var(--text-muted); }
.auth-status[data-kind="error"] { color: #f87171; }
.auth-footer { margin-top: 22px; font-size: 0.78rem; color: var(--text-muted); }
.auth-footer a { color: var(--text-muted); text-decoration: underline; }
.auth-footer a:hover { color: var(--ai-from); }

/* ── Páginas legales (ToS / Privacidad) ── */
body.legal-page { display: block; height: auto; min-height: 100vh; min-height: 100dvh; overflow-y: auto; }
.legal-doc { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }
.legal-doc .brand-text { font-size: 1.4rem; }
.legal-doc h1 { margin: 22px 0 6px; font-size: 1.7rem; }
.legal-doc h2 { margin: 28px 0 8px; font-size: 1.1rem; }
.legal-doc p, .legal-doc li { color: var(--text-muted); line-height: 1.65; font-size: 0.92rem; }
.legal-doc ul { margin: 8px 0 8px 20px; }
.legal-doc .legal-meta { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 8px; }
.legal-doc .legal-note { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 18px 0; font-size: 0.84rem; }
.legal-doc a { color: var(--ai-from); }

/* ── Dashboard del owner ── */
body.dash-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; animation: pageIn 0.32s ease; }
body.dash-page.leaving { animation: pageOut 0.18s ease forwards; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pageOut { from { opacity: 1; } to { opacity: 0; transform: scale(0.992); } }
/* Feedback de presión en todos los botones del dashboard (mantequilla). */
.dash-page button:active:not(:disabled) { transform: scale(0.96); }
#dash-topbar { height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--glass-border); background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); position: relative; z-index: 10; }
#dash-topbar .logo { gap: 0.5em; align-items: baseline; }
.app-sub { color: var(--text-muted); font-size: 0.85rem; letter-spacing: 0.02em; }
.dash-actions { display: flex; align-items: center; gap: 14px; }
.plan-badge { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); padding: 3px 10px; border-radius: 999px; border: 1px solid transparent; letter-spacing: 0.01em; }
.plan-badge[data-plan="pro"] { color: #c4b5fd; border-color: rgba(167,139,250,0.45); background: rgba(124,58,237,0.14); }
.plan-badge[data-plan="premium"] { color: #fff; border: none; background: var(--ai-gradient-btn); box-shadow: 0 2px 12px rgba(139,92,246,0.4); }
.btn-upgrade { position: relative; overflow: hidden; background: var(--ai-gradient-btn); color: #fff; border: none; border-radius: 999px; padding: 7px 16px; font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease; }
.btn-upgrade:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.btn-upgrade::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%); transform: translateX(-130%); }
.btn-upgrade:hover::after { animation: shimmer 0.9s ease; }
@keyframes shimmer { to { transform: translateX(130%); } }
.user-chip { position: relative; cursor: pointer; outline: none; display: flex; align-items: center; }
.avatar-wrap { position: relative; display: inline-flex; border-radius: 50%; padding: 0; background: transparent; transition: transform 0.18s ease; }
.user-chip:hover .avatar-wrap { transform: translateY(-1px); }
.avatar-wrap img { width: 34px; height: 34px; border-radius: 50%; display: block; }
.avatar-wrap[data-plan="pro"] { padding: 2px; background: linear-gradient(135deg, #818cf8, #c084fc); }
.avatar-wrap[data-plan="premium"] { padding: 2px; background: var(--ai-gradient-btn); box-shadow: 0 0 14px rgba(139,92,246,0.55); animation: ringPulse 3.2s ease-in-out infinite; }
.avatar-wrap[data-plan="pro"] img, .avatar-wrap[data-plan="premium"] img { width: 32px; height: 32px; border: 2px solid var(--bg-solid); }
@keyframes ringPulse { 0%, 100% { box-shadow: 0 0 12px rgba(139,92,246,0.45); } 50% { box-shadow: 0 0 20px rgba(192,132,252,0.7); } }
.user-menu { position: absolute; right: 0; top: 42px; background: var(--bg-solid); border: 1px solid var(--glass-border); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 12px; padding: 10px; min-width: 200px; box-shadow: 0 12px 30px rgba(0,0,0,0.5); z-index: 50; }
.user-email { font-size: 0.8rem; color: var(--text-muted); padding: 6px 8px; word-break: break-all; }
.menu-item { width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 8px; border-radius: 6px; cursor: pointer; font-size: 0.88rem; }
.menu-item:hover { background: var(--glass-strong); }
.menu-item.logout { color: #f87171; }
.menu-item.logout:hover { background: rgba(248,113,113,0.12); }

#dash-main { flex: 1; overflow-y: auto; padding: 22px 26px 44px; min-width: 0; position: relative; z-index: 1; }

/* Barra de contenido: breadcrumb · chip de uso · "+ Nuevo" (estilo Drive) */
#content-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 3px; min-width: 0; flex-wrap: wrap; }
.crumb { background: transparent; border: none; color: var(--text-muted); font-size: 1.06rem; font-weight: 500; cursor: pointer; padding: 4px 7px; border-radius: 8px; font-family: 'Inter', sans-serif; transition: color 0.15s ease, background 0.15s ease; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover { color: var(--text); background: var(--glass); }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.crumb.current:hover { background: transparent; }
.crumb-sep { color: var(--text-muted); opacity: 0.45; }
.content-actions { display: flex; align-items: center; gap: 12px; }
.usage-chip { display: inline-flex; align-items: center; gap: 9px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 999px; padding: 7px 14px; color: var(--text); font-size: 0.82rem; cursor: pointer; font-family: 'Inter', sans-serif; transition: border-color 0.18s ease, transform 0.18s ease; }
.usage-chip:hover { border-color: rgba(129,140,248,0.5); transform: translateY(-1px); }
.usage-chip .uc-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.usage-chip .uc-item b { color: var(--text); font-weight: 600; }
.usage-chip .uc-item.near b { color: #fbbf24; }
.usage-chip .uc-item svg { width: 14px; height: 14px; opacity: 0.85; }
.usage-chip .uc-div { width: 1px; height: 14px; background: var(--glass-border); }
.new-wrap { position: relative; }
.new-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 14px; padding: 6px; min-width: 184px; box-shadow: 0 16px 40px rgba(0,0,0,0.55); z-index: 40; animation: menuIn 0.16s cubic-bezier(0.16,1,0.3,1); }
.new-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 0.9rem; font-family: 'Inter', sans-serif; transition: background 0.14s ease; }
.new-menu-item svg { width: 17px; height: 17px; color: var(--text-muted); }
.new-menu-item:hover { background: var(--glass-strong); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: none; } }

/* Grid unificado: carpetas + tableros */
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.grid-card { position: relative; }
#grid.enter .grid-card { animation: cardIn 0.42s cubic-bezier(0.16,1,0.3,1) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.grid-card.card-out { animation: cardOut 0.18s ease forwards; }
@keyframes cardOut { to { opacity: 0; transform: scale(0.92); } }
.folder-card { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 14px; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.folder-card:hover { border-color: rgba(129,140,248,0.5); box-shadow: 0 0 26px rgba(139,92,246,0.16); transform: translateY(-2px); }
.fc-head { display: flex; align-items: flex-start; justify-content: space-between; }
.fc-icon { color: var(--ai-mid); }
.fc-icon svg { width: 30px; height: 30px; }
.fc-name { font-weight: 600; font-size: 0.96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Menú ⋯ por carpeta (siempre visible, sutil). Sustituye a los iconos hover invisibles-pero-tapeables. */
.card-menu-wrap { position: relative; }
.card-kebab { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; background: transparent; border: none; color: var(--text-muted); border-radius: 8px; cursor: pointer; transition: color 0.15s ease, background 0.15s ease; }
.card-kebab svg { width: 18px; height: 18px; }
.card-kebab:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.card-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 152px; background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,0.5); animation: menuIn 0.16s cubic-bezier(0.16,1,0.3,1); }
.card-menu.hidden { display: none; }
.card-menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 0.88rem; font-family: 'Inter', sans-serif; transition: background 0.14s ease; }
.card-menu button svg { width: 15px; height: 15px; color: var(--text-muted); }
.card-menu button:hover { background: var(--glass-strong); }
.card-menu button.danger:hover, .card-menu button.danger:hover svg { color: #f87171; }
.board-ai-tag { align-self: flex-start; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; color: var(--text-muted); background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); padding: 2px 9px; border-radius: 999px; }
.board-card { background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.board-card:hover { border-color: rgba(129,140,248,0.5); box-shadow: 0 0 30px rgba(139,92,246,0.18); transform: translateY(-2px); }
/* Arrastrar un tablero a una carpeta (o crumb ancestro) para moverlo. */
.grid-card { cursor: grab; }
.grid-card.dragging { opacity: 0.4; }
/* Ghost flotante del arrastre propio (drag.ts): sigue al puntero, sin capturar eventos. */
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none; max-width: 220px; padding: 9px 14px; border-radius: 10px; background: var(--bg-solid); border: 1px solid var(--ai-mid); color: var(--text); font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 12px 30px rgba(0,0,0,0.5); transform: translate(-9999px, -9999px); }
.grid-card.drop-target { border-color: var(--ai-mid); box-shadow: 0 0 0 2px rgba(168,85,247,0.55), 0 0 26px rgba(139,92,246,0.3); transform: translateY(-2px); animation: dropPulse 1s ease-in-out infinite; }
.crumb.drop-target { background: rgba(168,85,247,0.25); color: #fff; border-radius: 8px; animation: dropPulse 1s ease-in-out infinite; }
/* Soltar en el fondo = mover a la carpeta abierta (currentFolder). */
#grid.drop-target { outline: 2px dashed rgba(168,85,247,0.6); outline-offset: 8px; border-radius: 16px; animation: none; box-shadow: none; transform: none; }
@keyframes dropPulse { 0%, 100% { box-shadow: 0 0 0 2px rgba(168,85,247,0.5); } 50% { box-shadow: 0 0 0 3px rgba(192,132,252,0.85), 0 0 22px rgba(139,92,246,0.4); } }
.board-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-name { font-weight: 600; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.board-status.on { background: #34d399; box-shadow: 0 0 6px #34d399; }
.board-status.off { background: var(--text-muted); }
.board-open { color: var(--ai-from); font-size: 0.85rem; text-decoration: none; }
.board-open:hover { text-decoration: underline; }
.icon-btn { position: relative; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); color: var(--text-muted); border-radius: 9px; cursor: pointer; transition: transform 0.15s cubic-bezier(0.16,1,0.3,1), color 0.15s ease, border-color 0.15s ease, background 0.15s ease; padding: 0; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); border-color: var(--ai-from); background: rgba(255,255,255,0.07); transform: translateY(-1px); }
.icon-btn.danger:hover { color: #f87171; border-color: rgba(248,113,113,0.6); }
.menu-item.locked { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-item.locked::after { content: 'Pro'; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--ai-gradient-btn); padding: 2px 9px; border-radius: 999px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(139,92,246,0.35); }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty-icon { display: flex; justify-content: center; color: var(--text-muted); opacity: 0.4; margin-bottom: 14px; }
.empty-icon svg { width: 52px; height: 52px; }
.empty-state h2 { color: var(--text); font-size: 1.15rem; margin-bottom: 6px; }
.empty-state p { margin-bottom: 18px; }

.btn-primary { background: var(--ai-gradient-btn); color: #fff; border: none; border-radius: 999px; padding: 11px 18px; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: transform 0.12s ease, box-shadow 0.2s ease; }
.btn-primary:hover { transform: scale(1.03); box-shadow: var(--glow); }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost { background: var(--glass); border: 1px solid var(--glass-border); color: var(--text-muted); border-radius: 999px; padding: 9px 16px; font-size: 0.85rem; cursor: pointer; transition: all 0.2s ease; }
.btn-ghost:hover { color: var(--text); border-color: rgba(129,140,248,0.5); }

/* ── Modal genérico + formularios ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,0,8,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-card { background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 22px; width: min(94vw, 440px); padding: 26px; box-shadow: 0 24px 70px rgba(0,0,0,0.6); max-height: 90vh; overflow-y: auto; }
.modal-card.modal-wide { width: min(96vw, 920px); }
.modal-overlay:not(.hidden) { animation: overlayIn 0.2s ease; }
.modal-overlay:not(.hidden) .modal-card { animation: modalIn 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-overlay.closing { animation: overlayOut 0.15s ease forwards; }
.modal-overlay.closing .modal-card { animation: modalOut 0.15s ease forwards; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes modalOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 1.15rem; font-weight: 600; }
.modal-x { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; background: var(--glass); border: 1px solid var(--glass-border); color: var(--text-muted); font-size: 0.95rem; cursor: pointer; border-radius: 50%; transition: all 0.18s ease; }
.modal-x:hover { color: var(--text); background: var(--glass-strong); }
.modal-card label { display: block; font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 0 6px; }
.modal-card input[type="text"], .modal-card input[type="url"], .modal-card select { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: var(--text); padding: 11px 14px; border-radius: 12px; font-family: 'Inter', sans-serif; font-size: 0.9rem; outline: none; transition: border-color 0.2s, background 0.2s; }
.modal-card input:focus, .modal-card select:focus { border-color: rgba(192,132,252,0.5); background: rgba(255,255,255,0.08); }
.modal-card select option { background: var(--bg-solid); color: var(--text); }
/* Selects con apariencia propia (sin el chrome nativo del SO) + flecha personalizada. */
.modal-card select, .modal-body select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b8b3c7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.modal-card select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Select personalizado (panel estilizado acorde al diseño; el <select> nativo no lo permite). */
.cselect { position: relative; width: 100%; }
.cselect-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: var(--text); padding: 11px 14px; border-radius: 12px; font-family: 'Inter', sans-serif; font-size: 0.9rem; cursor: pointer; text-align: left; transition: border-color 0.18s ease, background 0.18s ease; }
.cselect-trigger:hover { background: rgba(255,255,255,0.08); }
.cselect.open .cselect-trigger { border-color: rgba(192,132,252,0.5); background: rgba(255,255,255,0.08); }
.cselect-trigger svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s ease; }
.cselect.open .cselect-trigger svg { transform: rotate(180deg); }
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect.disabled { opacity: 0.5; pointer-events: none; }
.cselect-panel { position: fixed; background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,0.6); z-index: 120; max-height: 260px; overflow-y: auto; animation: menuIn 0.16s cubic-bezier(0.16,1,0.3,1); }
.cselect-opt { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 0.88rem; font-family: 'Inter', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.14s ease; }
.cselect-opt:hover { background: var(--glass-strong); }
.cselect-opt.active { background: rgba(124,58,237,0.22); color: #fff; }
/* Selector de IA bloqueado (sin BYOK): el propio campo ES el badge premium, clickeable → abre el pricing. */
.cselect-locked { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-radius: 12px; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 0.9rem; color: #fff; text-align: left; background: linear-gradient(135deg, rgba(124,58,237,0.22), rgba(236,72,153,0.16)); border: 1px solid rgba(167,139,250,0.45); transition: transform 0.18s cubic-bezier(0.16,1,0.3,1), box-shadow 0.18s ease, border-color 0.18s ease; }
.cselect-locked:hover { transform: translateY(-1px); border-color: var(--ai-mid); box-shadow: 0 0 18px rgba(168,85,247,0.4); }
.cselect-locked-label { font-weight: 600; }
.cselect-locked-badge { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--ai-gradient-btn); padding: 2px 10px; border-radius: 999px; flex-shrink: 0; }

/* Upsell: acción/control bloqueado por plan → "Mejorar plan" + la función concreta (apetecible). */
.upsell { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 7px 12px 7px 14px; background: linear-gradient(135deg, rgba(124,58,237,0.16), rgba(236,72,153,0.12)); border: 1px solid rgba(167,139,250,0.4); border-radius: 999px; cursor: pointer; font-family: 'Inter', sans-serif; text-decoration: none; transition: transform 0.18s cubic-bezier(0.16,1,0.3,1), box-shadow 0.18s ease, border-color 0.18s ease; }
.upsell:hover { transform: translateY(-1px); border-color: var(--ai-mid); box-shadow: 0 0 18px rgba(168,85,247,0.4); }
.upsell-cta { font-size: 0.82rem; font-weight: 600; background: var(--ai-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.upsell-feat { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--ai-gradient-btn); padding: 2px 9px; border-radius: 999px; }
.modal-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }
.modal-foot { margin-top: 18px; display: flex; justify-content: flex-end; }
.modal-error { color: #f87171; font-size: 0.82rem; min-height: 1em; margin-top: 8px; }
.modal-message { color: var(--text-muted); font-size: 0.92rem; line-height: 1.55; }
.btn-danger { background: #ef4444; color: #fff; border: none; border-radius: 999px; padding: 10px 16px; font-size: 0.86rem; font-weight: 600; cursor: pointer; transition: all 0.15s ease; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 0 20px rgba(239,68,68,0.3); }
.link-inline { color: var(--ai-mid); cursor: pointer; text-decoration: underline; }
.link-inline:hover { color: var(--ai-from); }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; }
.switch-row { display: flex !important; align-items: center; gap: 8px; text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important; font-size: 0.9rem !important; cursor: pointer; }

.cycle-toggle { display: flex; gap: 6px; background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.cycle-toggle button { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 8px; border-radius: 999px; font-size: 0.82rem; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s ease; }
.cycle-toggle button.active { background: var(--glass-strong); color: var(--text); }
.save-badge { background: rgba(52,211,153,0.15); color: #34d399; font-size: 0.62rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 5px; vertical-align: middle; white-space: nowrap; }
.feat-plus { color: #6ee7b7; font-weight: 700; }
.annual-callout { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: #6ee7b7; border-radius: 12px; padding: 10px 14px; font-size: 0.84rem; text-align: center; margin-bottom: 14px; }
.annual-callout b { color: #a7f3d0; font-weight: 600; }
/* Motivo sutil que abrió el pricing (la función bloqueada que el usuario tocó). */
.plans-reason { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin: -4px 0 14px; }
.plans-reason b { background: var(--ai-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; font-weight: 600; }

/* ── Pantalla de precios (3 tiers, Pro destacado) ── */
.tiers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.tier-col { position: relative; display: flex; flex-direction: column; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.03); border-radius: 18px; padding: 22px 16px 18px; }
.tier-col.popular { border: 1.5px solid transparent; background-image: linear-gradient(var(--bg-solid), var(--bg-solid)), var(--ai-gradient-btn); background-origin: border-box; background-clip: padding-box, border-box; box-shadow: 0 0 34px rgba(139,92,246,0.2); }
.tier-col.is-current { outline: 1px dashed rgba(255,255,255,0.22); outline-offset: 2px; }
.tier-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--ai-gradient-btn); color: #fff; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 4px 12px; border-radius: 999px; white-space: nowrap; box-shadow: 0 4px 14px rgba(139,92,246,0.4); }
.tier-name { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.tier-price-wrap { margin-bottom: 16px; min-height: 58px; }
.tier-price { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.tier-price span { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.tier-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }
.tier-feats { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.tier-feats li { display: flex; align-items: flex-start; gap: 8px; font-size: 0.82rem; color: var(--text); line-height: 1.35; }
.feat-check { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; fill: var(--ai-mid); }
.tier-cta { width: 100%; padding: 10px; border-radius: 999px; font-size: 0.86rem; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.18s ease; border: 1px solid transparent; }
.tier-cta.primary { background: var(--ai-gradient-btn); color: #fff; }
.tier-cta.primary:hover { box-shadow: var(--glow); transform: translateY(-1px); }
.tier-cta.ghost { background: var(--glass); border-color: var(--glass-border); color: var(--text); }
.tier-cta.ghost:hover { border-color: rgba(129,140,248,0.5); }
.tier-cta.current { background: transparent; border-color: var(--glass-border); color: var(--text-muted); cursor: default; }

/* Modales en móvil = bottom sheet (los tiers se apilan a ancho completo; ya no se cortan). */
@media (max-width: 768px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-card { width: 100% !important; max-width: none; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  .modal-card.modal-wide { width: 100% !important; }
  .modal-overlay:not(.hidden) .modal-card { animation: sheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-overlay.closing .modal-card { animation: sheetDown 0.2s ease forwards; }
  @keyframes sheetDown { from { transform: translateY(0); } to { transform: translateY(100%); } }
  .tiers-grid { grid-template-columns: 1fr; gap: 10px; }
  .tier-price-wrap { min-height: 0; margin-bottom: 12px; }
  .tier-col { padding: 18px 16px; }
}

/* ── Uso (dashboard) — limpio, sin mayúsculas ── */
#usage-meter { display: flex; flex-direction: column; gap: 14px; padding: 14px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px; }
.usage-item { display: flex; flex-direction: column; gap: 7px; }
.usage-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.82rem; gap: 10px; }
.usage-key { color: var(--text-muted); }
.usage-num { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-num.full { color: #fbbf24; }
.usage-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ai-from), var(--ai-mid)); transition: width 0.5s cubic-bezier(0.16,1,0.3,1); }
.usage-fill.near { background: linear-gradient(90deg, #fbbf24, #f472b6); }
.usage-upgrade { position: relative; overflow: hidden; margin-top: 4px; background: var(--ai-gradient-btn); border: none; color: #fff; border-radius: 999px; padding: 8px; font-size: 0.8rem; cursor: pointer; font-weight: 600; transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease; }
.usage-upgrade:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.usage-upgrade::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%); transform: translateX(-130%); }
.usage-upgrade:hover::after { animation: shimmer 1s ease; }

/* Botón "+ Nuevo" — sutil (glass) para no competir con el gradiente de "Mejorar plan". */
.btn-new { display: inline-flex; align-items: center; gap: 7px; background: var(--glass-strong); color: var(--text); border: 1px solid var(--glass-border); border-radius: 999px; padding: 9px 16px; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: transform 0.18s cubic-bezier(0.16,1,0.3,1), border-color 0.18s ease, background 0.18s ease; }
.btn-new svg { width: 16px; height: 16px; color: var(--ai-mid); }
.btn-new:hover { transform: translateY(-1px); border-color: var(--ai-from); background: rgba(255,255,255,0.08); }
.btn-new:active { transform: scale(0.97); }

/* Biblioteca de claves de IA */
.keys-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 16px; max-height: 40vh; overflow-y: auto; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px; padding: 10px 12px; }
.key-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.key-provider { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: #fff; background: var(--ai-gradient-btn); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.key-label { font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-last4 { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.key-add { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--glass-border); }
.key-add-row { display: flex; gap: 10px; align-items: center; }
.key-add-row .cselect { flex: 0 0 148px; } /* el selector de proveedor no aplasta al campo de nombre */
.key-add-row input { flex: 1; min-width: 0; }
.key-add .btn-primary { align-self: flex-start; }
.byok-status { font-size: 0.84rem; color: #34d399; margin: 4px 0; }
/* ── Página de Insights (dedicada, a pantalla completa) ── */
body.insights-page .board-user { display: flex; } /* la ruta ya está protegida: siempre mostramos la cuenta */
#ins-main { flex: 1; overflow-y: auto; padding: 24px; width: 100%; max-width: 1120px; margin: 0 auto; }
.ins-crumb { color: var(--text-muted); }
.ins-root { display: flex; flex-direction: column; gap: 16px; }
.ins-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.ins-panel { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; padding: 18px; }
.ins-panel h4 { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 14px; }
.ins-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.ins-panel-head h4 { margin: 0; }
.ins-convos-panel .ins-search { margin: 0; max-width: 340px; }

/* Insights: componentes (contadores, actividad, lo más solicitado, conversaciones) — compartidos por la página. */
.ins-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.ins-stat { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px; padding: 13px 8px; text-align: center; }
.ins-num { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; background: var(--ai-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; display: inline-flex; align-items: baseline; gap: 5px; }
.ins-lbl { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }
/* Variación semana vs. semana (▲/▼) */
.ins-wow { font-size: 0.6rem; font-weight: 700; -webkit-text-fill-color: initial; padding: 1px 6px; border-radius: 999px; }
.ins-wow.up { color: #34d399; background: rgba(52,211,153,0.14); }
.ins-wow.down { color: #fb7185; background: rgba(251,113,133,0.14); }
/* Mini-stats de audiencia (preguntas/sesión, recurrencia, tasa de filtro) */
.ins-mini { display: flex; gap: 10px; }
.ins-mini-item { flex: 1; background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: 12px; padding: 10px; text-align: center; }
.ins-mini-item b { display: block; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }
.ins-mini-item span { font-size: 0.66rem; color: var(--text-muted); }
/* "Lo más solicitado": etiqueta de dimensión sobre el segmento */
.ins-seg-dim { display: block; font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ai-mid); margin-bottom: 1px; }
.ins-hint { font-size: 0.82rem; color: var(--text-muted); }
.ins-bars-30 { gap: 3px; height: 64px; }

/* ── Insights v2: resumen IA (necesidades/oportunidades) ── */
.ins-ai { background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(236,72,153,0.06)); border: 1px solid rgba(167,139,250,0.28); border-radius: 16px; padding: 16px; }
.ins-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ins-ai-head h4 { margin: 0; font-size: 0.78rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.btn-ai-analyze { display: inline-flex; align-items: center; gap: 6px; background: var(--ai-gradient-btn); color: #fff; border: none; border-radius: 999px; padding: 7px 14px; font-size: 0.8rem; font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer; flex-shrink: 0; transition: transform 0.14s ease, box-shadow 0.2s ease; }
.btn-ai-analyze:hover { transform: translateY(-1px); box-shadow: var(--glow); }
.btn-ai-analyze:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-ai-analyze svg { width: 14px; height: 14px; }
.ins-ai-summary { font-size: 0.9rem; line-height: 1.5; color: var(--text); margin: 0 0 12px; }
.ins-themes { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.ins-theme { font-size: 0.78rem; color: #ddd6fe; background: rgba(124,58,237,0.18); border: 1px solid rgba(167,139,250,0.3); padding: 4px 10px; border-radius: 999px; }
.ins-theme b { color: #fff; margin-left: 3px; }
.ins-opps { display: flex; flex-direction: column; gap: 8px; }
.ins-opp { background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); border-left: 2px solid var(--ai-mid); border-radius: 10px; padding: 9px 12px; }
.ins-opp-t { font-size: 0.86rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.ins-opp-r { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.ins-ai-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 10px; }

/* ── Insights v2: conversaciones reales (P + respuesta de la IA), con buscador ── */
.ins-search { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: var(--text); border-radius: 10px; padding: 9px 12px; font-size: 0.86rem; font-family: 'Inter', sans-serif; outline: none; margin-bottom: 10px; }
.ins-search:focus { border-color: rgba(129,140,248,0.5); }
#ins-convos { display: flex; flex-direction: column; gap: 9px; max-height: 50vh; overflow-y: auto; padding-right: 2px; }
.conv-item { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px; padding: 12px 13px; }
.conv-item.hidden { display: none; }
.conv-label { display: block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 3px; }
.conv-q { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 9px; }
.conv-q .conv-label { color: var(--ai-mid); }
.conv-a { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; word-break: break-word; }
/* Cuerpo de la respuesta: recortado por defecto (con degradado), expandible con "ver más". */
.conv-a-body { max-height: 4.7em; overflow: hidden; position: relative; }
.conv-a-body::after { content: ''; position: absolute; inset: auto 0 0 0; height: 1.6em; background: linear-gradient(transparent, var(--bg-solid)); pointer-events: none; }
.conv-item.expanded .conv-a-body { max-height: none; }
.conv-item.expanded .conv-a-body::after { display: none; }
.conv-more { background: none; border: none; color: var(--ai-from); font-size: 0.78rem; font-weight: 600; cursor: pointer; padding: 4px 0 0; font-family: 'Inter', sans-serif; }
.conv-more.hidden { display: none; }
.conv-empty { font-style: italic; opacity: 0.7; }
.conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; font-size: 0.7rem; color: var(--text-muted); }
.conv-chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.conv-chip { font-size: 0.68rem; color: #c4b5fd; background: rgba(124,58,237,0.16); border: 1px solid rgba(167,139,250,0.28); padding: 1px 8px; border-radius: 999px; }
/* Markdown dentro de la respuesta (compacto). */
.conv-a-body.md p { margin: 0 0 6px; }
.conv-a-body.md p:last-child { margin-bottom: 0; }
.conv-a-body.md ul, .conv-a-body.md ol { margin: 4px 0; padding-left: 18px; }
.conv-a-body.md strong { color: var(--text); }
.conv-a-body.md table { border-collapse: collapse; font-size: 0.78rem; margin: 4px 0; }
.conv-a-body.md th, .conv-a-body.md td { border: 1px solid var(--glass-border); padding: 3px 7px; }
.conv-a-body.md .chart-block { display: none; }
/* Sección plegable "Más métricas". */
.ins-bars { display: flex; align-items: flex-end; gap: 5px; height: 78px; }
.ins-bar { flex: 1; display: flex; align-items: flex-end; height: 100%; background: rgba(255,255,255,0.04); border-radius: 5px; }
.ins-bar-fill { width: 100%; min-height: 3px; border-radius: 5px; background: linear-gradient(180deg, var(--ai-mid), var(--ai-from)); transition: height 0.5s cubic-bezier(0.16,1,0.3,1); }
.ins-top { margin-bottom: 12px; }
.ins-top-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.86rem; margin-bottom: 5px; }
.ins-top-q { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-top-n { color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ins-top-bar { height: 5px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.ins-top-bar div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ai-from), var(--ai-mid)); transition: width 0.5s cubic-bezier(0.16,1,0.3,1); }
.ins-empty { text-align: center; padding: 28px 10px; color: var(--text-muted); }
.ins-empty h3 { color: var(--text); margin: 8px 0 6px; font-size: 1.1rem; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-solid); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--text); padding: 11px 18px; border-radius: 12px; font-size: 0.88rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 200; }
.toast[data-kind="error"] { border-color: #f87171; color: #fca5a5; }
.toast:not(.hidden) { animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* La vista de tablero entra con un fade suave (transición desde el dashboard). */
body.board-page { animation: pageIn 0.34s ease; }

/* Menú ⋯ del tablero (solo el dueño): el server marca <body data-owner> y aquí se revela en el primer
   paint (sin aparecer tarde). El visitante anónimo nunca lo ve. */
.board-menu { position: relative; display: none; }
body[data-owner] .board-menu { display: inline-flex; }
#btn-board-menu { background: transparent; border: none; color: rgba(255,255,255,0.72); font-size: 1.2rem; cursor: pointer; margin-left: 15px; padding: 0; transition: color 0.2s; }
#btn-board-menu:hover { color: var(--text); }
.board-menu-pop { position: absolute; right: 0; top: calc(100% + 10px); background: var(--bg-solid); border: 1px solid var(--glass-border); border-radius: 14px; padding: 6px; min-width: 198px; box-shadow: 0 16px 40px rgba(0,0,0,0.55); z-index: 60; animation: menuIn 0.16s cubic-bezier(0.16,1,0.3,1); }
.bm-item { display: flex; align-items: center; gap: 11px; width: 100%; margin: 0; text-align: left; background: transparent; border: none; color: var(--text); padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 0.9rem; font-family: 'Inter', sans-serif; transition: background 0.14s ease; }
.bm-item i { font-size: 1.05rem; color: var(--text-muted); width: 18px; text-align: center; }
.bm-item:hover { background: var(--glass-strong); }
.bm-item.danger:hover, .bm-item.danger:hover i { color: #f87171; }
.bm-item.locked-item::after { content: 'Premium'; margin-left: auto; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--ai-gradient-btn); padding: 2px 8px; border-radius: 999px; box-shadow: 0 2px 8px rgba(139,92,246,0.35); }

/* Vista pública de tablero: estado "no disponible" */
.board-unavailable { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--text-muted); background: var(--bg-app); font-size: 0.95rem; }

/* Chip de cuota dentro del tablero (solo el dueño). */
/* Uso: contador arriba-izquierda + barra fina pegada al borde superior del input (parecen un solo elemento). */
.board-quota { padding: 0 4px; margin-bottom: 6px; }
.board-quota .bq-count { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; margin-bottom: 5px; }
.board-quota .bq-count.near { color: #fbbf24; }
.board-quota .bq-count.byok { color: var(--ai-from); }
.board-quota .bq-track { height: 3px; border-radius: 999px 999px 0 0; background: rgba(255,255,255,0.07); overflow: hidden; }
.board-quota .bq-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ai-from), var(--ai-mid)); transition: width 0.5s cubic-bezier(0.16,1,0.3,1); }
.board-quota .bq-fill.near { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

@media (max-width: 768px) {
  /* Dashboard móvil (Drive): sin sidebar ni FAB. La barra de contenido se reacomoda. */
  #dash-main { padding: 16px 14px 32px; }
  #content-bar { gap: 12px; row-gap: 14px; }
  .breadcrumb { order: 1; flex-basis: 100%; }
  .content-actions { order: 2; width: 100%; justify-content: space-between; }
  .usage-chip { flex: 1; justify-content: center; }
  .crumb { font-size: 1rem; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .key-add-row { flex-direction: column; align-items: stretch; }
  .key-add-row .cselect { flex: 0 0 auto; width: 100%; }
}

/* ── Scrollbars homologadas en todo el portal (mismo look que #messages). ── */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.14) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
