/* ============================================
   RESET Y VARIABLES
============================================ */
:root {
    --sp-primary-color: #ff2c2c;
    --sp-primary-hover: #ca2222;
    --sp-dark-bg: #0f0f0f;
    --sp-sidebar-bg: #0f0f0f;
    --sp-sidebar-hover: #272727;
    --sp-text-color: #f1f1f1;
    --sp-text-light: #aaaaaa;
    --sp-text-dark: #9E9E9E;
    --sp-border-color: #272727;
    --sp-card-bg: #1a1a1a;
    --sp-search-bg: #121212;
    --sp-search-border: #303030;
    --sp-chip-bg: #272727;
    --sp-chip-hover: #3f3f3f;
    --sp-header-height: 56px;
    --sp-chips-height: 44px;
    --sp-sidebar-width: 240px;
    --sp-sidebar-collapsed: 72px;
    --sp-bottom-nav-height: 60px;
    --sp-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.sp-body-override {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--sp-dark-bg);
    color: var(--sp-text-color);
    overflow-x: hidden;
    line-height: 1.6;
    font-weight: 400;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #1a1a1a;
}
::-webkit-scrollbar-thumb {
    background: var(--sp-primary-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--sp-primary-hover);
}

/* ============================================
   WRAPPER
============================================ */
.sp-wrapper {
    display: flex;
    flex: 1;
    min-height: 100vh;
    min-width: 0;
}

/* ============================================
   SIDEBAR - ESTILO YOUTUBE (RAIL ICONO + ETIQUETA)
============================================ */
.sp-sidebar {
    width: var(--sp-sidebar-collapsed);
    background: var(--sp-sidebar-bg);
    position: fixed;
    left: 0;
    top: var(--sp-header-height);
    height: calc(100vh - var(--sp-header-height));
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.25s var(--sp-ease), transform 0.25s var(--sp-ease);
    padding: 8px 0;
    scrollbar-width: thin;
    border-right: 1px solid var(--sp-border-color);
}

/* Expandido mediante click (persistido en localStorage), no por hover */
html.sp-sidebar-expanded .sp-sidebar {
    width: var(--sp-sidebar-width);
}

html.sp-sidebar-expanded .sp-nav-text {
    opacity: 1;
    width: auto;
}

/* Sin overrides propios: hereda el mismo scrollbar rojo (::-webkit-scrollbar*)
   definido a nivel global, para que sea idéntico al de toda la página */
.sp-sidebar {
    scrollbar-color: var(--sp-primary-color) #1a1a1a;
}

.sp-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sp-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 8px;
}

.sp-sidebar-nav.sp-sidebar-bottom {
    margin-top: auto;
    padding-top: 8px;
}

.sp-sidebar-divider {
    border: none;
    border-top: 1px solid var(--sp-border-color);
    margin: 12px 12px;
}

.sp-nav-item {
    margin-bottom: 0;
    text-align: center;
}

/* --- Estado COLAPSADO (rail): icono arriba, etiqueta pequeña debajo, tal cual YouTube --- */
.sp-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px 10px;
    color: var(--sp-text-light);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    position: relative;
    font-weight: 400;
    font-size: 10px;
    text-align: center;
    cursor: pointer;
}

.sp-nav-link:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

/* YouTube resalta el ítem activo con un fondo gris neutro, no con el color de marca */
.sp-nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sp-text-color);
    font-weight: 500;
}

.sp-nav-link.active:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sp-nav-link.active .sp-nav-icon {
    color: var(--sp-text-color);
}

.sp-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    font-size: 20px;
    color: var(--sp-text-light);
    transition: color 0.2s;
}

.sp-nav-link:hover .sp-nav-icon {
    color: var(--sp-text-color);
}

.sp-nav-link.active .sp-nav-icon {
    color: var(--sp-text-color);
}

.sp-nav-text {
    font-size: 10px;
    font-weight: inherit;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    opacity: 1;
    width: auto;
    max-width: 64px;
    transition: font-size 0.2s ease;
}

/* --- Estado EXPANDIDO: icono + etiqueta en fila, como el menú desplegado de YouTube --- */
html.sp-sidebar-expanded .sp-nav-link {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 10px 12px;
    text-align: left;
    border-radius: 10px;
}

html.sp-sidebar-expanded .sp-nav-text {
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: none;
    text-align: left;
}

/* ============================================
   SIDEBAR HEADER (idéntico a la top bar)
============================================ */
.sp-sidebar-header {
    display: none; /* Oculto por defecto, solo visible en modo overlay */
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px; /* Misma altura que la top bar */
    border-bottom: 1px solid var(--sp-border-color);
    background: var(--sp-sidebar-bg);
    flex-shrink: 0;
    margin-top: 0;
}

