/* =====================================================================
   Bihar Study Portal - shared theme
   Loaded by header.php on every page. Selectors are prefixed with
   `body` so they win over the older per-page <style> blocks.
   ===================================================================== */

:root {
    --accent: #0284c7;
    --accent-strong: #075985;
    --accent-soft: #f0f9ff;
    --accent-2: #6366f1;

    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --page-bg: #f1f5f9;

    --ok: #16a34a;
    --ok-soft: #f0fdf4;
    --bad: #dc2626;
    --bad-soft: #fef2f2;

    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
    --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);

    --nav-h: 64px;
    --sidebar-w: 320px;
    --reading-scale: 1;
    --font: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.subject-history         { --accent: #9f1239; --accent-strong: #7f1d1d; --accent-soft: #fff1f2; --accent-2: #d97706; }
body.subject-geography       { --accent: #059669; --accent-strong: #065f46; --accent-soft: #ecfdf5; --accent-2: #0ea5e9; }
body.subject-polity          { --accent: #7c3aed; --accent-strong: #5b21b6; --accent-soft: #f5f3ff; --accent-2: #db2777; }
body.subject-economy         { --accent: #0284c7; --accent-strong: #075985; --accent-soft: #f0f9ff; --accent-2: #6366f1; }
body.subject-current_affairs { --accent: #ea580c; --accent-strong: #9a3412; --accent-soft: #fff7ed; --accent-2: #e11d48; }

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body.app {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    color: var(--ink-2);
    line-height: 1.65;
    background:
        radial-gradient(1200px 500px at 100% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
        radial-gradient(900px 400px at -10% 10%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 60%),
        var(--page-bg);
    background-attachment: fixed;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}

:where(body.app) a { color: inherit; text-decoration: none; }
body.app img, body.app video, body.app iframe:not(.goog-te-banner-frame) { max-width: 100%; height: auto; }
body.app ::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

body.app :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------------------------------------------------------------------
   Top navigation
   --------------------------------------------------------------------- */
body .topnav {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: var(--nav-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px clamp(12px, 3vw, 28px);
    background: linear-gradient(120deg, #0f172a 0%, color-mix(in srgb, var(--accent-strong) 70%, #0f172a) 55%, color-mix(in srgb, var(--accent) 65%, #0f172a) 100%);
    color: #fff;
    box-shadow: 0 8px 24px -12px rgba(2, 6, 23, .6);
    backdrop-filter: saturate(140%) blur(8px);
}

body .nav-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

body .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: -.2px;
    font-size: 1.08rem;
    color: #fff;
    white-space: nowrap;
}
body .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    box-shadow: 0 6px 16px -6px var(--accent-2), inset 0 0 0 1px rgba(255, 255, 255, .25);
    animation: logo-float 6s ease-in-out infinite;
}
body .brand-sub { display: block; font-size: .68rem; font-weight: 600; opacity: .7; letter-spacing: .6px; text-transform: uppercase; }

body .icon-btn,
body .sidebar-toggle-btn {
    display: none;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background .2s ease, transform .2s ease;
    -webkit-tap-highlight-color: transparent;
}
body .icon-btn:hover,
body .sidebar-toggle-btn:hover { background: rgba(255, 255, 255, .22); }
body .icon-btn:active,
body .sidebar-toggle-btn:active { transform: scale(.94); }

body .nav-links {
    flex: 1;
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px;
    mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}
body .nav-links::-webkit-scrollbar { display: none; }

body .nav-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    color: rgba(255, 255, 255, .82);
    font-weight: 600;
    font-size: .9rem;
    flex-shrink: 0;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}
body .nav-links a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
body .nav-links a.active {
    color: #0f172a;
    background: #fff;
    box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .55);
}

body .nav-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

body .home-btn,
body .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .88rem;
    color: #fff;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .22);
    white-space: nowrap;
    transition: background .2s ease, transform .2s ease;
}
body .home-btn:hover,
body .back-btn:hover { background: rgba(255, 255, 255, .26); transform: translateY(-1px); }

body .read-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    transform-origin: 0 50%;
    transform: scaleX(var(--progress, 0));
    background: linear-gradient(90deg, var(--accent-2), #fde047, var(--accent-2));
    transition: transform .1s linear;
}

/* ---------------------------------------------------------------------
   Layout shell
   --------------------------------------------------------------------- */
body .main-container {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-height: calc(100dvh - var(--nav-h));
    position: relative;
    overflow: visible;
}

body .content-area {
    flex: 1;
    min-width: 0;
    width: auto;
    max-width: none;
    margin: 0;
    padding: clamp(14px, 3vw, 34px) clamp(10px, 3vw, 34px) 90px;
    overflow: visible;
    background: transparent;
}

body .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(2, 6, 23, .5);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
body .sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------------
   Sidebar (shared by every subject)
   --------------------------------------------------------------------- */
body .sidebar {
    position: sticky;
    top: var(--nav-h);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--line);
    padding: 0 0 24px;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--accent) 35%, transparent) transparent;
    transition: transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .35s ease;
}
body .sidebar > * { flex-shrink: 0; }
body .sidebar::-webkit-scrollbar { width: 6px; }
body .sidebar::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 6px; }

body .sidebar-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 18px 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .9));
    border-bottom: 1px solid var(--line);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    text-align: left;
    box-shadow: none;
}
body .sidebar-header-title { display: flex; align-items: center; gap: 10px; width: auto; text-align: left; }
body .sidebar-header-title::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    box-shadow: 0 0 0 4px var(--accent-soft);
    flex-shrink: 0;
}

body .close-sidebar-btn {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

body .period-header {
    position: static;
    margin: 16px 16px 8px;
    padding: 0;
    background: none;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

body .period-group { margin: 10px 12px 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
body .period-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 13px 14px;
    border: 0;
    cursor: pointer;
    background: linear-gradient(90deg, var(--accent-soft), #fff);
    color: var(--accent-strong);
    font: inherit;
    font-size: .86rem;
    font-weight: 800;
    letter-spacing: .4px;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
}
body .period-toggle .period-label { display: inline-flex; align-items: center; gap: 8px; text-align: left; }
body .period-body { display: none; padding: 6px; }
body .period-group.is-open .period-body { display: block; }
body .period-group.is-open > .period-toggle .arrow { transform: rotate(180deg); }

body .chapter-container { margin: 2px 8px; border: 0; }
body .period-body .chapter-container { margin: 2px 0; }

body .sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-2);
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
    -webkit-tap-highlight-color: transparent;
}
body .sidebar-link:hover { background: var(--accent-soft); color: var(--accent-strong); }
body .sidebar-link.active-chapter {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
    border-left: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    padding-left: 12px;
    font-weight: 700;
}

body .arrow,
body .chapter-arrow,
body .period-arrow {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 0;
    color: currentColor;
    transition: transform .3s ease;
}
body .arrow::before,
body .chapter-arrow::before,
body .period-arrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    opacity: .7;
}

