:root {
    /* =========================================================
       🎨 PRIMARY TEAL — اللون الأساسي للهوية
       HEX: #0093AB
       ========================================================= */
    --primary-teal: #0093AB;

    /* =========================================================
       💗 PRIMARY PINK — الوردي الرئيسي
       HEX: #ED4E9C
       ========================================================= */
    --primary-pink: #ED4E9C;

    /* =========================================================
       💚 LIME GREEN — الأخضر الليموني
       HEX: #A0CD4E
       ========================================================= */
    --lime-green: #A0CD4E;

    /* =========================================================
       🩵 LIGHT CYAN — السماوي الفاتح
       HEX: #A4E1EA
       ========================================================= */
    --light-cyan: #A4E1EA;

    /* =========================================================
       🔵 LIGHT TEAL — التركواز الفاتح
       HEX: #25A2B6
       ========================================================= */
    --light-teal: #25A2B6;

    /* =========================================================
       🩶 DARK GRAY — الرمادي الداكن
       HEX: #535353
       ========================================================= */
    --dark-gray: #535353;

    /* =========================================================
       ⬜ WHITE — الأبيض
       HEX: #FFFFFF
       ========================================================= */
    --white: #FFFFFF;

    /* =========================================================
       🎯 DESIGN SYSTEM — قواعد استخدام الألوان
       ========================================================= */
    --color-primary: var(--primary-teal);
    --color-accent: var(--primary-pink);
    --color-success: var(--lime-green);
    --color-background-soft: var(--light-cyan);
    --color-secondary: var(--light-teal);
    --color-text: var(--dark-gray);
    --color-background: var(--white);

    /* Buttons */
    --button-primary-bg: var(--primary-teal);
    --button-primary-text: var(--white);
    --button-primary-hover: var(--light-teal);

    --button-accent-bg: var(--primary-pink);
    --button-accent-text: var(--white);
    --button-accent-hover: var(--primary-teal);

    /* Text */
    --heading-color: var(--primary-teal);
    --heading-accent-color: var(--primary-pink);
    --body-text-color: var(--dark-gray);
    --link-color: var(--primary-teal);
    --link-hover-color: var(--primary-pink);

    /* Cards */
    --card-background: var(--white);
    --card-border: var(--light-cyan);
    --card-icon-color: var(--primary-teal);
    --card-accent: var(--primary-pink);
    --card-hover-border: var(--light-teal);

    /* Section Backgrounds */
    --section-primary-bg: var(--white);
    --section-soft-bg: var(--light-cyan);
    --section-brand-bg: var(--primary-teal);
    --section-accent-bg: var(--primary-pink);

    /* Badges & Labels */
    --badge-primary-bg: var(--primary-teal);
    --badge-primary-text: var(--white);
    --badge-accent-bg: var(--primary-pink);
    --badge-accent-text: var(--white);
    --badge-success-bg: var(--lime-green);
    --badge-success-text: var(--white);

    /* Status / Success */
    --success-color: var(--lime-green);

    /* Reader Specific */
    --paper: var(--white);
    --edge: rgba(164, 225, 234, 0.6);
    --control: var(--dark-gray);
    --muted: #6e7982;
    --accent: var(--primary-teal);

    /* Reader Typography Variables */
    --reader-font-family: 'Cairo', system-ui, -apple-system, sans-serif;
    --reader-font-size: 16.5px;
    --reader-line-height: 1.85;
    --reader-text-align: right;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--body-text-color);
    font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
    background:
        radial-gradient(circle at 12% 12%, rgba(164, 225, 234, .45) 0%, transparent 40%),
        radial-gradient(circle at 88% 88%, rgba(0, 147, 171, .12) 0%, transparent 48%),
        #f5fafc;
    overflow-x: hidden;
}

.reader-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.reader-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid rgba(164, 225, 234, .65);
    backdrop-filter: blur(14px);
}

.reader-top h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--heading-color);
}

