/* ═══════════════════════════════════════════════════════════════════
   CodeHub — VIEWPORT GUARD  (última capa CSS, se carga SIEMPRE al final)
   Wilson.E 2026

   PROPÓSITO
   ─────────
   Red de seguridad para que NINGUNA modificación de componentes rompa
   la visualización en pantallas de distintos tamaños. Este archivo se
   carga después de index.css, components.css, index-responsive.css y
   site-tour.css, por lo que sus reglas ganan la cascada y actúan como
   "última palabra" para evitar desbordes horizontales y roturas de layout.

   BREAKPOINTS CANÓNICOS DEL PROYECTO (no usar otros)
   ───────────────────────────────────────────────────
   Usar SIEMPRE estos rangos al escribir @media nuevas. No inventar
   anchos nuevos: la fragmentación de breakpoints es lo que rompe
   pantallas pequeñas (380–720px).

     ≤ 360px   teléfonos muy antiguos (iPhone SE 1ª gen, Galaxy pequeños)
     ≤ 380px   teléfonos compactos   — rango mínimo soportado
     ≤ 420px   teléfonos medianos (p.ej. ciertos Android)
     ≤ 480px   teléfonos grandes (iPhone 12/13 mini en vertical)
     ≤ 550px   phablets / teléfonos grandes
     ≤ 640px   teléfonos XXL y tablets pequeñas en vertical
     ≤ 720px   tablets compactas / landscape de teléfonos
     ≤ 768px   tablets verticales  — breakpoint principal mobile/desktop
     ≤ 860px   tablets grandes vertical / desktop compacto
     ≤ 1080px  desktop medio

   REGLA DE ORO
   ────────────
   - Toda nueva regla de layout DEBE comprobarse en 380, 480, 640, 720
     y 768 px (al menos), además de escritorio.
   - Los contenedores de grid/flex deben usar `min-width: 0` en sus
     hijos cuando puedan desbordar (texto largo, tablas, pre, code).
   - Todo medio (img/video/canvas/iframe/table) debe tener max-width:100%.
   - Cualquier corrección de un componente debe añadirse AL FINAL de
     este archivo o dentro de su @media canónica, nunca inventando
     breakpoints intermedios arbitrarios.
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. SANIDAD GLOBAL — impedir desbordes horizontales ───────────── */
img, svg, video, canvas, iframe, embed, object, audio {
  max-width: 100%;
}
img, video { height: auto; }
picture, figure { max-width: 100%; }

/* Morphicons (<morph-icon>) — el svg generado hereda el color del botón
   y no debe empujar el layout ni salirse del contenedor. */
morph-icon { display: inline-flex; align-items: center; justify-content: center; }
morph-icon svg { max-width: 100%; }
/* En cuanto el custom element está definido, ocultar el icono Font Awesome
   de respaldo para que no se vean los dos a la vez. */
[data-theme-toggle]:has(morph-icon:defined) [data-fa-theme-icon],
.wx-alerts-toggle:has(morph-icon:defined) [data-fa-wx-icon] { display: none; }

/* Refuerzo absoluto: el documento nunca debe ser más ancho que la
   pantalla, ni generar scroll horizontal ni forzar el zoom-out que hace
   que el móvil muestre el sitio "en miniatura de escritorio". */
html { overflow-x: hidden; overflow-x: clip; }
html, body { max-width: 100%; }
body { overflow-x: hidden; overflow-x: clip; width: 100%; }

/* Cualquier elemento fijo/absoluto debe caber dentro del viewport */
[class*="dock"], .side-nav, .mobile-nav, #ai-panel, #config-panel,
#command-palette, #auth-panel, #experimental-menu, .menu-toggle-btn,
#sw-update-banner, .ai-fab-wrap, .ai-bottom-bar, .ai-circle-btn,
#egg-overlay, #devtools-warning, #ch-splash, #command-overlay,
#ios-notif-overlay, #ch-app-perms-overlay {
  max-width: 100vw;
}


