/* ==========================================================================
           QWIK STUDY CORE DESIGN TOKENS + STORYBOOK FOLIO THEME
           ========================================================================== */
        :root {
            --primary: #FF007A;
            --primary-light: #FF5E5E;
            --primary-grad: linear-gradient(135deg, #FF007A 0%, #FF7A00 100%);
            --dark-blue: #0A0F1C;

            --bg-page: #F4F7FA;
            --bg-card: #FFFFFF;
            --bg-card-subtle: #EDF2F7;
            --text-main: #111827;
            --text-muted: #6B7280;
            --border-subtle: #E5E7EB;
            --border-hover: #D1D5DB;

            /* Storybook Paper Variables (Default: Warm Cream Book Page) */
            --book-cover-border: #E6DEC8;
            --book-page-bg: #FCF9F2;
            --book-page-inner: #F7F1E3;
            --book-ink: #231F1C;
            --book-muted: #6E6559;
            --book-accent: #C81E5D;
            --book-gold: #D97706;
            --book-spine-shadow: inset 18px 0 28px -18px rgba(60, 45, 25, 0.14), 0 18px 40px -15px rgba(17, 24, 39, 0.1);

            --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
            --shadow-md: 0 10px 20px -5px rgba(0, 0, 0, 0.08);
            --shadow-hover: 0 20px 25px -5px rgba(255, 0, 122, 0.14);
            --shadow-nav: 0 4px 20px rgba(0, 0, 0, 0.06);

            --radius-sm: 12px;
            --radius-md: 20px;
            --radius-lg: 28px;
            --radius-pill: 9999px;
            --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }

        [data-theme="dark"] {
            --bg-page: #0A0F1C;
            --bg-card: #151F32;
            --bg-card-subtle: #1E293B;
            --text-main: #F9FAFB;
            --text-muted: #9CA3AF;
            --border-subtle: #1E293B;
            --border-hover: #374151;
            --shadow-nav: 0 4px 20px rgba(0, 0, 0, 0.5);

            --book-cover-border: #28354E;
            --book-page-bg: #131C2E;
            --book-page-inner: #1B2740;
            --book-ink: #F1F5F9;
            --book-muted: #94A3B8;
            --book-accent: #FF4D9E;
            --book-spine-shadow: inset 18px 0 28px -18px rgba(0, 0, 0, 0.55), 0 18px 40px -15px rgba(0, 0, 0, 0.45);
        }

        /* Paper Surface Overrides */
        [data-paper="cream"] {
            --book-page-bg: #FCF9F2;
            --book-page-inner: #F4EFE4;
            --book-ink: #231F1C;
            --book-muted: #6E6559;
            --book-cover-border: #E5DEC9;
        }
        [data-paper="sepia"] {
            --book-page-bg: #F4E9D4;
            --book-page-inner: #EADBC0;
            --book-ink: #302418;
            --book-muted: #6E5840;
            --book-cover-border: #D9C4A3;
        }
        [data-paper="white"] {
            --book-page-bg: #FFFFFF;
            --book-page-inner: #F8FAFC;
            --book-ink: #111827;
            --book-muted: #64748B;
            --book-cover-border: #E2E8F0;
        }
        [data-paper="night"] {
            --book-page-bg: #131C2E;
            --book-page-inner: #1B2740;
            --book-ink: #F1F5F9;
            --book-muted: #94A3B8;
            --book-cover-border: #28354E;
        }

        *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; min-width: 0; }
        html { scroll-behavior: smooth; max-width: 100vw; overflow-x: hidden; }
        body {
            background-color: var(--bg-page);
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            line-height: 1.6;
            padding-top: 66px;
            transition: background-color 0.3s, color 0.3s;
            overflow-x: hidden;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        @media (min-width: 768px) { body { padding-top: 84px; } }
        h1, h2, h3, h4 { font-family: 'Plus Jakarta Sans', sans-serif; letter-spacing: -0.025em; }

        /* Fullscreen Distraction-Free Mode */
        body.fullscreen-reading {
            padding-top: 12px !important;
        }
        body.fullscreen-reading .navbar,
        body.fullscreen-reading .main-footer {
            display: none !important;
        }

        /* Content Security & Anti-Copy Protection */
        .protected-content {
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
        }

        .container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 14px; }
        @media (min-width: 640px) { .container { padding: 0 20px; } }
        @media (min-width: 1024px) { .container { padding: 0 24px; } }

        /* Reading Progress Bar */
        .reading-progress-wrap {
            position: fixed; top: 0; left: 0; right: 0; height: 4px;
            background: rgba(255, 0, 122, 0.1); z-index: 1100;
        }
        .reading-progress-fill {
            height: 100%; width: 0%; background: var(--primary-grad);
            transition: width 0.25s ease;
        }

        /* ==========================================================================
           QWIK STUDY NAVBAR (NO EXTRA QWIK READ TAB)
           ========================================================================== */
        .navbar {
            position: fixed; top: 0; left: 0; right: 0; height: 66px;
            background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-nav);
            z-index: 1000; display: flex; align-items: center;
        }
        [data-theme="dark"] .navbar { background: rgba(10, 15, 28, 0.92); }
        @media (min-width: 768px) { .navbar { height: 84px; } }

        .nav-container { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; }
        .nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; cursor: pointer; }
        .header-logo { height: 32px; width: auto; object-fit: contain; }
        @media (min-width: 768px) { .header-logo { height: 42px; } }

        .nav-text-container { display: flex; flex-direction: column; justify-content: center; }
        .nav-title { font-size: 1.15rem; font-weight: 800; color: var(--text-main); line-height: 1.1; }
        .nav-title span { background: var(--primary-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
        @media (min-width: 768px) { .nav-title { font-size: 1.35rem; } }
        .nav-subtitle { display: none; }
        @media (min-width: 1140px) { .nav-subtitle { display: block; font-size: 0.74rem; color: var(--text-muted); font-weight: 600; } }

        .main-nav-links { display: none; }
        @media (min-width: 1024px) {
            .main-nav-links { display: flex; gap: 12px; align-items: center; justify-content: center; flex-grow: 1; }
        }
        .nav-link {
            text-decoration: none; font-weight: 600; font-size: 0.92rem; color: var(--text-muted);
            display: inline-flex; align-items: center; gap: 7px; transition: var(--transition);
            padding: 8px 14px; border-radius: var(--radius-pill); white-space: nowrap;
        }
        .nav-link:hover { color: var(--primary); background: rgba(255, 0, 122, 0.08); }

        .header-actions { display: flex; align-items: center; gap: 8px; }
        .uid-pill-btn {
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--bg-card-subtle); color: var(--text-main);
            border: 1px solid var(--border-subtle); padding: 6px 12px;
            border-radius: var(--radius-pill); font-weight: 700; font-size: 0.76rem;
            cursor: pointer; transition: var(--transition); font-family: inherit;
        }
        .uid-pill-btn:hover { border-color: var(--primary); color: var(--primary); }

        .btn-theme-toggle {
            background: var(--bg-card-subtle); border: none; color: var(--text-main); cursor: pointer;
            border-radius: 50%; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
            font-size: 1rem; transition: var(--transition); flex-shrink: 0;
        }
        .btn-theme-toggle:hover { background: var(--border-hover); }

        .btn-streak {
            display: flex; align-items: center; gap: 5px; background: #FEF3C7; color: #D97706;
            padding: 6px 11px; border-radius: var(--radius-pill); font-weight: 800; font-size: 0.82rem;
        }
        [data-theme="dark"] .btn-streak { background: #451A03; color: #FBBF24; }

        /* ==========================================================================
           MAIN PAGE: HERO BANNER WITH TWO ACTION BUTTONS
           ========================================================================== */
        .hero-section { padding: 20px 0 14px; }
        .hero-card {
            background: var(--primary-grad); border-radius: 22px; padding: 30px 20px;
            text-align: center; color: #FFFFFF; box-shadow: var(--shadow-md); position: relative; overflow: hidden;
        }
        @media (min-width: 768px) { .hero-card { padding: 40px 44px; border-radius: var(--radius-lg); } }
        .hero-card::before {
            content: ''; position: absolute; top: -60%; right: -10%; width: 380px; height: 380px;
            background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%); pointer-events: none;
        }
        .hero-tag {
            display: inline-flex; align-items: center; gap: 7px; background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(8px); padding: 5px 14px; border-radius: var(--radius-pill);
            font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
            margin-bottom: 12px; border: 1px solid rgba(255, 255, 255, 0.35);
        }
        .hero-card h1 { font-size: clamp(1.5rem, 4vw, 2.4rem); font-weight: 800; margin-bottom: 8px; line-height: 1.18; }
        .hero-card p {
            font-size: clamp(0.88rem, 2vw, 1.02rem); color: rgba(255, 255, 255, 0.95);
            max-width: 640px; margin: 0 auto 22px; font-weight: 500;
        }
        .hero-cta-group {
            display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
            position: relative; z-index: 2;
        }
        .btn-hero-primary {
            background: #FFFFFF; color: var(--primary); border: none;
            padding: 12px 26px; border-radius: var(--radius-pill); font-weight: 800;
            font-size: 0.92rem; cursor: pointer; display: inline-flex; align-items: center;
            gap: 8px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16); transition: var(--transition);
            font-family: inherit; text-decoration: none;
        }
        .btn-hero-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 24px rgba(0, 0, 0, 0.22); }
        .btn-hero-secondary {
            background: rgba(255, 255, 255, 0.18); color: #FFFFFF;
            border: 1.5px solid rgba(255, 255, 255, 0.55); padding: 11px 22px;
            border-radius: var(--radius-pill); font-weight: 700; font-size: 0.9rem;
            cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
            transition: var(--transition); font-family: inherit; text-decoration: none;
            backdrop-filter: blur(6px);
        }
        .btn-hero-secondary:hover { background: rgba(255, 255, 255, 0.28); transform: translateY(-2px); }

        /* ==========================================================================
           MAIN PAGE: STORY INDEX LIST & PROGRESS TRACKING
           ========================================================================== */
        .story-index-section {
            margin: 12px 0 56px;
        }
        .index-header-bar {
            display: flex; align-items: center; justify-content: space-between;
            flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
        }
        .index-section-title {
            font-size: 1.25rem; font-weight: 800; display: flex; align-items: center; gap: 9px;
        }
        .sync-status-badge {
            font-size: 0.76rem; font-weight: 700; color: var(--text-muted);
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--bg-card); padding: 6px 13px; border-radius: var(--radius-pill);
            border: 1px solid var(--border-subtle);
        }

        .story-index-list {
            display: flex; flex-direction: column; gap: 16px;
        }
        .story-index-card {
            background: var(--bg-card); border: 1.5px solid var(--border-subtle);
            border-radius: 22px; padding: 22px 20px; box-shadow: var(--shadow-sm);
            display: flex; flex-direction: column; gap: 18px;
            transition: var(--transition); position: relative; overflow: hidden;
        }
        @media (min-width: 768px) {
            .story-index-card {
                flex-direction: row; align-items: center; justify-content: space-between;
                padding: 24px 28px;
            }
        }
        .story-index-card:hover {
            border-color: var(--primary); box-shadow: var(--shadow-hover); transform: translateY(-2px);
        }
        .story-index-card.completed-card {
            border-left: 6px solid #10B981;
        }

        .story-index-info { flex: 1; }
        .story-index-meta {
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
        }
        .meta-chip {
            display: inline-flex; align-items: center; gap: 5px;
            font-size: 0.74rem; font-weight: 700; color: var(--text-muted);
            background: var(--bg-page); padding: 4px 11px; border-radius: var(--radius-pill);
            border: 1px solid var(--border-subtle);
        }
        .status-chip {
            display: inline-flex; align-items: center; gap: 5px;
            font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
            letter-spacing: 0.04em; padding: 4px 11px; border-radius: var(--radius-pill);
        }
        .status-chip.completed {
            background: #DCFCE7; color: #047857;
        }
        [data-theme="dark"] .status-chip.completed {
            background: rgba(16, 185, 129, 0.2); color: #34D399;
        }
        .status-chip.unread {
            background: rgba(255, 0, 122, 0.1); color: var(--primary);
        }

        .story-index-title {
            font-family: 'Lora', Georgia, serif; font-size: clamp(1.2rem, 2.5vw, 1.45rem);
            font-weight: 700; color: var(--text-main); margin-bottom: 4px;
        }
        .story-index-desc {
            font-size: 0.88rem; color: var(--text-muted); max-width: 680px;
        }

        /* Progress Pills inside Story Index Card */
        .story-progress-metrics {
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px;
        }
        .metric-pill {
            display: inline-flex; align-items: center; gap: 6px;
            font-size: 0.78rem; font-weight: 700; padding: 5px 12px;
            border-radius: 10px; background: var(--bg-page); border: 1px solid var(--border-subtle);
            color: var(--text-main);
        }
        .metric-pill i { color: var(--primary); }

        .story-index-actions {
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0;
        }
        .btn-open-story {
            background: var(--primary-grad); color: #FFFFFF; border: none;
            padding: 12px 24px; border-radius: var(--radius-pill); font-weight: 800;
            font-size: 0.88rem; cursor: pointer; display: inline-flex; align-items: center;
            gap: 8px; box-shadow: 0 8px 18px rgba(255, 0, 122, 0.25); transition: var(--transition);
            font-family: inherit; width: 100%; justify-content: center;
        }
        @media (min-width: 640px) { .btn-open-story { width: auto; } }
        .btn-open-story:hover {
            transform: translateY(-2px); box-shadow: 0 12px 22px rgba(255, 0, 122, 0.35);
        }
        .btn-take-quiz-direct {
            background: var(--bg-page); color: var(--text-main);
            border: 1.5px solid var(--border-subtle); padding: 11px 18px;
            border-radius: var(--radius-pill); font-weight: 700; font-size: 0.84rem;
            cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
            transition: var(--transition); font-family: inherit; width: 100%; justify-content: center;
        }
        @media (min-width: 640px) { .btn-take-quiz-direct { width: auto; } }
        .btn-take-quiz-direct:hover { border-color: var(--primary); color: var(--primary); }

        /* ==========================================================================
           DISTRACTION-FREE STORY READING PAGE (CENTERED PAGE-BASED FOLIO)
           ========================================================================== */
        .reader-view-wrapper {
            max-width: 900px; margin: 18px auto 56px;
        }

        /* THE OPEN STORYBOOK CARD */
        .storybook-folio {
            background: var(--book-page-bg);
            color: var(--book-ink);
            border: 2px solid var(--book-cover-border);
            border-radius: 24px;
            box-shadow: var(--book-spine-shadow);
            position: relative;
            overflow: hidden;
            transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
        }

        /* Decorative Book Spine & Page Edge */
        .storybook-folio::before {
            content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 10px;
            background: linear-gradient(90deg, rgba(255, 0, 122, 0.32), rgba(255, 122, 0, 0.08));
            pointer-events: none;
        }

        /* Bookmark Ribbon at Top Right */
        .storybook-ribbon {
            position: absolute; top: 0; right: 24px; width: 30px; height: 48px;
            background: var(--primary-grad); color: #FFF; display: flex; align-items: flex-end;
            justify-content: center; padding-bottom: 9px; font-size: 0.8rem;
            clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
            box-shadow: 0 6px 14px rgba(255, 0, 122, 0.3); z-index: 5;
        }

        /* Book Top Utility Toolbar */
        .folio-toolbar {
            display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
            gap: 10px; padding: 14px 64px 14px 22px;
            border-bottom: 1px solid var(--book-cover-border);
            background: var(--book-page-inner);
        }
        @media (max-width: 640px) {
            .folio-toolbar { padding: 12px 54px 12px 16px; }
        }

        .toolbar-left-group {
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
        }
        .btn-back-index {
            background: var(--book-page-bg); color: var(--book-ink);
            border: 1px solid var(--book-cover-border); border-radius: var(--radius-pill);
            padding: 6px 13px; font-size: 0.78rem; font-weight: 800; cursor: pointer;
            display: inline-flex; align-items: center; gap: 6px; transition: var(--transition);
            font-family: inherit;
        }
        .btn-back-index:hover { border-color: var(--primary); color: var(--primary); }

        .paper-swatches { display: flex; align-items: center; gap: 7px; }
        .swatch-label { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--book-muted); }
        .paper-dot {
            width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
            border: 2px solid rgba(0,0,0,0.15); transition: transform 0.2s, border-color 0.2s;
        }
        .paper-dot.active { border-color: var(--primary); transform: scale(1.14); box-shadow: 0 0 0 3px rgba(255, 0, 122, 0.16); }
        .paper-dot.cream { background: #FCF9F2; }
        .paper-dot.sepia { background: #EADBC0; }
        .paper-dot.white { background: #FFFFFF; }
        .paper-dot.night { background: #131C2E; }

        .typo-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
        .folio-tool-btn {
            background: var(--book-page-bg); color: var(--book-ink);
            border: 1px solid var(--book-cover-border); border-radius: 10px;
            padding: 6px 11px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
            transition: var(--transition); font-family: inherit; display: inline-flex;
            align-items: center; gap: 5px;
        }
        .folio-tool-btn:hover, .folio-tool-btn.active {
            border-color: var(--primary); color: var(--primary);
        }
        .font-px-badge { font-size: 0.75rem; font-weight: 700; color: var(--book-muted); min-width: 36px; text-align: center; }

        /* CLEAN CHAPTER / PAGE STEPPER BAR */
        .chapter-stepper-bar {
            display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
            gap: 12px; padding: 12px 24px; background: rgba(255, 0, 122, 0.03);
            border-bottom: 1px dashed var(--book-cover-border);
        }
        @media (max-width: 640px) { .chapter-stepper-bar { padding: 10px 16px; } }

        .chapter-dots-row {
            display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
        }
        .chap-step-dot {
            width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--book-cover-border);
            background: var(--book-page-bg); color: var(--book-muted); font-weight: 800;
            font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center;
            justify-content: center; transition: var(--transition); font-family: inherit;
        }
        .chap-step-dot:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
        .chap-step-dot.active {
            background: var(--primary-grad); color: #FFFFFF; border-color: transparent;
            box-shadow: 0 4px 10px rgba(255, 0, 122, 0.25);
        }
        .chap-step-dot.read-done {
            border-color: #10B981; color: #10B981;
        }

        .chapter-jump-select {
            background: var(--book-page-bg); color: var(--book-ink);
            border: 1px solid var(--book-cover-border); border-radius: var(--radius-pill);
            padding: 6px 14px; font-size: 0.8rem; font-weight: 700; font-family: inherit;
            cursor: pointer; outline: none; max-width: 100%;
        }

        /* STORYBOOK INNER PAGE CONTENT */
        .folio-page-body {
            padding: 28px 20px 28px;
        }
        @media (min-width: 640px) { .folio-page-body { padding: 38px 44px 34px; } }
        @media (min-width: 1024px) { .folio-page-body { padding: 44px 58px 40px; } }

        /* Book Title Header */
        .storybook-title-header {
            text-align: center; padding-bottom: 22px; margin-bottom: 24px;
            border-bottom: 1px solid var(--book-cover-border); position: relative;
        }
        .story-meta-badges {
            display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
        }
        .story-pill {
            font-size: 0.68rem; font-weight: 800; padding: 4px 11px; border-radius: var(--radius-pill);
            text-transform: uppercase; letter-spacing: 0.05em;
        }
        .story-pill.genre { background: #FCE7F3; color: #BE185D; }
        .story-pill.date { background: #D1FAE5; color: #047857; }

        .storybook-main-title {
            font-family: 'Lora', Georgia, serif;
            font-size: clamp(1.55rem, 3.8vw, 2.35rem);
            font-weight: 700; color: var(--book-ink); line-height: 1.22; margin-bottom: 8px;
        }
        .storybook-subtitle {
            font-family: 'Lora', Georgia, serif; font-style: italic;
            font-size: clamp(0.92rem, 2vw, 1.05rem); color: var(--book-muted);
            max-width: 600px; margin: 0 auto 12px;
        }
        .storybook-byline {
            display: flex; align-items: center; justify-content: center; gap: 14px;
            flex-wrap: wrap; font-size: 0.8rem; font-weight: 600; color: var(--book-muted);
        }
        .storybook-byline i { color: var(--primary); margin-right: 4px; }

        .highlight-legend {
            display: inline-flex; align-items: center; justify-content: center; gap: 14px;
            flex-wrap: wrap; background: var(--book-page-inner); border: 1px solid var(--book-cover-border);
            padding: 7px 16px; border-radius: var(--radius-pill); margin-top: 12px; font-size: 0.74rem;
        }
        .legend-item { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--book-ink); }
        .legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

        /* Chapter Banner inside the Book */
        .chapter-ornament-header {
            text-align: center; margin-bottom: 24px;
        }
        .chapter-kicker {
            font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
            letter-spacing: 0.15em; color: var(--primary); display: block; margin-bottom: 4px;
        }
        .chapter-heading-title {
            font-family: 'Lora', Georgia, serif; font-size: clamp(1.22rem, 3vw, 1.55rem);
            font-weight: 700; color: var(--book-ink);
        }
        .ornament-divider {
            display: flex; align-items: center; justify-content: center; gap: 10px;
            margin-top: 8px; color: var(--primary); opacity: 0.65; font-size: 0.8rem;
        }
        .ornament-divider::before, .ornament-divider::after {
            content: ''; width: 50px; height: 1px; background: var(--book-cover-border);
        }

        /* STORY PROSE TYPOGRAPHY */
        .story-prose {
            font-family: 'Lora', Georgia, serif;
            font-size: 18px;
            line-height: 1.9;
            color: var(--book-ink);
        }
        .story-prose.sans-mode {
            font-family: 'Inter', sans-serif;
            line-height: 1.82;
        }
        .story-prose p {
            margin-bottom: 1.35em;
            text-align: left;
        }
        .story-prose p.first-para::first-letter {
            float: left;
            font-family: 'Lora', Georgia, serif;
            font-size: 3.3em;
            line-height: 0.82;
            padding-top: 4px;
            padding-right: 12px;
            padding-bottom: 4px;
            font-weight: 700;
            color: var(--primary);
        }

        /* Highlighted Vocabulary, Phrasal Verbs & Idioms Inside Text */
        .hl-word, .hl-phrasal, .hl-idiom {
            cursor: pointer;
            padding: 1px 5px;
            border-radius: 5px;
            font-weight: 600;
            transition: var(--transition);
            position: relative;
            display: inline;
        }
        .hl-word {
            background: rgba(255, 0, 122, 0.11);
            border-bottom: 2px dashed #FF007A;
            color: inherit;
        }
        .hl-phrasal {
            background: rgba(147, 51, 234, 0.11);
            border-bottom: 2px dashed #9333EA;
            color: inherit;
        }
        .hl-idiom {
            background: rgba(217, 119, 6, 0.14);
            border-bottom: 2px dashed #D97706;
            color: inherit;
        }
        .hl-word:hover, .hl-phrasal:hover, .hl-idiom:hover {
            filter: brightness(0.92);
        }
        .inline-hindi-hint {
            font-family: 'Inter', sans-serif;
            font-size: 0.76em;
            font-weight: 700;
            color: var(--primary);
            margin-left: 3px;
            opacity: 0.9;
        }

        /* Moral / Chapter Takeaway Box */
        .chapter-moral-box {
            margin-top: 26px;
            padding: 15px 18px;
            border-radius: 16px;
            background: var(--book-page-inner);
            border-left: 4px solid var(--primary);
            display: flex;
            align-items: flex-start;
            gap: 12px;
            font-size: 0.9rem;
            color: var(--book-ink);
        }
        .chapter-moral-box i {
            color: var(--primary); font-size: 1.15rem; margin-top: 2px; flex-shrink: 0;
        }

        /* Storybook Page Footer (Turn Page Controls & Done Button) */
        .folio-footer-nav {
            margin-top: 30px; padding-top: 20px;
            border-top: 1px solid var(--book-cover-border);
            display: flex; align-items: center; justify-content: space-between;
            gap: 12px; flex-wrap: wrap;
        }
        .btn-page-turn {
            background: var(--book-page-inner); color: var(--book-ink);
            border: 1px solid var(--book-cover-border); padding: 11px 20px;
            border-radius: var(--radius-pill); font-weight: 800; font-size: 0.86rem;
            cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
            transition: var(--transition); font-family: inherit;
        }
        .btn-page-turn:hover:not(:disabled) {
            border-color: var(--primary); color: var(--primary); transform: translateY(-2px);
        }
        .btn-page-turn:disabled { opacity: 0.4; cursor: not-allowed; }
        .btn-page-turn.primary {
            background: var(--primary-grad); color: #FFFFFF; border-color: transparent;
            box-shadow: 0 8px 18px rgba(255, 0, 122, 0.24);
        }
        .btn-page-turn.done-btn {
            background: linear-gradient(135deg, #10B981 0%, #059669 100%);
            color: #FFFFFF; border-color: transparent;
            box-shadow: 0 8px 18px rgba(16, 185, 129, 0.28);
        }
        .btn-page-turn.primary:hover:not(:disabled),
        .btn-page-turn.done-btn:hover:not(:disabled) {
            color: #FFFFFF; transform: translateY(-2px);
        }
        .page-number-badge {
            font-family: 'Lora', Georgia, serif; font-style: italic;
            font-size: 0.86rem; color: var(--book-muted); text-align: center;
        }

        /* ==========================================================================
           VIEW 3: VOCABULARY QUIZ (10 RANDOM MCQS, 5 OPTIONS, 2-MIN TIMER)
           ========================================================================== */
        .quiz-view-wrapper {
            max-width: 780px; margin: 22px auto 56px;
        }
        .quiz-card-shell {
            background: var(--bg-card); border: 1.5px solid var(--border-subtle);
            border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow-md);
        }
        @media (min-width: 768px) { .quiz-card-shell { padding: 32px 36px; } }

        .quiz-top-bar {
            display: flex; align-items: center; justify-content: space-between;
            flex-wrap: wrap; gap: 12px; padding-bottom: 16px;
            border-bottom: 1px solid var(--border-subtle); margin-bottom: 20px;
        }
        .quiz-timer-pill {
            display: inline-flex; align-items: center; gap: 8px;
            background: rgba(255, 0, 122, 0.09); color: var(--primary);
            padding: 8px 16px; border-radius: var(--radius-pill);
            font-weight: 800; font-size: 0.95rem; border: 1px solid rgba(255, 0, 122, 0.2);
        }
        .quiz-timer-pill.paused {
            background: #FEF3C7; color: #B45309; border-color: #F59E0B;
        }
        .quiz-progress-track {
            width: 100%; height: 6px; background: var(--bg-page);
            border-radius: 99px; overflow: hidden; margin-bottom: 22px;
        }
        .quiz-progress-bar {
            height: 100%; background: var(--primary-grad); width: 10%;
            transition: width 0.25s ease;
        }

        .quiz-type-badge {
            display: inline-block; font-size: 0.7rem; font-weight: 800;
            text-transform: uppercase; letter-spacing: 0.06em;
            padding: 4px 11px; border-radius: var(--radius-pill);
            background: rgba(255, 0, 122, 0.1); color: var(--primary);
            margin-bottom: 10px;
        }
        .quiz-question-title {
            font-size: clamp(1.05rem, 2.5vw, 1.25rem); font-weight: 800;
            color: var(--text-main); margin-bottom: 16px; line-height: 1.45;
        }

        .quiz-options-list {
            display: flex; flex-direction: column; gap: 10px;
        }
        .quiz-opt-btn {
            width: 100%; text-align: left; background: var(--bg-page);
            border: 1.5px solid var(--border-subtle); color: var(--text-main);
            padding: 13px 16px; border-radius: 14px; font-weight: 600; font-size: 0.92rem;
            cursor: pointer; display: flex; align-items: center; justify-content: space-between;
            gap: 12px; transition: var(--transition); font-family: inherit;
        }
        .quiz-opt-btn:hover:not(:disabled) {
            border-color: var(--primary); background: var(--bg-card);
        }
        .quiz-opt-letter {
            width: 28px; height: 28px; border-radius: 50%;
            background: var(--bg-card); border: 1px solid var(--border-subtle);
            display: inline-flex; align-items: center; justify-content: center;
            font-weight: 800; font-size: 0.78rem; flex-shrink: 0;
        }
        .quiz-opt-btn.selected-correct, .quiz-opt-btn.reveal-correct {
            background: #DCFCE7; border-color: #16A34A; color: #14532D;
        }
        .quiz-opt-btn.selected-correct .quiz-opt-letter,
        .quiz-opt-btn.reveal-correct .quiz-opt-letter {
            background: #16A34A; color: #FFFFFF; border-color: #16A34A;
        }
        .quiz-opt-btn.selected-wrong {
            background: #FFE4E6; border-color: #E11D48; color: #881337;
        }
        .quiz-opt-btn.selected-wrong .quiz-opt-letter {
            background: #E11D48; color: #FFFFFF; border-color: #E11D48;
        }

        .quiz-feedback-banner {
            margin-top: 16px; padding: 14px 16px; border-radius: 14px;
            background: #FFF1F2; border-left: 4px solid #E11D48;
            color: #881337; font-size: 0.88rem; display: none;
        }
        [data-theme="dark"] .quiz-feedback-banner {
            background: rgba(225, 29, 72, 0.15); color: #FECDD3;
        }

        .quiz-footer-controls {
            margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border-subtle);
            display: flex; align-items: center; justify-content: space-between; gap: 12px;
        }

        /* Quiz Results & Review Cards */
        .results-summary-grid {
            display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0;
        }
        @media (min-width: 640px) {
            .results-summary-grid { grid-template-columns: repeat(4, 1fr); }
        }
        .result-stat-card {
            background: var(--bg-page); border: 1px solid var(--border-subtle);
            border-radius: 16px; padding: 16px 12px; text-align: center;
        }
        .result-stat-val { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
        .result-stat-lbl { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }

        .review-list-container {
            margin-top: 24px; display: flex; flex-direction: column; gap: 14px;
            text-align: left;
        }
        .review-item-card {
            background: var(--bg-page); border: 1px solid var(--border-subtle);
            border-radius: 16px; padding: 16px 18px;
        }

        /* ==========================================================================
           MODALS: STORY COMPLETION POPUP, UID SYNC, AND PROJECT FILE EXPORTER
           ========================================================================== */
        .modal-backdrop {
            position: fixed; inset: 0; background: rgba(10, 15, 28, 0.68);
            backdrop-filter: blur(6px); z-index: 2300;
            display: flex; align-items: center; justify-content: center; padding: 16px;
        }
        .modal-card {
            background: var(--bg-card); color: var(--text-main);
            border: 1.5px solid var(--border-subtle); border-radius: 24px;
            width: 100%; max-width: 480px; padding: 28px 24px;
            text-align: center; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
            animation: popFade 0.22s ease-out;
        }
        .modal-icon-ring {
            width: 68px; height: 68px; border-radius: 50%;
            background: rgba(16, 185, 129, 0.14); color: #10B981;
            display: flex; align-items: center; justify-content: center;
            font-size: 1.9rem; margin: 0 auto 16px;
        }

        /* Floating Vocabulary Popover */
        .vocab-popover {
            position: fixed; z-index: 2200; width: 310px; max-width: calc(100vw - 24px);
            background: var(--bg-card); color: var(--text-main);
            border: 2px solid var(--primary); border-radius: 18px;
            padding: 16px; box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.25);
            display: none;
        }
        .vocab-popover.show { display: block; animation: popFade 0.18s ease-out; }
        @keyframes popFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

        .vault-card-badge {
            font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
            padding: 3px 9px; border-radius: 6px; letter-spacing: 0.04em;
        }
        .badge-word { background: #FCE7F3; color: #BE185D; }
        .badge-phrasal { background: #F3E8FF; color: #7E22CE; }
        .badge-idiom { background: #FEF3C7; color: #B45309; }

        /* ==========================================================================
           FOOTER & TOAST
           ========================================================================== */
        .main-footer {
            margin-top: auto;
            background: #0A0F1C; color: #9CA3AF; text-align: center;
            padding: 28px 14px 32px; font-size: 0.84rem; border-top: 1px solid #1E293B;
        }
        .footer-links {
            margin-top: 12px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 14px 20px; font-size: 0.82rem;
        }
        .footer-links a, .footer-links button {
            color: #9CA3AF; text-decoration: none; background: none; border: none;
            font-family: inherit; font-size: inherit; cursor: pointer;
        }
        .footer-links a:hover, .footer-links button:hover { color: #FFFFFF; }

        .toast-notification {
            visibility: hidden; min-width: 240px; max-width: 90vw; background-color: var(--dark-blue);
            color: #fff; text-align: center; border-radius: var(--radius-pill);
            padding: 11px 20px; position: fixed; z-index: 2600; left: 50%;
            transform: translateX(-50%); bottom: 24px; font-weight: 700; font-size: 0.85rem;
            box-shadow: var(--shadow-md); opacity: 0; transition: opacity 0.25s, bottom 0.25s;
        }
        .toast-notification.show { visibility: visible; opacity: 1; bottom: 36px; }
        .hidden { display: none !important; }