.reader-top a {
    color: var(--primary-teal);
    text-decoration: none;
    border: 1px solid var(--card-border);
    background: var(--white);
    border-radius: 9px;
    padding: 8px 14px;
    font-weight: 500;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.reader-top a:hover {
    background: #f0fbfd;
    border-color: var(--light-teal);
    color: var(--primary-teal);
    transform: translateY(-1px);
}

.book-stage {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow: hidden;
    perspective: 1800px;
}

.flipbook {
    width: min(94vw, 1040px);
    height: min(72vh, 720px);
    filter: drop-shadow(0 22px 38px rgba(0, 75, 88, .16));
    opacity: 0;
    transition: opacity .24s ease;
}

.flipbook.is-ready,
.flipbook.flipbook-fallback {
    opacity: 1;
}

.flipbook:not(.is-ready):not(.flipbook-fallback) .page:not(:first-child) {
    display: none;
}

.flipbook-fallback {
    overflow: auto;
    background: var(--paper);
}

.page {
    background: var(--paper);
    border: 1px solid var(--edge);
    box-shadow: inset 0 0 28px rgba(0, 147, 171, .04);
    overflow: hidden;
}

.flipbook .page.--left {
    box-shadow:
        inset 0 0 28px rgba(0, 147, 171, .04),
        inset -12px 0 24px rgba(0, 60, 70, .05);
}

.flipbook .page.--right {
    box-shadow:
        inset 0 0 28px rgba(0, 147, 171, .04),
        inset 12px 0 24px rgba(0, 60, 70, .05);
}

.blank-page {
    background: var(--paper);
}

.content-page {
    padding: clamp(24px, 3.5vw, 42px);
    direction: rtl;
    line-height: var(--reader-line-height, 1.85);
    font-size: var(--reader-font-size, 16.5px);
    font-family: var(--reader-font-family, 'Cairo', system-ui, sans-serif);
    color: var(--body-text-color);
    text-align: var(--reader-text-align, right);
}

.content-page h2 {
    margin-top: 0;
    font-size: calc(var(--reader-font-size, 16.5px) * 1.45);
    font-family: var(--reader-font-family, 'Cairo', system-ui, sans-serif);
    font-weight: 700;
    color: var(--heading-color);
    border-bottom: 2px solid var(--light-cyan);
    padding-bottom: 12px;
}

.book-content {
    max-height: calc(100% - 60px);
    overflow-wrap: anywhere;
    overflow: auto;
    padding-inline-end: 6px;
    scrollbar-width: thin;
    font-family: var(--reader-font-family, 'Cairo', system-ui, sans-serif);
    font-size: var(--reader-font-size, 16.5px);
    line-height: var(--reader-line-height, 1.85);
    text-align: var(--reader-text-align, right);
}

.book-content p { margin: 0 0 1.1em; }
.book-content ul, .book-content ol { padding-inline-start: 28px; }

.book-content blockquote {
    margin: 18px 0;
    padding: 14px 18px;
    border-inline-start: 4px solid var(--primary-pink);
    background: rgba(164, 225, 234, .22);
    border-radius: 9px;
    color: var(--dark-gray);
}

.book-content a {
    color: var(--link-color);
    text-decoration: none;
    transition: color .18s ease;
}

.book-content a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

.book-content figure.image {
    margin: 16px auto;
    max-width: 100%;
    display: table;
    clear: both;
    text-align: center;
}

.book-content figure.image img,
.book-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 75, 88, .09);
    display: block;
    margin: 0 auto;
}

.book-content figure.image figcaption {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
    caption-side: bottom;
    display: table-caption;
    text-align: center;
}

.book-content figure.image.image-style-side {
    float: left;
    max-width: 50%;
    margin: 8px 18px 14px 0;
}

.book-content figure.image.image-style-align-left {
    float: left;
    margin: 8px 18px 14px 0;
}

.book-content figure.image.image-style-align-right {
    float: right;
    margin: 8px 0 14px 18px;
}

.book-content figure.image.image-style-block {
    display: block;
    margin: 18px auto;
}

.book-content .raw-html-embed {
    margin: 14px 0;
    width: 100%;
    overflow-x: auto;
}

.book-content table {
    width: 100%;
    border-collapse: collapse;
    margin-block: 16px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.book-content td, .book-content th {
    border: 1px solid #d2edf2;
    padding: 10px 12px;
    text-align: right;
}

.book-content th {
    background: #f1fbfc;
    color: var(--primary-teal);
    font-weight: 700;
}

/* Video Player Containers (YouTube & Direct MP4) */
.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    overflow: hidden;
    margin: 16px 0;
    background: #000;
    box-shadow: 0 6px 18px rgba(0, 75, 88, .12);
}

.video-wrapper iframe,
.video-wrapper video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    object-fit: contain;
    background: #000;
}

figure.media {
    margin: 16px 0;
    width: 100%;
    max-width: 100%;
}

.page-cover {
    position: relative;
    display: grid;
    place-items: center;
    padding: 36px;
    color: #fff;
    background: linear-gradient(145deg, #00768a, #0093AB 55%, #25A2B6);
}

.page-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 40, 48, .2), rgba(0, 30, 36, .7));
}

.cover-text, .back-cover h2, .back-cover p {
    position: relative;
    z-index: 1;
    text-align: center;
}