body .sidebar-module-list {
    list-style: none;
    margin: 4px 0 8px 14px;
    padding: 2px 0 2px 10px;
    border-left: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
    background: transparent;
    max-height: none;
    overflow: visible;
}
body .sidebar-module-list li { list-style: none; }

body .sidebar-module-item {
    position: relative;
    display: block;
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 500;
    line-height: 1.45;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}
body .sidebar-module-item::before { content: none; }
body .sidebar-module-item:hover { color: var(--accent-strong); background: var(--accent-soft); transform: translateX(2px); }
body .sidebar-module-item.active-module {
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
    box-shadow: 0 8px 18px -10px var(--accent);
    border-left: 0;
    margin-left: 0;
}

/* ---------------------------------------------------------------------
   Module card
   --------------------------------------------------------------------- */
body .module-content {
    position: relative;
    display: block;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 42px);
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-top: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    font-size: calc(1rem * var(--reading-scale));
    animation: card-in .5s cubic-bezier(.22, 1, .36, 1) both;
}
body .module-content::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
    background-size: 200% 100%;
    animation: shimmer 6s linear infinite;
}

body .header-top-bar,
body .breadcrumb-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
body .top-controls-wrapper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

body .modern-breadcrumb,
body .breadcrumb {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .2px;
    text-transform: none;
    line-height: 1.4;
}
body .modern-breadcrumb span,
body .breadcrumb span { color: inherit !important; }

body .module-title {
    margin: 4px 0 18px;
    padding: 0;
    border: 0;
    font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.15rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -.5px;
    color: var(--ink);
    background: linear-gradient(120deg, var(--ink) 30%, var(--accent-strong));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body .chapter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px 0 20px;
}
body .meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------------
   Controls (selects, toolbar buttons)
   --------------------------------------------------------------------- */
body .lang-dropdown,
body .speed-dropdown,
body .voice-selector,
body .tts-select {
    height: 42px;
    padding: 0 34px 0 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='2' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    appearance: none;
    color: var(--ink-2);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
body .lang-dropdown:hover, body .lang-dropdown:focus,
body .speed-dropdown:hover, body .speed-dropdown:focus,
body .voice-selector:hover, body .voice-selector:focus,
body .tts-select:hover, body .tts-select:focus {
    border-color: var(--accent);
    background-color: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
body .voice-selector { flex: 1; min-width: 170px; max-width: 100%; }

body .tts-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 26px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--line);
}

body .tts-btn,
body .pdf-btn,
body .pdf-download-btn,
body .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
    box-shadow: 0 8px 18px -10px var(--accent);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
    -webkit-tap-highlight-color: transparent;
}
body .tts-btn:hover,
body .pdf-btn:hover,
body .pdf-download-btn:hover,
body .btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 12px 22px -10px var(--accent); }
body .tts-btn:active,
body .pdf-btn:active,
body .pdf-download-btn:active,
body .btn:active { transform: scale(.97); }

