:root {
    --bg-main: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --accent-color: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.15);
    --border-light: rgba(0, 0, 0, 0.08);
    --nav-height: 80px;
    --content-width: 850px;
    --nav-bg: rgba(255, 255, 255, 0.75);
    --radial-start: rgba(37, 99, 235, 0.03);
    --nav-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    --focus-bg-paper: #fcfcf9; /* Tono cálido tipo papel libro */
}

:root.dark-mode {
    --bg-main: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --accent-color: #60a5fa;
    --accent-glow: rgba(96, 165, 250, 0.15);
    --border-light: rgba(255, 255, 255, 0.1);
    --nav-bg: rgba(17, 24, 39, 0.85);
    --radial-start: rgba(96, 165, 250, 0.03);
    --nav-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
    --focus-bg-paper: #111827;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    font-size: 21px;
    line-height: 1.7;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: background-color 0.3s ease, color 0.3s ease;
    
    /* --- ANTI-COPY SHIELD --- */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

img {
    pointer-events: none; /* Prevents dragging images */
}

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 0%, var(--radial-start) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* Glassmorphic Navbar */
.academic-nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--nav-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5vw;
    z-index: 100;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.academic-nav .nav-brand {
    flex: 1;
    order: 1;
    line-height: 1.2;
    max-width: max-content;
    white-space: nowrap;
    font-family: 'Crimson Text', Georgia, serif;
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -0.2px;
    text-transform: none;
    color: var(--text-primary);
}

/* Nav Controls */
.nav-controls {
    flex: 1;
    order: 3;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}

/* Language Selector */
.lang-selector {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Lato', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}



.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover {
    border-color: var(--text-primary);
}

.lang-btn.active {
    background: var(--text-primary);
    color: var(--bg-main);
    border-color: var(--text-primary);
}

.nav-links {
    flex: 2;
    order: 2;
    justify-content: center;
    list-style: none;
    display: flex;
    gap: 3vw; /* Responsive gap */
    align-items: center;
    height: 100%;
    margin: 0;
    padding: 0;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    padding: 10px 0;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.nav-links li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
}

.nav-links li a:hover,
.nav-links li a.active {
    color: var(--text-primary);
}

.nav-links li a:hover::after,
.nav-links li a.active::after {
    width: 100%;
}

.site-wrapper {
    padding-top: calc(var(--nav-height) + 80px);
    padding-bottom: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page-section {
    display: none;
    width: 100%;
    max-width: var(--content-width);
    padding: 0 24px;
    box-sizing: border-box;
    overflow-x: hidden;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.page-section.active {
    display: block;
}

.lang-section {
    display: none;
}

.lang-section.active {
    display: block;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes slideUpFade {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Spectacular Title Block */
.title-block {
    text-align: center;
    margin-bottom: 80px;
    position: relative;
}

.title-block .date {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 3px;
    display: inline-block;
    padding: 6px 16px;
    background: var(--accent-glow);
    border-radius: 30px;
}

.title-block .paper-title {
    font-family: 'Crimson Text', serif;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 30px;
    color: var(--text-primary);
    background: linear-gradient(135deg, #111827 0%, #374151 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

:root.dark-mode .title-block .paper-title {
    background: linear-gradient(135deg, #f9fafb 0%, #9ca3af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.title-block .author-block {
    margin-bottom: 20px;
}

.title-block .author {
    font-family: 'Crimson Text', serif;
    font-size: 24px;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.title-block .affiliation {
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    color: var(--text-gray);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.title-block .author-links {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.title-block .author-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.title-block .social-links-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.title-block .orcid-link {
    color: #a6ce39; /* ORCID green */
}

.title-block .email-link,
.title-block .twitter-link {
    color: var(--text-secondary);
}

.title-block .author-link:hover {
    opacity: 0.8;
}

.title-block .link-icon {
    width: 16px;
    height: 16px;
}

.title-block .link-separator {
    color: var(--border-light);
    font-size: 12px;
}

.title-block .publication-badge {
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-color);
    background: var(--accent-glow);
    display: inline-block;
    padding: 8px 20px;
    border-radius: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.title-block .publication-badge a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.title-block .publication-badge a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Beautiful Content Formatting */
.content-body {
    text-align: justify;
    hyphens: auto;
}

.text-section {
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.text-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.text-section h2 {
    font-family: 'Crimson Text', serif;
    font-size: calc(18px * var(--font-scale)) !important;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 25px;
    color: #4A90E2;
    display: flex;
    align-items: center;
    line-height: 1.2;
}

:root.dark-mode .text-section h2 {
    color: var(--accent-color);
}

.text-section h2::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-light) 0%, rgba(255,255,255,0) 100%);
    margin-left: 20px;
}

.text-section p {
    margin-bottom: 25px;
    color: #374151;
}

:root.dark-mode .text-section p {
    color: var(--text-secondary);
}

/* Spectacular Math Containers */
.MathJax_Display, 
div[style*="text-align: center"] {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03), inset 0 1px 0 rgba(255,255,255,1);
    border: 1px solid var(--border-light);
    margin: 40px 0 !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.MathJax_Display:hover,
div[style*="text-align: center"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,1);
}

:root.dark-mode .MathJax_Display, 
:root.dark-mode div[style*="text-align: center"] {
    box-shadow: 0 10px 30px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}

:root.dark-mode .MathJax_Display:hover,
:root.dark-mode div[style*="text-align: center"]:hover {
    box-shadow: 0 15px 35px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Premium Figures */
.paper-figure {
    margin: 80px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.paper-figure.visible {
    opacity: 1;
    transform: translateY(0);
}

.img-wrapper {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,1);
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

:root.dark-mode .img-wrapper {
    background: #ffffff;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2), inset 0 1px 0 rgba(0,0,0,0.05);
}

.img-wrapper:hover {
    transform: scale(1.02);
}

.paper-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    mix-blend-mode: multiply;
}

.paper-figure figcaption {
    margin-top: 25px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: justify;
    padding: 0 20px;
    font-family: 'Lato', sans-serif;
}

.paper-figure figcaption strong {
    color: var(--accent-color);
    font-weight: 700;
}

.hero-figure {
    max-width: 1240px;
    margin-left: auto;
    margin-right: auto;
}

.hero-figure .img-wrapper {
    padding: 28px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(255, 255, 255, 1) 100%);
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.95);
}

:root.dark-mode .hero-figure .img-wrapper {
    background: #ffffff;
    box-shadow:
        0 18px 40px rgba(0,0,0,0.24),
        inset 0 1px 0 rgba(255,255,255,0.06);
}

.hero-figure img {
    width: 100%;
    max-width: 1160px;
    border-radius: 14px;
    mix-blend-mode: normal;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.hero-figure figcaption {
    max-width: 980px;
    margin-top: 22px;
    padding: 0;
    text-align: center;
    font-size: 15px;
    line-height: 1.72;
    color: #526477;
}

:root.dark-mode .hero-figure figcaption {
    color: #b5c1cf;
}

@media (max-width: 900px) {
    .hero-figure .img-wrapper {
        padding: 18px;
        border-radius: 18px;
    }

    .hero-figure figcaption {
        font-size: 14px;
        line-height: 1.65;
    }
}

/* Stunning Modern Tables */
table {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0;
    background: var(--bg-main);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    border: 1px solid var(--border-light);
}

:root.dark-mode table {
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

thead tr {
    background: var(--bg-secondary);
}

th {
    padding: 18px 20px !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light) !important;
}

td {
    padding: 18px 20px !important;
    border-bottom: 1px solid var(--border-light) !important;
    font-size: 14px;
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none !important;
}

tr:hover td {
    background: rgba(37, 99, 235, 0.02);
}

/* Bullet points styling */
.text-section ul {
    padding-left: 20px;
}

.text-section ul li {
    position: relative;
    margin-bottom: 15px;
    padding-left: 15px;
    list-style: none;
}

.text-section ul li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-size: 24px;
    line-height: 1;
    top: -2px;
}

/* Simple Explanation Boxes */
.simple-explanation {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.01) 100%);
    border-left: 4px solid var(--accent-color);
    padding: 20px 25px;
    margin: 30px 0 40px 0;
    border-radius: 0 12px 12px 0;
    font-family: 'Lato', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.simple-explanation strong {
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 8px;
}

.placeholder-text {
    font-style: italic;
    text-align: center;
    color: var(--text-gray);
    text-indent: 0 !important;
}

/* About Section */
.about-section {
    display: block; /* Permite que el texto rodee a la imagen flotante */
}

.profile-container {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--bg-main);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    position: relative;
    background: var(--bg-secondary);
    float: left; /* Flota a la izquierda para que el texto la rodee */
    margin-right: 30px;
    margin-bottom: 15px;
}

.about-text {
    display: block; /* Permite el flujo continuo del texto alrededor */
}

/* Footer Section */
.site-footer {
    margin-top: 60px;
    background: transparent;
    border-top: 1px solid var(--border-light);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.footer-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.footer-links {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-content p {
    margin: 5px 0;
    font-size: 13px;
    color: var(--text-gray);
    letter-spacing: 0.5px;
}

/* Info Section Resources */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.resource-card {
    border: 1px solid var(--border-light);
    padding: 30px 20px;
    border-radius: 12px;
    text-align: center;
    background: var(--bg-secondary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.resource-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

button.resource-link {
    width: 100%;
    appearance: none;
    background: var(--bg-secondary);
    font: inherit;
}

.resource-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border-color: var(--accent-color);
}

.resource-card h3 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-family: 'Lato', sans-serif;
}

.resource-card p {
    font-size: 14px;
    color: var(--text-gray);
    margin: 0;
}

.simulator-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    margin-top: 20px;
}

.simulator-controls,
.simulator-chart-card,
.insight-card {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-secondary);
}

.simulator-controls {
    padding: 24px;
}

.slider-group + .slider-group {
    margin-top: 22px;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
}

.slider-label-row span {
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
}

.simulator-controls input[type="range"] {
    width: 100%;
    accent-color: var(--accent-color);
}

.simulator-notes {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-light);
}

.simulator-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    color: var(--text-secondary);
}

.simulator-swatch {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-block;
}

.simulator-swatch-gr {
    background: #94a3b8;
}

.simulator-swatch-kernel {
    background: var(--accent-color);
}

.simulator-notes p {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--text-gray);
}

.simulator-chart-card {
    padding: 18px;
    min-height: 420px;
}

#kernel-simulator-chart {
    width: 100%;
    height: 100%;
    display: block;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.insight-card {
    padding: 28px;
}

.insight-kicker {
    margin-bottom: 12px;
    color: var(--accent-color);
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.insight-card h2 {
    margin: 0 0 14px;
    font-size: 28px;
}

.analogy-card p,
.timeline-card p {
    color: var(--text-secondary);
}

.timeline-flow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.timeline-step {
    position: relative;
    padding: 18px 16px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-main);
}

.timeline-step h3 {
    margin: 12px 0 10px;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    color: var(--text-primary);
}

.timeline-step p {
    margin: 0;
    font-size: 14px;
}

.timeline-badge {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-glow);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-family: 'Lato', sans-serif;
    font-weight: 700;
}

.cta-button:hover {
    background-color: var(--text-primary) !important;
    transform: translateY(-2px);
}

.download-btn {
    display: inline-block;
    background-color: var(--accent-glow);
    color: var(--accent-color) !important;
    border: 1px solid var(--accent-color);
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Lato', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
}

.download-btn:hover {
    transform: translateY(-2px);
    background-color: var(--accent-color);
    color: var(--bg-main) !important;
}

.profile-pic {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.profile-container:hover .profile-pic {
    transform: scale(1.05);
}

/* ==========================================================================
   Responsive Design (Mobile Devices)
   ========================================================================== */
@media (max-width: 768px) {
    .academic-nav {
        flex-direction: column;
        padding: 15px;
        height: auto;
        gap: 15px;
        position: relative; /* Unfix on mobile for better scrolling */
    }

    .academic-nav .nav-brand {
        position: static;
        transform: none;
        text-align: center;
        margin-bottom: 5px;
        flex: none;
        max-width: none;
    }

    .nav-controls {
        position: static;
        transform: none;
        justify-content: center;
        margin-bottom: 5px;
        flex: none;
        width: 100%;
    }
    
    .nav-links {
        position: static;
        transform: none;
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
        padding-bottom: 5px;
        flex: none;
    }

    .site-wrapper {
        padding-top: 40px;
        padding-bottom: 60px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        display: block; /* Remove flex and align-items center on mobile */
    }

    #router-view {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .page-section {
        padding: 0 15px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .content-body {
        padding: 20px 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .img-wrapper {
        padding: 10px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        display: block;
        text-align: center;
    }

    figure, .paper-figure {
        width: 100%;
        max-width: 100vw;
        margin-left: 0;
        margin-right: 0;
        box-sizing: border-box;
    }

    .title-block {
        padding: 20px 15px 15px;
    }

    .title-block .paper-title {
        font-size: 24px;
        line-height: 1.3;
    }

    .title-block .author-name {
        font-size: 16px;
    }

    .title-block .social-links-row {
        flex-direction: column;
        gap: 8px;
    }

    .title-block .link-separator {
        display: none;
    }

    .about-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 25px;
    }

    .about-image {
        flex: 0 0 auto;
        margin: 0 auto;
    }

    .math-block {
        padding: 15px 10px;
        overflow-x: auto;
        font-size: 13px; /* Slightly smaller math on mobile */
        -webkit-overflow-scrolling: touch;
    }

    .equation-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .simple-explanation {
        padding: 15px;
    }

    .resource-grid {
        grid-template-columns: 1fr;
    }

    .simulator-shell,
    .insight-grid,
    .timeline-flow {
        grid-template-columns: 1fr;
    }

    .simulator-chart-card {
        min-height: 320px;
    }

    .content-modal-overlay {
        padding: 16px 10px;
    }

    .content-modal-body {
        padding: 20px 16px;
    }

    .tech-note-grid {
        grid-template-columns: 1fr;
    }

    body {
        font-size: 18px; /* Slightly smaller base font for mobile */
    }
}

/* --- RECENT ADDITIONS --- */

/* Inline Links */
.inline-link {
    color: var(--accent-color);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: color 0.3s ease;
    cursor: pointer;
    user-select: text;
    -webkit-user-select: text;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.inline-link:hover {
    color: var(--text-primary);
}

/* Reading Progress Bar */
.reading-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    z-index: 1000;
}

.reading-progress-bar {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.1s ease-out;
}

/* Scroll Reveal Animations */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* CTA Button */
.cta-button {
    display: inline-block;
    background-color: transparent;
    color: var(--text-primary);
    padding: 12px 24px;
    border: 2px solid var(--accent-color);
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.1);
}

.cta-button:hover, .cta-button:active {
    background-color: var(--accent-color);
    color: #ffffff;
}

:root.dark-mode .cta-button:hover,
:root.dark-mode .cta-button:active {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

/* Audio Transcript Styles */
.transcript-toggle-btn {
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
    width: 100%;
    font-family: 'Lato', sans-serif;
}

.transcript-toggle-btn:hover {
    background: var(--accent-color);
    color: #ffffff;
}

.transcript-box {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out, margin 0.5s ease-in-out;
    background: var(--bg-main);
    border-radius: 12px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    text-align: left;
}

.transcript-box.active {
    max-height: 300px;
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border-light);
    overflow-y: auto;
}

/* Karaoke Styles */
.karaoke-cue {
    display: inline;
    margin-right: 4px;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.karaoke-cue.active-cue {
    color: var(--accent-color);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(74, 144, 226, 0.4);
}

/* Subtitle Container Styles */
.subtitle-container {
    min-height: 50px;
    margin: 15px 0;
    padding: 15px;
    background: var(--bg-main);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.4;
    text-align: center;
    transition: opacity 0.2s ease-in-out;
    opacity: 0;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Accordion Styles for Validation Protocol */
.accordion {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.accordion-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.accordion-item[open] {
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    border-color: var(--accent-color);
}

.accordion-item summary {
    padding: 20px 24px;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s ease;
}

.accordion-item summary::-webkit-details-marker {
    display: none;
}

.accordion-item summary::after {
    content: '→';
    font-size: 18px;
    color: var(--accent-color);
    transition: transform 0.3s ease;
    display: inline-block;
    margin-left: auto;
}

.accordion-item[open] summary::after {
    transform: rotate(90deg);
}

.accordion-item summary:hover {
    background-color: rgba(37, 99, 235, 0.04);
}

.accordion-content {
    padding: 24px;
    border-top: 1px solid var(--border-light);
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-secondary);
    background-color: var(--bg-main);
    font-family: 'Crimson Text', serif;
    text-align: justify;
}

.accordion-content h3,
.accordion-content h4 {
    font-family: 'Lato', sans-serif;
    color: var(--text-primary);
    margin-top: 25px;
    margin-bottom: 12px;
}

.accordion-content h3 {
    font-size: 18px;
    font-weight: 700;
}

.accordion-content h4 {
    font-size: 16px;
    font-weight: 600;
}

.accordion-content p {
    margin-bottom: 15px;
}

.accordion-content table {
    margin: 25px 0;
    width: 100%;
}

/* Modal / Lightbox */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.modal-overlay.active {
    display: flex;
}

.modal-content-wrapper {
    max-width: 90vw;
    max-height: 90vh;
}

.modal-content-wrapper img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-close {
    position: fixed;
    top: 20px; right: 30px;
    font-size: 36px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    z-index: 10000;
    transition: color 0.2s ease, transform 0.2s ease;
}

.modal-close:hover {
    color: #fff;
    transform: scale(1.1);
}

.content-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    z-index: 10000;
    padding: 32px 18px;
    overflow-y: auto;
}

.content-modal-overlay.active {
    display: block;
}

.content-modal-card {
    position: relative;
    max-width: 1120px;
    margin: 0 auto;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}

.content-modal-body {
    padding: 28px;
}

.content-modal-close {
    position: sticky;
    top: 10px;
    float: right;
    margin: 12px 12px 0 0;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.content-modal-close:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin: 8px 0 24px;
}

.modal-switch-button {
    cursor: pointer;
}

.tech-note-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.tech-note-block {
    padding: 18px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.tech-note-block h3 {
    margin-bottom: 10px;
    font-size: 18px;
    font-family: 'Lato', sans-serif;
}

.tech-note-block p:last-child {
    margin-bottom: 0;
}

.derivation-formula-shell {
    margin-bottom: 26px;
}

.derivation-formula-label {
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--accent-color);
}

.derivation-formula {
    text-align: center;
}

.route-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
}

.route-tab {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.route-tab:hover {
    color: var(--text-primary);
}

.route-tab.active {
    background: var(--bg-main);
    color: var(--accent-color);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.route-panel {
    display: none;
}

.route-panel.active {
    display: block;
}

.route-formula-caption {
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: var(--accent-color);
}

.route-formula-block {
    text-align: center;
    margin-bottom: 18px;
}

.route-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.route-step-card {
    min-height: 100%;
    padding: 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
}

.route-step-number {
    width: 28px;
    height: 28px;
    margin-bottom: 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-glow);
    color: var(--accent-color);
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 800;
}

.route-step-card h3 {
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
    font-size: 17px;
    line-height: 1.3;
    color: var(--text-primary);
}

.route-step-card p {
    margin-bottom: 0;
}

.step-formula {
    margin-top: 14px;
    text-align: center;
    overflow-x: auto;
    overflow-y: hidden;
}

.step-formula .MathJax_Display,
.step-formula div[style*="text-align: center"] {
    margin: 10px 0 !important;
    padding: 12px 10px;
    border-radius: 10px;
    font-size: 0.82em;
}

.route-step-card .MathJax,
.route-step-card .mjx-chtml {
    font-size: 0.9em !important;
}

.route-step-card .step-formula .MathJax_Display + .MathJax_Display {
    margin-top: 6px !important;
}

.derivation-takeaway {
    margin-top: 24px;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
}

@media (max-width: 800px) {
    .route-grid {
        grid-template-columns: 1fr;
    }

    .route-tabs {
        display: flex;
        width: 100%;
    }

    .route-tab {
        flex: 1 1 220px;
    }
}

/* Text Size Accessibility Controls */
.text-size-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.font-size-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-family: 'Lato', sans-serif;
}

.font-size-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background-color: rgba(37, 99, 235, 0.05);
}

/* Typography Scale Overrides */
:root {
    --font-scale: 1.0;
}

body, html {
    font-size: calc(21px * var(--font-scale)) !important;
}
.paper-title {
    font-size: calc(32px * var(--font-scale)) !important;
}
h2 {
    font-size: calc(24px * var(--font-scale)) !important;
}
.placeholder-text {
    font-size: calc(16px * var(--font-scale)) !important;
}
td, th {
    font-size: calc(15px * var(--font-scale)) !important;
}
.resource-card p {
    font-size: calc(14px * var(--font-scale)) !important;
}
.resource-card h3 {
    font-size: calc(17px * var(--font-scale)) !important;
}
.simple-explanation {
    font-size: calc(15px * var(--font-scale)) !important;
}
.nav-links li a {
    font-size: calc(13px * var(--font-scale)) !important;
}

/* --- PREMIUM FOCUS MODE & SELECTORS & MATH ANIMATIONS --- */

/* Focus Toggle Button */
.focus-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.focus-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.02);
}
:root.dark-mode .focus-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Exit Focus Button */
.focus-exit-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1100;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 30px;
    padding: 8px 18px;
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: none;
    align-items: center;
    gap: 6px;
}
.focus-exit-btn:hover {
    transform: translateY(-2px);
    border-color: var(--text-secondary);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
body.focus-mode .focus-exit-btn {
    display: flex;
}

/* Focus Mode Layout Overrides (Digital Physical Paper Layout) */
body.focus-mode {
    background-color: var(--focus-bg-paper) !important;
    transition: background-color 0.5s ease;
}
body.focus-mode::before {
    display: none; /* Quita el gradiente de fondo */
}
body.focus-mode .academic-nav {
    transform: translateY(-100%);
    pointer-events: none;
}
body.focus-mode .site-footer,
body.focus-mode .next-section-cta,
body.focus-mode .resource-grid,
body.focus-mode .accordion,
body.focus-mode .placeholder-text,
body.focus-mode h2[data-i18n="explore_title"],
body.focus-mode h2[data-i18n="val_protocol_title"] {
    display: none !important; /* Oculta elementos secundarios y recursos */
}
body.focus-mode .site-wrapper {
    padding-top: 40px;
}
body.focus-mode .content-body {
    max-width: 760px;
    margin: 0 auto;
    padding: 60px 40px;
    background: var(--bg-main);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-light);
    transition: all 0.5s ease;
}
:root.dark-mode body.focus-mode .content-body {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
body.focus-mode .text-section {
    margin-bottom: 50px;
    line-height: 1.85;
}
body.focus-mode p {
    font-size: calc(20px * var(--font-scale)) !important; /* Estilo papel de lectura */
    color: var(--text-primary);
}

/* Scroll Reveal animations for Ecuaciones Matemáticas */
.math-equation-block.reveal-on-scroll {
    opacity: 0;
    transform: scale(0.97) translateY(25px);
    filter: blur(5px);
    transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 1.2s cubic-bezier(0.16, 1, 0.3, 1),
                filter 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.math-equation-block.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
}

/* Simulator Class Tabs Selector styles */
.simulator-selector-group {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.selector-label {
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.class-selector-tabs {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}
.class-selector-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.class-selector-tab:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.02);
}
:root.dark-mode .class-selector-tab:hover {
    background: rgba(255, 255, 255, 0.02);
}
.class-selector-tab.active {
    background: var(--bg-main);
    color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
:root.dark-mode .class-selector-tab.active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Progress Milestones Styles
   ========================================================================== */
.progress-milestones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.progress-milestone {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    background: var(--bg-main);
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0;
}

.progress-milestone:hover {
    transform: translate(-50%, -50%) scale(1.35);
    border-color: var(--accent-color);
}

.progress-milestone.active {
    border-color: var(--accent-color);
    background: var(--accent-color);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
}

:root.dark-mode .progress-milestone.active {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

/* ==========================================================================
   Interactive Variables & Tooltips
   ========================================================================== */
.interactive-variable {
    border-bottom: 1px dotted var(--accent-color);
    cursor: help;
    transition: color 0.2s, border-bottom-color 0.2s;
    position: relative;
    padding-bottom: 1px;
}

.interactive-variable:hover {
    color: var(--accent-color);
    border-bottom-style: dashed;
}

.variable-tooltip {
    position: absolute;
    z-index: 2000;
    display: none;
    opacity: 0;
    pointer-events: none;
    width: 220px;
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(10px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #1e293b;
}

:root.dark-mode .variable-tooltip {
    border-color: rgba(63, 63, 70, 0.8);
    background: rgba(24, 24, 27, 0.85);
    color: #f4f4f5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.variable-tooltip.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.variable-tooltip h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-color);
}

.variable-tooltip p {
    margin: 0 0 10px 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.35;
}

.variable-tooltip canvas {
    display: block;
    width: 160px;
    height: 80px;
    margin: 0 auto;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.03);
}

:root.dark-mode .variable-tooltip canvas {
    background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   Complex Equations Scroll Animation
   ========================================================================== */
.math-equation-block.reveal-on-scroll {
    transform: translateY(40px) scale(0.98);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.math-equation-block.reveal-on-scroll.is-visible {
    transform: translateY(0) scale(1);
}
