/* ═══════════════════════════════════════════════════════════════════════════
   مذكرة HTML التفاعلية — سمة «ورقة المطوّر»
   فاتحة دافئة نهارًا، داكنة ليلًا. اللون المميّز برتقالي HTML (#E67E22).
   كل لون يمرّ عبر متغيّر — الوضع الليلي يعيد تعريف المتغيّرات لا القواعد.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --color-bg: #fffaf4;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #fbeee0;

    --color-primary: #e67e22;
    --color-primary-hover: #cf6d16;
    --color-accent: #0f766e;
    --color-accent-soft: rgba(15, 118, 110, .1);
    --color-primary-soft: rgba(230, 126, 34, .12);

    --color-text: #1f2937;
    --color-text-secondary: #4b5563;
    --color-text-muted: #9ca3af;

    --color-border: #f0dfcb;
    --color-success: #10b981;
    --color-error: #ef4444;

    /* المحرّر يبقى داكنًا في السمتين — كما في محرّرات الكود الحقيقية */
    --editor-bg: #1e1e2e;
    --editor-fg: #e2e8f0;
    --preview-bg: #ffffff;

    --font-sans: 'Cairo', system-ui, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;

    --radius-sm: 0.4rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --topbar-height: 64px;
    --nav-footer-height: 76px;
    --shadow-soft: 0 4px 20px -2px rgba(120, 60, 0, .08);
}

body.dark-mode {
    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-tertiary: #263449;
    --color-text: #f1f5f9;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #7c8aa5;
    --color-border: #334155;
    --color-primary-soft: rgba(230, 126, 34, .18);
    --color-accent: #2dd4bf;
    --color-accent-soft: rgba(45, 212, 191, .12);
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, .35);
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESET & BASE
   ───────────────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    transition: background-color .3s, color .3s;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LANDING
   ───────────────────────────────────────────────────────────────────────────── */
.landing {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 2rem 1rem 3rem;
    position: relative;
    overflow: hidden;
}

.landing__container {
    text-align: center;
    z-index: 10;
    max-width: 640px;
    width: 100%;
}

.landing__badge {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border: 1px solid rgba(230, 126, 34, .3);
    padding: .45rem 1rem;
    border-radius: 99px;
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.landing__title {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: .75rem;
    color: var(--color-text);
}

.landing__subtitle {
    font-size: 1.15rem;
    color: var(--color-text-secondary);
    margin-bottom: 2.25rem;
}

.landing__cta {
    background: linear-gradient(135deg, var(--color-primary), #f39c3d);
    color: #fff;
    padding: .95rem 2.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: var(--radius-xl);
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    box-shadow: 0 10px 25px -8px rgba(230, 126, 34, .6);
    transition: transform .2s, box-shadow .2s;
}

.landing__cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -8px rgba(230, 126, 34, .7);
}

.landing__stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 2.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.stat__number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}

.stat__label {
    font-size: .85rem;
    color: var(--color-text-secondary);
}

.landing__continue {
    margin-top: 1.25rem;
}

.btn-link {
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .95rem;
    padding: .4rem .8rem;
    border-radius: var(--radius-md);
}

.btn-link:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.landing__decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .35;
}

.blob--1 {
    width: 420px;
    height: 420px;
    background: #f5b56b;
    top: -140px;
    right: -120px;
}

.blob--2 {
    width: 360px;
    height: 360px;
    background: #7dd3c8;
    bottom: -140px;
    left: -100px;
}

body.dark-mode .blob {
    opacity: .18;
}

/* ─────────────────────────────────────────────────────────────────────────────
   COVER — CSS خالص
   ───────────────────────────────────────────────────────────────────────────── */
.landing__cover {
    margin: 0 auto 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .9rem;
}

.cover {
    --cover-w: 210px;
    --cover-h: 285px;
    position: relative;
    width: var(--cover-w);
    height: var(--cover-h);
    perspective: 1100px;
}

.cover__book {
    position: relative;
    width: 100%;
    height: 100%;
    transform: rotateY(16deg) rotateX(4deg);
    transform-style: preserve-3d;
    transition: transform .7s cubic-bezier(.22, 1, .36, 1);
}

.cover:hover .cover__book {
    transform: rotateY(0deg) rotateX(0deg) translateY(-6px);
}

