:root {
    --primary: #007AFF;
    --primary-dark: #0056b3;
    --secondary: #5AC8FA;
    --accent: #FF2D55;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --bg-main: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.65);
    --bg-glass-dark: rgba(255, 255, 255, 0.4);
    --blur-glass: 20px;
    --text-main: #1C1C1E;
    --text-muted: #636366;
    --text-light: #FFFFFF;
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    --radius-xs: 6px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-full: 12px;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(0, 122, 255, 0.3);
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-glass-dark: rgba(255, 255, 255, 0.5);
    --blur-glass: 12px;
    --transition-speed: 0.3s;
    --transition-ease: ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    line-height: 1.8;
    font-size: 16px;
}

#app {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 70px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

h1 {
    font-size: clamp(1.8rem, 4.5vw, 2.5rem);
}

h2 {
    font-size: clamp(1.4rem, 3.5vw, 2rem);
}

h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
}

h4,
h5,
h6 {
    font-family: 'Mitr', sans-serif;
    font-weight: 500;
    color: var(--text-main);
    letter-spacing: normal;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--transition-speed) var(--transition-ease),
        background-color var(--transition-speed) var(--transition-ease),
        box-shadow var(--transition-speed) var(--transition-ease),
        opacity var(--transition-speed) var(--transition-ease);
}

button:active {
    transform: scale(0.96);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 28px;
    min-height: 52px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1.05rem;
    font-family: 'Mitr', sans-serif;
    border: 1px solid transparent;
    transition: all var(--transition-speed) var(--transition-ease);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}



.loading-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--bg-main);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 122, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-glass);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 1000;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
}

.bottom-nav.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px 20px;
    border-radius: 20px;
}

.nav-item i {
    font-size: 1.4rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(0, 122, 255, 0.08);
}

.nav-item:active {
    transform: scale(0.9);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: scale(1);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.9);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.landing-page {
    min-height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle at center, #ffffff 0%, #f2f2f7 100%);
    padding: var(--spacing-md);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

.l-orbits {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
}

.l-orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px dashed rgba(0, 122, 255, 0.3);
    transform: translate(-50%, -50%);
}

.l-orbit-inner {
    width: 60vh;
    height: 60vh;
    animation: l-rotate-ccw 40s linear infinite;
}

.l-orbit-outer {
    width: 90vh;
    height: 90vh;
    animation: l-rotate-cw 60s linear infinite;
}

.l-orbit i {
    position: absolute;
    font-size: 1.8rem;
    color: #007AFF;
}

