/* ============================================================
   کتاب آنلاین «خط فرمان لینوکس» — linuxcommandline.ir
   تم اصلی هم‌راستا با linuxcli.ir (primary: #085a8b)
   ============================================================ */

/* ---------- فونت وزیرمتن ---------- */
@font-face {
    font-family: 'Vazirmatn';
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/Vazirmatn-Regular.woff2') format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/Vazirmatn-Medium.woff2') format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/Vazirmatn-Bold.woff2') format('woff2');
}

/* ---------- متغیرهای تم (هم‌راستا با سایت اصلی) ---------- */
:root {
    --primary: #085a8b;
    --primary-light: #0d7ab3;
    --primary-dark: #064066;
    --primary-subtle: #e6f0f7;
    --secondary: #6366f1;
    --accent: #8b5cf6;

    --dark: #1e293b;
    --dark-soft: #1a2a3a;
    --gray: #475569;
    --gray-light: #7a8a9a;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --light-blue: #eff6ff;
    --border: #cbd5e1;
    --border-soft: #e2e8f0;

    --success: #16a34a;
    --danger: #dc2626;

    --code-bg: #1e293b;
    --code-text: #e2e8f0;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05);

    --radius: 8px;
    --radius-lg: 12px;
    --transition: all .3s ease;

    --header-h: 64px;
    --sidebar-w: 320px;
    --sidebar-w-collapsed: 72px;
    --content-max: 860px;

    --reading-font-size: 1.05rem;
    --reading-line-height: 2;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #172033;
    --light-blue: #0c2a44;

    --dark: #e2e8f0;
    --dark-soft: #cbd5e1;
    --gray: #94a3b8;
    --gray-light: #64748b;

    --border: #334155;
    --border-soft: #1e293b;

    --primary-subtle: #0c2a44;
    --code-bg: #0b1220;
    --code-text: #e2e8f0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, .5);
}

/* ---------- ریست ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

img { max-width: 100%; height: auto; }

/* ============================================================
   مدیریت LTR/RTL — جلوگیری از تداخل دستورات با متن فارسی
   ============================================================ */

/* کد درون‌خطی: جدا شده از جریان RTL، بدون شکستن متن */
code, .ltr-inline {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
    font-family: 'Courier New', 'Liberation Mono', monospace;
    font-size: 0.9em;
    background: var(--primary-subtle);
    color: var(--primary-dark);
    padding: 1px 7px;
    border-radius: 5px;
    border: 1px solid var(--border-soft);
    line-height: 1.6;
    vertical-align: baseline;
}
[data-theme="dark"] code,
[data-theme="dark"] .ltr-inline {
    color: #7dd3fc;
}

/* بلوک کد کامل: کاملاً LTR */
pre, .ltr-block {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
}

/* نام فایل‌های لاتین در متن فارسی */
.ltr {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

/* جلوگیری از به‌هم‌ریختگی اعداد و علائم در متن RTL */
.force-ltr {
    direction: ltr;
    unicode-bidi: embed;
    display: inline-block;
}

/* ============================================================
   نوار پیشرفت مطالعه
   ============================================================ */
#progress-bar {
    position: fixed;
    top: 0;
    right: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 1000;
    transition: width .1s linear;
}

/* ============================================================
   هدر اصلی سایت
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
    transition: var(--transition);
}

.site-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--dark);
    white-space: nowrap;
    flex-shrink: 0;
}
.site-header .brand i {
    color: var(--primary);
    font-size: 1.35rem;
}
.site-header .brand .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.site-header .brand .brand-text small {
    font-weight: 400;
    color: var(--gray-light);
    font-size: 0.72rem;
}

.header-spacer { flex: 1; }

/* ---------- گروه دکمه‌های هدر ---------- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    position: relative;
}
.icon-btn:hover {
    background: var(--primary-subtle);
    color: var(--primary);
}
.icon-btn:active {
    transform: scale(0.94);
}

/* ---------- گروه کنترل اندازه فونت ---------- */
.font-controls {
    display: inline-flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 30px;
    padding: 2px;
    margin: 0 6px;
}
.font-controls button {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    transition: var(--transition);
}
.font-controls button:hover {
    background: var(--primary);
    color: #fff;
}
.font-controls button:disabled {
    opacity: .35;
    cursor: not-allowed;
}
.font-controls .divider {
    width: 1px;
    height: 18px;
    background: var(--border-soft);
    margin: 0 2px;
}

.menu-toggle { display: none; }

