:root {
    color-scheme: light;
    font-size: 16px;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: rgba(255, 255, 255, 0.98);
    --border: rgba(52, 152, 219, 0.18);
    --accent: #2e70d1;
    --text: #243248;
    --muted: #6d7c91;
    --background: #edf3fb;
    --shadow: 0 24px 80px rgba(47, 70, 103, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: radial-gradient(circle at top, #eef6ff 0%, #f4f8fc 40%, #f9fbff 100%);
    margin: 0;
    padding: 0;
}

body.page-loaded .container {
    opacity: 1;
    transform: translateY(0);
}

.container {
    max-width: 1140px;
    margin: 24px auto;
    padding: 26px;
    background: var(--surface);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 28px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.page-header.simple {
    justify-content: center;
}

.page-header img {
    width: 240px;
    border-radius: 24px;
    object-fit: cover;
    box-shadow: 0 28px 80px rgba(30, 66, 124, 0.14);
}

.header-content {
    max-width: 640px;
    text-align: center;
}

.hero-title {
    font-size: clamp(2.8rem, 4vw, 4.1rem);
    margin: 0 0 16px;
    letter-spacing: -0.05em;
    color: #1c2b44;
    line-height: 1.02;
    text-shadow: 0 10px 28px rgba(46, 112, 209, 0.15);
}

.intro-text {
    font-size: 1.05rem;
    color: var(--muted);
    margin: 0;
}

.chapter-card,
.iframe-card {
    background: linear-gradient(180deg, #ffffff, #f5f9ff);
    padding: 28px 28px 20px;
    border-radius: 28px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 45px rgba(46, 112, 209, 0.08);
    margin: 0 auto 28px;
    max-width: 820px;
    width: min(100%, 820px);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chapter-card h2,
.iframe-card h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.9rem;
    color: #1f3854;
}

.chapter-card .section-note,
.iframe-card .section-note {
    margin: 0 auto 22px;
    max-width: 700px;
    text-align: center;
}

.section-note {
    color: var(--muted);
    font-size: 1rem;
    margin-bottom: 22px;
}

iframe {
    width: min(100%, 760px);
    height: 840px;
    border: 1px solid rgba(60, 104, 186, 0.16);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(44, 94, 172, 0.08);
    margin: 0 auto;
    display: block;
    background-color: #fff;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

iframe::-webkit-scrollbar {
    display: none;
}

nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 30px;
    padding: 24px 0 0;
    border-top: 1px solid rgba(60, 104, 186, 0.12);
}

nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    padding: 12px 22px;
    background-color: #2e70d1;
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    transition: transform 0.2s ease, background-color 0.25s ease;
    font-weight: 600;
}

nav a:hover,
nav a:focus-visible {
    background-color: #2358a5;
    transform: translateY(-1px);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #2e70d1;
    border: 1px solid rgba(46, 112, 209, 0.16);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    background-color: rgba(46, 112, 209, 0.16);
    transform: translateY(-1px);
}

.theme-toggle.fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    min-width: 140px;
    box-shadow: 0 20px 45px rgba(46, 112, 209, 0.18);
    backdrop-filter: blur(12px);
}

body.dark-mode .theme-toggle.fixed {
    background-color: rgba(15, 23, 42, 0.92);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.3);
}

@media (max-width: 700px) {
    .theme-toggle.fixed {
        top: auto;
        right: auto;
        bottom: 20px;
        left: 20px;
        transform: none;
        min-width: auto;
        width: auto;
        padding: 8px 12px;
    }
}

.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 22px;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    background-color: #2e70d1;
    color: white;
    font-weight: 600;
    box-shadow: 0 22px 42px rgba(46, 112, 209, 0.26);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-4px);
}

body.dark-mode {
    background: #0f172a;
    color: #e2e8f0;
}

body.dark-mode .container {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35);
}

body.dark-mode .page-header img {
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.35);
}

body.dark-mode .hero-title,
body.dark-mode h1,
body.dark-mode h2 {
    color: #f8fafc;
}

body.dark-mode .intro-text,
body.dark-mode .section-note,
body.dark-mode p {
    color: #cbd5e1;
}

body.dark-mode .iframe-card,
body.dark-mode .chapter-card {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(96, 165, 250, 0.16);
}

body.dark-mode iframe {
    border-color: rgba(148, 163, 184, 0.24);
    background-color: #111827;
}