.l-orbit-inner i:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(2) {
    top: 14.6%;
    left: 85.4%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(3) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(4) {
    top: 85.4%;
    left: 85.4%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(5) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(6) {
    top: 85.4%;
    left: 14.6%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(7) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

.l-orbit-inner i:nth-child(8) {
    top: 14.6%;
    left: 14.6%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(2) {
    top: 6.7%;
    left: 75%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(3) {
    top: 25%;
    left: 93.3%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(4) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(5) {
    top: 75%;
    left: 93.3%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(6) {
    top: 93.3%;
    left: 75%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(7) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(8) {
    top: 93.3%;
    left: 25%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(9) {
    top: 75%;
    left: 6.7%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(10) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(11) {
    top: 25%;
    left: 6.7%;
    transform: translate(-50%, -50%);
}

.l-orbit-outer i:nth-child(12) {
    top: 6.7%;
    left: 25%;
    transform: translate(-50%, -50%);
}

@keyframes l-rotate-cw {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes l-rotate-ccw {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(-360deg);
    }
}

@media (max-width: 500px) {
    .l-orbit i {
        font-size: 1.5rem;
    }
}

.landing-title-gradient {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800;
    font-family: 'Mitr', sans-serif;
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.landing-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    line-height: 1.6;
    font-weight: 500;
}

.float-animation {
    animation: l-float 6s ease-in-out infinite;
}

@keyframes l-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.hero-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    z-index: 1;
    pointer-events: none;
}

@media (max-width: 600px) {
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
}

:root {
    --bg-paper: #fdfbf7;
    --bg-paper-alt: #f5f0e6;
    --text-ink: #2c3e50;
    --text-ink-light: #5a6c7d;
    --accent-stamp: #c0392b;
    --accent-highlight: #f1c40f;
    --border-page: rgba(0, 0, 0, 0.08);
    --shadow-page: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-page-lifted: 0 16px 48px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-wrapper {
    height: calc(100dvh - 70px);
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: clamp(12px, 3vw, 32px);
    padding-bottom: clamp(12px, 3vw, 24px);
    overflow-y: auto;
    overflow-x: hidden;
}

.book-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
}

.book-page {
    position: relative;
    background: var(--bg-paper);
    border-radius: 4px 16px 16px 4px;
    box-shadow: var(--shadow-page);
    padding: clamp(20px, 4vw, 40px);
    padding-left: clamp(28px, 5vw, 56px);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    min-height: 100%;
}

.book-page::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0.02) 40%, transparent 100%);
    border-radius: 4px 0 0 4px;
    pointer-events: none;
}

.book-page::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 6px;
    background: repeating-linear-gradient(180deg, transparent 0px, transparent 30px, rgba(0, 0, 0, 0.08) 30px, rgba(0, 0, 0, 0.08) 36px);
    border-radius: 3px;
    pointer-events: none;
}

.book-page .paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.page-content {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-title {
    font-family: 'Mitr', serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 600;
    color: var(--text-ink);
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--text-ink);
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-ink-light);
    margin-bottom: 1rem;
    font-style: italic;
}

/* --- TOC List (New Arrow Cards) --- */
.olcards,
.olcards * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.olcards {
    list-style: none;
    counter-reset: cardCount;
    font-family: 'Mitr', sans-serif;
    display: flex;
    flex-direction: column;
    --cardsGap: 1.25rem;
    gap: var(--cardsGap);
    padding: 1rem 0;
    width: 100%;
}

.olcards li {
    counter-increment: cardCount;
    display: flex;
    color: white;
    --labelOffset: 1rem;
    --arrowClipSize: 1.5rem;
    margin-top: var(--labelOffset);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
}

.olcards li.toc-unlocked {
    cursor: pointer;
}



.olcards li.toc-unlocked:active {
    transform: translateX(10px) scale(0.98);
}

.olcards li::before {
    content: counter(cardCount, decimal-leading-zero);
    background: white;
    color: var(--cardColor);
    font-size: 1.8em;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    transform: translateY(calc(-1 * var(--labelOffset)));
    margin-right: calc(-1 * var(--labelOffset));
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-inline: 0.5em;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.olcards li .content {
    background-color: var(--cardColor);
    --inlinePadding: 1em;
    --boxPadding: 0.85em;
    display: grid;
    padding: var(--boxPadding) calc(var(--inlinePadding) + var(--arrowClipSize)) var(--boxPadding) calc(var(--inlinePadding) + var(--labelOffset));
    grid-template-areas:
        "icon title"
        "icon text";
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    gap: 0.2em 1.2rem;
    clip-path: polygon(0 0,
            calc(100% - var(--arrowClipSize)) 0,
            100% 50%,
            calc(100% - var(--arrowClipSize)) 100%,
            calc(100% - var(--arrowClipSize)) calc(100% + var(--cardsGap)),
            0 calc(100% + var(--cardsGap)));
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 100px;
    /* Force consistent minimum height */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.olcards li.toc-locked .content {
    cursor: not-allowed;
    opacity: 0.7;
}

.olcards li .content::before {
    content: "";
    position: absolute;
    width: var(--labelOffset);
    height: var(--labelOffset);
    background: var(--cardColor);
    left: 0;
    bottom: 0;
    clip-path: polygon(0 0, 100% 0, 0 100%);
    filter: brightness(0.75);
}

.olcards li .content::after {
    content: "";
    position: absolute;
    height: var(--cardsGap);
    width: var(--cardsGap);
    background: linear-gradient(to right, rgba(0, 0, 0, 0.15), transparent 50%);
    left: 0;
    top: 100%;
}

.olcards li .icon {
    grid-area: icon;
    align-self: center;
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    /* Fixed width for icon area */
}

.olcards li .content .title-row {
    grid-area: title;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.olcards li .content .title {
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Mitr', sans-serif;
    text-shadow: 0 0 2px rgba(0, 0, 0, 1);
    color: white;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

@keyframes tip-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.2));
        transform: translateX(0);
    }

    50% {
        filter: drop-shadow(8px 0 12px var(--cardColor));
        transform: translateX(4px);
    }
}

.olcards li.toc-unlocked .content {
    background-color: var(--cardColor);
    animation: tip-glow 3s infinite ease-in-out;
}

.olcards li .content .text {
    grid-area: text;
    font-size: 0.85rem;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 2px rgba(0, 0, 0, 1);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    align-self: start;
}

.unit-cover {
    text-align: center;
    padding: 1rem 0.5rem 0.5rem;
}

.unit-cover-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    font-family: 'Mitr', sans-serif;
}

.unit-cover-title {
    font-family: 'Mitr', serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    color: var(--text-ink);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.unit-cover-desc {
    font-size: 0.95rem;
    color: var(--text-ink-light);
    max-width: 500px;
    margin: 0 auto 1rem;
    line-height: 1.6;
}

.unit-cover-image {
    width: 100%;
    max-width: 280px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin: 0.5rem auto 1.5rem;
    display: block;
}

.unit-info-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 1rem auto;
    max-width: 550px;
}

.unit-info-box {
    text-align: left;
    background: var(--bg-paper-alt);
    border-radius: 12px;
    padding: 14px 18px;
    border: 1px dashed var(--border-page);
}

/* Hide objective section */
.info-objective-section {
    display: none;
}

/* Spacing and divider for when both are present (in case objectives are unhidden) */
.info-objective-section+.info-indicator-section {
    margin-top: 0em;
    padding-top: 0rem;
    /* border-top: 1px dashed var(--border-page); */
}

.info-label {
    font-size: 1.15rem;
    justify-content: center;
    font-weight: 700;
    color: var(--text-ink);
    margin-bottom: 8px;
    font-family: 'Mitr', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}

.objectives .info-label {
    color: var(--accent-stamp);
}

.indicators .info-label {
    color: var(--primary);
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    font-size: 0.82rem;
    color: var(--text-ink-light);
    line-height: 1.6;
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
}

.info-list li:last-child {
    margin-bottom: 0;
}

.info-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    font-weight: bold;
}

.objectives .info-list li::before {
    color: var(--accent-stamp);
}

.indicators .info-list li::before {
    color: var(--primary);
}

.info-list strong {
    color: var(--text-ink);
    font-weight: 700;
}

.chapter-index {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-page);
    /* Removed flex: 1 and overflow-y: auto to allow the page to grow with content */
}

.chapter-index-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-ink-light);
    margin-bottom: 0.75rem;
}