.sp-sidebar-close {
    display: flex;
    background: none;
    border: none;
    color: var(--sp-text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
}

.sp-sidebar-close:hover {
    background: var(--sp-sidebar-hover);
}

.sp-sidebar-close svg {
    display: block;
    width: 24px;
    height: 24px;
}

.sp-sidebar-logo {
    display: flex;
    align-items: center;
    margin-right: auto;
}

.sp-sidebar-logo-img {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.sp-sidebar-logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--sp-text-color);
    text-decoration: none;
    letter-spacing: 0.5px;
}

.sp-sidebar-logo-text:hover {
    color: var(--sp-text-color);
}

/* ============================================
   ELIMINAR ESPACIO SUPERIOR EN MODO OVERLAY
============================================ */
.sp-sidebar.mobile-open {
    padding-top: 0 !important;
}

@media (max-width: 1024px) {
    .sp-sidebar {
        padding-top: 0 !important;
    }
}

.single .sp-sidebar.mobile-open {
    padding-top: 0 !important;
}

/* ============================================
   VISIBILIDAD DEL HEADER DEL SIDEBAR
============================================ */

/* En móvil (≤1024px) siempre visible (el sidebar es overlay) */
@media (max-width: 1024px) {
    .sp-sidebar .sp-sidebar-header {
        display: flex;
    }
}

/* En desktop, solo visible cuando el sidebar está en modo overlay (mobile-open) */
@media (min-width: 1025px) {
    .sp-sidebar.mobile-open .sp-sidebar-header {
        display: flex;
    }
    /* En la página de inicio en desktop, NUNCA mostrar el header del sidebar */
    body.home .sp-sidebar .sp-sidebar-header {
        display: none !important;
    }
    /* Cuando el sidebar está expandido (modo colapsado/expandido), tampoco mostrar */
    html.sp-sidebar-expanded .sp-sidebar .sp-sidebar-header {
        display: none !important;
    }
}

/* Ajuste para single posts en desktop (donde el sidebar es overlay) */
.single .sp-sidebar .sp-sidebar-header {
    display: none; /* Por defecto oculto */
}
.single .sp-sidebar.mobile-open .sp-sidebar-header {
    display: flex; /* Se muestra al abrir */
}

/* Sidebar collapsed state for mobile (siempre en fila dentro del panel deslizante) */
@media (max-width: 1024px) {
    .sp-sidebar {
        transform: translateX(-100%);
        width: var(--sp-sidebar-width);
        top: var(--sp-header-height);
        height: calc(100vh - var(--sp-header-height));
        border-right: none;
        padding-top: 0;
        z-index: 1030; /* Mayor que overlay, menor que topbar (1040) */
    }
    .sp-sidebar.mobile-open {
        transform: translateX(0);
    }
    .sp-sidebar .sp-nav-link {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
        padding: 10px 12px;
        text-align: left;
        border-radius: 10px;
    }
    .sp-sidebar .sp-nav-text {
        opacity: 1;
        width: auto;
        max-width: none;
        font-size: 14px;
        text-align: left;
        white-space: nowrap;
    }
}

/* Ocultar el ítem "Inicio" del sidebar en responsive: ya vive en la barra inferior */
@media (max-width: 768px) {
    .sp-nav-item-inicio {
        display: none;
    }
}

/* ============================================
   OVERLAY DEL SIDEBAR (MÓVIL)
   Estilo GLOBAL: funciona igual en TODAS las páginas
============================================ */
.sp-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1020; /* Menor que topbar (1040) y sidebar (1030) */
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sp-mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   SINGLE POST - SIDEBAR OCULTO POR DEFECTO CON OVERLAY
============================================ */
/* En single posts, el sidebar está oculto por defecto (como en móvil) */
.single .sp-sidebar {
    transform: translateX(-100%);
    width: var(--sp-sidebar-width);
    top: var(--sp-header-height);
    height: calc(100vh - var(--sp-header-height));
    border-right: none;
    padding-top: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cuando se abre el sidebar en single posts (modo overlay - versión expandida) */
.single .sp-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}

/* En single posts, el sidebar siempre se muestra en versión expandida (icono + texto) */
.single .sp-sidebar .sp-nav-link {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 10px 12px;
    text-align: left;
    border-radius: 10px;
}

.single .sp-sidebar .sp-nav-text {
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: none;
    text-align: left;
    opacity: 1;
    width: auto;
}

.single .sp-sidebar .sp-nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* En single posts, el contenido principal ocupa todo el ancho */
.single .sp-main,
.single .sp-main.sp-main-single {
    margin-left: 0 !important;
}

/* Asegurar que el sidebar esté por encima del overlay en single */
.single .sp-sidebar {
    z-index: 1030;
}

/* El botón de hamburguesa siempre visible en single */
.single .sp-mobile-toggle {
    display: flex !important;
}

/* En desktop single, el sidebar no debería tener el comportamiento de expandido */
.single html.sp-sidebar-expanded .sp-sidebar {
    width: var(--sp-sidebar-width);
    transform: translateX(-100%);
}

.single html.sp-sidebar-expanded .sp-sidebar.mobile-open {
    transform: translateX(0);
}

