:root {
    --fondo-gradiente: linear-gradient(135deg, #38bdf8 0%, #f472b6 50%, #2563eb 100%) !important;
    --bg-gradient: linear-gradient(135deg, #38bdf8 0%, #f472b6 50%, #2563eb 100%) !important;
    --texto-principal: #0f172a !important;
    --text-main: #0f172a !important;
    --text-muted: #1e293b !important;
    --tarjeta-bg: rgba(255, 255, 255, 0.16) !important;
    --card-bg: rgba(255, 255, 255, 0.16) !important;
    --tarjeta-hover: rgba(255, 255, 255, 0.25) !important;
    --card-hover-bg: rgba(255, 255, 255, 0.25) !important;
    --border-color: rgba(255, 255, 255, 0.3) !important;
    --header-bg: rgba(255, 255, 255, 0.1) !important;
    --btn-bg: rgba(255, 255, 255, 0.95) !important;
    --btn-text: #1d4ed8 !important;
    --topic-color: #bfdbfe !important;
    --ui-radius: 24px !important;
    --ui-radius-sm: 18px !important;
    --ui-shadow: 0 18px 35px rgba(0, 0, 0, 0.18) !important;
    --ui-shadow-strong: 0 16px 30px rgba(15, 23, 42, 0.22) !important;
    --ui-title: clamp(1.9rem, 3vw, 3.1rem) !important;
    --ui-subtitle: clamp(1.05rem, 1.6vw, 1.3rem) !important;
    --ui-section: clamp(1.35rem, 2vw, 2rem) !important;
    --ui-card-title: clamp(1.05rem, 1.4vw, 1.35rem) !important;
    --ui-body: clamp(0.95rem, 1vw, 1.02rem) !important;
    --ui-small: 0.95rem !important;
    --ui-space-section: clamp(1.2rem, 1.8vw, 2rem) !important;
}

body.dark-mode,
.dark-mode {
    --fondo-gradiente: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #1e1b4b 100%) !important;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #1e1b4b 100%) !important;
    --texto-principal: #e2e8f0 !important;
    --text-main: #e2e8f0 !important;
    --text-muted: #cbd5e1 !important;
    --tarjeta-bg: rgba(0, 0, 0, 0.32) !important;
    --card-bg: rgba(0, 0, 0, 0.32) !important;
    --tarjeta-hover: rgba(0, 0, 0, 0.46) !important;
    --card-hover-bg: rgba(0, 0, 0, 0.46) !important;
    --border-color: rgba(255, 255, 255, 0.12) !important;
    --header-bg: rgba(0, 0, 0, 0.36) !important;
    --btn-bg: rgba(15, 23, 42, 0.92) !important;
    --btn-text: #bfdbfe !important;
    --topic-color: #bfdbfe !important;
}

html,
body {
    background: var(--fondo-gradiente, var(--bg-gradient)) !important;
    background-attachment: fixed !important;
    color: var(--texto-principal, var(--text-main)) !important;
    font-family: 'Quicksand', sans-serif !important;
    line-height: 1.45 !important;
}

body {
    min-height: 100vh !important;
}

body:not(.dark-mode) {
    color: #0f172a !important;
}

body:not(.dark-mode) p,
body:not(.dark-mode) li,
body:not(.dark-mode) label,
body:not(.dark-mode) h1,
body:not(.dark-mode) h2,
body:not(.dark-mode) h3,
body:not(.dark-mode) h4,
body:not(.dark-mode) h5,
body:not(.dark-mode) h6,
body:not(.dark-mode) span:not(.grado-banner__title),
body:not(.dark-mode) .text-white,
body:not(.dark-mode) .text-sky-100,
body:not(.dark-mode) .text-sky-200,
body:not(.dark-mode) .text-blue-200,
body:not(.dark-mode) .text-cyan-100,
body:not(.dark-mode) .text-emerald-100,
body:not(.dark-mode) .text-lime-100,
body:not(.dark-mode) .text-pink-100,
body:not(.dark-mode) .text-pink-200 {
    color: #0f172a !important;
}

body:not(.dark-mode) .opacity-80,
body:not(.dark-mode) .opacity-90 {
    opacity: 1 !important;
}

.glass-panel,
.tema-card,
.menu-item,
.section-card,
.card-hover,
.glass-card,
.paper-box {
    background: var(--tarjeta-bg, var(--card-bg)) !important;
    border: 1px solid var(--border-color) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: var(--ui-shadow) !important;
    border-radius: var(--ui-radius) !important;
}

.tema-card:hover,
.menu-item:hover,
.section-card:hover,
.card-hover:hover,
.glass-panel:hover.card-hover {
    background: var(--tarjeta-hover, var(--card-hover-bg)) !important;
}

header.glass-panel,
header.glass-card,
header[class*="glass"] {
    background: var(--header-bg) !important;
    border-radius: calc(var(--ui-radius) + 4px) !important;
    padding: clamp(1.5rem, 2vw, 2.2rem) !important;
}

h1,
.header-text h1 {
    font-size: var(--ui-title) !important;
    line-height: 1.05 !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
}

h2,
.header-subtitle {
    font-size: var(--ui-section) !important;
    line-height: 1.12 !important;
    font-weight: 900 !important;
}

h3,
.menu-title,
.text-3xl.font-black,
.text-3xl.font-bold {
    font-size: var(--ui-card-title) !important;
    line-height: 1.18 !important;
    font-weight: 800 !important;
}

h4,
h5,
h6 {
    line-height: 1.2 !important;
}

p,
li,
label,
input,
textarea,
select,
.menu-desc,
.header-text p,
.header-text h3 {
    font-size: var(--ui-body) !important;
}

.header-text p,
.menu-desc,
.opacity-80,
.opacity-90 {
    font-weight: 700 !important;
}

.glass-panel + .glass-panel,
section + section,
header + section,
section + footer {
    margin-top: var(--ui-space-section) !important;
}

#contenido-clase,
[id^="contenido-"] {
    width: 100% !important;
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.grado-banner {
    position: relative !important;
    overflow: hidden !important;
    padding: 1.15rem 1.4rem !important;
    margin-bottom: 1.25rem !important;
    border-radius: 26px !important;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.24), transparent 38%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(191, 219, 254, 0.14), rgba(59, 130, 246, 0.18)) !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    box-shadow: var(--ui-shadow) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
}

.grado-banner::before {
    content: "" !important;
    position: absolute !important;
    inset: auto -40px -50px auto !important;
    width: 180px !important;
    height: 180px !important;
    border-radius: 999px !important;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 70%) !important;
    pointer-events: none !important;
}