body.dark-mode nav {
    border-top-color: rgba(148, 163, 184, 0.18);
}

body.dark-mode nav a {
    background-color: #60a5fa;
    color: #0f172a;
}

body.dark-mode nav a:hover,
body.dark-mode nav a:focus-visible {
    background-color: #3b82f6;
}

body.dark-mode .theme-toggle {
    background-color: rgba(148, 163, 184, 0.12);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.3);
}

body.dark-mode .back-to-top {
    background-color: #60a5fa;
}

/* Media Queries para Responsividade */

/* Tablets e telas menores */
@media (max-width: 980px) {
    .container {
        margin: 16px auto;
        padding: 20px;
    }

    .page-header img {
        width: 200px;
    }

    .hero-title {
        font-size: 3rem;
    }

    .chapter-card,
    .iframe-card {
        padding: 24px 20px 16px;
        margin-bottom: 24px;
    }

    .chapter-card h2,
    .iframe-card h2 {
        font-size: 1.7rem;
    }

    iframe {
        height: 700px;
        width: 100%;
    }

    nav {
        margin-top: 24px;
        padding-top: 20px;
    }

    nav a {
        min-width: 140px;
        padding: 10px 20px;
    }
}

/* Mobile grande */
@media (max-width: 700px) {
    .container {
        margin: 12px auto;
        padding: 16px;
        border-radius: 20px;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }

    .page-header img {
        width: 180px;
    }

    .header-content {
        max-width: 100%;
    }

    .hero-title {
        font-size: 2.4rem;
        margin-bottom: 12px;
    }

    .intro-text {
        font-size: 1rem;
    }

    .chapter-card,
    .iframe-card {
        padding: 20px 16px 14px;
        margin-bottom: 20px;
        border-radius: 20px;
    }

    .chapter-card h2,
    .iframe-card h2 {
        font-size: 1.5rem;
    }

    .section-note {
        font-size: 0.95rem;
        margin-bottom: 18px;
    }

    iframe {
        height: 560px;
        border-radius: 16px;
    }

    nav {
        flex-direction: column;
        gap: 12px;
        margin-top: 24px;
        padding-top: 16px;
    }

    nav a {
        min-width: 100%;
        padding: 12px 16px;
    }

    .theme-toggle.fixed {
        top: auto;
        right: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 70%;
        padding: 10px 16px;
    }

    .back-to-top {
        right: 16px;
        bottom: 16px;
        padding: 10px 16px;
    }
}

/* Mobile pequeno */
@media (max-width: 520px) {
    .container {
        margin: 8px auto;
        padding: 12px;
    }

    .page-header img {
        width: 160px;
    }

    .hero-title {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .intro-text {
        font-size: 0.95rem;
    }

    .chapter-card,
    .iframe-card {
        padding: 16px 12px 12px;
        margin-bottom: 16px;
    }

    .chapter-card h2,
    .iframe-card h2 {
        font-size: 1.3rem;
    }

    .section-note {
        font-size: 0.9rem;
        margin-bottom: 16px;
    }

    iframe {
        height: 480px;
        border-radius: 12px;
    }

    nav {
        gap: 10px;
        margin-top: 20px;
        padding-top: 12px;
    }

    nav a {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .theme-toggle.fixed {
        min-width: auto;
        width: auto;
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .back-to-top {
        right: 12px;
        bottom: 12px;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* Mobile muito pequeno */
@media (max-width: 400px) {
    .container {
        margin: 4px auto;
        padding: 8px;
        border-radius: 16px;
    }

    .page-header {
        gap: 12px;
    }

    .page-header img {
        width: 140px;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .intro-text {
        font-size: 0.9rem;
    }

    .chapter-card,
    .iframe-card {
        padding: 12px 8px 10px;
        margin-bottom: 12px;
        border-radius: 16px;
    }

    .chapter-card h2,
    .iframe-card h2 {
        font-size: 1.2rem;
    }

    .section-note {
        font-size: 0.85rem;
        margin-bottom: 14px;
    }

    iframe {
        height: 400px;
        border-radius: 10px;
    }

    nav {
        gap: 8px;
        margin-top: 16px;
        padding-top: 8px;
    }

    nav a {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .theme-toggle.fixed {
        min-width: auto;
        width: auto;
        padding: 4px 8px;
        font-size: 0.85rem;
    }

    .back-to-top {
        right: 8px;
        bottom: 8px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}