.cover-text h2 {
    font-size: 36px;
    margin: 0 0 12px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.cover-text p {
    line-height: 1.7;
    color: rgba(255, 255, 255, .92);
    font-size: 17px;
}

/* Front Cover Video Container */
.cover-video-box {
    width: 100%;
    max-width: 440px;
    margin: 14px auto 16px;
    position: relative;
    z-index: 2;
}

.cover-video-box .video-wrapper {
    margin: 0;
    box-shadow: 0 14px 32px rgba(0, 0, 0, .45);
    border: 1px solid rgba(255, 255, 255, .25);
}

.front-cover.has-cover-video {
    padding: 24px;
    align-content: center;
}

.front-cover.has-cover-video .cover-text h2 {
    font-size: 26px;
    margin-bottom: 8px;
}

.front-cover.has-cover-video .cover-text p {
    font-size: 14.5px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.back-cover {
    background: linear-gradient(145deg, #005c6a, #0093AB);
}

.reader-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(164, 225, 234, .7);
    box-shadow: 0 -4px 20px rgba(0, 147, 171, .05);
}

.reader-controls button,
.reader-controls input {
    height: 40px;
    border: 1px solid #c9ecf2;
    background: #fff;
    color: var(--dark-gray);
    border-radius: 9px;
    padding: 0 14px;
    font: inherit;
    font-weight: 500;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}

.reader-controls button:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
    background: #f0fbfd;
    transform: translateY(-1px);
}

.reader-controls span {
    font-size: 15px;
    color: var(--muted);
    padding: 0 4px;
}

.reader-controls span b#currentPage {
    color: var(--primary-teal);
    font-size: 17px;
    font-weight: 700;
}

.reader-controls input {
    width: 78px;
    text-align: center;
}

.reader-controls input:focus {
    border-color: var(--primary-teal);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 147, 171, .15);
}

.reader-empty {
    min-height: 100vh;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 24px;
}

.reader-empty a {
    color: var(--primary-teal);
}

.reader-shell.zoomed .flipbook {
    transform: scale(1.12);
}

.reader-shell.zoomed .reader-controls button[data-action="zoom"] {
    background: #fef0f7;
    border-color: var(--primary-pink);
    color: var(--primary-pink);
    font-weight: 600;
}


/* =========================================================
   🖊️ HIGHLIGHTER & NOTES SYSTEM
   ========================================================= */

.reader-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-header-tool {
    color: var(--primary-teal);
    background: var(--white);
    border: 1px solid var(--card-border);
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.btn-header-tool:hover {
    background: #f0fbfd;
    border-color: var(--light-teal);
    transform: translateY(-1px);
}

.btn-highlighter-toggle {
    transition: all 0.2s ease;
}

.btn-highlighter-toggle.active {
    background: #fef0f7 !important;
    border-color: var(--primary-pink) !important;
    color: var(--primary-pink) !important;
    font-weight: 700 !important;
    box-shadow: 0 0 0 3px rgba(237, 78, 156, 0.2);
}

.highlighter-mode-active .content-page,
.highlighter-mode-active .book-content {
    cursor: text !important;
}

.content-page {
    user-select: text;
    -webkit-user-select: text;
}

/* Highlight Text Mark */
.book-highlight {
    display: inline;
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    transition: background-color .2s ease, box-shadow .2s ease;
    position: relative;
    user-select: text;
}

.book-highlight.hl-yellow {
    background-color: rgba(255, 235, 59, 0.48);
    border-bottom: 2.5px solid #fbc02d;
}

.book-highlight.hl-teal {
    background-color: rgba(0, 147, 171, 0.28);
    border-bottom: 2.5px solid var(--primary-teal);
}

.book-highlight.hl-pink {
    background-color: rgba(237, 78, 156, 0.28);
    border-bottom: 2.5px solid var(--primary-pink);
}

.book-highlight:hover {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.book-highlight.flash-focus {
    animation: flashHighlight 1.5s ease-in-out;
}

@keyframes flashHighlight {
    0% { outline: 3px solid var(--primary-pink); transform: scale(1.02); }
    50% { outline: 4px solid var(--lime-green); transform: scale(1.04); }
    100% { outline: none; transform: scale(1); }
}

.highlight-comment-badge {
    display: inline-block;
    font-size: 12px;
    margin-inline-start: 3px;
    vertical-align: super;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

/* Floating Toolbar */
.highlight-floating-toolbar {
    position: fixed;
    z-index: 1200;
    background: var(--white);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 75, 88, 0.18);
    padding: 7px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    direction: rtl;
    font-family: inherit;
    font-size: 13px;
    animation: popIn 0.16s ease-out;
}

.highlight-floating-toolbar[hidden] {
    display: none !important;
}

.h-tools-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.h-label {
    font-weight: 700;
    color: var(--dark-gray);
    font-size: 12px;
}

.h-color-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
}

.h-color-btn:hover {
    transform: scale(1.22);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.h-color-btn.color-yellow { background: #ffeb3b; }
.h-color-btn.color-teal { background: var(--primary-teal); }
.h-color-btn.color-pink { background: var(--primary-pink); }

.h-divider {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
    margin: 0 2px;
}

.h-btn-comment {
    border: 1px solid var(--card-border);
    background: #f8fafc;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--dark-gray);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease;
}

.h-btn-comment:hover {
    background: #e6f6f9;
    border-color: var(--light-teal);
    color: var(--primary-teal);
}

.h-btn-close {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 50%;
    line-height: 1;
}

.h-btn-close:hover {
    background: #f1f5f9;
    color: var(--dark-gray);
}

.h-comment-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.h-comment-box textarea {
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    width: 230px;
    outline: none;
}

.h-comment-box textarea:focus {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 2px rgba(0, 147, 171, 0.15);
}

.h-comment-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* Reusable buttons for Highlighter UI */
.highlight-floating-toolbar .btn,
.highlight-comment-popover .btn,
.notes-drawer .btn {
    border: 1px solid var(--card-border);
    background: var(--white);
    color: var(--dark-gray);
    border-radius: 7px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.highlight-floating-toolbar .btn:hover,
.highlight-comment-popover .btn:hover,
.notes-drawer .btn:hover {
    background: #f8fafc;
    border-color: var(--light-teal);
}

.highlight-floating-toolbar .btn.primary,
.highlight-comment-popover .btn.primary,
.notes-drawer .btn.primary {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: var(--white);
}

.highlight-floating-toolbar .btn.primary:hover,
.highlight-comment-popover .btn.primary:hover,
.notes-drawer .btn.primary:hover {
    background: var(--light-teal);
    border-color: var(--light-teal);
}

.highlight-comment-popover .btn.danger {
    background: #fff;
    border-color: #fecaca;
    color: #ef4444;
}

.highlight-comment-popover .btn.danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Comment Popover */
.highlight-comment-popover {
    position: fixed;
    z-index: 1250;
    width: 300px;
    max-width: 90vw;
    background: var(--white);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 0 14px 34px rgba(0, 75, 88, 0.22);
    padding: 14px;
    direction: rtl;
    font-family: inherit;
    animation: popIn 0.16s ease-out;
}

.highlight-comment-popover[hidden] {
    display: none !important;
}

.popover-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.popover-head strong {
    font-size: 13px;
    color: var(--primary-teal);
}

.btn-close-popover {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    border-radius: 4px;
    padding: 2px 5px;
}

.btn-close-popover:hover {
    background: #f1f5f9;
    color: var(--dark-gray);
}

.popover-quote {
    font-size: 12.5px;
    font-style: italic;
    color: var(--muted);
    border-inline-start: 3px solid var(--primary-teal);
    margin: 0 0 10px 0;
    padding: 4px 8px;
    max-height: 60px;
    overflow-y: auto;
    background: #f8fafc;
    border-radius: 0 6px 6px 0;
}

.popover-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--dark-gray);
    margin-bottom: 4px;
}

.popover-body textarea {
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.popover-body textarea:focus {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 2px rgba(0, 147, 171, 0.15);
}

.popover-colors {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--dark-gray);
}

.popover-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

/* Notes Drawer & Backdrop */
.notes-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 20, 30, 0.4);
    z-index: 1300;
    backdrop-filter: blur(3px);
}