/* Asegurar que el divider se vea correctamente en single */
.single .sp-sidebar .sp-sidebar-divider {
    margin: 12px 12px;
}

/* Asegurar que los items del sidebar en single tengan el estilo correcto */
.single .sp-sidebar .sp-nav-item {
    text-align: left;
}

/* ============================================
   MAIN CONTENT
============================================ */
.sp-main {
    flex: 1;
    margin-left: var(--sp-sidebar-collapsed);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.25s var(--sp-ease);
    padding-top: var(--sp-header-height);
}

html.sp-sidebar-expanded .sp-main {
    margin-left: var(--sp-sidebar-width);
}

@media (max-width: 1024px) {
    .sp-main,
    html.sp-sidebar-expanded .sp-main {
        margin-left: 0;
    }
}

/* ============================================
   TOP BAR - ESTILO YOUTUBE
============================================ */
.sp-top-bar {
    background: var(--sp-dark-bg);
    border-bottom: 1px solid var(--sp-border-color);
    padding: 0 16px;
    height: var(--sp-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1040; /* Mayor que sidebar (1030) y overlay (1020) */
    flex-shrink: 0;
}

.sp-top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
}

/* ===== ESCRITORIO: buscador centrado al ancho total de la barra =====
   Se usa CSS Grid con 3 columnas simétricas (izq / centro fijo / der)
   para que el buscador quede centrado respecto al ancho total,
   sin importar cuánto ocupen el logo o las acciones de usuario. */
@media (min-width: 1025px) {
    .sp-top-bar {
        display: grid;
        grid-template-columns: minmax(160px, 1fr) minmax(0, 640px) minmax(160px, 1fr);
        column-gap: 16px;
    }
    .sp-top-bar-left {
        justify-self: start;
        min-width: 0;
    }
    .sp-user-actions {
        justify-self: end;
        min-width: 0;
    }
    .sp-search-container {
        justify-self: center;
        margin: 0;
        width: 100%;
    }
}

.sp-mobile-toggle {
    display: flex;
    background: none;
    border: none;
    color: var(--sp-text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sp-mobile-toggle:hover {
    background: var(--sp-sidebar-hover);
}

.sp-logo-container {
    display: flex;
    align-items: center;
}

.sp-topbar-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.sp-logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--sp-text-color);
    text-decoration: none;
    letter-spacing: 0.5px;
}

.sp-logo-text:hover {
    color: var(--sp-text-color);
}

/* ============================================
   BUSCADOR - CONTENEDOR PRINCIPAL
============================================ */
.sp-search-container {
    position: relative;
    flex: 1;
    max-width: 640px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 20px;
    min-width: 0;
}

.sp-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--sp-search-bg);
    border: 1px solid var(--sp-search-border);
    border-radius: 40px;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex: 1;
    height: 40px;
    overflow: visible;
    min-width: 0;
}

.sp-search-box:focus-within {
    border-color: var(--sp-primary-color);
    box-shadow: 0 0 0 1px var(--sp-primary-color);
}

.sp-search-input {
    background: transparent;
    border: none;
    color: var(--sp-text-color);
    height: 100%;
    width: 100%;
    padding: 0 16px;
    font-size: 14px;
    outline: none;
    font-weight: 400;
    min-width: 0;
}

.sp-search-input::placeholder {
    color: var(--sp-text-dark);
}

.sp-search-btn {
    background: transparent;
    border: none;
    border-left: 1px solid var(--sp-search-border);
    color: var(--sp-text-dark);
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 0 40px 40px 0;
    flex-shrink: 0;
}

.sp-search-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sp-text-color);
}

.sp-voice-search-btn {
    background: none;
    border: none;
    color: var(--sp-text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.sp-voice-search-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-voice-search-btn.listening {
    color: var(--sp-primary-color);
    background: rgba(255, 44, 44, 0.15);
    animation: sp-pulse 1.5s infinite;
}

@keyframes sp-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================
   RESULTADOS DE BÚSQUEDA - CENTRADOS Y ALINEADOS CON EL INPUT
   Ancho ajustado dinámicamente - Sin scroll - Alto automático
============================================ */
.sp-search-results {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    background: #1a1a1a;
    border: 1px solid #303030;
    border-radius: 12px;
    padding: 0;
    overflow: visible;
    display: none;
    z-index: 1001;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.9);
}

.sp-search-results::-webkit-scrollbar {
    display: none;
}

/* Item de resultado - IMAGEN A LA DERECHA (16:9) */
.sp-search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    text-decoration: none;
    color: #f1f1f1;
    transition: background 0.15s ease;
    gap: 10px;
    border-bottom: 1px solid #2a2a2a;
    min-height: 48px;
}

/* Primer resultado: borde redondeado arriba */
.sp-search-result-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Último resultado: borde redondeado abajo y sin borde inferior */
.sp-search-result-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Si hay un solo resultado: todos los bordes redondeados */
.sp-search-result-item:only-child {
    border-radius: 12px;
    border-bottom: none;
}

