body {
    background: linear-gradient(180deg, #f7fbff 0%, #eef7f4 52%, #f8fafc 100%);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

main,
section,
article,
aside,
header,
footer,
nav,
div {
    min-width: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
a,
span,
li {
    overflow-wrap: anywhere;
}

img,
video,
iframe,
embed,
object {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

table {
    max-width: 100%;
}

.learning-surface {
    box-shadow: 0 16px 36px rgba(30, 64, 175, 0.08);
}

.prose {
    color: #263244;
}

.prose h2,
.prose h3,
.prose h4 {
    scroll-margin-top: 6rem;
    color: #0f172a;
}

.prose p,
.prose li {
    line-height: 1.8;
}

.prose pre {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.prose code:not(pre code) {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 0.1rem 0.35rem;
    border-radius: 0.35rem;
    font-weight: 700;
}

.chapter-body {
    font-size: 1.08rem;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
}

.chapter-body *,
.chapter-body *::before,
.chapter-body *::after {
    box-sizing: border-box;
}

.chapter-body > *,
.chapter-body img,
.chapter-body iframe,
.chapter-body table {
    max-width: 100% !important;
}

.chapter-body h3 {
    margin-top: 2.4rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 1.65rem;
    line-height: 1.25;
}

.chapter-body h4,
.chapter-body h5 {
    margin-top: 1.75rem;
    margin-bottom: 0.55rem;
    color: #1e40af;
}

.chapter-body p {
    margin: 1rem 0;
}

.chapter-body strong {
    color: #0f172a;
    font-weight: 800;
}

.chapter-body ul,
.chapter-body ol {
    margin: 1.25rem 0 1.5rem 1.4rem;
    padding-left: 1.1rem;
}

.chapter-body li {
    margin: 0.45rem 0;
    padding-left: 0.25rem;
    overflow-wrap: anywhere;
}

.chapter-body table {
    width: 100% !important;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 1.5rem 0;
    overflow: hidden;
    border-radius: 0.85rem;
    border: 1px solid #e2e8f0;
    font-size: 0.95rem;
}

.chapter-body th,
.chapter-body td {
    border: 1px solid #e2e8f0;
    padding: 0.9rem 1rem;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chapter-body th {
    background: #f8fafc;
    color: #0f172a;
    font-weight: 900;
}

.chapter-body td {
    background: #ffffff;
}

.chapter-body blockquote {
    margin: 1.5rem 0;
    border-left: 4px solid #2563eb;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 1rem 1.25rem;
    border-radius: 0 0.65rem 0.65rem 0;
    font-weight: 700;
}

.chapter-image-placeholder {
    margin: 1.75rem 0;
    padding: 1.25rem;
    border: 1px dashed #93c5fd;
    border-radius: 0.9rem;
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    color: #1e3a8a;
}

.chapter-image-placeholder div {
    font-weight: 800;
}

.chapter-image-placeholder figcaption {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.ad-slot {
    width: min(100%, 520px);
    margin-left: auto;
    margin-right: auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 0.7rem;
    text-align: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.ad-slot > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.45rem;
    color: #64748b;
    background: #eef2f7;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.62rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 900;
}

.ad-slot-frame {
    width: min(100%, 468px);
    min-height: 72px;
    max-height: 260px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: #ffffff;
}

.ad-slot-frame > *,
.ad-slot-frame ins,
.ad-slot-frame iframe {
    max-width: 100% !important;
}

.ad-slot-frame img {
    display: block;
    width: 100%;
    max-width: 468px;
    height: auto;
    max-height: 240px;
    object-fit: contain;
    border-radius: 6px;
}

.ad-slot-sponsored-note,
.ad-slot-native-text-link,
.ad-slot-resource-recommendation,
.ad-slot-quiz-prompt-sponsor {
    width: min(100%, 420px);
}

.ad-slot-sponsored-note .ad-slot-frame,
.ad-slot-native-text-link .ad-slot-frame,
.ad-slot-resource-recommendation .ad-slot-frame,
.ad-slot-quiz-prompt-sponsor .ad-slot-frame {
    min-height: 64px;
    max-height: none;
    padding: 0.75rem;
}

.ad-slot-cta-card,
.ad-slot-code-break-sponsor,
.ad-slot-bottom-recommendation {
    width: min(100%, 560px);
}

.ad-slot-inline-middle-paragraph,
.ad-slot-inline-after-first-paragraph {
    width: min(100%, 468px);
}

#chapter-sidebar {
    min-width: 0;
}

.chapter-btn {
    min-height: 64px;
    align-items: center;
}

.chapter-btn .chapter-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.chapter-number {
    width: 2rem;
    height: 2rem;
}

.student-id-card {
    width: min(330px, 100%);
}

.student-id-card img,
.student-id-card canvas {
    max-width: 100%;
}

.student-card-qr {
    width: min(205px, 100%);
    aspect-ratio: 1 / 1;
}

.student-card-qr img,
.student-card-qr canvas {
    width: 100% !important;
    height: auto !important;
}

.editorial-grid {
    background-color: #eef7ff !important;
    background-image:
        linear-gradient(rgba(37, 99, 235, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 184, 166, 0.055) 1px, transparent 1px);
    background-size: 32px 32px;
}

.editorial-grid.border-slate-800,
.editorial-grid.border-slate-700 {
    border-color: #cfe8ff !important;
}

.editorial-grid .text-white,
.editorial-grid .text-slate-100 {
    color: #0f172a !important;
}

.editorial-grid .text-slate-300,
.editorial-grid .text-blue-200,
.editorial-grid .text-slate-400 {
    color: #475569 !important;
}

.editorial-grid .bg-blue-500\/10,
.editorial-grid .bg-emerald-500\/10 {
    background: #ffffff !important;
    color: #1d4ed8 !important;
    border-color: #bfdbfe !important;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.08);
}

.site-hero-light {
    background:
        linear-gradient(135deg, rgba(219, 234, 254, 0.9) 0%, rgba(236, 253, 245, 0.92) 58%, rgba(255, 255, 255, 0.95) 100%),
        linear-gradient(rgba(37, 99, 235, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 184, 166, 0.055) 1px, transparent 1px);
    background-size: auto, 34px 34px, 34px 34px;
}

.edu-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid #bfdbfe;
    background: #ffffff;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.08);
}

.edu-primary-btn {
    background: #2563eb;
    color: #ffffff;
    border-radius: 0.9rem;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.edu-primary-btn:hover {
    background: #1d4ed8;
}

.edu-soft-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbeafe;
    box-shadow: 0 16px 42px rgba(37, 99, 235, 0.09);
}

.notification-badge {
    position: absolute;
    top: -0.2rem;
    right: -0.2rem;
    min-width: 1.15rem;
    height: 1.15rem;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-size: 0.62rem;
    line-height: 1;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.2rem;
}

@media (max-width: 768px) {
    .site-hero-light h1 {
        font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
        line-height: 1.2 !important;
    }

    .site-hero-light p {
        font-size: 0.98rem;
    }

    .learning-surface {
        border-radius: 0.85rem;
    }

    footer .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    footer .grid {
        gap: 1.25rem;
    }

    .prose table:not(.chapter-body table) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .chapter-body {
        font-size: 1rem;
    }

    .chapter-body h3 {
        font-size: 1.35rem;
        margin-top: 1.75rem;
    }

    .chapter-body h4,
    .chapter-body h5 {
        font-size: 1.08rem;
    }

    .chapter-body pre {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre;
        -webkit-overflow-scrolling: touch;
    }

    .chapter-body code {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .chapter-body table,
    .chapter-body thead,
    .chapter-body tbody,
    .chapter-body tr,
    .chapter-body th,
    .chapter-body td {
        display: block;
        width: 100%;
    }

    .chapter-body table {
        table-layout: auto;
        border: 0;
        border-radius: 0;
    }

    .chapter-body thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .chapter-body tr {
        margin: 0 0 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.9rem;
        overflow: hidden;
        background: #fff;
    }

    .chapter-body th,
    .chapter-body td {
        border: 0;
        border-bottom: 1px solid #e2e8f0;
        padding: 0.85rem 0.95rem;
    }

    .chapter-body tr > :last-child {
        border-bottom: 0;
    }

    .chapter-image-placeholder,
    .ad-slot,
    .chapter-body blockquote {
        padding: 0.95rem;
        border-radius: 0.75rem;
    }

    .ad-slot {
        width: min(100%, 336px);
        padding: 0.55rem;
    }

    .ad-slot-frame {
        width: 100%;
        min-height: 72px;
        max-height: 220px;
    }

    .ad-slot-frame img {
        max-height: 200px;
    }

    .chapter-btn {
        min-height: 58px;
        padding-top: 0.85rem !important;
        padding-bottom: 0.85rem !important;
    }
}

@media (max-width: 420px) {
    .chapter-body ul,
    .chapter-body ol {
        margin-left: 0;
        padding-left: 1.15rem;
    }

    .prose {
        font-size: 0.98rem;
    }

    .edu-primary-btn,
    .edu-pill {
        width: 100%;
        justify-content: center;
    }
}
