        /* === ESTILO HOME === */
        :root {
            --bg-color: #121212;
            --card-bg: #1e1e1e;
            --text-primary: #ffffff;
            --text-secondary: #aaaaaa;
            --accent-color: #3759a3;
            --bottom-nav-bg: #1a1a1a;
            --border-color: #2c2c2c;
            --modal-overlay: rgba(0, 0, 0, 0.85);
            /* Variables para la biblia */
            --bg: #121212;
            --card: #1e1e1e;
            --text: #ffffff;
            --muted: #98989d;
            --accent: #ffffffcc;
            --radius: 18px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            background-color: var(--bg-color);
            color: var(--text-primary);
            padding-bottom: 100px;
            overflow-x: hidden;
        }

        /* === HEADER SPA (mejorado) === */

/* Variables para fácil ajuste */
:root{
  --header-bg: rgba(10,12,16,0.72);
  --header-blur: 8px;
  --header-padding-vertical: 14px;
  --header-padding-horizontal: 16px;
  --header-height: 64px;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-bg-hover: rgba(255,255,255,0.12);
  --btn-active: rgba(255,255,255,0.18);
  --btn-size: 40px;
  --text-primary: var(--text-primary, #ffffff);
  --muted: rgba(255,255,255,0.75);
  --shadow: 0 6px 20px rgba(2,6,23,0.45);
  --transition: 200ms cubic-bezier(.2,.9,.3,1);
}

/* Contenedor sticky con efecto glass y sombra sutil */
/* === HEADER SPA (ajustado para separar contenido debajo) === */

/* Valores por defecto que puedes sobrescribir en tu tema */
:root{
  --header-height: var(--header-height, 64px);
  --header-bottom-gap: 18px; /* espacio entre header y el contenido (menu) */
}

/* Header principal (reemplaza tu bloque existente) */
header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--header-padding-vertical) var(--header-padding-horizontal);
  height: var(--header-height);
  background: var(--header-bg);
  backdrop-filter: blur(var(--header-blur));
  -webkit-backdrop-filter: blur(var(--header-blur));
  border-bottom: 1px solid rgba(255,255,255,0.04);
  box-shadow: var(--shadow);
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);

  /* separación visual: crea espacio entre header y el siguiente contenido */
  margin-bottom: var(--header-bottom-gap);
  box-sizing: border-box;
}

/* Compact variant when scrolled (optional class .scrolled added by JS if desired) */
header.scrolled{
  background: rgba(8,10,14,0.86);
  box-shadow: 0 10px 30px rgba(2,6,23,0.6);
  transform: translateY(0);

  /* ajustar gap si el header se compacta */
  margin-bottom: calc(var(--header-bottom-gap) - 6px);
}

/* Título: ocupa el espacio restante y se adapta */
header h1{
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 0;
  color: var(--text-primary);
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Contenedor para acciones a la derecha (si existe) */
.header-actions{
  display:flex;
  gap:8px;
  align-items:center;
  margin-left: 8px;
}

/* Botón de retroceso: redondeado, centrado y con estados */
.header-back-btn{
  width: var(--btn-size);
  height: var(--btn-size);
  min-width: var(--btn-size);
  min-height: var(--btn-size);
  border-radius: 50%;
  border: none;
  background: var(--btn-bg);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), transform 140ms ease, box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(2,6,23,0.25);
}

/* Hover / focus / active */
.header-back-btn:hover{
  background: var(--btn-bg-hover);
  transform: translateY(-2px);
}
.header-back-btn:active{
  transform: scale(0.94);
  background: var(--btn-active);
}
.header-back-btn:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(79,116,214,0.12);
}

/* Icon inside button: ensure consistent sizing */
.header-back-btn i,
.header-back-btn svg{
  font-size: 16px;
  line-height: 1;
  display:block;
}

/* Small screens: reduce paddings and sizes */
@media (max-width: 520px){
  :root{
    --header-padding-vertical: 10px;
    --header-height: 56px;
    --btn-size: 36px;
  }
  header h1{
    font-size: 18px;
  }
}

/* Safe-area support for devices with notch */
@supports(padding: max(0px)) {
  header {
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-padding-vertical));
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + (var(--header-padding-vertical) / 2));
  }
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce){
  header, .header-back-btn{
    transition: none;
    transform: none;
  }
}


        /* === VISTAS SPA === */
        .page-view {
            display: none;
            padding: 0 16px;
            position: relative;
        }
        .page-view.active {
            display: flex;
            flex-direction: column;
            gap: 16px;
            animation: fadeInView 0.3s ease-out;
        }

        /* Animaciones iOS */
        .page-view.ios-enter {
            display: flex !important;
            position: fixed;
            top: 56px; left: 0; right: 0; bottom: 0;
            z-index: 2;
            animation: iosSlideInLeft 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
        }
        .page-view.ios-enter.right {
            animation: iosSlideInRight 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
        }
        .page-view.ios-exit {
            display: flex !important;
            position: fixed;
            top: 56px; left: 0; right: 0; bottom: 0;
            z-index: 1;
            animation: iosSlideOutLeft 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
        }
        .page-view.ios-exit.right {
            animation: iosSlideOutRight 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
        }

        @keyframes fadeInView {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }
        @keyframes iosSlideInLeft {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        @keyframes iosSlideInRight {
            from { transform: translateX(-40%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        @keyframes iosSlideOutLeft {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(-40%); opacity: 0; }
        }
        @keyframes iosSlideOutRight {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(100%); opacity: 0; }
        }


/* === MODALES HOME === */
.modal-overlay {
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--modal-overlay); 
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; 
    display: flex; align-items: center; justify-content: center;
    padding: 8px; /* Reducido al mínimo para ganar altura en el dispositivo */
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content { 
    background-color: var(--card-bg); 
    border-radius: 20px; 
    width: 100%; 
    max-width: 420px; /* Un poco más ancho para redistribuir el texto horizontalmente */
    border: 1px solid var(--border-color); 
    overflow: hidden; 
    transform: scale(0.9); transition: transform 0.3s ease; 
    position: relative; 
    max-height: 98vh; /* Aprovecha casi todo el alto de la pantalla */
    display: flex;
    flex-direction: column;
}
.modal-overlay.active .modal-content { transform: scale(1); }

.close-modal-btn { 
    position: absolute; 
    top: 10px; right: 10px; 
    background: rgba(255,255,255,0.2); 
    border: none; color: #fff; 
    width: 28px; height: 28px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; z-index: 10; 
}