.grado-banner::after {
    content: "" !important;
    position: absolute !important;
    top: -35% !important;
    left: -18% !important;
    width: 34% !important;
    height: 170% !important;
    background: linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, 0.06) 35%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.08) 65%, transparent 100%) !important;
    transform: skewX(-22deg) !important;
    animation: brillo-grado 4.8s ease-in-out infinite !important;
    pointer-events: none !important;
}

.grado-banner__title {
    margin: 0 !important;
    display: inline-block !important;
    position: relative !important;
    z-index: 1 !important;
    font-size: clamp(2.2rem, 7vw, 5rem) !important;
    font-weight: 900 !important;
    line-height: 0.95 !important;
    letter-spacing: -0.04em !important;
    text-transform: uppercase !important;
    text-shadow: 0 10px 30px rgba(15, 23, 42, 0.28) !important;
    background: linear-gradient(90deg, #67e8f9 0%, #60a5fa 35%, #2563eb 62%, #f472b6 100%) !important;
    background-size: 220% 100% !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    filter: drop-shadow(0 0 12px rgba(96, 165, 250, 0.22)) !important;
    transform-origin: left center !important;
    will-change: transform, filter, background-position !important;
    animation: texto-grado-flota 2.8s ease-in-out infinite, texto-grado-color 5s linear infinite !important;
}

body.dark-mode .grado-banner,
.dark-mode .grado-banner {
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, 0.18), transparent 38%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.78), rgba(30, 41, 59, 0.7), rgba(49, 46, 129, 0.72)) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

@media (max-width: 640px) {
    .grado-banner {
        padding: 1rem 1.1rem !important;
    }
}

@keyframes brillo-grado {
    0% {
        transform: translateX(-120%) skewX(-22deg) !important;
        opacity: 0 !important;
    }
    12% {
        opacity: 0.9 !important;
    }
    32% {
        transform: translateX(340%) skewX(-22deg) !important;
        opacity: 0 !important;
    }
    100% {
        transform: translateX(340%) skewX(-22deg) !important;
        opacity: 0 !important;
    }
}

@keyframes texto-grado-flota {
    0% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg) !important;
        filter: drop-shadow(0 0 12px rgba(96, 165, 250, 0.22)) !important;
    }
    25% {
        transform: translate3d(6px, -4px, 0) scale(1.02) rotate(-1deg) !important;
        filter: drop-shadow(0 0 18px rgba(96, 165, 250, 0.32)) !important;
    }
    50% {
        transform: translate3d(0, -2px, 0) scale(1.035) rotate(0deg) !important;
        filter: drop-shadow(0 0 18px rgba(244, 114, 182, 0.28)) !important;
    }
    75% {
        transform: translate3d(-6px, -4px, 0) scale(1.02) rotate(1deg) !important;
        filter: drop-shadow(0 0 18px rgba(37, 99, 235, 0.3)) !important;
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg) !important;
        filter: drop-shadow(0 0 12px rgba(96, 165, 250, 0.22)) !important;
    }
}