body .pdf-btn,
body .pdf-download-btn { background: linear-gradient(135deg, #f59e0b, #ea580c); box-shadow: 0 8px 18px -10px #ea580c; }

body .tts-btn.playing,
body .tts-btn.tts-playing { background: linear-gradient(135deg, #16a34a, #059669); animation: pulse-ring 1.6s ease-out infinite; }
body .tts-btn.tts-paused { background: linear-gradient(135deg, #f59e0b, #d97706); }
body .tts-stop-btn { background: var(--bad-soft); color: var(--bad); border: 1px solid #fecaca; box-shadow: none; }

body .tts-player-bar {
    display: flex;
    width: 100%;
    gap: 10px;
    padding: 10px;
    margin-bottom: 22px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--line);
    box-shadow: none;
}
body .tts-ctrl-group, body .tts-options-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
body .tts-options-group { flex: 1; }
body .tts-select { max-width: 240px; }

body .unified-top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 6px 0 24px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--line);
}
body .unified-top-bar .controls-col-center { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
body .unified-top-bar form { margin: 0; }

body .goog-te-gadget-simple {
    height: 42px;
    display: inline-flex !important;
    align-items: center;
    padding: 0 12px !important;
    border-radius: 12px !important;
    border: 1px solid var(--line) !important;
    background: var(--surface-2) !important;
    font-size: .85rem !important;
}
body .goog-te-gadget .goog-te-combo {
    height: 42px !important;
    border-radius: 12px !important;
    border: 1px solid var(--line) !important;
    background: var(--surface-2) !important;
}

/* ---------------------------------------------------------------------
   Reading content
   --------------------------------------------------------------------- */
body .module-body,
body .concept-block,
body .topic-study-unit {
    color: var(--ink-2);
    font-size: 1.03em;
    line-height: 1.85;
}
body .module-body p,
body .concept-block p { margin: 0 0 14px; }

body .module-body h2, body .concept-block h2,
body .module-body h3, body .concept-block h3,
body .module-body h4, body .concept-block h4 {
    color: var(--ink);
    line-height: 1.35;
    letter-spacing: -.2px;
    scroll-margin-top: calc(var(--nav-h) + 16px);
}
body .module-body h2, body .concept-block h2 {
    position: relative;
    margin: 6px 0 16px !important;
    padding: 0 0 10px 16px !important;
    font-size: clamp(1.15rem, 1rem + .6vw, 1.4rem) !important;
    border-bottom: 1px dashed var(--line) !important;
}
body .module-body h2::before, body .concept-block h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .2em;
    bottom: calc(10px + .2em);
    width: 5px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
body .module-body h3, body .concept-block h3 { margin: 26px 0 10px; font-size: 1.18em; }

body .module-body ul, body .module-body ol,
body .concept-block ul, body .concept-block ol { padding-left: 1.3em; margin: 12px 0 18px; }
body .module-body li, body .concept-block li { margin-bottom: 9px; }
body .module-body li::marker, body .concept-block li::marker { color: var(--accent); }
body .module-body strong, body .concept-block strong { color: var(--ink); }
body .module-body blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

body .table-scroll,
body .table-responsive-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 18px 0;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    background: #fff;
}
body .module-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: .93em;
    background: #fff;
}
body .module-content th {
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
    color: #fff;
    font-weight: 700;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 60%, #fff);
    text-align: left;
    white-space: nowrap;
}
body .module-content td { padding: 10px 12px; border: 1px solid var(--line); vertical-align: top; }
body .module-content tbody tr:nth-child(even) td { background: var(--surface-2); }
body .module-content tbody tr:hover td { background: var(--accent-soft); }

/* Key points & one-liners */
body .points-wrapper,
body .oneliner-wrapper {
    position: relative;
    margin: 22px 0;
    padding: 18px 18px 14px;
    border-radius: var(--radius);
    border: 1px solid;
    overflow: hidden;
}
body .points-wrapper {
    background: linear-gradient(135deg, var(--accent-soft), #fff 70%);
    border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
body .oneliner-wrapper {
    background: linear-gradient(135deg, #fffbeb, #fff 70%);
    border-color: #fde68a;
}
body .points-title,
body .oneliner-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: 800;
}
body .points-title { color: var(--accent-strong); }
body .oneliner-title { color: #b45309; }
body .points-list,
body .oneliner-list { margin: 0; padding-left: 1.2em; font-size: .95em; color: var(--ink-2); text-align: left; }
body .points-list li,
body .oneliner-list li { margin-bottom: 8px; padding-left: 4px; }
body .points-list li::marker { color: var(--accent); }
body .oneliner-list li::marker { color: #d97706; }

body .unit-divider {
    height: 1px;
    margin: 34px 0;
    border: 0;
    background: linear-gradient(90deg, transparent, var(--line) 15%, var(--line) 85%, transparent);
}

/* ---------------------------------------------------------------------
   MCQs
   --------------------------------------------------------------------- */
body .mcq-section-wrapper {
    margin: 26px 0 10px;
    padding: clamp(14px, 3vw, 24px);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--surface-2), #fff);
    border: 1px solid var(--line);
}
body .mcq-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-size: 1.12rem;
    font-weight: 800;
}

body .modern-mcq-card {
    position: relative;
    margin-bottom: 16px;
    padding: clamp(14px, 3vw, 20px);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
body .modern-mcq-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
body .modern-mcq-card.is-correct { border-color: #86efac; }
body .modern-mcq-card.is-wrong { border-color: #fca5a5; animation: shake .4s ease; }

body .mcq-question {
    margin: 0 0 14px;
    color: var(--ink);
    font-weight: 700;
    font-size: 1em;
    line-height: 1.6;
    text-align: left;
}

body .options-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) {
    body .options-grid.two-col { grid-template-columns: 1fr 1fr; }
}

body .modern-option-btn {
    position: relative;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    text-align: left;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    font: inherit;
    font-size: .95em;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .15s ease, box-shadow .2s ease;
    -webkit-tap-highlight-color: transparent;
}
body .modern-option-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent-strong);
    transform: translateX(3px);
    box-shadow: 0 6px 16px -10px var(--accent);
}
body .modern-option-btn:active:not(:disabled) { transform: scale(.985); }
body .modern-option-btn:disabled { cursor: default; }
body .modern-option-btn.opt-correct { background: #dcfce7 !important; border-color: #22c55e !important; color: #15803d !important; font-weight: 700; opacity: 1 !important; }
body .modern-option-btn.opt-wrong { background: #fee2e2 !important; border-color: #ef4444 !important; color: #b91c1c !important; font-weight: 700; opacity: 1 !important; }
body .modern-option-btn.opt-dim { opacity: .55; }

body .modern-explanation-box {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    font-size: .93em;
    line-height: 1.65;
}
body .modern-explanation-box.ok,
body .modern-explanation-box.bad {
    position: static;
    width: auto;
    height: auto;
    margin-top: 14px;
    padding: 14px 16px;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    border-radius: 12px;
    animation: card-in .35s ease both;
}
body .modern-explanation-box.ok { display: block; background: var(--ok-soft); color: #166534; border: 1px solid #bbf7d0; border-left: 5px solid #22c55e; }
body .modern-explanation-box.bad { display: block; background: var(--bad-soft); color: #991b1b; border: 1px solid #fecaca; border-left: 5px solid #ef4444; }

/* ---------------------------------------------------------------------
   Completion card & footer navigation
   --------------------------------------------------------------------- */
body .completion-card {
    position: relative;
    overflow: hidden;
    margin: 34px 0 10px;
    padding: clamp(20px, 4vw, 30px);
    text-align: center;
    border-radius: var(--radius-lg);
    color: #fff;
    border: 0;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent) 55%, var(--accent-2));
    box-shadow: var(--shadow-lg);
}
body .completion-card::after {
    content: "";
    position: absolute;
    inset: -40% -10% auto auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 70%);
    pointer-events: none;
}
body .completion-title { margin-bottom: 8px; font-size: 1.3rem; font-weight: 800; color: #fff; }
body .completion-desc { margin: 0 auto 18px; max-width: 560px; font-size: .95rem; color: rgba(255, 255, 255, .88); }
body .completion-btn {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: 999px;
    background: #fff;
    color: var(--accent-strong) !important;
    font-weight: 800;
    font-size: .98rem;
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .45);
    transition: transform .2s ease, box-shadow .2s ease;
}
body .completion-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 16px 30px -12px rgba(0, 0, 0, .5); }

body .module-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 34px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

body .nav-btn,
body .unified-top-bar .nav-btn,
body .module-footer .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: auto;
    min-height: 46px;
    padding: 10px 20px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    background: #334155;
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
body .nav-btn:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 10px 20px -12px rgba(15, 23, 42, .6); }
body .nav-btn.prev-btn { background: #334155; }
body .nav-btn.prev-btn:hover { transform: translateX(-3px); }
body .nav-btn.next-btn {
    margin-left: auto;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
    box-shadow: 0 8px 18px -10px var(--accent);
}
body .nav-btn.next-btn:hover { transform: translateX(3px); }
body .nav-btn-disabled { background: #cbd5e1 !important; color: #f8fafc !important; pointer-events: none; opacity: .75; }

body .module-counter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: .82rem;
    font-weight: 800;
}
body .module-dots { display: inline-flex; gap: 4px; }
body .module-dots i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 25%, transparent); }
body .module-dots i.on { background: var(--accent); width: 18px; border-radius: 6px; }

/* ---------------------------------------------------------------------
   Floating tools (added by theme.js)
   --------------------------------------------------------------------- */
body .floating-tools {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    bottom: 86px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
body .fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 24px -10px var(--accent);
    transition: transform .25s ease, opacity .25s ease;
    -webkit-tap-highlight-color: transparent;
}
body .fab:hover { transform: translateY(-2px); }
body .fab-font { display: none; background: #fff; color: var(--accent-strong); border: 1px solid var(--line); box-shadow: var(--shadow); }
body .fab-top { opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; }
body .fab-top.show { opacity: 1; transform: none; pointer-events: auto; }

body .font-tools {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
body .font-tools button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
body .font-tools button:hover { background: var(--accent-soft); color: var(--accent-strong); }

body .score-pill {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
}
body .score-pill.show { display: inline-flex; animation: pop .35s cubic-bezier(.34, 1.56, .64, 1); }
body .score-pill .score-bar { width: 60px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .2); overflow: hidden; }
body .score-pill .score-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4ade80, #22c55e); transition: width .4s ease; }

/* Reveal-on-scroll */
body .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.22, 1, .36, 1); }
body .reveal.is-visible { opacity: 1; transform: none; }

/* ---------------------------------------------------------------------
   Simple standalone pages (upload / download / overview)
   --------------------------------------------------------------------- */
body.standalone {
    display: grid;
    place-items: center;
    padding: 20px;
}
body .panel {
    width: 100%;
    max-width: 560px;
    padding: clamp(22px, 5vw, 36px);
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    animation: card-in .5s cubic-bezier(.22, 1, .36, 1) both;
}
body .panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
body .panel h1, body .panel h2 { margin: 0 0 10px; color: var(--ink); font-size: 1.45rem; letter-spacing: -.3px; }

body .alert { padding: 12px 16px; border-radius: 12px; margin: 14px 0; font-size: .94rem; font-weight: 600; }
body .alert-success { background: var(--ok-soft); color: #166534; border: 1px solid #bbf7d0; }
body .alert-error { background: var(--bad-soft); color: #991b1b; border: 1px solid #fecaca; }

body .dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 28px 16px;
    text-align: center;
    border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent-strong);
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
body .dropzone:hover, body .dropzone.drag { border-color: var(--accent); transform: scale(1.01); }
body .dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
body .dropzone .dz-icon { font-size: 2rem; }
body .dropzone .dz-name { font-size: .85rem; color: var(--muted); word-break: break-all; }

body .welcome-screen {
    max-width: 760px;
    margin: 6vh auto 0;
    text-align: center;
    padding: clamp(24px, 5vw, 48px);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow);
}
body .welcome-screen h2 { margin: 0 0 10px; font-size: clamp(1.4rem, 1rem + 2vw, 2.1rem); color: var(--ink); }
body .welcome-screen p { color: var(--muted); margin: 0; }

body .panel .chapter-meta { margin: 6px 0 18px; }
body .upload-form { display: grid; gap: 14px; }
body .upload-submit, body .upload-back { width: 100%; justify-content: center; }
body .upload-back { margin-top: 12px; }

body .download-panel { max-width: 900px; }
body .download-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin: 4px 0 22px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}
body .download-status { display: inline-flex; align-items: center; gap: 10px; }
body .download-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; }
body .download-actions .nav-btn { min-height: 38px; padding: 8px 14px; font-size: .88rem; }
body .spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
body .download-status.done .spinner { animation: none; border-color: var(--ok); background: var(--ok); }
body #pdf-target { color: var(--ink-2); line-height: 1.8; }
body #pdf-target h1 { margin: 0 0 18px; padding-bottom: 12px; border-bottom: 3px solid var(--accent); color: var(--ink); font-size: clamp(1.35rem, 1rem + 1.6vw, 1.85rem); }
body #pdf-target table { width: 100%; border-collapse: collapse; margin: 16px 0; display: block; overflow-x: auto; }
body #pdf-target th { background: var(--accent); color: #fff; padding: 10px 12px; text-align: left; }
body #pdf-target td { padding: 8px 12px; border: 1px solid var(--line); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes gradient-shift { 0%, 100% { background-position: 0 0, 0% 50%; } 50% { background-position: 0 0, 100% 50%; } }