/* ---------- دکمه‌ی دانلود PDF ---------- */
.pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    white-space: nowrap;
    margin-right: 6px;
}
.pdf-btn:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.pdf-btn i { font-size: .85rem; }

/* ============================================================
   چیدمان اصلی
   ============================================================ */
.layout {
    display: flex;
    max-width: 1500px;
    margin: 0 auto;
    position: relative;
    transition: var(--transition);
}

/* ---------- نوار کناری ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-left: 1px solid var(--border-soft);
    height: calc(100vh - var(--header-h));
    position: sticky;
    top: var(--header-h);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0 40px;
    transition: width .3s ease, padding .3s ease;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* نوار کناری جمع‌شده (دسکتاپ) */
.layout.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}
.layout.sidebar-collapsed .sidebar .sidebar-search,
.layout.sidebar-collapsed .sidebar .part-title,
.layout.sidebar-collapsed .sidebar .toc-link-text {
    opacity: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    transition: opacity .2s;
}
.layout.sidebar-collapsed .sidebar .toc-list li a {
    justify-content: center;
    padding: 10px 6px;
}
.layout.sidebar-collapsed .sidebar .toc-list li a .num {
    margin: 0;
    min-width: 36px;
    height: 36px;
    font-size: .85rem;
}

.sidebar-search {
    padding: 0 16px 14px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 10px;
    transition: var(--transition);
}
.sidebar-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--dark);
    font-family: inherit;
    font-size: .88rem;
    transition: var(--transition);
}
.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.toc-part { margin: 4px 0; }

.part-title {
    padding: 12px 20px 6px;
    font-size: .75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .85;
    transition: var(--transition);
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.toc-list li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--gray);
    font-size: .9rem;
    border-right: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc-list li a:hover {
    background: var(--surface-2);
    color: var(--primary);
}
.toc-list li a.active {
    background: var(--primary-subtle);
    color: var(--primary);
    border-right-color: var(--primary);
    font-weight: 600;
}
.toc-list li a .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--gray-light);
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: var(--transition);
}
.toc-list li a.active .num {
    background: var(--primary);
    color: #fff;
}
.toc-link-text {
    transition: var(--transition);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   محتوای اصلی
   ============================================================ */
.content {
    flex: 1;
    min-width: 0;
    padding: 32px 40px 80px;
    transition: var(--transition);
}

.chapter {
    max-width: var(--content-max);
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 46px 52px;
    transition: var(--transition);
    position: relative;
}

/* حالت تمرکز (Focus Mode): بدون حاشیه‌ی کناری */
.layout.focus-mode .sidebar { display: none; }
.layout.focus-mode .content {
    max-width: 100%;
    padding: 40px;
}
.layout.focus-mode .chapter {
    max-width: 900px;
}

/* ---------- نان‌ریزه ---------- */
.breadcrumb {
    max-width: var(--content-max);
    margin: 0 auto 18px;
    font-size: .85rem;
    color: var(--gray-light);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; opacity: .6; }

/* ---------- سرصفحه فصل ---------- */
.chapter-header {
    border-bottom: 2px solid var(--primary-subtle);
    padding-bottom: 22px;
    margin-bottom: 32px;
}
.chapter-header .chapter-label {
    display: inline-block;
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-subtle);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}
.chapter-header h1 {
    font-size: clamp(1.6rem, 3.5vw, 2.1rem);
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 10px;
    line-height: 1.45;
    letter-spacing: -.01em;
}
.chapter-header .chapter-meta {
    font-size: .85rem;
    color: var(--gray-light);
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}
.chapter-header .chapter-meta i {
    margin-left: 6px;
    color: var(--primary);
}

/* ---------- تیترها ---------- */
.chapter h2 {
    color: var(--primary);
    font-size: clamp(1.3rem, 2.5vw, 1.6rem);
    font-weight: 700;
    margin: 2.6rem 0 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--primary-subtle);
    position: relative;
    scroll-margin-top: 90px;
    line-height: 1.5;
}
.chapter h3 {
    color: var(--dark-soft);
    font-size: clamp(1.1rem, 2vw, 1.28rem);
    font-weight: 700;
    margin: 2rem 0 .8rem;
    scroll-margin-top: 90px;
    line-height: 1.5;
}
.chapter h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1.5rem 0 .6rem;
    color: var(--gray);
    scroll-margin-top: 90px;
}

.chapter h2 .anchor,
.chapter h3 .anchor,
.chapter h4 .anchor {
    opacity: 0;
    margin-right: 8px;
    font-size: .8em;
    color: var(--primary-light);
    transition: var(--transition);
}
.chapter h2:hover .anchor,
.chapter h3:hover .anchor,
.chapter h4:hover .anchor { opacity: 1; }