/* الكعب على اليمين — كتاب عربي */
.cover__spine {
    position: absolute;
    top: 0;
    right: -13px;
    width: 14px;
    height: 100%;
    border-radius: 0 5px 5px 0;
    background: linear-gradient(180deg, #a3520f, #7a3d0a 55%, #5c2d06);
    box-shadow: inset 3px 0 6px rgba(0, 0, 0, .35);
}

.cover__face {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 12px 4px 4px 12px;
    background:
        radial-gradient(120% 90% at 15% 0%, rgba(255, 255, 255, .25), transparent 60%),
        linear-gradient(155deg, #f39c3d 0%, #e67e22 50%, #c9601a 100%);
    box-shadow:
        0 22px 45px -12px rgba(120, 50, 0, .45),
        0 3px 10px rgba(15, 23, 42, .18),
        inset 0 0 0 1px rgba(255, 255, 255, .18);
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    color: #fff;
}

/* سطور دفتر خفيفة — تلميح لكلمة «مذكرة» */
.cover__lines {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px);
    background-size: 100% 22px;
    background-position: 0 14px;
    pointer-events: none;
}

.cover__sheen {
    position: absolute;
    top: -60%;
    left: -70%;
    width: 55%;
    height: 220%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
    transform: rotate(18deg);
    animation: cover-sheen 7s ease-in-out infinite;
    pointer-events: none;
}

@keyframes cover-sheen {
    0%, 62% { left: -70%; }
    88%, 100% { left: 130%; }
}

.cover__tagline {
    font-family: var(--font-mono);
    font-size: .72rem;
    direction: ltr;
    text-align: left;
    color: rgba(255, 255, 255, .85);
    letter-spacing: .03em;
}

.cover__tagline--close {
    margin-top: auto;
}

/* هيكل صفحة مرسوم بأشرطة: صورة، عنوان، فقرتان */
.cover__skeleton {
    margin: .6rem 0 .5rem;
    display: grid;
    gap: .32rem;
    direction: ltr;
}

.cover__bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .55);
}

.cover__bar--img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .3);
    border: 1.5px dashed rgba(255, 255, 255, .8);
    margin-bottom: .2rem;
}

.cover__bar--h1 {
    width: 70%;
    height: 9px;
    background: rgba(255, 255, 255, .9);
    animation: cover-type 4s ease-in-out infinite;
}

.cover__bar--short {
    width: 55%;
}

@keyframes cover-type {
    0%, 15% { width: 0; }
    55%, 100% { width: 70%; }
}

.cover__title {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 .35rem;
    text-shadow: 0 2px 12px rgba(90, 40, 0, .3);
}

.cover__tag {
    align-self: flex-start;
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    padding: .2rem .6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .5);
    background: rgba(255, 255, 255, .14);
    direction: ltr;
}

.cover__shadow {
    position: absolute;
    bottom: -16px;
    left: 8%;
    width: 84%;
    height: 22px;
    border-radius: 50%;
    background: rgba(120, 50, 0, .3);
    filter: blur(13px);
    transition: transform .7s cubic-bezier(.22, 1, .36, 1), opacity .7s;
}

.cover:hover .cover__shadow {
    transform: scale(.92);
    opacity: .75;
}

.cover__note {
    font-size: .78rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: .4rem;
}

.cover__note i {
    color: var(--color-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   READER
   ───────────────────────────────────────────────────────────────────────────── */
.reader {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    background: var(--color-bg-secondary);
    flex-shrink: 0;
}

.topbar__right,
.topbar__left {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.topbar__title {
    font-weight: 700;
    font-size: .95rem;
    color: var(--color-text);
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background .2s, color .2s;
}

.topbar__btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-primary);
}

.topbar__center {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: .85rem;
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    padding: .25rem .75rem;
    border-radius: 6px;
}

.progress-bar {
    height: 3px;
    background: var(--color-border);
    flex-shrink: 0;
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #f39c3d);
    transition: width .4s ease;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem calc(var(--nav-footer-height) + 2rem);
}

.page {
    max-width: 860px;
    margin: 0 auto;
    animation: page-in .35s ease;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TYPOGRAPHY داخل الصفحة
   ───────────────────────────────────────────────────────────────────────────── */
.page h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 1rem;
}

.page h2 {
    font-size: 1.7rem;
    font-weight: 800;
    margin: 2rem 0 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text);
}

.page h2:first-child {
    margin-top: 0;
}

.page h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 1.5rem 0 .6rem;
    color: var(--color-primary);
}

.page h4 {
    font-size: 1.05rem;
    margin: 1rem 0 .4rem;
}

.page p {
    font-size: 1.05rem;
    margin-bottom: 1.1rem;
    color: var(--color-text-secondary);
}

.page ul,
.page ol {
    margin: 1rem 0 1.25rem;
    padding-right: 1.5rem;
    color: var(--color-text-secondary);
}

.page li {
    margin-bottom: .5rem;
}

.page strong {
    color: var(--color-text);
}