/* Texto largo / palabras sin espacios no pueden empujar el layout */
p, h1, h2, h3, h4, h5, h6, li, a, span, strong, em, small,
button, label, legend, caption, blockquote, figcaption {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
code, pre, kbd, samp {
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Inputs/selects/textareas: no crecen más que su contenedor */
input, select, textarea, button {
  max-width: 100%;
  min-width: 0;
}

/* ── 2. PROTECCIÓN DE CONTENEDORES — grids/flex no desbordan ───────── */
/* Hijos de contenedores flexibles necesitan min-width:0 para poder
   encogerse con el texto largo. Solo en contenedores con ancho fluido. */
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > *,
.flex-row > *, .flex-col > *, .services-grid > *, .stats-section > *,
.wx-grid > *, .blogger-grid > *, .skills-grid > *, .hero-inner > *,
.otw-content > *, .otw-left > *, .otw-right > *,
.hero-stack > *, .hero-ctas > *, .blogger-card > *, .game-grid > * {
  min-width: 0;
}

/* ── 3. FIXES DE RANGO MÓVIL — 380px a 720px ───────────────────────── */
/* Estas reglas solo aplican en pantallas pequeñas. Su objetivo es
   absorber errores de layout y garantizar el soporte del rango móvil
   completo, aunque la corrección original solo se haya pensado en
   un ancho concreto. */

/* 380px — el ancho mínimo soportado */
@media (max-width: 380px) {
  /* Cualquier fila/barra del header debe caber en 380px sin desbordar */
  .header-inner { gap: 0.5rem; }
  .header-actions { gap: 0.35rem; }
  .burger-btn { min-width: 38px; min-height: 38px; }

  /* Drawer Windows Enhance: las 3 pestañas caben en 380px sin apretar */
  .we-tabs { gap: 0.3rem; padding-left: 0.6rem; padding-right: 0.6rem; }
  .we-tab { font-size: 0.66rem !important; padding: 0.4rem 0.3rem !important; }

  /* Header: en el mínimo, el logo no puede empujar el layout */
  .header-logo { flex-shrink: 1; min-width: 0; }
  .header-logo-copy { min-width: 0; overflow: hidden; }
  .header-logo-text { font-size: 0.95rem !important; }
  .header-logo-badge { font-size: 0.6rem !important; padding: 2px 7px !important; }

  /* El hero y sus botones no pueden desbordar en el mínimo */
  .hero-card { min-width: 0; }

  /* Paneles flotantes (config, ai, command) nunca más anchos que el viewport */
  #config-panel, #ai-panel, #command-palette {
    max-width: calc(100vw - 16px);
    width: auto;
  }
}

/* 420px — teléfonos medianos: reforzar header y grids */
@media (max-width: 420px) {
  .header-logo-text { font-size: 1rem !important; }
  .header-logo-meta { flex-wrap: nowrap; min-width: 0; }
  .hero-inner { grid-template-columns: 1fr !important; }
  .hero-visual { display: none !important; }
  .blogger-card { flex-direction: column !important; }
  .blogger-card-thumb { width: 100% !important; height: auto !important; max-height: 170px; }
  .blogger-card-desc { display: none !important; }
}

/* 480px — teléfonos grandes en vertical */
@media (max-width: 480px) {
  /* Textos de cabecera no desbordan */
  .header-logo-text { font-size: 0.9rem !important; }
  .header-logo-desc { max-width: 100%; }

  /* Hero: ocultar visual y forzar una columna limpia */
  .hero-visual { display: none !important; }
  .hero-inner { grid-template-columns: 1fr !important; }
  .hero-title { font-size: clamp(1.6rem, 8vw, 2.4rem) !important; }
  .hero-ctas { flex-wrap: wrap; }
  .hero-stack { flex-wrap: wrap; }

  /* Skills en cuadrícula compacta (2 col) y otw en una columna */
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.6rem !important; }
  .otw-content { grid-template-columns: 1fr !important; }

  /* Office download bar: botones más grandes para touch */
  .office-dl-bar { gap: .35rem; padding: .45rem .5rem; flex-wrap: wrap; }
  .office-dl-btn { padding: .45rem .7rem; font-size: .72rem; min-height: 38px; }
  .office-dl-btn i { font-size: .8rem; }
  .office-dl-label { font-size: .58rem; }

  /* Tablas/wx-grid no desbordan */
  .wx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* 720px — tablets compactas / landscape de teléfonos */
@media (max-width: 720px) {
  /* Red de seguridad: ningún elemento posicionado o flotante se sale */
  .side-nav, .mobile-nav, [class*="dock"], .ai-circle-btn, .ai-bottom-bar {
    max-width: 100vw;
  }
  /* Grids principales no desbordan: otw/hero en 1 col, skills en 2 */
  .otw-content, .hero-inner {
    grid-template-columns: 1fr !important;
  }
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.6rem !important; }
  /* Roadmap en cuadrícula compacta en tablets/móvil */
  .roadmap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.6rem !important; }
  .roadmap-card { padding: 0.9rem; }
  /* Juegos: forzar cuadrícula de 2 columnas en todo el rango móvil
     (el auto-fit con minmax(210px) de base degenera a una sola columna
     en pantallas <420px y en 551-720px, viéndose como lista) */
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* ── 4. GUARDAS DE COMPONENTES CRÍTICOS ────────────────────────────── */
/* Si un componente nuevo se rompe en móvil, corrige AQUÍ abajo con el
   breakpoint canónico que corresponda. Nunca inventes anchos nuevos. */