.sp-search-result-item:hover {
    background: #272727;
}

/* Información - a la izquierda (ocupa el espacio disponible) */
.sp-search-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 2px 0;
}

.sp-search-result-title {
    font-weight: 600;
    font-size: 13px;
    color: #f1f1f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sp-search-result-original-title {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Meta datos - SIN iconos de CPT */
.sp-search-result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-top: 1px;
    flex-wrap: wrap;
}

.sp-search-result-rating {
    color: #ffd700;
    font-weight: 600;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.sp-search-result-year {
    color: #888;
    background: rgba(255, 255, 255, 0.06);
    padding: 0 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    line-height: 18px;
}

/* Imagen - a la derecha con proporción 16:9 */
.sp-search-result-image {
    flex-shrink: 0;
    width: 80px;
    height: 45px;
    border-radius: 6px;
    overflow: hidden;
    background: #0f0f0f;
    order: 2;
}

.sp-search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Loading y no results - compactos */
.sp-search-loading,
.sp-search-no-results {
    padding: 16px 12px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

/* ============================================
   RESPONSIVE - RESULTADOS
============================================ */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    .sp-search-results {
        border-radius: 10px;
        top: calc(100% + 1px);
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        transform: none !important;
    }
    
    .sp-search-result-item {
        padding: 5px 10px;
        gap: 8px;
        min-height: 40px;
    }
    
    .sp-search-result-item:first-child {
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
    }
    
    .sp-search-result-item:last-child {
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
    }
    
    .sp-search-result-item:only-child {
        border-radius: 10px;
    }
    
    .sp-search-result-image {
        width: 64px;
        height: 36px;
        border-radius: 4px;
    }
    
    .sp-search-result-title {
        font-size: 12px;
    }
    
    .sp-search-result-original-title {
        font-size: 10px;
    }
    
    .sp-search-result-meta {
        font-size: 10px;
        gap: 4px;
    }
    
    .sp-search-result-rating {
        font-size: 10px;
    }
    
    .sp-search-result-year {
        font-size: 9px;
        padding: 0 6px;
        line-height: 16px;
    }
}

/* Móvil (≤480px) */
@media (max-width: 480px) {
    .sp-search-results {
        border-radius: 8px;
        padding: 0;
        top: calc(100% + 1px);
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        transform: none !important;
    }
    
    .sp-search-result-item {
        padding: 4px 8px;
        gap: 6px;
        min-height: 34px;
    }
    
    .sp-search-result-item:first-child {
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }
    
    .sp-search-result-item:last-child {
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
    }
    
    .sp-search-result-item:only-child {
        border-radius: 8px;
    }
    
    .sp-search-result-image {
        width: 48px;
        height: 27px;
        border-radius: 3px;
    }
    
    .sp-search-result-title {
        font-size: 11px;
    }
    
    .sp-search-result-original-title {
        font-size: 9px;
    }
    
    .sp-search-result-meta {
        font-size: 9px;
        gap: 3px;
    }
    
    .sp-search-result-rating {
        font-size: 9px;
    }
    
    .sp-search-result-year {
        font-size: 8px;
        padding: 0 5px;
        line-height: 14px;
    }
    
    .sp-search-loading,
    .sp-search-no-results {
        padding: 12px 8px;
        font-size: 11px;
    }
}

/* ============================================
   BUSCADOR EN MÓVIL
============================================ */
@media (max-width: 768px) {
    .sp-search-container {
        margin: 0;
        max-width: 100%;
        padding: 0 8px;
    }
    
    .sp-search-container.mobile-open {
        display: flex;
        padding: 8px 16px;
        background: var(--sp-dark-bg);
        border-bottom: 1px solid var(--sp-border-color);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    }
    
    .sp-search-box {
        flex: 1;
    }
    
    .sp-search-results {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        top: calc(100% + 1px);
        transform: none !important;
    }
}

/* ============================================
   USER ACTIONS
============================================ */
.sp-user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.sp-vip-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    color: var(--sp-primary-color);
    border: 1px solid var(--sp-primary-color);
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s var(--sp-ease), box-shadow 0.2s var(--sp-ease);
    height: 36px;
    overflow: hidden;
}

.sp-vip-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    transform: skewX(-20deg);
    animation: sp-vip-shine 3.5s ease-in-out infinite;
}

@keyframes sp-vip-shine {
    0% { left: -60%; }
    50% { left: 130%; }
    100% { left: 130%; }
}

.sp-vip-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px var(--sp-primary-color);
}

.sp-vip-btn svg {
    stroke: #fff;
    position: relative;
    z-index: 1;
}

/* Auth buttons */
.sp-auth-btn {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    height: 36px;
}

.sp-login-btn {
    background: transparent;
    color: var(--sp-text-color);
    border: 1px solid var(--sp-border-color);
}

.sp-login-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-register-btn {
    background: var(--sp-primary-color);
    color: #424242;
    border: 1px solid var(--sp-primary-color);
}