.notes-drawer-backdrop[hidden] {
    display: none !important;
}

.notes-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--white);
    box-shadow: -8px 0 28px rgba(0, 75, 88, 0.2);
    z-index: 1310;
    display: flex;
    flex-direction: column;
    direction: rtl;
    transition: transform 0.25s ease;
}

.notes-drawer[hidden] {
    display: none !important;
}

.notes-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    background: #f8fafc;
}

.notes-drawer-head h3 {
    margin: 0;
    font-size: 16px;
    color: var(--dark-gray);
    font-weight: 700;
}

.btn-close-drawer {
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    border-radius: 4px;
    padding: 2px 6px;
}

.btn-close-drawer:hover {
    background: #e2e8f0;
    color: var(--dark-gray);
}

.notes-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notes-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--dark-gray);
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px;
    background: #fff;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    border-inline-start: 4.5px solid #ffeb3b;
}

.note-card.hl-teal {
    border-inline-start-color: var(--primary-teal);
}

.note-card.hl-pink {
    border-inline-start-color: var(--primary-pink);
}

.note-card:hover {
    box-shadow: 0 4px 14px rgba(0, 75, 88, 0.08);
}

.note-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

.note-page-tag {
    background: var(--light-cyan);
    color: var(--primary-teal);
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
}

.note-title-tag {
    color: var(--muted);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11.5px;
}

.btn-delete-note {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    opacity: 0.6;
    padding: 2px 4px;
    border-radius: 4px;
}

.btn-delete-note:hover {
    opacity: 1;
    background: #fef2f2;
}

.note-quote {
    font-size: 13px;
    color: var(--dark-gray);
    margin-bottom: 8px;
    line-height: 1.55;
    cursor: pointer;
    font-style: italic;
    background: #fcfdfe;
    padding: 6px 8px;
    border-radius: 6px;
}

.note-quote:hover {
    color: var(--primary-teal);
}

.note-comment {
    font-size: 12.5px;
    background: #fefce8;
    border-radius: 6px;
    padding: 6px 10px;
    color: #854d0e;
    margin-bottom: 8px;
    word-break: break-word;
    border: 1px solid #fef08a;
}