/* Secciones: nunca más anchas que la pantalla */
section, main, .container, .wrap, .inner, .section-wrap {
  max-width: 100%;
  min-width: 0;
}

/* Noticias: tarjetas en una columna, texto limitado */
.blogger-grid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.blogger-card { min-width: 0; overflow: hidden; }
.blogger-card-title { overflow-wrap: break-word; }
.blogger-card-body { min-width: 0; }

/* Pueblo: paneles y video no desbordan */
.pueblo-panels, .pueblo-video-wrap, .pueblo-iframe-wrap {
  max-width: 100%;
}
.pueblo-iframe-wrap iframe { max-width: 100%; }

/* Roadmap y stats: cards no desbordan */
.roadmap-grid, .stats-grid { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }

/* Hero: código/visual nunca desborda */
.hc-code pre { white-space: pre-wrap; overflow-wrap: break-word; }
.hero-card { max-width: 100%; }

/* Refuerzo mobile-first universal para rangos críticos: los hijos de
   cualquier fila se encogen y el texto envuelve (regla de oro del proyecto). */
@media (max-width: 768px) {
  .hero-inner { grid-template-columns: 1fr !important; }
  .hero-visual { display: none !important; }
  .hero-text, .hero-visual-shell, .otw-inner, .otw-content {
    min-width: 0;
  }
  /* Contacto unificado dentro de otw: se apila en móvil */
  .contact-wrap { grid-template-columns: 1fr; }
}

/* Fin del guard. Todo lo nuevo va antes de esta línea. */

/* ── 5. CENTRO DE NOTIFICACIONES — seguridad responsiva ────────── */
/* El panel flotante nunca más ancho que el viewport y bien anclado */
#notif-panel {
  max-width: calc(100vw - 20px);
  right: 10px;
}
#notif-panel.open {
  transform: translateY(0) scale(1);
}

/* 380px — mínimo soportado */
@media (max-width: 380px) {
  #notif-panel {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
    top: 4.2rem;
    max-height: 60vh;
  }
  #notif-btn { min-width: 34px; min-height: 34px; }
  #notif-badge { min-width: 14px; height: 14px; font-size: .45rem; }
}

/* 480px — panel casi a lo ancho, sin pegarse al borde */
@media (max-width: 480px) {
  #notif-panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
  }
  .notif-item { padding: .55rem .7rem; }
}