.chapter-entry {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 1.25rem;
    background: var(--bg-paper-alt);
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    min-height: 110px;
}

.chapter-entry-info {
    flex: 1;
    min-width: 0;
}



.chapter-entry-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-xs);
}

.chapter-entry-info h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-ink);
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chapter-entry-info p {
    font-size: 0.85rem;
    color: var(--text-ink-light);
    margin: 0;
}

.lesson-body {
    font-size: 1rem;
    line-height: 1.9;
    color: var(--text-ink);
}

.lesson-body h3 {
    font-family: 'Mitr', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-ink);
    margin: 2rem 0 1rem;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
}

.lesson-body p {
    margin-bottom: 1.25rem;
    text-align: justify;
    text-justify: inter-word;
}

.lesson-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
}

.journal-article {
    color: var(--text-ink);
    line-height: 1.8;
}

.journal-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--text-ink);
}

.journal-lead {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-ink-light);
    text-align: center;
    margin: 0;
}

.journal-lead strong {
    color: var(--primary);
    font-style: normal;
}

.journal-section {
    margin-bottom: 1.5rem;
}

.journal-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Mitr', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-ink);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-page);
}

.heading-number {
    width: 28px;
    height: 28px;
    background: var(--text-ink);
    color: var(--bg-paper);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.journal-text {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.journal-box {
    background: var(--bg-paper-alt);
    border: 1px solid var(--border-page);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.journal-box.alt {
    background: transparent;
    border-style: dashed;
}

.box-title {
    font-family: 'Mitr', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 0.75rem;
}

.trait-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trait-item {
    background: white;
    border: 1px solid var(--border-page);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    width: calc(33.33% - 6px);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}



.trait-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.trait-item span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-ink);
    line-height: 1.2;
}

@media (max-width: 500px) {
    .trait-item {
        width: calc(50% - 4px);
    }
}

.method-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.method-step {
    background: white;
    border: 1px solid var(--border-page);
    border-radius: 12px;
    padding: 0.85rem;
    position: relative;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.method-step-content {
    flex: 1;
}

.method-step-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}



.method-step-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.method-step-num {
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.method-step p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-ink-light);
    line-height: 1.4;
    text-align: left;
}