/* ---------- پاراگراف‌ها ---------- */
.chapter p {
    font-size: var(--reading-font-size);
    line-height: var(--reading-line-height);
    color: var(--dark);
    text-align: justify;
    margin: 0 0 1.1rem;
    transition: font-size .2s ease, line-height .2s ease;
}
.chapter strong { color: var(--primary-dark); font-weight: 700; }
[data-theme="dark"] .chapter strong { color: var(--primary-light); }

.chapter ul, .chapter ol {
    margin: 0 1.6rem 1.4rem 0;
    padding: 0;
    font-size: var(--reading-font-size);
    line-height: var(--reading-line-height);
}
.chapter li { margin-bottom: .45rem; }
.chapter li::marker { color: var(--primary); }

/* ---------- بلوک کدها ---------- */
.chapter pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 20px 22px;
    border-radius: var(--radius);
    overflow-x: auto;
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
    font-family: 'Courier New', 'Liberation Mono', monospace;
    font-size: .88rem;
    line-height: 1.7;
    margin: 1.4rem 0;
    border-left: 4px solid var(--primary-light);
    position: relative;
    scrollbar-width: thin;
}
.chapter pre::-webkit-scrollbar { height: 8px; }
.chapter pre::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.2);
    border-radius: 4px;
}
.chapter pre code {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
    display: block;
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
    white-space: pre;
}

/* دکمه کپی */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, .1);
    color: #cbd5e1;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chapter pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.copy-btn.copied { color: #4ade80; }

/* ---------- جعبه‌های اطلاعاتی ---------- */
.chapter .note-box,
.chapter .tip-box,
.chapter .warning-box,
.chapter .highlight-box {
    padding: 16px 22px;
    margin: 1.6rem 0;
    border-radius: var(--radius);
    border-right: 4px solid;
    font-size: var(--reading-font-size);
    line-height: var(--reading-line-height);
}
.chapter .note-box {
    background: var(--primary-subtle);
    border-color: var(--primary);
}
.chapter .note-box strong { color: var(--primary); }
.chapter .tip-box {
    background: #ecfdf5;
    border-color: var(--success);
}
[data-theme="dark"] .chapter .tip-box { background: #052e1e; }
.chapter .tip-box strong { color: var(--success); }
.chapter .warning-box {
    background: #fef2f2;
    border-color: var(--danger);
}
[data-theme="dark"] .chapter .warning-box { background: #3a0a0a; }
.chapter .warning-box strong { color: var(--danger); }
.chapter .highlight-box {
    background: var(--surface-2);
    border-color: var(--accent);
}

/* ---------- جدول‌ها ---------- */
.chapter .table-wrap {
    overflow-x: auto;
    margin: 1.6rem 0;
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
}
.chapter table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
    background: var(--surface);
}
.chapter table th {
    background: var(--primary);
    color: #fff;
    padding: 11px 14px;
    text-align: right;
    font-weight: 600;
    font-size: .9rem;
}
.chapter table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    line-height: 1.8;
}
.chapter table tr:last-child td { border-bottom: none; }
.chapter table tr:nth-child(even) td { background: var(--surface-2); }

/* ============================================================
   ناوبری فصل قبل/بعد
   ============================================================ */
.chapter-nav {
    max-width: var(--content-max);
    margin: 32px auto 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.nav-card {
    display: flex;
    flex-direction: column;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    gap: 6px;
}
.nav-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.nav-card.next { text-align: left; }
.nav-card .label {
    font-size: .75rem;
    color: var(--gray-light);
    font-weight: 500;
}
.nav-card .title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.5;
}
.nav-card.next { grid-column: 2; }

/* ============================================================
   فوتر
   ============================================================ */