body .nav-links .nav-soon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    color: rgba(255, 255, 255, .45);
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
    cursor: not-allowed;
}
body .nav-links .nav-soon small {
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: rgba(255, 255, 255, .75);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* History overview hub */
body .hub-hero {
    position: relative;
    overflow: hidden;
    max-width: 1100px;
    margin: 0 auto 28px;
    padding: clamp(26px, 5vw, 52px);
    border-radius: var(--radius-lg);
    color: #fff;
    background:
        radial-gradient(circle at 85% 15%, rgba(255, 255, 255, .22), transparent 40%),
        linear-gradient(135deg, var(--accent-strong), var(--accent) 55%, var(--accent-2));
    background-size: 100% 100%, 200% 200%;
    animation: card-in .6s cubic-bezier(.22, 1, .36, 1) both, gradient-shift 12s ease infinite;
    box-shadow: var(--shadow-lg);
}
body .hub-hero h1 { margin: 10px 0 8px; font-size: clamp(1.8rem, 1.2rem + 3vw, 3rem); letter-spacing: -.6px; color: #fff; }
body .hub-hero p { margin: 0; max-width: 620px; opacity: .92; font-size: 1.05rem; }
body .hub-eyebrow { display: inline-block; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: .8rem; font-weight: 700; letter-spacing: .4px; }
body .hub-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; }
body .hub-stats span {
    display: grid;
    min-width: 96px;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .14);
    backdrop-filter: blur(6px);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}