.sp-register-btn:hover {
    background: var(--sp-primary-hover);
    border-color: var(--sp-primary-hover);
}

/* Notifications */
.sp-notification-dropdown,
.sp-user-dropdown {
    position: relative;
}

.sp-random-btn {
    background: none;
    border: none;
    color: var(--sp-text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s, transform 0.2s var(--sp-ease);
}

.sp-random-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-random-btn:active {
    transform: scale(0.9) rotate(15deg);
}

.sp-random-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.sp-notification-bell {
    background: none;
    border: none;
    color: var(--sp-text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: background 0.2s, color 0.2s;
    position: relative;
}

.sp-notification-bell:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--sp-primary-color);
    border-radius: 50%;
    animation: sp-pulse 2s infinite;
}

/* Cuando el punto lleva un número adentro (contador real, no solo un
   aviso de "hay algo") -- se agranda para que el número entre bien. */
.sp-notification-dot.sp-notification-count {
    width: auto;
    height: 16px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    animation: none;
}

.sp-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-shrink: 0;
}

.sp-notification-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--sp-border-color);
    background: transparent;
    color: var(--sp-text-secondary, #a3a3a3);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.sp-notification-check:hover {
    border-color: var(--sp-primary-color);
    color: var(--sp-primary-color);
}

.sp-notification-item.sp-notification-leida .sp-notification-check {
    background: var(--sp-primary-color);
    border-color: var(--sp-primary-color);
    color: #fff;
}

.sp-notification-item.sp-notification-leida {
    opacity: .6;
}

.sp-notification-body {
    flex: 1;
    min-width: 0;
}

.sp-notification-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.sp-notification-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--sp-card-bg);
    border: 1px solid var(--sp-border-color);
    border-radius: 12px;
    min-width: 320px;
    max-width: 400px;
    /* Alto según la pantalla, no un número fijo -- en una pantalla chica
       (o con muchas notificaciones) no se corta ni se sale del
       viewport, aparece scroll interno en vez de eso. */
    max-height: min(70vh, 480px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
    z-index: 1003;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.16s var(--sp-ease), transform 0.16s var(--sp-ease), visibility 0.16s;
    pointer-events: none;
}

.sp-notification-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sp-notification-header {
    position: sticky;
    top: 0;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 15px;
    color: var(--sp-text-color);
    border-bottom: 1px solid var(--sp-border-color);
    background: var(--sp-card-bg);
    z-index: 1;
    flex-shrink: 0;
}

.sp-notification-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--sp-border-color);
}

.sp-notification-item:last-child {
    border-bottom: none;
}

.sp-notification-item:hover {
    background: var(--sp-sidebar-hover);
}

.sp-notification-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--sp-text-color);
    margin-bottom: 4px;
}

.sp-notification-message {
    font-size: 13px;
    color: var(--sp-text-light);
    margin-bottom: 8px;
    line-height: 1.4;
}

.sp-notification-action {
    display: inline-block;
    background: var(--sp-primary-color);
    color: #fff;
    padding: 4px 14px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}

.sp-notification-action:hover {
    background: var(--sp-primary-hover);
    color: #fff;
}

.sp-no-notifications {
    padding: 30px 20px;
    text-align: center;
    color: var(--sp-text-dark);
    font-size: 14px;
}

/* ============================================
   AVATAR DE USUARIO - ESTILO YOUTUBE
============================================ */
.sp-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sp-primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
    line-height: 1;
}

.sp-user-avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.sp-user-menu-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

/* User menu */
.sp-user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--sp-text-dark);
    cursor: pointer;
    padding: 4px 10px 4px 4px;
    border-radius: 40px;
    transition: background 0.2s, color 0.2s;
    height: 36px;
    font-size: 13px;
}

.sp-user-menu-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-user-menu-btn .sp-nav-text {
    display: inline;
    opacity: 1;
    width: auto;
    color: var(--sp-text-color);
    font-weight: 500;
}

.sp-user-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--sp-card-bg);
    border: 1px solid var(--sp-border-color);
    border-radius: 12px;
    min-width: 260px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
    z-index: 1002;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.16s var(--sp-ease), transform 0.16s var(--sp-ease), visibility 0.16s;
    pointer-events: none;
}

.sp-user-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sp-user-menu-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--sp-border-color);
    background: rgba(255, 255, 255, 0.03);
}

.sp-user-name {
    font-weight: 500;
    font-size: 15px;
    color: var(--sp-text-color);
}

.sp-user-email {
    font-size: 12px;
    color: var(--sp-text-dark);
}

.sp-membership-level {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
}

.sp-membership-active {
    color: #4caf50;
}
.sp-membership-free {
    color: #ffd700;
}
.sp-membership-expired {
    color: #f44336;
}

.sp-membership-expiry {
    font-size: 12px;
    color: var(--sp-text-dark);
    margin-top: 2px;
}

.sp-vip-days {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #ffd700;
    margin-top: 2px;
}