.skill-detail-list {
    display: grid;
    gap: 0.75rem;
}

.skill-detail-list.compact {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.skill-detail {
    background: white;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-page);
    box-shadow: var(--shadow-xs);
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.2s ease;
}



.skill-icon-mini {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.skill-info {
    flex: 1;
}

.skill-detail strong {
    display: block;
    color: var(--text-ink);
    font-family: 'Mitr', sans-serif;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.skill-detail span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-ink-light);
    line-height: 1.3;
}

/* Journal Decoration */
.journal-sticker {
    position: absolute;
    width: 60px;
    height: auto;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
}

@media (max-width: 600px) {
    .method-step {
        gap: 0.75rem;
        padding: 0.65rem;
    }

    .method-step-img {
        width: 48px;
        height: 48px;
    }

    .method-step p {
        font-size: 0.78rem;
    }

    .skill-detail {
        padding: 0.5rem 0.65rem;
    }

    .skill-icon-mini {
        width: 32px;
        height: 32px;
    }
}

.worksheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-page);
}

.worksheet-title {
    font-family: 'Mitr', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-ink);
}

.worksheet-progress {
    font-size: 0.9rem;
    color: var(--text-ink-light);
    font-weight: 600;
}

.worksheet-question {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-ink);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.worksheet-options {
    display: grid;
    gap: 12px;
}

.worksheet-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 1rem 1.25rem;
    background: white;
    border: 2px solid var(--border-page);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}



.worksheet-option-marker {
    width: 28px;
    height: 28px;
    border: 2px solid var(--text-ink-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-ink-light);
    flex-shrink: 0;
    transition: all 0.2s ease;
}



.worksheet-option.correct {
    border-color: var(--success);
    background: rgba(52, 199, 89, 0.08);
}

.worksheet-option.correct .worksheet-option-marker {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.worksheet-option.incorrect {
    border-color: var(--danger);
    background: rgba(255, 59, 48, 0.08);
}

.worksheet-option.incorrect .worksheet-option-marker {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.worksheet-progressbar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.worksheet-progressbar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.gradebook {
    padding: 1rem 0;
}

.gradebook-header {
    text-align: center;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--text-ink);
}

.gradebook-total {
    font-family: 'Outfit', monospace;
    font-size: clamp(4rem, 12vw, 6rem);
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin: 1rem 0;
}

.gradebook-label {
    font-size: 1.1rem;
    color: var(--text-ink-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.gradebook-table {
    width: 100%;
    border-collapse: collapse;
}

.gradebook-table th,
.gradebook-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-page);
}

.gradebook-table th {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-ink-light);
    background: var(--bg-paper-alt);
}