.note-foot {
    display: flex;
    justify-content: flex-end;
}

.btn-jump-page {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary-teal);
    transition: all 0.15s ease;
}

.btn-jump-page:hover {
    background: var(--light-cyan);
    border-color: var(--light-teal);
}

.notes-drawer-foot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--card-border);
    background: #f8fafc;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* =========================================================
   🎧 FLOATING AUDIO PLAYER & TTS BAR
   ========================================================= */

.btn-audio-toggle {
    transition: all 0.2s ease;
}

.btn-audio-toggle.active {
    background: #e6f6f9 !important;
    border-color: var(--primary-teal) !important;
    color: var(--primary-teal) !important;
    font-weight: 700 !important;
    box-shadow: 0 0 0 3px rgba(0, 147, 171, 0.2);
}

.reader-audio-player {
    position: fixed;
    bottom: 68px;
    left: 50%;
    transform: translateX(-50%);
    width: min(94vw, 860px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0, 75, 88, 0.18);
    z-index: 1100;
    direction: rtl;
    font-family: inherit;
    animation: slideUpAudio 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.reader-audio-player[hidden] {
    display: none !important;
}

@keyframes slideUpAudio {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.audio-player-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    flex-wrap: wrap;
}

.audio-source-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-indicator {
    font-size: 12px;
    font-weight: 700;
    background: #e6f6f9;
    color: var(--primary-teal);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 147, 171, 0.25);
    white-space: nowrap;
}

.btn-switch-mode {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-switch-mode:hover {
    background: #f1f5f9;
    color: var(--primary-teal);
    border-color: var(--light-teal);
}

.audio-main-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-audio-play {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-teal);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 147, 171, 0.35);
    transition: transform 0.15s ease, background 0.15s ease;
}

.btn-audio-play:hover {
    transform: scale(1.08);
    background: var(--light-teal);
}

.btn-audio-ctrl {
    background: #f8fafc;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--dark-gray);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-audio-ctrl:hover:not(:disabled) {
    background: #e6f6f9;
    border-color: var(--light-teal);
    color: var(--primary-teal);
}

.btn-audio-ctrl:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.audio-progress-wrap {
    flex: 1 1 200px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-time {
    font-size: 11.5px;
    font-family: monospace;
    color: var(--muted);
    min-width: 40px;
    text-align: center;
}

.audio-slider-container {
    flex: 1;
    display: flex;
    align-items: center;
}

.audio-slider {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-teal);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.12s ease;
}

.audio-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.audio-extra-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-audio-speed {
    background: #f8fafc;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--dark-gray);
    cursor: pointer;
    min-width: 42px;
}

.btn-audio-speed:hover {
    background: #f1f5f9;
    color: var(--primary-teal);
}

.btn-audio-mute {
    background: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.btn-audio-mute:hover {
    background: #f1f5f9;
}

.btn-audio-close {
    background: transparent;
    border: none;
    font-size: 16px;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-audio-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.tts-status-notice {
    padding: 6px 18px 8px;
    font-size: 12.5px;
    color: var(--primary-teal);
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fafffe;
    border-radius: 0 0 16px 16px;
}

@media (max-width: 700px) {
    .reader-audio-player {
        bottom: 84px;
        width: 95vw;
    }
    .audio-player-inner {
        padding: 8px 12px;
        gap: 8px;
    }
    .audio-progress-wrap {
        order: 3;
        flex: 1 1 100%;
    }
}

/* =========================================================
   📑 TABLE OF CONTENTS (TOC) DRAWER STYLES
   ========================================================= */

.btn-toc-toggle {
    transition: all 0.2s ease;
}

.btn-toc-toggle.active {
    background: #e6f6f9 !important;
    border-color: var(--primary-teal) !important;
    color: var(--primary-teal) !important;
    font-weight: 700 !important;
    box-shadow: 0 0 0 3px rgba(0, 147, 171, 0.2);
}

.toc-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 20, 30, 0.4);
    z-index: 1300;
    backdrop-filter: blur(3px);
}

.toc-drawer-backdrop[hidden] {
    display: none !important;
}

.toc-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--white);
    box-shadow: -8px 0 28px rgba(0, 75, 88, 0.2);
    z-index: 1310;
    display: flex;
    flex-direction: column;
    direction: rtl;
    transition: transform 0.25s ease;
}

.toc-drawer[hidden] {
    display: none !important;
}

.toc-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    background: #f8fafc;
}

.toc-head-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toc-head-info h3 {
    margin: 0;
    font-size: 16px;
    color: var(--dark-gray);
    font-weight: 700;
}

.toc-total-badge {
    font-size: 11.5px;
    font-weight: 700;
    background: var(--light-cyan);
    color: var(--primary-teal);
    padding: 3px 8px;
    border-radius: 12px;
}