.sp-user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: var(--sp-text-color);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 14px;
    border-bottom: 1px solid var(--sp-border-color);
}

.sp-user-menu-item:last-child {
    border-bottom: none;
}

.sp-user-menu-item:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-user-menu-item.sp-logout-item {
    color: #f44336;
}

.sp-user-menu-item.sp-logout-item:hover {
    background: rgba(244, 67, 54, 0.1);
}

/* ============================================
   MOBILE ACTIONS
============================================ */
.sp-mobile-actions {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.sp-mobile-search-btn,
.sp-mobile-random-btn {
    background: none;
    border: none;
    color: var(--sp-text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: background 0.2s, color 0.2s;
}

.sp-mobile-search-btn:hover,
.sp-mobile-random-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-mobile-search-btn.active {
    color: var(--sp-primary-color);
}

/* ============================================
   BARRA DE CHIPS - ESTILO YOUTUBE
============================================ */
.sp-chips-bar-wrapper {
    position: sticky;
    top: var(--sp-header-height);
    z-index: 998;
    background: var(--sp-dark-bg);
    border-bottom: 1px solid var(--sp-border-color);
}

.sp-chips-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: var(--sp-chips-height);
}

/* Desvanecido en los bordes: solo cuando la barra realmente tiene scroll pendiente
   (caso sin JS, o pantallas extremadamente angostas donde ni el primer chip cabe) */
.sp-chips-bar.sp-chips-scrollable {
    mask-image: linear-gradient(to right, transparent 0, black 24px, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 24px, black calc(100% - 24px), transparent 100%);
}

.sp-chips-bar::-webkit-scrollbar {
    display: none;
}

.sp-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--sp-chip-bg);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sp-text-color);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s var(--sp-ease), transform 0.15s var(--sp-ease);
}

.sp-chip:hover {
    background: var(--sp-chip-hover);
    color: var(--sp-text-color);
}

.sp-chip:active {
    transform: scale(0.96);
}

.sp-chip.active {
    background: var(--sp-text-color);
    color: #0f0f0f;
}

/* ============================================================
   MENÚ "MÁS" - CORREGIDO
============================================================ */

/* ===== 1. Wrapper del botón "Más" ===== */
#sp-chip-more-wrapper {
    position: relative;
    flex-shrink: 0;
    display: none;
    overflow: visible !important;
    z-index: 9999 !important;
}

#sp-chip-more-wrapper.has-overflow {
    display: block;
}

/* ===== 2. Botón "Más" ===== */
.sp-chip-more {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 6px 12px 6px 14px;
    background: var(--sp-chip-bg);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--sp-text-color);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s var(--sp-ease);
    position: relative;
    z-index: 9999;
}

.sp-chip-more:hover {
    background: var(--sp-chip-hover);
}

/* ===== 3. Botón "Más" cuando está activo (menú abierto) ===== */
.sp-chip-more.active {
    background: var(--sp-text-color);
    color: #0f0f0f;
}

/* ===== 4. SVG del botón "Más" ===== */
.sp-chip-more svg {
    transition: transform 0.15s var(--sp-ease);
    flex-shrink: 0;
}

/* ===== 5. SVG girado cuando el menú está abierto ===== */
.sp-chip-more.open svg {
    transform: rotate(180deg);
}

/* ===== 6. Menú desplegable ===== */
.sp-chip-more-menu {
    position: fixed;
    top: calc(100% + 8px);
    right: 0;
    background: var(--sp-card-bg);
    border: 1px solid var(--sp-border-color);
    border-radius: 12px;
    min-width: 200px;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.9);
    z-index: 99999 !important;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.16s var(--sp-ease), transform 0.16s var(--sp-ease), visibility 0.16s;
    pointer-events: none;
}

.sp-chip-more-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ===== 7. Elementos del menú ===== */
.sp-chip-more-menu a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--sp-text-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s;
}

.sp-chip-more-menu a:hover {
    background: var(--sp-sidebar-hover);
}

.sp-chip-more-menu a.active {
    background: rgba(255, 44, 44, 0.15);
    color: var(--sp-primary-color);
}

/* ============================================
   CONTENT AREA
============================================ */
.sp-content-area {
    flex: 1;
    padding: 0;
    min-width: 0;
}

/* ============================================
   BOTTOM NAV - MOBILE (estilo YouTube)
   Inicio / VIP (condicional) / Usuario
============================================ */
.sp-bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1005;
    background: var(--sp-dark-bg);
    border-top: 1px solid var(--sp-border-color);
    align-items: stretch;
    justify-content: space-around;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    height: var(--sp-bottom-nav-height);
}

.sp-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--sp-text-light);
    text-decoration: none;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    min-width: 0;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

.sp-bottom-nav-item:active {
    background: var(--sp-sidebar-hover);
}

.sp-bottom-nav-item.active {
    color: var(--sp-text-color);
}