body .hub-stats strong { font-size: 1.6rem; letter-spacing: 0; line-height: 1.1; }
body .hub-actions { display: flex; flex-wrap: wrap; gap: 10px; }
body .hub-actions .nav-btn.next-btn { background: #fff; color: var(--accent-strong); }
body .hub-actions .nav-btn.prev-btn { background: rgba(255, 255, 255, .16); color: #fff; }

body .hub-period { max-width: 1100px; margin: 0 auto 30px; }
body .hub-period-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
body .hub-period-head h2 { margin: 0; color: var(--ink); font-size: clamp(1.2rem, 1rem + 1vw, 1.5rem); }
body .hub-period-head p { margin: 2px 0 0; color: var(--muted); font-size: .94rem; }
body .hub-period-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--accent-soft);
    font-size: 1.6rem;
    box-shadow: var(--shadow-sm);
}
body .hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
body .hub-card {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 18px 18px 16px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    color: var(--ink-2);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
body .hub-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
body .hub-card-num {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 800;
}
body .hub-card-title { color: var(--ink); font-weight: 700; line-height: 1.4; }
body .hub-card-meta { color: var(--accent); font-size: .85rem; font-weight: 600; }
@media (max-width: 760px) {
    body .hub-grid { gap: 10px; }
    body .hub-card { grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; padding: 12px 14px; align-items: center; }
    body .hub-card-num { grid-row: span 2; }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1024px) {
    body .sidebar-toggle-btn,
    body .icon-btn { display: inline-flex; }
    body.no-sidebar .sidebar-toggle-btn { display: none; }

    body .close-sidebar-btn { display: inline-flex; }

    body .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100%;
        height: 100dvh;
        width: min(88vw, 340px);
        min-width: 0;
        z-index: 1200;
        background: #fff;
        transform: translateX(-105%);
        box-shadow: none;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
    body .sidebar.drawer-open {
        transform: translateX(0);
        box-shadow: 24px 0 60px -20px rgba(2, 6, 23, .5);
    }

    body .nav-links { justify-content: flex-start; }
}

@media (max-width: 760px) {
    :root { --nav-h: 58px; }

    body .topnav { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
    body .brand-text { display: none; }
    body .nav-right { margin-left: auto; }
    body .nav-links { order: 3; flex: 1 0 100%; padding: 2px 0 4px; }
    body .nav-links a { padding: 7px 12px; font-size: .82rem; }
    body .home-btn, body .back-btn { padding: 8px 12px; font-size: .8rem; }

    body .content-area { padding: 12px 8px 110px; }
    body .module-content { border-radius: 16px; padding: 20px 14px; }
    body .module-content::before { border-radius: 16px 16px 0 0; }

    body .header-top-bar, body .breadcrumb-row { flex-direction: column; align-items: stretch; }
    body .modern-breadcrumb, body .breadcrumb { border-radius: 14px; }
    body .top-controls-wrapper { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
    body .top-controls-wrapper > * { flex: 1 1 140px; min-width: 0; }
    body .top-controls-wrapper form > button,
    body .top-controls-wrapper .lang-dropdown { width: 100%; }

    body .tts-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
    body .tts-controls .tts-btn { grid-column: 1 / -1; }
    body .tts-controls .voice-selector { grid-column: 1 / -1; min-width: 0; }
    body .tts-controls .pdf-btn,
    body .tts-controls .speed-dropdown { width: 100%; padding-left: 10px; padding-right: 10px; }
    body .tts-player-bar, body .tts-ctrl-group, body .tts-options-group { flex-direction: column; align-items: stretch; }
    body .tts-select { max-width: none; width: 100%; }

    body .unified-top-bar { padding: 10px; }
    body .unified-top-bar .controls-col-center { order: 1; width: 100%; flex-direction: row; flex-wrap: wrap; }
    body .unified-top-bar .controls-col-center > * { flex: 1 1 140px; min-width: 0; }
    body .unified-top-bar .controls-col-center .lang-dropdown { width: 100%; }

    body .module-nav-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    body .module-nav-bar .nav-btn { width: 100%; margin: 0 !important; }
    body .module-nav-bar > :only-child { grid-column: 1 / -1; }
    body .unified-top-bar .nav-col-left, body .unified-top-bar .nav-col-right { order: 2; flex: 1 1 45%; }
    body .unified-top-bar .nav-btn { width: 100%; }
    body .unified-top-bar .pdf-download-btn { width: 100%; }

    body .module-body, body .concept-block, body .topic-study-unit { font-size: 1em; line-height: 1.8; }
    body .module-body p, body .module-body li,
    body .concept-block p, body .concept-block li, body .concept-block div,
    body .points-list li, body .oneliner-list li, body .mcq-question, body .modern-explanation-box { text-align: left !important; }
    body .module-content th { white-space: normal; }

    body .module-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    body .module-footer .nav-btn { width: 100%; margin: 0 !important; padding: 10px 12px; font-size: .84rem; }
    body .module-footer .module-counter { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
    body .module-footer > :only-child { grid-column: 1 / -1; }

    body .completion-btn { width: 100%; justify-content: center; }

    body .floating-tools { left: 10px; right: auto; bottom: 78px; }
    body .fab { width: 44px; height: 44px; }
    body .fab-font { display: grid; }
    body .font-tools { display: none; }
    body .floating-tools.font-open .font-tools { display: flex; animation: pop .25s ease; }
    body .score-pill { font-size: .78rem; padding: 8px 12px; }
}

@media (hover: none) {
    body .modern-option-btn:hover:not(:disabled) { transform: none; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    body .reveal { opacity: 1; transform: none; }
}

@media print {
    body .topnav, body .sidebar, body .sidebar-overlay, body .floating-tools,
    body .tts-controls, body .tts-player-bar, body .unified-top-bar, body .module-footer,
    body .mcq-section-wrapper, body .completion-card, body .top-controls-wrapper { display: none !important; }
    body.app { background: #fff; }
    body .module-content { box-shadow: none; border: 0; max-width: none; }
}

/* ---------------------------------------------------------------------
   Keyframes
   --------------------------------------------------------------------- */
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: 200% 0; } }
@keyframes logo-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-4deg); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 100% { box-shadow: 0 0 0 14px rgba(22, 163, 74, 0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------------
   Economics-style study split.
   The left chapter list is unchanged. Notes stay on the left of the
   lesson, and questions move one at a time on the right.
   --------------------------------------------------------------------- */
@media (min-width: 901px) {
    body.app:has(.magazine-sheet) {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }
    body.app:has(.magazine-sheet) .main-container {
        height: calc(100dvh - var(--nav-h));
        max-height: calc(100dvh - var(--nav-h));
        min-height: 0;
        overflow: hidden;
        align-items: stretch;
    }
    body.app:has(.magazine-sheet) .content-area {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 8px 12px;
    }
    body.app:has(.magazine-sheet) .module-content.magazine-sheet {
        max-width: none;
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 10px 12px 6px;
        animation: none;
    }
}

body .magazine-sheet .header-top-bar,
body .magazine-sheet .module-title,
body .magazine-sheet .chapter-meta,
body .magazine-sheet .function-list,
body .magazine-sheet .completion-card,
body .magazine-sheet .module-footer {
    flex: 0 0 auto;
}
body .magazine-sheet .function-list {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    margin: 0;
    padding: 4px 6px;
}
body .magazine-sheet .pipeline-flow-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
body .magazine-sheet .unit-block { display: none; }
body .magazine-sheet .unit-block.is-on {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
body .magazine-sheet .topic-study-unit,
body .magazine-sheet .study-split {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}
body .magazine-sheet .topic-study-unit { display: flex; flex-direction: column; }
body .magazine-sheet .study-split {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    gap: 10px;
    width: 100%;
}
body .magazine-sheet .study-split:has(.topic-rail:not([hidden])) {
    grid-template-columns: minmax(0, 1.35fr) 56px minmax(280px, 0.8fr);
}
body .magazine-sheet .study-lesson,
body .magazine-sheet .study-questions {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
    background: var(--surface);
}
body .magazine-sheet .study-questions { background: var(--surface-2); }
body .magazine-sheet .subtopic-stage,
body .magazine-sheet .q-stack {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--accent) 55%, #cbd5e1) transparent;
}
body .magazine-sheet .subtopic-stage { position: relative; }
body .magazine-sheet .subtopic { display: block; }
body .magazine-sheet .subtopic:not(.is-on) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    pointer-events: none;
}
body .magazine-sheet .subtopic.is-on {
    position: relative;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    pointer-events: auto;
}
body .magazine-sheet .q-stage[hidden] { display: none !important; }
body .magazine-sheet .study-questions { position: relative; }
body .magazine-sheet .q-stage.is-off {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    border: 0 !important;
}
body .magazine-sheet .q-stage:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
body .magazine-sheet .q-deck {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
body .magazine-sheet .q-card { display: none; }
body .magazine-sheet .q-card.is-on { display: block; }
body .magazine-sheet .exam-bar,
body .magazine-sheet .sub-nav,
body .magazine-sheet .q-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
}
body .magazine-sheet .exam-bar {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
body .magazine-sheet .kicker,
body .magazine-sheet .section-label,
body .magazine-sheet .sub-count,
body .magazine-sheet .q-count,
body .magazine-sheet .deck-hint {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-strong);
}
body .magazine-sheet .deck-hint {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--muted);
    margin: 0 0 8px;
}
body .magazine-sheet .sub-nav,
body .magazine-sheet .q-nav { margin-top: 10px; }
body .magazine-sheet .sub-nav button,
body .magazine-sheet .q-nav button,
body .magazine-sheet .topic-arrow {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
}
body .magazine-sheet .sub-nav button:disabled,
body .magazine-sheet .q-nav button:disabled,
body .magazine-sheet .topic-arrow:disabled {
    opacity: 0.4;
    cursor: default;
}
body .magazine-sheet .topic-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
body .magazine-sheet .topic-rail[hidden] { display: none !important; }
body .magazine-sheet .topic-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}
body .magazine-sheet .topic-pos {
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent-strong);
}
body .magazine-sheet .q-line { margin: 0 0 10px; line-height: 1.55; }
body .liner-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
body .liner-form { display: flex; flex-direction: column; gap: 8px; }
body .liner-label {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--muted);
}
body .liner-input {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
    line-height: 1.45;
}
body .liner-input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
body .liner-submit {
    align-self: flex-start;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}