.gradebook-table td {
    font-size: 1rem;
    color: var(--text-ink);
}

.gradebook-score {
    font-weight: 700;
    color: var(--primary);
}

.page-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-page);
}

.page-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-paper-alt);
    border: 1px solid var(--border-page);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-ink);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Mitr', sans-serif;
}



.page-nav-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}



.book-progression {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.book-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.book-step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-page);
    border: 2px solid var(--border-page);
    transition: all 0.3s ease;
}

.book-step.active .book-step-dot {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
}

.book-step.done .book-step-dot {
    background: var(--success);
    border-color: var(--success);
}

.book-step-label {
    font-size: 0.7rem;
    color: var(--text-ink-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.book-step.active .book-step-label {
    color: var(--primary);
    font-weight: 700;
}

.stage-card {
    background: var(--bg-paper-alt);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    border: 1px solid var(--border-page);
}

.stage-icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
}

.stage-title {
    font-family: 'Mitr', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-ink);
    margin-bottom: 0.75rem;
}

.stage-desc {
    font-size: 1rem;
    color: var(--text-ink-light);
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.stage-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 40px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Mitr', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}



.stage-btn.game {
    background: linear-gradient(135deg, #fca311, #ffb703);
}



.stage-btn.final {
    background: linear-gradient(135deg, #4cc9f0, #4361ee);
}

@keyframes pageFlipIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pageFlipOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        opacity: 0;
        transform: translateX(20px);
    }
}

.page-enter {
    animation: pageFlipIn 0.4s ease-out forwards;
}

.page-exit {
    animation: pageFlipOut 0.25s ease forwards;
}

.book-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-page);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-ink-light);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
    font-family: 'Sarabun', sans-serif;
    flex-shrink: 0;
}



@media (max-width: 768px) {
    .book-wrapper {
        padding: 8px;
        height: calc(100dvh - 70px);
    }

    .book-page {
        border-radius: 4px 12px 12px 4px;
        padding: 16px;
        padding-left: 24px;
    }

    .book-page::before {
        width: 16px;
    }

    .book-page::after {
        left: 6px;
        width: 4px;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .toc-item {
        padding: 0.5rem 0.5rem;
    }

    .unit-cover {
        padding: 1rem 0.5rem;
    }

    .chapter-entry {
        padding: 1rem;
    }

    .worksheet-card {
        padding: 1.25rem;
    }

    .stage-card {
        padding: 1.5rem;
    }

    .stage-btn {
        padding: 14px 28px;
        font-size: 1rem;
    }

    .gradebook-total {
        font-size: 3.5rem;
    }
}

/* --- Lesson Summary Dashboard --- */
.summary-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.summary-card {
    background: var(--bg-paper-alt);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border-page);
    position: relative;
    overflow: hidden;
}

.summary-header {
    text-align: center;
    margin-bottom: 2rem;
}

.summary-score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 2rem;
}

.score-box {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-page);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-box.highlight {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.02);
}

.score-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-ink-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-ink);
    line-height: 1;
}

.score-value.plus {
    color: var(--success);
}

.summary-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.summary-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--border-page);
    border-radius: 12px;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}



.summary-nav-btn i {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.summary-nav-btn span {
    font-family: 'Mitr', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-ink);
}

.summary-nav-btn small {
    font-size: 0.8rem;
    color: var(--text-ink-light);
    margin-top: 4px;
}

.summary-nav-btn.next {
    background: var(--primary);
    border-color: var(--primary);
}

.summary-nav-btn.next span,
.summary-nav-btn.next small,
.summary-nav-btn.next i {
    color: white;
}



@media (max-width: 600px) {
    .summary-card {
        padding: 1.5rem;
    }

    .score-value {
        font-size: 1.8rem;
    }
}

/* Journal Video Design */
.journal-video-container {
    margin: 2rem 0;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 4px solid var(--bg-paper-alt);
    transition: transform 0.3s ease;
}



.journal-video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
}

.journal-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 122, 255, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-family: 'Mitr', sans-serif;
}