/* 720px — en tablets/landscape el panel queda a la derecha y tope superior ajustado */
@media (max-width: 720px) {
  #notif-panel { top: 4.4rem; }
  .header-inner { gap: 0.5rem; }
  .header-actions { gap: 0.4rem; }
}

/* ═══ 6. PWA INSTALADA — comportamiento de app nativa ═══════════════ */
/* Cuando CodeHub se ejecuta como app instalada (standalone), se activan
   ajustes para que se comporte como una app compilada, no como un sitio web. */

/* General: cuando está instalada, el header se adapta al status bar */
@media (display-mode: standalone) {
  /* Status bar transparente — el header se extiende detrás */
  header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding-top: env(safe-area-inset-top);
  }

  /* Body: contenido debajo del header + status bar */
  body {
    padding-top: calc(env(safe-area-inset-top) + 60px);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Ocultar barra de direcciones del navegador */
  html {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* Desactivar zoom en inputs */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Scroll suave sin rebote */
  body, html {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }

  /* Links no abren en nueva pestaña */
  a[href^="http"]:not([href*="wilson360-labs.vercel.app"]) {
    target: _self;
  }

  /* Ocultar elementos de "navegador" */
  .browser-only {
    display: none !important;
  }

  /* Swipe back gesture hint */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    z-index: 99999;
    pointer-events: none;
  }

  /* Pull-to-refresh indicator */
  .ptr-indicator {
    display: none;
  }
}

/* Android standalone */
@media (display-mode: standalone) and (platform: android) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* iOS standalone */
@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) {
    body {
      padding-top: calc(env(safe-area-inset-top) + 50px);
    }
    header {
      padding-top: env(safe-area-inset-top);
      height: calc(50px + env(safe-area-inset-top));
    }
  }
}

/* ═══ 7. VIEW TRANSITIONS — transiciones tipo app nativa ═══════════ */
/* Transiciones suaves entre páginas como una app compilada */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.3s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-old(root) {
  animation-name: slide-out-left;
}

::view-transition-new(root) {
  animation-name: slide-in-right;
}

@keyframes slide-out-left {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-30px); opacity: 0; }
}

@keyframes slide-in-right {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Navegación activa — indicador animado */
.native-app #mobile-nav-bar a.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: linear-gradient(135deg, #7c4dff, #2f80ed);
  border-radius: 2px;
  animation: navIndicator 0.3s ease;
}

@keyframes navIndicator {
  from { width: 0; opacity: 0; }
  to { width: 20px; opacity: 1; }
}

/* ── Diálogo de actualización ── */
@keyframes ch-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
#ch-update-overlay {
  animation: ch-fade-in .25s ease;
}
#ch-update-dialog {
  animation: ch-slide-up .3s cubic-bezier(.22,1,.36,1);
}
@keyframes ch-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #ch-update-overlay, #ch-update-dialog { animation: none; }
}

/* ── Weather live indicator ─────────────────────────── */
.wx-live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 4px;
  vertical-align: middle;
  animation: wx-pulse 2s ease-in-out infinite;
}
@keyframes wx-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
  50% { opacity: .6; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}