body .liner-submit:disabled { opacity: .55; cursor: default; }
body .liner-answer-source,
body .liner-result:not(.ok):not(.show) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
body .liner-result.ok,
body .liner-result.show {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    margin-top: 10px;
    padding: 10px 12px;
    overflow: visible !important;
    clip-path: none !important;
    white-space: normal !important;
    border-radius: 8px;
    line-height: 1.5;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
}
body .liner-result.ok {
    background: var(--ok-soft);
    color: #166534;
    border-color: #bbf7d0;
}
body .magazine-sheet .completion-card { margin-top: 8px; }
body .magazine-sheet .module-footer { margin-top: 6px; }

@media (max-width: 900px) {
    body.app:has(.magazine-sheet) { height: auto; overflow: visible; }
    body.app:has(.magazine-sheet) .main-container,
    body.app:has(.magazine-sheet) .content-area,
    body.app:has(.magazine-sheet) .module-content.magazine-sheet,
    body .magazine-sheet .pipeline-flow-body,
    body .magazine-sheet .unit-block.is-on,
    body .magazine-sheet .topic-study-unit {
        height: auto;
        overflow: visible;
        display: block;
    }
    body .magazine-sheet .study-split,
    body .magazine-sheet .study-split:has(.topic-rail:not([hidden])) {
        display: flex;
        flex-direction: column;
        height: auto;
    }
    body .magazine-sheet .topic-rail {
        flex-direction: row;
        order: 2;
        justify-content: center;
    }
    body .magazine-sheet .study-questions { order: 3; }
    body .magazine-sheet .study-lesson,
    body .magazine-sheet .study-questions {
        display: block;
        overflow: visible;
        min-height: 0;
        height: auto;
        max-height: none;
    }
    body .magazine-sheet .q-stage:not([hidden]),
    body .magazine-sheet .q-deck,
    body .magazine-sheet .q-stack,
    body .magazine-sheet .study-lesson .subtopic-stage {
        display: block;
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: visible;
        flex: none;
    }
    body .magazine-sheet .liner-card {
        margin: 0 0 12px;
        max-width: 100%;
    }
    body .magazine-sheet .q-line,
    body .magazine-sheet .oneliner-list,
    body .magazine-sheet .oneliner-list li,
    body .liner-card,
    body .liner-form,
    body .liner-input,
    body .liner-result {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    /* The one-liner part must stay in the page flow and inside the screen.
       A clipped or nowrap stage cuts the Hindi question and hides the answer box. */
    body .magazine-sheet .study-split,
    body .magazine-sheet .study-lesson,
    body .magazine-sheet .study-questions,
    body .magazine-sheet .q-deck,
    body .magazine-sheet .q-stack,
    body .magazine-sheet .liner-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    body .magazine-sheet .q-stage:not(.is-off) {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        overflow: visible !important;
        clip-path: none !important;
        white-space: normal !important;
        pointer-events: auto !important;
    }
    body .oneliner-wrapper {
        overflow: visible;
        max-width: 100%;
    }
    body .liner-input {
        width: 100%;
        max-width: 100%;
        min-height: 72px;
    }
    body .liner-submit {
        align-self: stretch;
        width: 100%;
        min-height: 44px;
        height: auto;
    }
    /* One-word / one-liner prompts must never clip on phones. */
    body .magazine-sheet .q-line {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
        text-overflow: clip;
        -webkit-line-clamp: unset;
        line-clamp: unset;
    }
    body .magazine-sheet .liner-card,
    body .magazine-sheet .liner-form {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }
}

/* Chapter list stays closed until the three-line button is used. */
body .sidebar-toggle-btn,
body .close-sidebar-btn { display: inline-flex; }
body .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    width: min(88vw, 340px);
    min-width: 0;
    z-index: 1200;
    background: #fff;
    transform: translateX(-105%);
    box-shadow: none;
}
body .sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 24px 0 60px -20px rgba(2, 6, 23, .5);
}
body .completion-card { display: none !important; }