.toc-search-box {
    padding: 12px 16px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.toc-search-box input {
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.toc-search-box input:focus {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 2px rgba(0, 147, 171, 0.15);
}

.toc-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
}

.toc-empty {
    text-align: center;
    padding: 40px 16px;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.toc-item:hover {
    background: #f0fbfd;
    border-color: #c9ecf2;
}

.toc-item.active {
    background: #e6f6f9;
    border-color: var(--light-teal);
    border-inline-start: 4px solid var(--primary-teal);
    font-weight: 700;
}

.toc-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
}

.toc-item-icon {
    font-size: 14px;
    opacity: 0.85;
}

.toc-item-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 5px;
    white-space: nowrap;
}

.toc-item.active .toc-item-badge {
    background: var(--primary-teal);
    color: #fff;
}

.toc-item-title {
    font-size: 13.5px;
    color: var(--dark-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item-tags {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.toc-tag {
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.toc-tag.video {
    background: #fef0f7;
    color: var(--primary-pink);
    border: 1px solid rgba(237, 78, 156, 0.25);
}

.toc-tag.notes {
    background: #fefce8;
    color: #854d0e;
    border: 1px solid #fef08a;
}

/* =========================================================
   🔤 READER TYPOGRAPHY CONTROLS (لوحة خيارات الخط والنص)
   ========================================================= */
.typography-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(3px);
    z-index: 1300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.typography-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.typography-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.96);
    width: 92%;
    max-width: 440px;
    max-height: 90vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(164, 225, 234, 0.85);
    border-radius: 20px;
    box-shadow: 0 20px 48px rgba(0, 75, 88, 0.22), 0 4px 12px rgba(0, 0, 0, 0.06);
    z-index: 1350;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl;
}

.typography-modal.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.typography-head {
    padding: 13px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(164, 225, 234, 0.5);
    background: rgba(240, 249, 251, 0.7);
}

.typography-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-teal);
    display: flex;
    align-items: center;
    gap: 8px;
}

.typography-body {
    padding: 14px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 13px;
    max-height: calc(90vh - 105px);
}

.typography-section {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.typography-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.typography-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark-gray);
}

.font-size-display {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-teal);
    background: rgba(0, 147, 171, 0.08);
    padding: 2px 9px;
    border-radius: 20px;
    border: 1px solid rgba(0, 147, 171, 0.2);
}

/* Font Family Grid */
.font-family-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.font-option-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    text-align: right;
    transition: all 0.18s ease;
}

.font-option-btn:hover {
    border-color: var(--primary-teal);
    background: #f8fafc;
    transform: translateY(-1px);
}

.font-option-btn.active {
    border-color: var(--primary-teal);
    background: rgba(0, 147, 171, 0.08);
    box-shadow: 0 0 0 2px rgba(0, 147, 171, 0.25);
}

.font-option-btn .font-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark-gray);
    margin-bottom: 2px;
}

.font-option-btn.active .font-name {
    color: var(--primary-teal);
}

.font-option-btn .font-sample {
    font-size: 11.5px;
    color: var(--muted);
}

/* Font Size Step Controls & Slider */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--dark-gray);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.btn-step:hover {
    border-color: var(--primary-teal);
    background: var(--primary-teal);
    color: #fff;
}

.typography-slider {
    flex: 1;
    height: 6px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    accent-color: var(--primary-teal);
    cursor: pointer;
}

.font-size-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 2px;
}

.size-preset-btn {
    padding: 5px 6px;
    font-size: 11px;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--dark-gray);
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    text-align: center;
    transition: all 0.18s ease;
}

.size-preset-btn:hover {
    background: #e2e8f0;
    color: var(--primary-teal);
}

.size-preset-btn.active {
    background: var(--primary-teal);
    color: #fff;
}

/* Segmented Controls (Line Height & Alignment) */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 2.5px;
    border-radius: 9px;
    gap: 2.5px;
}

.segment-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark-gray);
    border: none;
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
    text-align: center;
    transition: all 0.18s ease;
}

.segment-btn:hover {
    color: var(--primary-teal);
}

.segment-btn.active {
    background: #fff;
    color: var(--primary-teal);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Foot & Reset button */
.typography-foot {
    padding: 10px 18px;
    border-top: 1px solid rgba(164, 225, 234, 0.4);
    background: #f8fafc;
    display: flex;
    justify-content: center;
}

.btn-reset-typography {
    background: transparent;
    border: 1px dashed #94a3b8;
    color: #64748b;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 11.5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.18s ease;
}

.btn-reset-typography:hover {
    border-color: var(--primary-pink);
    color: var(--primary-pink);
    background: #fff;
}

/* Floating Reader Notification Toast */
.reader-toast {
    position: fixed;
    bottom: 75px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10000;
    white-space: nowrap;
    direction: rtl;
}

.reader-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.reader-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--lime-green);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