.sp-bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.sp-bottom-nav-text {
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.sp-bottom-nav-vip {
    color: #f5af19;
}

.sp-bottom-nav-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--sp-primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* Botón "Usuario" con dropdown en la barra inferior */
.sp-bottom-nav-user-dropdown {
    padding: 0;
    position: relative;
}

.sp-bottom-nav-user-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    height: 100%;
    padding: 6px 4px;
    background: none;
    border: none;
    color: var(--sp-text-light);
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    transition: color 0.2s, background 0.2s;
}

.sp-bottom-nav-user-btn:active {
    background: var(--sp-sidebar-hover);
}

.sp-bottom-nav-user-btn.active {
    color: var(--sp-text-color);
}

/* El menú de usuario de la barra inferior se abre hacia arriba (bottom-sheet),
   no hacia abajo como el del top bar */
.sp-bottom-user-dropdown-menu {
    transform-origin: bottom center;
    transform: translateY(16px) scale(0.98);
    max-width: 400px;
    margin: 0 auto;
}

.sp-bottom-user-dropdown-menu.open {
    transform: translateY(0) scale(1);
}

/* Overlay oscuro detrás del bottom-sheet, mismo efecto que el overlay del sidebar */
.sp-bottom-sheet-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1004;
    opacity: 0;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sp-bottom-sheet-overlay.active {
    opacity: 1;
}

@media (max-width: 768px) {
    .sp-bottom-nav {
        display: flex;
    }
    .sp-main {
        padding-bottom: var(--sp-bottom-nav-height);
    }
}

/* ============================================
   TERABOX MODAL
   Sin botones de "Mostrar generador" / "Mostrar instrucciones":
   iframe arriba (con offset ~50px) y bloque de instrucciones
   debajo, con scroll propio si el contenido no cabe.
============================================ */
.sp-terabox-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .3s;
}

.sp-terabox-modal.active {
    display: flex;
    opacity: 1;
}

.sp-terabox-container {
    background: #28282a;
    border: 1px solid #444;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    padding: 30px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(.9);
    transition: transform .3s;
}

.sp-terabox-modal.active .sp-terabox-container {
    transform: scale(1);
}

.sp-terabox-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    padding: 0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: .3s;
    border: 1px solid rgba(255,255,255,.1);
    cursor: pointer;
}

.sp-terabox-close-btn:hover {
    background: rgba(255,44,44,.9);
    transform: rotate(90deg);
}

.sp-terabox-header {
    flex-shrink: 0;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ff2c2c;
}

.sp-terabox-title {
    color: #dbdbdb;
    text-align: center;
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
}

/* Contenido apilado siempre: iframe arriba, espacio, instrucciones abajo con scroll */
.sp-terabox-main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.sp-terabox-viewer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sp-search-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--sp-border-color);
}

.sp-terabox-iframe-header {
    background: var(--sp-primary-color);
    color: #fff;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    flex-shrink: 0;
}

/* Recorte de ~50px de la cabecera propia del iframe embebido */
.sp-terabox-iframe-container {
    background: #000;
    position: relative;
    height: 320px;
    overflow: hidden;
}

.sp-terabox-iframe-container iframe {
    width: 100%;
    height: calc(100% + 50px);
    border: none;
    position: absolute;
    top: -50px;
    left: 0;
}

.sp-terabox-instructions {
    flex-shrink: 0;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #333;
    overflow-y: auto;
    max-height: 320px;
    scrollbar-width: thin;
    scrollbar-color: #ff2c2c #1a1a1a;
}

.sp-terabox-instructions::-webkit-scrollbar {
    width: 8px;
}

.sp-terabox-instructions::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
    margin: 5px 0;
}

.sp-terabox-instructions::-webkit-scrollbar-thumb {
    background: #ff2c2c;
    border-radius: 4px;
    border: 2px solid #1a1a1a;
}

.sp-terabox-instructions::-webkit-scrollbar-thumb:hover {
    background: #d82323;
}

.sp-terabox-instructions h2 {
    color: var(--sp-text-color);
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--sp-border-color);
}

.sp-terabox-step {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--sp-primary-color);
}

.sp-terabox-step-number {
    display: inline-block;
    background: var(--sp-primary-color);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    text-align: center;
    line-height: 26px;
    font-weight: 700;
    font-size: 13px;
    margin-right: 10px;
}

.sp-terabox-step h3 {
    display: inline;
    color: var(--sp-text-color);
    font-size: 15px;
}

.sp-terabox-step p {
    margin-top: 6px;
    color: var(--sp-text-light);
    font-size: 13px;
    line-height: 1.5;
}