.site-footer {
    background: var(--dark-soft);
    color: #cbd5e1;
    padding: 36px 24px;
    text-align: center;
    font-size: .88rem;
    line-height: 1.9;
    margin-top: 40px;
    border-top: 1px solid var(--border-soft);
}
[data-theme="dark"] .site-footer {
    background: #0a0f1a;
    color: #94a3b8;
}
.site-footer a {
    color: var(--primary-light);
    font-weight: 500;
}
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .domains {
    margin-top: 12px;
    font-size: .82rem;
    color: rgba(255, 255, 255, .7);
}
[data-theme="dark"] .site-footer .domains { color: #64748b; }

/* ============================================================
   صفحه‌ی فرود
   ============================================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 72px 32px 96px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M0,0 L100,100 M100,0 L0,100" stroke="rgba(255,255,255,0.06)" stroke-width="1"/></svg>');
    opacity: .5;
}
.hero > * { position: relative; z-index: 1; }
.hero .book-icon {
    font-size: 3.6rem;
    color: rgba(255, 255, 255, .9);
    margin-bottom: 18px;
    display: block;
    animation: float 3.5s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    margin: 0 0 12px;
    letter-spacing: -.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.hero .subtitle {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: rgba(255, 255, 255, .95);
    margin: 0 0 6px;
    font-weight: 500;
}
.hero .author {
    font-size: .98rem;
    color: rgba(255, 255, 255, .82);
    margin: 0 0 30px;
    font-weight: 300;
}
.hero .actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ---------- دکمه‌ها ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 13px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: .95rem;
    transition: var(--transition);
    border: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary {
    background: #fff;
    color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-subtle);
    color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .15);
}
.btn-outline {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, .55);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, .15);
    border-color: #fff;
    color: #fff;
    transform: translateY(-2px);
}

/* ---------- کارت‌های معرفی روی صفحه‌ی فرود ---------- */
.features {
    max-width: 1120px;
    margin: -56px auto 0;
    padding: 0 24px 56px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    position: relative;
    z-index: 2;
}
.feature-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 26px 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-soft);
    transition: var(--transition);
    text-align: right;
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.feature-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-subtle);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 14px;
    transition: var(--transition);
}
.feature-card:hover .icon {
    background: var(--primary);
    color: #fff;
}
.feature-card h3 {
    margin: 0 0 8px;
    font-size: 1.02rem;
    color: var(--dark);
    font-weight: 700;
}
.feature-card p {
    margin: 0;
    font-size: .9rem;
    color: var(--gray);
    line-height: 1.8;
    text-align: justify;
}

/* ---------- بخش معرفی کتاب در فرود ---------- */
.intro-section {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 20px 24px 60px;
}
.intro-section h2 {
    color: var(--primary);
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    margin: 2.2rem 0 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--primary-subtle);
    font-weight: 700;
}
.intro-section h2:first-child { margin-top: 0; }
.intro-section p {
    text-align: justify;
    line-height: 2;
    font-size: 1.02rem;
    color: var(--dark);
}
.intro-section strong { color: var(--primary-dark); }
[data-theme="dark"] .intro-section strong { color: var(--primary-light); }

/* ---------- کاور کتاب ---------- */
.book-cover {
    display: flex;
    justify-content: center;
    margin: 0 0 30px;
}
.book-cover img {
    max-width: 260px;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}
.book-cover img:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, .2);
}

/* ---------- جعبه‌ی نکات (لیست ویژگی‌ها) ---------- */
.highlight-box {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 22px 0;
    border-right: 4px solid var(--primary);
}
.highlight-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px 18px;
}
.highlight-box ul li {
    position: relative;
    padding-right: 20px;
    font-size: .92rem;
    margin-bottom: 4px;
    color: var(--dark);
}
.highlight-box ul li::before {
    content: "✓";
    color: var(--primary);
    position: absolute;
    right: 0;
    font-weight: 700;
}

/* ---------- بخش مجوز ---------- */
.license-info {
    background: var(--light-blue);
    border-radius: var(--radius-lg);
    padding: 28px 30px;
    margin: 36px 0;
    border-right: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}
.license-info h2 {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.license-info p {
    color: var(--dark);
    font-size: .98rem;
    line-height: 1.9;
    text-align: justify;
    margin-bottom: 10px;
}
.license-info p:last-child { margin-bottom: 0; }

/* ---------- FAQ ---------- */
.faq { margin: 40px 0; }
.faq h2 {
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}
.faq-item {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.faq-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}
.faq-item.active {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(8, 90, 139, .12);
}
.faq-question {
    padding: 18px 22px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--dark);
    transition: var(--transition);
    background: var(--surface-2);
    gap: 12px;
    font-size: .98rem;
}
.faq-question:hover { background: var(--primary-subtle); }
.faq-question i {
    transition: var(--transition);
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}
.faq-answer {
    padding: 0 22px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .4s ease, padding .3s ease;
    color: var(--gray);
    text-align: justify;
    line-height: 1.9;
    font-size: .95rem;
}
.faq-item.active .faq-answer {
    max-height: 500px;
    padding: 18px 22px 22px;
}
.faq-item.active .faq-question i { transform: rotate(180deg); }
.faq-item.active .faq-question {
    background: var(--primary-subtle);
    border-bottom: 1px solid var(--primary-light);
}