/* TOC Chapter/Page Direct Copy Button */
.btn-toc-copy-page {
    background: rgba(164, 225, 234, 0.28);
    border: 1px solid rgba(0, 147, 171, 0.3);
    color: var(--primary-teal);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    margin-right: 4px;
}

.btn-toc-copy-page:hover {
    background: var(--primary-teal);
    color: #fff;
    border-color: var(--primary-teal);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 147, 171, 0.2);
}

.btn-toc-copy-page.copied {
    background: var(--lime-green) !important;
    border-color: var(--lime-green) !important;
    color: #fff !important;
}

/* Copied feedback for header and bottom controls */
.btn-share-toggle.copied,
.btn-header-tool.copied {
    background: #ecfdf5 !important;
    border-color: var(--lime-green) !important;
    color: #059669 !important;
    box-shadow: 0 0 0 3px rgba(160, 205, 78, 0.25) !important;
}

/* Target page highlight animation on direct link arrival */
@keyframes targetPageFlash {
    0% { box-shadow: inset 0 0 0 4px var(--primary-teal); }
    50% { box-shadow: inset 0 0 0 6px var(--primary-pink); }
    100% { box-shadow: none; }
}

.page-target-flash {
    animation: targetPageFlash 1.6s ease-in-out;
}

/* =========================================================
   📱 MOBILE RESPONSIVE SUITE (Screens <= 768px)
   ========================================================= */