@keyframes texto-grado-color {
    0% {
        background-position: 0% 50% !important;
    }
    100% {
        background-position: 100% 50% !important;
    }
}

.cartel-bienvenida {
    width: min(84vw, 520px) !important;
    border-radius: 28px !important;
    padding: clamp(1.8rem, 3vw, 2.5rem) !important;
}

.cartel-bienvenida h1 {
    margin-bottom: 0.5rem !important;
}

.tema-card {
    border-radius: 24px !important;
}

.tema-card h4,
.tema-card h3 {
    margin-top: 0.25rem !important;
    margin-bottom: 0 !important;
}

.tema-card p {
    margin-top: 0.45rem !important;
}

.grid .tema-card {
    min-height: 160px !important;
}

.grid.sm\:grid-cols-3 .tema-card,
.grid[class*="sm:grid-cols-3"] .tema-card,
.grid[class*="lg:grid-cols-3"] .tema-card {
    min-height: 180px !important;
}

.borde-t1,
.borde-t2,
.borde-t3 {
    padding-bottom: 0.5rem !important;
    margin-bottom: 1.25rem !important;
}

footer {
    opacity: 0.75 !important;
    text-align: center !important;
}

button,
.btn-interactivo,
.btn-volver,
a[class*="bg-white"],
a[class*="rounded"],
a[class*="px-"],
.menu-item,
.tema-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease !important;
}

button:not(.theme-toggle):not(.accessibility-toggle),
.btn-interactivo,
.btn-volver,
.unified-back-button,
a.unified-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    min-height: 52px !important;
    padding: 0.9rem 1.4rem !important;
    border-radius: 18px !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #1d4ed8 !important;
    font-size: 1rem !important;
    font-weight: 900 !important;
    text-decoration: none !important;
    box-shadow: var(--ui-shadow-strong) !important;
    width: auto !important;
}

body.dark-mode button:not(.theme-toggle):not(.accessibility-toggle),
body.dark-mode .btn-interactivo,
body.dark-mode .btn-volver,
body.dark-mode .unified-back-button,
body.dark-mode a.unified-button {
    background: rgba(15, 23, 42, 0.9) !important;
    color: #dbeafe !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

button:not(.theme-toggle):not(.accessibility-toggle):hover,
.btn-interactivo:hover,
.btn-volver:hover,
.unified-back-button:hover,
a.unified-button:hover {
    transform: translateY(-2px) scale(1.01) !important;
}

.unified-back-button {
    min-width: 180px !important;
}

header a.unified-back-button,
header .btn-volver,
header a[href*="index"],
header a[href*="submenu"],
header a[href*="tema"] {
    align-self: center !important;
    white-space: nowrap !important;
}

.win-close {
    min-height: unset !important;
    min-width: unset !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: inherit !important;
    border: none !important;
}

.theme-toggle,
.accessibility-toggle {
    position: fixed !important;
    right: 20px !important;
    z-index: 4000 !important;
    cursor: pointer !important;
    min-width: 180px !important;
    min-height: 46px !important;
    padding: 12px 18px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    font-family: 'Quicksand', sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 900 !important;
    letter-spacing: 0.02em !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18) !important;
    transition: transform 0.2s ease, background 0.2s ease !important;
}

.theme-toggle,
.accessibility-toggle {
    text-transform: none !important;
}

.theme-toggle {
    top: 20px !important;
}

.accessibility-toggle {
    top: 78px !important;
}

.theme-toggle:hover,
.accessibility-toggle:hover {
    transform: translateY(-2px) scale(1.02) !important;
    background: rgba(255, 255, 255, 0.3) !important;
}

body.dark-mode .theme-toggle,
body.dark-mode .accessibility-toggle {
    background: rgba(15, 23, 42, 0.75) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

body.text-uppercase,
body.text-uppercase p,
body.text-uppercase h1,
body.text-uppercase h2,
body.text-uppercase h3,
body.text-uppercase h4,
body.text-uppercase h5,
body.text-uppercase h6,
body.text-uppercase a,
body.text-uppercase button,
body.text-uppercase span,
body.text-uppercase li,
body.text-uppercase label,
body.text-uppercase div {
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
}

body.text-uppercase input,
body.text-uppercase textarea {
    text-transform: none !important;
}

@media (max-width: 640px) {
    h1,
    .header-text h1 {
        padding-right: 0.5rem !important;
    }

    .theme-toggle,
    .accessibility-toggle {
        min-width: 150px !important;
        right: 12px !important;
        font-size: 0.8rem !important;
        padding: 10px 14px !important;
    }

    .theme-toggle {
        top: 12px !important;
    }

    .accessibility-toggle {
        top: 62px !important;
    }

    header a.unified-back-button,
    header .btn-volver,
    header a[href*="index"],
    header a[href*="submenu"],
    header a[href*="tema"] {
        width: 100% !important;
    }
}