/* ============================================================
   صفحه‌ی فهرست
   ============================================================ */
.toc-page {
    max-width: 900px;
    margin: 40px auto 60px;
    padding: 0 24px;
}
.toc-page h1 {
    color: var(--primary);
    font-size: clamp(1.6rem, 4vw, 2rem);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.toc-page .lead {
    color: var(--gray);
    margin-bottom: 32px;
    font-size: 1rem;
}
.part-block {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 22px 26px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
    transition: var(--transition);
}
.part-block:hover { box-shadow: var(--shadow-md); }
.part-block h2 {
    color: var(--primary);
    font-size: 1.08rem;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 10px;
}
.part-block ol {
    list-style: none;
    counter-reset: ch;
    padding: 0;
    margin: 0;
}
.part-block ol li {
    counter-increment: ch;
    padding: 11px 0;
    border-bottom: 1px dashed var(--border-soft);
    display: flex;
    align-items: baseline;
    gap: 14px;
    transition: var(--transition);
}
.part-block ol li:last-child { border-bottom: none; }
.part-block ol li::before {
    content: counter(ch);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--primary-subtle);
    color: var(--primary);
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.part-block ol li a {
    font-weight: 500;
    color: var(--dark);
    font-size: .96rem;
    transition: var(--transition);
}
.part-block ol li a:hover {
    color: var(--primary);
    padding-right: 4px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--dark-soft);
    color: #fff;
    padding: 16px 28px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    font-size: .95rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all .4s ease;
    z-index: 9999;
    max-width: 90vw;
    text-align: center;
    border-right: 4px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.7;
}
.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   واکنش‌گرا
   ============================================================ */
@media (max-width: 1024px) {
    .content { padding: 28px 26px 60px; }
    .chapter { padding: 36px 32px; }
}

@media (max-width: 860px) {
    .menu-toggle { display: inline-flex; }
    .sidebar {
        position: fixed;
        top: var(--header-h);
        right: 0;
        height: calc(100vh - var(--header-h));
        width: min(320px, 85vw);
        transform: translateX(100%);
        transition: transform .3s ease;
        box-shadow: var(--shadow-lg);
        z-index: 90;
        padding-top: 16px;
    }
    .layout.sidebar-collapsed .sidebar {
        width: min(320px, 85vw);
    }
    .layout.sidebar-collapsed .sidebar .sidebar-search,
    .layout.sidebar-collapsed .sidebar .part-title,
    .layout.sidebar-collapsed .sidebar .toc-link-text {
        opacity: 1;
        height: auto;
        pointer-events: auto;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        position: fixed;
        inset: var(--header-h) 0 0 0;
        background: rgba(0, 0, 0, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
        z-index: 89;
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }

    .content { padding: 20px 16px 60px; }
    .chapter { padding: 26px 20px; border-radius: var(--radius); }
    .chapter-nav { grid-template-columns: 1fr; }
    .nav-card.next { grid-column: 1; }
    .font-controls { margin: 0 2px; }
    .font-controls button { width: 28px; height: 28px; }
    .pdf-btn span { display: none; }
    .pdf-btn { padding: 8px 10px; }
    .site-header { padding: 0 12px; gap: 6px; }
}

@media (max-width: 520px) {
    .site-header .brand .brand-text { display: none; }
    .chapter { padding: 22px 16px; }
    .chapter pre { font-size: .78rem; padding: 14px 16px; }
    .hero { padding: 56px 20px 70px; }
    .hero h1 { font-size: 1.9rem; }
    .features { margin-top: -40px; padding: 0 16px 40px; }
    .chapter-header h1 { font-size: 1.35rem; }
    .chapter-header .chapter-meta { font-size: .78rem; gap: 12px; }
    .font-controls .divider { display: none; }
}

/* ---------- چاپ ---------- */
@media print {
    .site-header, .sidebar, .chapter-nav, .site-footer,
    .breadcrumb, #progress-bar, .copy-btn, .toast,
    .font-controls, .pdf-btn, .menu-toggle, .sidebar-overlay { display: none !important; }
    .layout { display: block; }
    .content { padding: 0; }
    .chapter { box-shadow: none; padding: 0; max-width: 100%; }
    body { background: #fff; color: #000; font-size: 11pt; }
    .chapter a { color: #000; text-decoration: underline; }
    .chapter pre {
        background: #f5f5f5;
        color: #000;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    .chapter h2, .chapter h3 { page-break-after: avoid; }
    .chapter code { background: #f0f0f0; color: #000; border-color: #ccc; }
}