@media (max-width: 768px) {
    /* 1. Full viewport mobile container */
    .reader-shell {
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: #f0f6f8;
    }

    /* 2. Sleek compact top bar */
    .reader-top {
        height: 48px;
        min-height: 48px;
        padding: 6px 10px;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0;
        scrollbar-width: none;
        background: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid rgba(164, 225, 234, 0.7);
        box-shadow: 0 2px 10px rgba(0, 100, 120, 0.05);
    }

    .reader-top::-webkit-scrollbar {
        display: none;
    }

    .reader-top h1 {
        margin: 0;
        font-size: 14.5px;
        font-weight: 700;
        white-space: nowrap;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 0;
        color: var(--primary-teal);
    }

    .reader-top-actions {
        display: flex;
        align-items: center;
        gap: 5px;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }

    .btn-header-tool,
    .reader-top a {
        height: 32px;
        padding: 5px 8px;
        font-size: 11.5px;
        border-radius: 7px;
        white-space: nowrap;
        gap: 4px;
    }

    /* 3. Book Stage & Flipbook Scaling */
    .book-stage {
        flex: 1 1 auto;
        min-height: 0;
        padding: 4px 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        box-sizing: border-box;
    }

    .flipbook {
        width: 100% !important;
        max-width: 400px !important;
        height: 100% !important;
        max-height: calc(100vh - 130px) !important;
        max-height: calc(100dvh - 130px) !important;
        margin: 0 auto !important;
        filter: drop-shadow(0 10px 24px rgba(0, 75, 88, 0.14));
    }

    .stf__parent {
        width: 100% !important;
        max-width: 400px !important;
        min-width: 0 !important;
        margin: 0 auto !important;
        height: 100% !important;
        max-height: calc(100vh - 130px) !important;
        max-height: calc(100dvh - 130px) !important;
    }

    .stf__wrapper {
        margin: 0 auto !important;
        max-width: 100% !important;
    }

    /* 4. Reading Page Layout & Content */
    .page {
        border-radius: 6px;
        box-sizing: border-box;
    }

    .content-page {
        padding: 14px 14px 16px 14px !important;
        font-size: 14.5px !important;
        line-height: 1.75 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .content-page h2 {
        font-size: 17px !important;
        margin-top: 0 !important;
        margin-bottom: 8px !important;
        padding-bottom: 6px !important;
        border-bottom: 1.5px solid var(--light-cyan);
    }

    .book-content {
        max-height: calc(100% - 36px) !important;
        font-size: inherit;
    }

    .book-content p {
        margin: 0 0 0.85em !important;
    }

    .book-content ul,
    .book-content ol {
        padding-inline-start: 20px !important;
        margin-bottom: 10px !important;
    }

    .book-content blockquote {
        margin: 10px 0 !important;
        padding: 10px 12px !important;
        font-size: 13.5px !important;
    }

    .book-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        font-size: 12px;
        margin-block: 10px;
    }

    .book-content td,
    .book-content th {
        padding: 5px 8px !important;
    }

    .book-content figure.image {
        margin: 10px auto !important;
    }

    .book-content figure.image.image-style-side,
    .book-content figure.image.image-style-align-left,
    .book-content figure.image.image-style-align-right {
        float: none !important;
        max-width: 100% !important;
        margin: 10px auto !important;
    }

    .video-wrapper {
        margin: 8px 0 !important;
        aspect-ratio: 16 / 9;
    }

    /* 5. Cover Page Responsive */
    .page-cover {
        padding: 16px 12px !important;
        box-sizing: border-box;
        text-align: center;
    }

    .cover-text h2 {
        font-size: 20px !important;
        margin-bottom: 6px !important;
        line-height: 1.35 !important;
    }

    .cover-text p {
        font-size: 13.5px !important;
        line-height: 1.6 !important;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .cover-video-box {
        margin: 8px auto !important;
        max-width: 100% !important;
    }

    /* 6. Streamlined Mobile Controls Bar */
    .reader-controls {
        flex-shrink: 0;
        padding: 6px 8px 8px 8px !important;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(164, 225, 234, 0.8);
        box-shadow: 0 -3px 16px rgba(0, 80, 100, 0.08);
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 5px;
    }

    /* Hide desktop-only clutter on mobile */
    .reader-controls button[data-action="start"],
    .reader-controls button[data-action="go"],
    .reader-controls button[data-action="zoom"],
    .reader-controls button[data-action="fullscreen"],
    .reader-controls input#pageInput {
        display: none !important;
    }

    /* Row 1: Primary Navigation */
    .reader-controls button[data-action="prev"] {
        order: 1;
        flex: 1 1 80px;
        max-width: 110px;
        height: 36px;
        font-size: 13px;
        font-weight: 700;
        background: var(--light-cyan) !important;
        color: var(--primary-teal) !important;
        border: 1.5px solid var(--primary-teal) !important;
        border-radius: 8px;
    }

    .reader-controls span {
        order: 2;
        flex: 0 0 auto;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 12px;
        font-size: 13px;
        font-weight: 700;
        color: var(--dark-gray);
        background: rgba(164, 225, 234, 0.3);
        border-radius: 18px;
        border: 1px solid rgba(164, 225, 234, 0.8);
        gap: 4px;
    }

    .reader-controls span b#currentPage {
        font-size: 15px;
    }

    .reader-controls button[data-action="next"] {
        order: 3;
        flex: 1 1 80px;
        max-width: 110px;
        height: 36px;
        font-size: 13px;
        font-weight: 700;
        background: var(--light-cyan) !important;
        color: var(--primary-teal) !important;
        border: 1.5px solid var(--primary-teal) !important;
        border-radius: 8px;
    }

    /* Flex break: forces tools to Row 2 */
    .reader-controls::before {
        content: "";
        order: 4;
        flex: 1 0 100%;
        height: 0;
        margin: 0;
    }

    /* Row 2: Secondary Quick Tools */
    .reader-controls button[data-action="toc"],
    .reader-controls button[data-action="share-page"],
    .reader-controls button[data-action="typography"],
    .reader-controls button[data-action="audio"],
    .reader-controls button[data-action="highlighter"],
    .reader-controls button[data-action="notes"] {
        order: 10;
        height: 30px;
        padding: 0 7px;
        font-size: 11px;
        border-radius: 7px;
        flex: 0 1 auto;
        white-space: nowrap;
        border: 1px solid #c9ecf2;
        background: #fff;
    }

    /* 7. Drawers & Modals on Mobile */
    .toc-drawer,
    .notes-drawer {
        width: 100vw !important;
        max-width: 380px !important;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .typography-modal {
        width: min(94vw, 390px) !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        padding: 16px !important;
        border-radius: 16px !important;
    }

    .font-family-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    .font-option-btn {
        padding: 6px !important;
        font-size: 12px !important;
    }

    .font-size-presets {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    .reader-audio-player {
        width: calc(100% - 12px) !important;
        left: 6px !important;
        right: 6px !important;
        bottom: 84px !important;
        padding: 8px !important;
        border-radius: 12px !important;
    }

    .audio-player-inner {
        flex-wrap: wrap !important;
        gap: 6px !important;
        justify-content: space-between !important;
    }

    .audio-progress-wrap {
        width: 100% !important;
        order: 3 !important;
    }

    .audio-source-badge {
        order: 1 !important;
        font-size: 11px !important;
    }

    .audio-main-controls {
        order: 2 !important;
    }

    .audio-extra-controls {
        order: 4 !important;
        width: 100% !important;
        justify-content: flex-end !important;
    }
}

/* Extra small mobile screens (e.g. iPhone SE, <= 380px) */
@media (max-width: 380px) {
    .reader-top h1 {
        max-width: 110px;
        font-size: 13.5px;
    }

    .reader-controls button[data-action="prev"],
    .reader-controls button[data-action="next"] {
        max-width: 85px;
        font-size: 12px;
    }

    .reader-controls button[data-action="toc"],
    .reader-controls button[data-action="share-page"],
    .reader-controls button[data-action="typography"],
    .reader-controls button[data-action="audio"],
    .reader-controls button[data-action="highlighter"],
    .reader-controls button[data-action="notes"] {
        font-size: 10px;
        padding: 0 4px;
    }

    .content-page {
        padding: 12px 10px 14px 10px !important;
        font-size: 14px !important;
    }
}