body .magazine-sheet .module-title,
body .magazine-sheet .feature-title {
    font-size: 1.15rem;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: 0;
    margin: 2px 0 6px;
    -webkit-text-fill-color: var(--ink);
    background: none;
    color: var(--ink);
}
body .magazine-sheet .chapter-meta { margin: 0 0 4px; }
body .magazine-sheet .modern-breadcrumb { font-size: .78rem; margin-bottom: 4px; }
body .magazine-sheet .topic-row {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    gap: 4px;
    margin-bottom: 6px;
}
body .magazine-sheet .tts-controls.function-list {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    grid-template-columns: none !important;
    margin: 0;
    padding: 4px 6px;
}
body .magazine-sheet .tts-controls.function-list > * {
    grid-column: auto !important;
    flex: 0 0 auto;
    width: auto !important;
    min-width: 0;
}
body .magazine-sheet .tts-controls .lang-dropdown,
body .magazine-sheet .tts-controls .speed-dropdown,
body .magazine-sheet .tts-controls .voice-selector,
body .magazine-sheet .tts-controls .tts-btn,
body .magazine-sheet .tts-controls .pdf-btn {
    height: 32px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: .78rem;
    box-shadow: none;
    gap: 6px;
}
body .magazine-sheet .tts-controls .speed-dropdown {
    width: 68px !important;
    padding-left: 8px;
    padding-right: 24px;
    background-position: right 8px center;
}
body .magazine-sheet .tts-controls .lang-dropdown {
    padding-right: 26px;
    background-position: right 8px center;
}
body .magazine-sheet .tts-controls .voice-selector {
    flex: 1 1 180px;
    min-width: 140px;
    max-width: none;
    width: auto !important;
    padding-right: 28px;
    background-position: right 8px center;
}
body .magazine-sheet #google_translate_element {
    flex: 0 0 auto;
    max-width: 168px;
    height: 32px;
    overflow: hidden;
}
body .magazine-sheet .goog-te-gadget {
    font-size: 0 !important;
    height: 32px !important;
    line-height: 32px !important;
    overflow: hidden;
}
body .magazine-sheet .goog-te-gadget-simple,
body .magazine-sheet .goog-te-gadget .goog-te-combo {
    height: 32px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    border-radius: 8px !important;
    font-size: .78rem !important;
    line-height: 30px !important;
}
@media (min-width: 901px) {
    body .magazine-sheet .pipeline-flow-body,
    body .magazine-sheet .unit-block.is-on,
    body .magazine-sheet .topic-study-unit,
    body .magazine-sheet .study-split {
        overflow: hidden;
        min-height: 0;
        max-height: 100%;
    }
    body .magazine-sheet .study-split {
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
    }
    body .magazine-sheet .study-lesson,
    body .magazine-sheet .study-questions {
        height: 100%;
        max-height: 100%;
        min-height: 0;
    }
}
@media (max-width: 760px) {
    body .magazine-sheet .tts-controls.function-list {
        display: flex !important;
        flex-flow: row nowrap !important;
        overflow-x: auto;
    }
    body .magazine-sheet .tts-controls .tts-btn,
    body .magazine-sheet .tts-controls .voice-selector,
    body .magazine-sheet .tts-controls .pdf-btn,
    body .magazine-sheet .tts-controls .speed-dropdown,
    body .magazine-sheet .tts-controls .lang-dropdown {
        grid-column: auto !important;
        width: auto !important;
    }
    body .magazine-sheet .tts-controls .speed-dropdown { width: 64px !important; }
    body .magazine-sheet .tts-controls .voice-selector {
        width: auto !important;
        flex: 1 1 140px;
        min-width: 120px;
    }
}