/* ===== LAYOUT DE DOS COLUMNAS PARA ESCRITORIO ===== */
@media (min-width: 769px) {
    .sp-terabox-main-content {
        flex-direction: row !important;
        gap: 24px !important;
        align-items: stretch !important;
    }
    .sp-terabox-viewer {
        flex: 1 1 50% !important;
        max-width: 50% !important;
        min-width: 0 !important;
    }
    .sp-terabox-instructions {
        flex: 1 1 50% !important;
        max-width: 50% !important;
        min-width: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
    }
    .sp-terabox-iframe-container {
        height: 420px !important;
    }
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 1024px) {
    .sp-user-actions .sp-nav-text {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --sp-header-height: 48px;
    }

    .sp-top-bar {
        padding: 0 12px;
        height: var(--sp-header-height);
    }

    .sp-main {
        padding-top: var(--sp-header-height);
    }
    
    .sp-topbar-logo {
        height: 28px;
    }
    
    .sp-search-container {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--sp-dark-bg);
        padding: 8px 16px;
        border-bottom: 1px solid var(--sp-border-color);
        margin: 0;
        max-width: none;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    }
    
    .sp-search-container.mobile-open {
        display: flex;
    }
    
    .sp-search-box {
        height: 36px;
    }
    
    .sp-search-input {
        font-size: 16px;
        padding: 0 12px;
    }
    
    .sp-search-btn {
        padding: 0 16px;
    }
    
    .sp-voice-search-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .sp-mobile-actions {
        display: flex;
    }
    
    .sp-user-actions .sp-auth-btn,
    .sp-user-actions .sp-vip-btn,
    .sp-user-actions .sp-notification-bell,
    .sp-user-actions .sp-user-menu-btn {
        display: none;
    }

    /* El botón aleatorio ya vive en la topbar (sp-mobile-random-btn);
       no hace falta duplicarlo dentro del buscador en móvil */
    .sp-search-container .sp-random-btn {
        display: none;
    }
    
    .sp-user-actions .sp-user-menu-btn .sp-nav-text {
        display: none;
    }
    
    .sp-sidebar {
        padding-top: 0;
    }

    /* ===== OCULTAR EL HEADER DEL SIDEBAR EN MÓVIL (NO DUPLICAR) ===== */
    .sp-sidebar .sp-sidebar-header {
        display: none !important;
    }
    
    /* ===== NOTIFICACIONES EN MÓVIL: popup centrado, mismo estilo que
       la Ficha Técnica (fondo oscuro + caja centrada), en vez de un
       dropdown angosto pegado a la campanita. =====
       El "fondo oscuro" se logra con un box-shadow gigante en vez de
       agregar un elemento nuevo al HTML -- mismo resultado visual, sin
       tener que tocar la estructura ni el JS que abre/cierra esto. */
    .sp-notification-menu {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        min-width: 0;
        width: 90%;
        max-width: 400px;
        max-height: 75vh;
        transform: translate(-50%, -48%) scale(0.95);
        transform-origin: center;
        border-radius: 16px;
    }

    .sp-notification-menu.open {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75), 0 20px 60px rgba(0, 0, 0, 0.5);
    }

    .sp-user-dropdown-menu {
        min-width: 220px;
        right: -60px;
    }

    .sp-terabox-modal {
        align-items: flex-end;
        justify-content: center;
    }

    .sp-terabox-container {
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        margin: 0;
        border: none;
        border-top: 2px solid #ff2c2c;
        transform: translateY(100%);
        transition: transform .4s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 0 -10px 40px rgba(0,0,0,.5);
    }

    .sp-terabox-modal.active .sp-terabox-container {
        transform: translateY(0);
    }

    .sp-terabox-close-btn {
        top: 10px;
        right: 14px;
        width: 36px;
        height: 36px;
        font-size: 22px;
        background: rgba(0,0,0,.7);
    }

    .sp-terabox-title {
        font-size: 1.2em;
    }

    .sp-terabox-iframe-container {
        height: 260px;
    }

    .sp-terabox-instructions {
        max-height: 240px;
    }
}

@media (max-width: 480px) {
    :root {
        --sp-header-height: 44px;
    }

    .sp-top-bar {
        padding: 0 8px;
        height: var(--sp-header-height);
    }

    .sp-main {
        padding-top: var(--sp-header-height);
    }
    
    .sp-topbar-logo {
        height: 24px;
    }
    
    .sp-mobile-actions {
        gap: 0;
    }
    
    .sp-mobile-search-btn,
    .sp-mobile-random-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    /* La regla de arriba (max-width: 768px) ya deja esto como popup
       centrado -- no hace falta un ajuste aparte acá, y agregar uno
       pisaría esa centrado con position:fixed. */

    .sp-user-dropdown-menu {
        min-width: 200px;
        right: -40px;
    }

    .sp-terabox-iframe-container {
        height: 220px;
    }

    .sp-terabox-instructions {
        max-height: 200px;
        padding: 16px;
    }

    /* ===== OCULTAR EL HEADER DEL SIDEBAR EN MÓVIL (NO DUPLICAR) ===== */
    .sp-sidebar .sp-sidebar-header {
        display: none !important;
    }
}

/* ============================================
   UTILITIES
============================================ */
.sp-container {
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    flex-grow: 1;
    min-width: 0;
}

.sp-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .sp-container {
        padding: 0 12px;
    }
}

.sp-mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1003;
}

.sp-dropdown-close-btn {
    display: none;
}