.page code {
    background: var(--color-primary-soft);
    color: #b45309;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .88em;
    unicode-bidi: isolate;
}

body.dark-mode .page code {
    color: #fbbf77;
}

/* كتل الكود: اتجاه LTR دائمًا وإلا انقلبت الأقواس */
.page pre {
    background: var(--editor-bg);
    color: var(--editor-fg);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin: 1rem 0 1.25rem;
    overflow-x: auto;
    font-size: .88rem;
    line-height: 1.65;
}

.page pre,
.page pre code {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
    white-space: pre;
}

.page pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* تلوين خفيف للوسوم في الأمثلة — <span class="t">tag</span> <span class="a">attr</span> <span class="v">"val"</span> */
.page pre .t { color: #f9a8d4; }
.page pre .a { color: #93c5fd; }
.page pre .v { color: #bef264; }
.page pre .c { color: #94a3b8; font-style: italic; }

/* ─────────────────────────────────────────────────────────────────────────────
   صناديق
   ───────────────────────────────────────────────────────────────────────────── */
.info-box,
.warning-box,
.success-box,
.tip-box {
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    border-right: 4px solid;
    background: var(--color-bg-secondary);
    box-shadow: var(--shadow-soft);
}

.info-box { border-color: var(--color-accent); }
.warning-box { border-color: var(--color-error); }
.success-box { border-color: var(--color-success); }
.tip-box { border-color: var(--color-primary); }

.info-box h4,
.success-box h4 {
    margin-top: 0;
}

.info-box p:last-child,
.tip-box p:last-child,
.success-box p:last-child,
.warning-box p:last-child {
    margin-bottom: 0;
}

/* شارة المستوى أعلى الدرس */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--color-accent);
    background: var(--color-accent-soft);
    padding: .3rem .8rem;
    border-radius: 999px;
    margin-bottom: 1rem;
}

/* عمودا «لك / ليس لك» في الافتتاحية */
.foryou {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.25rem 0 1.5rem;
}

.foryou__col {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
}

.foryou__col h4 {
    margin: 0 0 .6rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.foryou__col--yes h4 { color: var(--color-success); }
.foryou__col--no h4 { color: var(--color-text-muted); }

.foryou__col ul {
    margin: 0;
    padding-right: 1.1rem;
}

.foryou__col li {
    font-size: .95rem;
}

/* شجرة ملفات */
.tree {
    background: var(--editor-bg);
    color: var(--editor-fg);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    font-family: var(--font-mono);
    font-size: .88rem;
    line-height: 1.8;
    direction: ltr;
    text-align: left;
    margin: 1rem 0 1.25rem;
    white-space: pre;
    overflow-x: auto;
}

.tree .d { color: #fbbf77; }
.tree .f { color: #e2e8f0; }
.tree .x { color: #f87171; }
.tree .ok { color: #86efac; }
.tree .c { color: #94a3b8; }

/* تشريح وسم: <div class="tag-anatomy"> ... */
.tag-anatomy {
    background: var(--editor-bg);
    color: var(--editor-fg);
    border-radius: var(--radius-md);
    padding: 1.6rem 1.25rem 1rem;
    font-family: var(--font-mono);
    font-size: 1.15rem;
    direction: ltr;
    text-align: center;
    margin: 1.25rem 0;
    overflow-x: auto;
    /* سطر واحد يُمرَّر أفقيًا على الجوال بدل أن يلتفّ فتتبعثر الأجزاء */
    white-space: nowrap;
}

.tag-anatomy__part {
    position: relative;
    display: inline-block;
    padding: .15rem .35rem;
    border-radius: 4px;
    margin: 1.2rem .1rem .2rem;
}

.tag-anatomy__part::before {
    content: attr(data-tag);
    position: absolute;
    top: -1.35rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--font-sans);
    font-size: .68rem;
    direction: rtl;
    opacity: .85;
}

.tag-anatomy__part--tag { background: rgba(249, 168, 212, .18); color: #f9a8d4; }
.tag-anatomy__part--attr { background: rgba(147, 197, 253, .18); color: #93c5fd; }
.tag-anatomy__part--val { background: rgba(190, 242, 100, .18); color: #bef264; }
.tag-anatomy__part--text { background: rgba(255, 255, 255, .1); color: #fff; }

/* ─────────────────────────────────────────────────────────────────────────────
   CODE PLAYGROUND — المحرّر والمعاينة
   ───────────────────────────────────────────────────────────────────────────── */
.code-playground {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin: 1.5rem 0 0;
    background: var(--color-bg-secondary);
    padding: .9rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-soft);
}

.playground-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
}

.playground-title {
    font-family: var(--font-mono);
    font-size: .85rem;
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    direction: ltr;
}

.playground-title i {
    color: var(--color-primary);
}

.playground-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.run-btn {
    background: var(--color-success);
    color: #fff;
    padding: .45rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    transition: filter .2s;
}

.run-btn:hover {
    filter: brightness(1.08);
}

.reset-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reset-btn:hover {
    color: var(--color-error);
    border-color: var(--color-error);
}

.playground-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    height: 380px;
}

.playground-grid--tall {
    height: 480px;
}

.editor-wrapper,
.preview-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.editor-label {
    font-size: .78rem;
    margin-bottom: .4rem;
    color: var(--color-text-muted);
}

.code-editor {
    flex: 1;
    background: var(--editor-bg);
    color: var(--editor-fg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: .9rem 1rem;
    font-family: var(--font-mono);
    font-size: .86rem;
    line-height: 1.55;
    resize: none;
    outline: none;
    direction: ltr;
    text-align: left;
    tab-size: 4;
}

.code-editor:focus {
    border-color: var(--color-primary);
}

.preview-frame {
    flex: 1;
    background: var(--preview-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .playground-grid,
    .playground-grid--tall {
        grid-template-columns: 1fr;
        height: 560px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   NAV FOOTER
   ───────────────────────────────────────────────────────────────────────────── */
.nav-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-secondary);
    height: var(--nav-footer-height);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 50;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    font-weight: 600;
    transition: all .2s;
}

.nav-btn:disabled {
    opacity: .4;
    cursor: default;
}

.nav-btn:not(:disabled):hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.nav-btn--next {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.nav-btn--next:not(:disabled):hover {
    background: var(--color-primary-hover);
    color: #fff;
}

.nav-dots {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 40vw;
}

.nav-dot {
    width: 7px;
    height: 7px;
    background: var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    transition: transform .2s, background .2s;
}

.nav-dot.done {
    background: var(--color-success);
}

.nav-dot.active {
    background: var(--color-primary);
    transform: scale(1.4);
}

@media (max-width: 600px) {
    .nav-dots { display: none; }
    .nav-btn span { display: none; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   SIDE MENU
   ───────────────────────────────────────────────────────────────────────────── */
.side-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    max-width: 90vw;
    height: 100%;
    background: var(--color-bg-secondary);
    border-left: 1px solid var(--color-border);
    z-index: 200;
    transition: right .3s ease;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    right: 0;
}

.side-menu__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--color-border);
}

.side-menu__header h3 {
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.side-menu__close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
}

.side-menu__close:hover {
    background: var(--color-bg-tertiary);
}

.side-menu__nav {
    overflow-y: auto;
    flex: 1;
}

.toc-item {
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .92rem;
    transition: background .15s;
}

.toc-item > i:first-child {
    color: var(--color-text-muted);
    width: 1rem;
    text-align: center;
    font-size: .8rem;
}

.toc-item span {
    flex: 1;
}

.toc-item:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.toc-item.active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: 700;
}

.toc-done {
    color: var(--color-success);
    opacity: 0;
    transition: opacity .2s;
}

.toc-done.on {
    opacity: 1;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: .3s;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   شاشة المحتوى المقفل (تأتي من api.php حين لا يملك القارئ الصلاحية)
   ───────────────────────────────────────────────────────────────────────────── */
.locked {
    text-align: center;
    padding: 4rem 1.5rem;
    max-width: 520px;
    margin: 0 auto;
}

.locked i {
    font-size: 2.5rem;
    color: var(--color-primary);
    opacity: .55;
    margin-bottom: 1.25rem;
    display: block;
}

.locked h3 {
    font-size: 1.35rem;
    margin-bottom: .75rem;
    color: var(--color-text);
}

.locked p {
    color: var(--color-text-secondary);
    line-height: 1.9;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE & MOTION
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .landing__title { font-size: 2rem; }
    .landing__stats { gap: 1.25rem; padding: 1rem; }
    .stat__number { font-size: 1.5rem; }
    .foryou { grid-template-columns: 1fr; }
    .page h1 { font-size: 1.7rem; }
    .page h2 { font-size: 1.35rem; }
    .cover { --cover-w: 170px; --cover-h: 230px; }
    .cover__title { font-size: 1.5rem; }
    .topbar__title { max-width: 32vw; font-size: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cover__sheen,
    .cover__bar--h1,
    .page {
        animation: none !important;
    }
    .cover__book,
    .cover__shadow,
    .progress-bar__fill {
        transition: none !important;
    }
}

/* النصوص العربية داخل كتل الكود تُعزل اتجاهيًا حتى لا تنقلب حول علامات الترقيم */
.page pre span {
    unicode-bidi: isolate;
}