/* One MCQ is visible. Next shows the following question. One-liners stay listed. */
body .magazine-sheet .q-stack { position: relative; }
body .magazine-sheet .q-card.modern-mcq-card {
    display: block;
}
body .magazine-sheet .q-card.modern-mcq-card:not(.is-on) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    pointer-events: none;
    border: 0;
}
body .magazine-sheet .q-card.modern-mcq-card.is-on {
    position: relative;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    pointer-events: auto;
}
body .magazine-sheet .liner-card,
body .magazine-sheet .liner-card.is-on { display: block; }
body .magazine-sheet .q-deck:has(.liner-card) .q-nav { display: none; }
body .magazine-sheet .study-lesson p,
body .magazine-sheet .subtopic p,
body .magazine-sheet .concept-block p,
body .module-body p,
body .concept-block p {
    text-align: justify !important;
    text-justify: inter-word;
}
body .magazine-sheet .topic-study-unit,
body .module-body,
body .concept-block {
    font-size: calc(1.05rem * var(--reading-scale, 1)) !important;
}
body .magazine-sheet .subtopic p:not(.section-label),
body .magazine-sheet .subtopic li,
body .magazine-sheet .mcq-question,
body .magazine-sheet .modern-option-btn,
body .magazine-sheet .modern-explanation-box,
body .magazine-sheet .q-line,
body .module-body p,
body .module-body li,
body .concept-block p,
body .concept-block li {
    font-size: calc(1.05rem * var(--reading-scale, 1)) !important;
}
body .font-scale-readout {
    min-width: 38px;
    font-size: .72rem !important;
    font-weight: 800;
    text-align: center;
    color: var(--accent-strong);
}
body .function-list .font-tools,
body .unified-top-bar .font-tools,
body .tts-controls .font-tools {
    display: inline-flex !important;
    flex: 0 0 auto;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
body .function-list .font-tools button,
body .unified-top-bar .font-tools button,
body .tts-controls .font-tools button,
body .font-size-row .font-tools button {
    width: 32px;
    height: 32px;
    min-height: 32px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: .78rem;
    font-weight: 800;
}
@media (max-width: 760px) {
    body .magazine-sheet .font-size-row {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        width: 100%;
        margin-top: 4px;
    }
    body .font-size-row .font-tools {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    body .font-size-row .font-tools button {
        width: 44px;
        height: 44px;
        min-height: 44px;
        font-size: 1rem !important;
        touch-action: manipulation;
    }
    body .font-size-row .font-scale-readout {
        min-width: 48px;
        font-size: .95rem !important;
    }
}

/* Google Translate adds a fixed banner and shifts the page. Keep that
   banner a single thin strip, and let the lesson scroll so the header
   and the bottom controls stay on screen. */
iframe.goog-te-banner-frame,
iframe.goog-te-banner-frame.skiptranslate {
    display: block !important;
    height: 40px !important;
    max-height: 40px !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}
html.translated-ltr body.app,
html.translated-rtl body.app,
body.app.translate-mode {
    top: 0 !important;
    position: static !important;
    margin-top: 40px !important;
}
html.translated-ltr body.app .topnav,
html.translated-rtl body.app .topnav,
body.app.translate-mode .topnav {
    top: 40px;
}
/* Translated pages on phones and tablets: let the lesson grow in the page flow. */
@media (max-width: 900px) {
    html.translated-ltr body.app:has(.magazine-sheet),
    html.translated-rtl body.app:has(.magazine-sheet),
    body.app.translate-mode:has(.magazine-sheet),
    html.translated-ltr body.app:has(.magazine-sheet) .main-container,
    html.translated-rtl body.app:has(.magazine-sheet) .main-container,
    body.app.translate-mode:has(.magazine-sheet) .main-container,
    html.translated-ltr body.app:has(.magazine-sheet) .content-area,
    html.translated-rtl body.app:has(.magazine-sheet) .content-area,
    body.app.translate-mode:has(.magazine-sheet) .content-area,
    html.translated-ltr body.app:has(.magazine-sheet) .module-content.magazine-sheet,
    html.translated-rtl body.app:has(.magazine-sheet) .module-content.magazine-sheet,
    body.app.translate-mode:has(.magazine-sheet) .module-content.magazine-sheet,
    html.translated-ltr body.app:has(.magazine-sheet) .pipeline-flow-body,
    html.translated-rtl body.app:has(.magazine-sheet) .pipeline-flow-body,
    body.app.translate-mode:has(.magazine-sheet) .pipeline-flow-body,
    html.translated-ltr body .magazine-sheet .topic-study-unit,
    html.translated-rtl body .magazine-sheet .topic-study-unit,
    body.app.translate-mode .magazine-sheet .topic-study-unit,
    html.translated-ltr body .magazine-sheet .study-split,
    html.translated-rtl body .magazine-sheet .study-split,
    body.app.translate-mode .magazine-sheet .study-split,
    html.translated-ltr body .magazine-sheet .study-lesson,
    html.translated-rtl body .magazine-sheet .study-lesson,
    body.app.translate-mode .magazine-sheet .study-lesson,
    html.translated-ltr body .magazine-sheet .study-questions,
    html.translated-rtl body .magazine-sheet .study-questions,
    body.app.translate-mode .magazine-sheet .study-questions {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}
/* Translated pages on desktop: keep the lesson fitted to the window, made
   40px shorter for the Google banner, so both boxes still scroll inside. */
@media (min-width: 901px) {
    html.translated-ltr body.app:has(.magazine-sheet),
    html.translated-rtl body.app:has(.magazine-sheet),
    body.app.translate-mode:has(.magazine-sheet) {
        height: calc(100dvh - 40px);
        max-height: calc(100dvh - 40px);
    }
    html.translated-ltr body.app:has(.magazine-sheet) .main-container,
    html.translated-rtl body.app:has(.magazine-sheet) .main-container,
    body.app.translate-mode:has(.magazine-sheet) .main-container {
        height: calc(100dvh - var(--nav-h) - 40px);
        max-height: calc(100dvh - var(--nav-h) - 40px);
    }
}
body .magazine-sheet .geo-figure {
    margin: 0.9rem 0 1.1rem;
    padding: 0.55rem 0.55rem 0.7rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    max-width: 100%;
}
body .magazine-sheet .geo-figure a {
    display: block;
    max-width: 100%;
}
body .magazine-sheet .geo-figure img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    background: #fff;
    border-radius: 8px;
}
body .magazine-sheet .geo-figure figcaption {
    margin: 0.45rem 0.2rem 0;
    font-size: 0.92rem;
    line-height: 1.45;
    font-weight: 650;
    color: #334155;
    text-align: center !important;
}

/* ---------------------------------------------------------------------
   Laptops (short desktop screens). The lesson stays fitted to the window
   (no page scroll); the space above and below the two boxes is compacted
   so the topic and question boxes get more height. Both boxes keep the
   same height and their content scrolls inside them.
   --------------------------------------------------------------------- */
@media (min-width: 901px) and (max-height: 820px) {
    body.app:has(.magazine-sheet) .content-area { padding: 4px 10px; }
    body.app:has(.magazine-sheet) .module-content.magazine-sheet { padding: 6px 10px 4px; }
    body .magazine-sheet .topic-row { gap: 4px; margin: 0 0 4px; }
    body .magazine-sheet .function-list { padding: 2px 4px; }
    body .magazine-sheet .modern-breadcrumb,
    body .magazine-sheet .chapter-meta { display: none; }
    body .magazine-sheet .module-title {
        margin: 2px 0 0;
        font-size: 1.05rem;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body .magazine-sheet .study-lesson,
    body .magazine-sheet .study-questions { padding: 8px 12px; }
    body .magazine-sheet .exam-bar { padding-bottom: 4px; margin-bottom: 4px; }
    body .magazine-sheet .section-label { margin: 2px 0 6px; }
    body .magazine-sheet .deck-hint { margin: 0 0 6px; }
    body .magazine-sheet .module-footer { padding-top: 4px; margin-top: 4px; }
    body .magazine-sheet .module-footer .nav-btn { padding-top: 7px; padding-bottom: 7px; }
}