@media (prefers-reduced-motion: reduce) {
  .wx-live-dot { animation: none; }
}
[data-theme="light"] .wx-live-dot { background: #16a34a; }

/* ── Minimapa del clima (Leaflet) ─────────────────────── */
.wx-map-box { display: block; margin-top: .5rem; }
.wx-map-togglebtn {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  width: 100%; padding: .8rem 1rem; border-radius: 14px; cursor: pointer;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.28);
  color: #22c55e; font-weight: 700; font-size: .82rem; font-family: var(--font);
  transition: all .18s;
}
.wx-map-togglebtn:hover { background: rgba(34,197,94,.18); }
.wx-map-togglebtn > span { text-align: left; }
.wx-map-togglebtn .wx-map-caret { font-size: .75rem; opacity: .8; transition: transform .2s; }
.wx-map-inner { margin-top: .7rem; }
.wx-map-box.closed .wx-map-inner { display: none; }
.wx-map-search { display: flex; gap: .4rem; margin-bottom: .6rem; }
.wx-map-search .wx-input {
  flex: 1; min-width: 0; padding: .6rem .85rem;
  border-radius: 10px; border: 1px solid rgba(128,128,128,.25);
  background: var(--card, #fff); color: inherit; font-size: .85rem;
}
.wx-map-search .wx-search-btn {
  border: none; width: 44px; min-width: 44px; border-radius: 10px;
  background: linear-gradient(135deg,#2f80ed,#22c55e); color: #fff; cursor: pointer;
}
.wx-minimap {
  width: 100%; height: 260px; border-radius: 14px;
  overflow: hidden; position: relative;
  border: 1px solid rgba(128,128,128,.25); z-index: 1;
  background: #a6cad4; /* color de respaldo tipo agua/cielo OSM */
}
.wx-map-loading {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; gap: .5rem; font-size: .8rem; color: var(--muted, #666);
  flex-direction: column;
}
.wx-spinner-map {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(34,197,94,.2); border-top-color: #22c55e;
  animation: spin .8s linear infinite;
}
.wx-map-fail {
  padding: 1.4rem; text-align: center; font-size: .8rem;
  color: #b45309; line-height: 1.5;
}
.wx-map-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; margin-top: .6rem; font-size: .75rem; color: var(--muted, #888);
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.wx-map-select-btn {
  flex-shrink: 0; padding: .55rem .9rem; border: none; border-radius: 10px;
  background: linear-gradient(135deg,#22c55e,#16a34a); color: #fff;
  font-weight: 700; font-size: .75rem; cursor: pointer; white-space: nowrap;
}
.wx-map-select-btn:active { transform: scale(.96); }
.wx-map-marker svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.wx-minimap.leaflet-container { font: inherit; }
.wx-minimap .leaflet-control-attribution { font-size: 9px !important; background: rgba(255,255,255,.7) !important; }
.wx-minimap .leaflet-bar a { color: #333 !important; }

@media (max-width: 640px) {
  .wx-minimap { height: 220px; }
}
@media (max-width: 380px) {
  .wx-minimap { height: 190px; }
  .wx-map-foot { flex-direction: column; align-items: stretch; white-space: normal; }
  .wx-map-select-btn { width: 100%; }
}

/* ── Panel de clima mejorado ─────────────────────────── */
.wx-card {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(13,13,26,.96), rgba(17,24,39,.92));
}
.wx-main { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.wx-big {
  font-size: 3.4rem; line-height: 1; flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.35));
}
.wx-hdr { flex: 1; min-width: 0; }
.wx-temp-row { display: flex; align-items: flex-end; gap: .7rem; flex-wrap: wrap; }
.wx-temp { margin-top: .2rem; }
.wx-desc { font-size: 1rem; font-weight: 600; margin: 0 0 .25rem; padding-bottom: .35rem; }
.wx-feels { margin-top: .1rem; }
.wx-stat i { font-size: 1.05rem; }

@media (max-width: 380px) {
  .wx-main { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .wx-big { font-size: 3rem; }
}

/* ── Selector de frecuencia de notificaciones ────────── */
.wx-interval {
  margin-top: .7rem; padding: .7rem .8rem;
  border: 1px solid rgba(128,128,128,.25); border-radius: 14px;
  background: rgba(128,128,128,.06);
}
.wx-interval-label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 700; margin-bottom: .6rem;
  color: var(--text, currentColor);
}
.wx-interval-label i { color: #22c55e; }
.wx-interval-options {
  display: flex; flex-wrap: wrap; gap: .4rem;
}
.wx-int-btn {
  border: 1px solid rgba(128,128,128,.3); background: transparent;
  color: var(--text, currentColor); padding: .45rem .7rem;
  border-radius: 999px; font-size: .75rem; cursor: pointer;
  transition: all .15s;
}
.wx-int-btn.active {
  background: linear-gradient(135deg,#2f80ed,#22c55e);
  color: #fff; border-color: transparent; font-weight: 700;
}
.wx-interval-hint {
  margin-top: .55rem; font-size: .7rem; color: var(--muted, #888);
  line-height: 1.4;
}
@media (max-width: 380px) {
  .wx-int-btn { flex: 1 1 40%; text-align: center; }
  .wx-map-foot { flex-direction: column; align-items: stretch; white-space: normal; }
  .wx-map-select-btn { width: 100%; }
}

/* ── EMI: barra de modos ───────────────────────────────────── */
.ai-modes-bar {
  display: flex; gap: .4rem; padding: .5rem .75rem;
  background: var(--ai-s1, #1c1c26);
  border-bottom: 1px solid var(--ai-border2, rgba(255,255,255,.07));
  flex-shrink: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; position: relative; z-index: 1;
}
.ai-modes-bar::-webkit-scrollbar { display: none; }
.ai-mode-chip {
  flex-shrink: 0; white-space: nowrap;
  padding: .3rem .65rem; border-radius: var(--radius-full, 50px);
  border: 1px solid var(--ai-border, rgba(255,255,255,.09));
  background: transparent; color: var(--ai-muted, rgba(210,210,225,.5));
  font-size: .72rem; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.ai-mode-chip:hover { border-color: rgba(124,77,255,.45); color: var(--ai-text, #ECECF3); }
.ai-mode-chip.active {
  background: linear-gradient(135deg, #7C4DFF, #00B0FF);
  color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(124,77,255,.35);
}

/* ── EMI: pantalla completa ────────────────────────────────── */
#ai-panel.ai-fullscreen {
  right: 0; bottom: 0; width: 100vw; height: 100dvh; max-height: 100dvh;
  min-height: 100dvh; border-radius: 0; border: none;
}
@media (max-width: 768px) {
  .ai-head-actions { gap: 4px; }
  .ai-modes-bar { padding: .45rem .65rem; }
}

/* ── EMI: cuerpo del chat (sin sidebar fijo) ──────────────── */
#ai-panel { display: flex; flex-direction: column; }
.ai-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
#ai-msgs { flex: 1; min-height: 0; }

/* ── EMI: menú hamburguesa deslizante (drawer) ────────────── */
.emi-drawer {
  position: fixed; inset: 0; z-index: 9700;
  display: flex; justify-content: flex-start;
  pointer-events: none;
}
.emi-drawer-scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; transition: opacity .28s;
  backdrop-filter: blur(2px);
}
.emi-drawer-panel {
  position: relative; width: min(300px, 82vw); height: 100%;
  background: var(--ai-bg, #17171f);
  border-right: 1px solid var(--ai-border, rgba(255,255,255,.09));
  box-shadow: 0 0 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.2,.9,.2,1);
  overflow: hidden;
}
.emi-drawer.is-open { pointer-events: all; }
.emi-drawer.is-open .emi-drawer-scrim { opacity: 1; }
.emi-drawer.is-open .emi-drawer-panel { transform: translateX(0); }

.emi-drawer-head {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1rem .9rem; border-bottom: 1px solid var(--ai-border2, rgba(255,255,255,.07));
  background: linear-gradient(135deg, rgba(124,77,255,.16), rgba(0,176,255,.1));
}
.emi-drawer-title {
  font-size: .9rem; font-weight: 800; color: var(--ai-text, #ECECF3);
  display: flex; flex-direction: column; gap: .2rem;
}
.emi-drawer-status {
  font-size: .62rem; font-weight: 600; color: var(--ai-muted, rgba(210,210,225,.5));
  display: flex; align-items: center; gap: .35rem;
}
.emi-drawer-status .online-dot { font-size: .38rem; color: #3ecf8e; }
.emi-drawer-close {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--ai-border, rgba(255,255,255,.09));
  background: transparent; color: var(--ai-muted, rgba(210,210,225,.5)); cursor: pointer; font-size: .9rem;
}
.emi-drawer-close:hover { color: #fff; background: rgba(255,255,255,.08); }
.emi-drawer-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: .6rem .8rem 1.2rem;
  scrollbar-width: thin;
}

.emi-sec {
  font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ai-accent, #7C4DFF); margin: 1rem 0 .4rem;
}
.emi-sec:first-child { margin-top: .3rem; }

.emi-item {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  background: none; border: none; color: var(--ai-text, #ECECF3);
  font-size: .8rem; text-align: left; padding: .62rem .7rem;
  border-radius: var(--radius-sm, 10px); cursor: pointer; transition: background .15s;
}
.emi-item i { width: 17px; text-align: center; color: var(--ai-accent, #7C4DFF); font-size: .9rem; }
.emi-item:hover { background: rgba(124,77,255,.14); }
.emi-item.danger i { color: #ff5c6c; }
.emi-item.danger:hover { background: rgba(255,92,108,.12); }

.emi-mode {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  background: none; border: 1px solid transparent; color: var(--ai-text, #ECECF3);
  font-size: .78rem; text-align: left; padding: .55rem .7rem;
  border-radius: var(--radius-sm, 10px); cursor: pointer; transition: all .15s; margin-bottom: .25rem;
}
.emi-mode:hover { background: rgba(124,77,255,.1); }
.emi-mode.is-active { background: linear-gradient(135deg, rgba(124,77,255,.22), rgba(0,176,255,.16)); border-color: rgba(124,77,255,.35); }
.emi-mode-ico { font-size: 1rem; }
.emi-mode-lbl { flex: 1; }
.emi-mode-check { color: #7C4DFF; font-weight: 800; }

.emi-usage {
  background: rgba(255,255,255,.035); border: 1px solid var(--ai-border, rgba(255,255,255,.07));
  border-radius: var(--radius-sm, 10px); padding: .6rem .7rem; margin-bottom: .4rem;
}
.emi-usage-top { display: flex; justify-content: space-between; font-size: .74rem; color: var(--ai-muted, rgba(210,210,225,.5)); }
.emi-usage-top b { color: var(--ai-text, #ECECF3); }
.emi-usage-bar { height: 6px; border-radius: 50px; background: rgba(255,255,255,.08); overflow: hidden; margin: .45rem 0 .35rem; }
.emi-usage-bar > span { display: block; height: 100%; border-radius: 50px; background: linear-gradient(90deg,#7C4DFF,#00B0FF); }
.emi-usage-hint { font-size: .66rem; color: var(--ai-muted, rgba(210,210,225,.5)); }

.emi-opt-row { display: flex; gap: .4rem; padding: 0 .1rem; }
.emi-pill {
  flex: 1 1 auto; min-width: 42px; padding: .4rem .5rem; text-align: center;
  font-size: .72rem; font-weight: 600; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--ai-border, rgba(255,255,255,.09));
  background: transparent; color: var(--ai-muted, rgba(210,210,225,.5)); transition: all .15s;
}
.emi-pill:hover { border-color: rgba(124,77,255,.45); color: #fff; }
.emi-pill.is-active { background: linear-gradient(135deg,#7C4DFF,#00B0FF); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(124,77,255,.3); }
.emi-opt-hint { font-size: .64rem; color: var(--ai-muted, rgba(210,210,225,.4)); margin: .4rem 0 .3rem; }
.emi-check {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .1rem; font-size: .76rem; color: var(--ai-text, #ECECF3);
}
.emi-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: #7C4DFF; cursor: pointer; }

/* Botón de menú en el header */
.ai-menu-trigger { background: rgba(124,77,255,.12); border-color: rgba(124,77,255,.3) !important; color: #fff; }
.ai-menu-trigger:hover { background: rgba(124,77,255,.25); }

