/* ═══════════════════════════════════════════════════════
   Isomer — Design System
   ═══════════════════════════════════════════════════════ */

/* ─── Tokens ─────────────────────────────────────────── */
:root {
    --bg: #ffffff;
    --bg-subtle: #f9fafb;
    --bg-muted: #f3f4f6;
    --text: #111827;
    --text-soft: #4b5563;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --primary: #0f766e;
    --primary-hover: #115e59;
    --primary-soft: #f0fdfa;
    --primary-text: #0f766e;

    --warn-soft: #fffbeb;
    --warn-border: #fcd34d;
    --warn-text: #92400e;

    --success: #059669;
    --danger: #dc2626;

    --font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Monaco, monospace;

    --sidebar-w: 272px;
    --header-h: 56px;
    --content-max: 720px;

    --r-sm: 6px;
    --r: 8px;
    --r-lg: 12px;
}

[data-theme="dark"] {
    --bg: #0b0d10;
    --bg-subtle: #12151a;
    --bg-muted: #1a1e25;
    --text: #f3f4f6;
    --text-soft: #d1d5db;
    --text-muted: #6b7280;
    --border: #232830;
    --border-strong: #333a45;

    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #042f2e;
    --primary-text: #5eead4;

    --warn-soft: #2a1f08;
    --warn-border: #78350f;
    --warn-text: #fbbf24;

    --success: #10b981;
    --danger: #ef4444;
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

code {
    font-family: var(--mono);
    font-size: .86em;
    background: var(--bg-muted);
    padding: .15em .45em;
    border-radius: var(--r-sm);
    direction: ltr;
    display: inline-block;
    line-height: 1.5;
}

/* ─── Layout ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-subtle);
    border-inline-end: 1px solid var(--border);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.sidebar-header {
    height: var(--header-h);
    flex-shrink: 0;
    padding: 0 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -.01em;
}
.brand:hover { color: var(--text); }

.brand-mark {
    width: 28px; height: 28px;
    border-radius: var(--r);
    background: var(--primary);
    color: #fff;
    display: grid; place-items: center;
    font-size: 14px;
    flex-shrink: 0;
}
[data-theme="dark"] .brand-mark { color: #0b0d10; }

.sidebar-nav {
    flex: 1;
    padding: 1.25rem .75rem 2rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.nav-home {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--r);
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 1.5rem;
    transition: all .12s;
}
.nav-home:hover { background: var(--bg-muted); color: var(--text); }
.nav-home.active {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.nav-section { margin-bottom: 1.5rem; }

.nav-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 .75rem;
    margin-bottom: .5rem;
    line-height: 1.4;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--r);
    color: var(--text-soft);
    font-size: 13.5px;
    line-height: 1.5;
    transition: background .12s, color .12s;
    margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-muted); color: var(--text); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-text);
    font-weight: 600;
}

.nav-num {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--r-sm);
    transition: all .12s;
}
.nav-item.active .nav-num {
    background: var(--primary);
    color: #fff;
}
[data-theme="dark"] .nav-item.active .nav-num { color: #0b0d10; }

.nav-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer {
    padding: .9rem 1.1rem;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-close {
    display: none;
    width: 32px; height: 32px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.sidebar-close:hover { background: var(--bg-muted); color: var(--text); }

/* ─── Main column ────────────────────────────────────── */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 2rem;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
[data-theme="dark"] .topbar { background: rgba(11,13,16,.85); }

.topbar-breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    font-size: 13px;
    color: var(--text-muted);
}
.topbar-breadcrumb .sep { opacity: .5; }
.topbar-breadcrumb .current {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-breadcrumb a { color: var(--text-soft); }
.topbar-breadcrumb a:hover { color: var(--primary); }

.topbar-actions { display: flex; align-items: center; gap: .25rem; }

.icon-btn {
    width: 34px; height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r);
    color: var(--text-soft);
    font-size: 15px;
    transition: all .12s;
}
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }

.menu-btn { display: none; }

/* ─── Content ────────────────────────────────────────── */
.content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
    position: relative;
    z-index: 1;
}

/* ─── Hero (home) ────────────────────────────────────── */
.hero { padding: 2rem 0 3rem; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    border-radius: 100px;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.hero h1 {
    font-size: 2.25rem;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -.025em;
    margin-bottom: 1rem;
}
.hero h1 .accent { color: var(--primary); }

.hero p {
    font-size: 1rem;
    color: var(--text-soft);
    line-height: 1.75;
    max-width: 560px;
    margin-bottom: 1.75rem;
}

.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .65rem 1.2rem;
    border-radius: var(--r);
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    transition: all .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
[data-theme="dark"] .btn-primary { color: #0b0d10; }
.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}
[data-theme="dark"] .btn-primary:hover { color: #0b0d10; }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-muted); color: var(--text); }

/* ─── Section heading ────────────────────────────────── */
.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0 0 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.section-heading .count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Chapter list (home) ────────────────────────────── */
.part-block { margin-bottom: 2.5rem; }
.part-block:last-child { margin-bottom: 0; }

.part-title {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .75rem;
    padding: 0 .25rem;
}

.chapter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .5rem;
}

.ch-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    background: var(--bg);
    transition: all .15s;
}
.ch-link:hover {
    border-color: var(--primary);
    color: var(--text);
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.ch-num {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: var(--r);
    background: var(--bg-muted);
    color: var(--text-soft);
    display: grid; place-items: center;
    font-size: 13px;
    font-weight: 700;
    transition: all .15s;
}
.ch-link:hover .ch-num { background: var(--primary); color: #fff; }
[data-theme="dark"] .ch-link:hover .ch-num { color: #0b0d10; }

.ch-body { flex: 1; min-width: 0; }
.ch-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ch-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Chapter page ───────────────────────────────────── */
.ch-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.ch-header .eyebrow {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-text);
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: .5rem;
}
.ch-header h1 {
    font-size: 1.9rem;
    line-height: 1.3;
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: .75rem;
}
.ch-header .lead {
    font-size: 1rem;
    color: var(--text-soft);
    line-height: 1.75;
    max-width: 620px;
}

/* ─── Blocks ─────────────────────────────────────────── */
.block { margin-bottom: 2rem; }

.block > h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.block-formula {
    padding: 1.5rem;
    background: var(--bg-subtle);
    border-radius: var(--r-lg);
    text-align: center;
    margin: 1.5rem 0;
}

.block-trap {
    padding: 1.25rem 1.5rem;
    background: var(--warn-soft);
    border-radius: var(--r-lg);
    border-inline-start: 3px solid var(--warn-border);
}
.block-trap > h2 { color: var(--warn-text) !important; font-size: 1rem; margin-bottom: .75rem; }

.block-summary {
    padding: 1.25rem 1.5rem;
    background: var(--bg-subtle);
    border-radius: var(--r-lg);
    border-inline-start: 3px solid var(--primary);
}

.block-example {
    padding: 1.25rem 1.5rem;
    background: var(--bg-subtle);
    border-radius: var(--r-lg);
}

/* ─── Prose ──────────────────────────────────────────── */
.prose p { margin: .9rem 0; line-height: 1.85; }
.prose h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 2rem 0 1rem;
    line-height: 1.5;
}
.prose h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 1.5rem 0 .75rem;
}
.prose ul, .prose ol { padding-inline-start: 1.5rem; margin: .9rem 0; }
.prose li { margin: .4rem 0; line-height: 1.8; }
.prose li::marker { color: var(--text-muted); }
.prose strong { font-weight: 700; }

.prose blockquote {
    margin: 1.25rem 0;
    padding: .75rem 1.1rem;
    border-inline-start: 3px solid var(--border-strong);
    color: var(--text-soft);
    background: var(--bg-subtle);
    border-radius: 0 var(--r) var(--r) 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
}
.prose th, .prose td {
    padding: .7rem .9rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}
.prose th {
    background: var(--bg-subtle);
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.prose tr:last-child td { border-bottom: 0; }

/* ─── Simulators ─────────────────────────────────────── */
.sim-list { display: grid; gap: .5rem; margin-top: 1rem; }

.sim-link {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    background: var(--bg);
    transition: all .15s;
}
.sim-link:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--text);
}

.sim-icon {
    width: 36px; height: 36px;
    border-radius: var(--r);
    background: var(--bg-muted);
    display: grid; place-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sim-body { flex: 1; min-width: 0; }
.sim-name { font-weight: 600; font-size: 14px; line-height: 1.5; margin-bottom: 2px; }
.sim-guide { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.sim-arrow {
    color: var(--text-muted);
    font-size: 14px;
    transition: transform .15s;
}
.sim-link:hover .sim-arrow { color: var(--primary); transform: translateX(-3px); }

/* ─── Flashcards ─────────────────────────────────────── */
.flash-list { display: grid; gap: .5rem; margin-top: 1rem; }

.flash {
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--bg);
}
.flash summary {
    padding: .9rem 1rem .9rem 2.5rem;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
    cursor: pointer;
    list-style: none;
    position: relative;
    transition: background .12s;
    user-select: none;
}
.flash summary::-webkit-details-marker { display: none; }
.flash summary:hover { background: var(--bg-subtle); }

.flash summary::before {
    content: '';
    position: absolute;
    inset-inline-start: 1rem;
    top: 50%;
    width: 6px; height: 6px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-70%) rotate(-45deg);
    transition: transform .2s;
}
.flash[open] summary::before {
    transform: translateY(-30%) rotate(45deg);
    border-color: var(--primary);
}

.flash-content {
    padding: 1rem;
    font-size: 13.5px;
    color: var(--text-soft);
    line-height: 1.8;
    border-top: 1px solid var(--border);
}

/* ─── Quiz ───────────────────────────────────────────── */
.quiz-list { display: grid; gap: .75rem; margin-top: 1rem; }

.quiz-item {
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg);
}

.quiz-q {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.7;
    margin-bottom: .9rem;
    display: flex;
    gap: .5rem;
    align-items: flex-start;
}
.quiz-q .q-num {
    flex-shrink: 0;
    display: inline-block;
    min-width: 22px; height: 22px;
    padding: 0 6px;
    background: var(--bg-muted);
    color: var(--text-soft);
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    line-height: 22px;
}

.quiz-opts { display: grid; gap: .4rem; }

.quiz-opt {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: 13.5px;
    line-height: 1.6;
    text-align: right;
    color: var(--text);
    transition: all .13s;
    width: 100%;
}
.quiz-opt:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.quiz-opt:disabled { cursor: default; }

.quiz-opt .k {
    flex-shrink: 0;
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border-radius: 5px;
    background: var(--bg-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-soft);
    transition: all .13s;
}

.quiz-opt.is-correct {
    border-color: var(--success);
    background: rgba(5,150,105,.08);
}
.quiz-opt.is-correct .k { background: var(--success); color: #fff; }

.quiz-opt.is-wrong {
    border-color: var(--danger);
    background: rgba(220,38,38,.08);
}
.quiz-opt.is-wrong .k { background: var(--danger); color: #fff; }

.quiz-explain {
    margin-top: .85rem;
    padding: .85rem 1rem;
    background: var(--bg-subtle);
    border-inline-start: 3px solid var(--primary);
    border-radius: 0 var(--r) var(--r) 0;
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.75;
}

/* ─── Footer ─────────────────────────────────────────── */
.site-footer {
    padding: 2rem;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ─── Overlay ────────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 90;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 960px) {
    .layout { display: block; }

    .sidebar {
        position: fixed;
        top: 0; bottom: 0;
        right: 0;
        width: 300px;
        max-width: 84vw;
        z-index: 100;
        transform: translateX(100%);
        box-shadow: -8px 0 40px rgba(0,0,0,.12);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .menu-btn { display: inline-flex; }

    .topbar { padding: 0 1.25rem; }
    .content { padding: 1.75rem 1.25rem 4rem; }
    .hero h1 { font-size: 1.75rem; }
    .ch-header h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .content { padding: 1.25rem 1rem 3rem; }
    .topbar { padding: 0 1rem; }
    .hero { padding: 1rem 0 2rem; }
    .hero h1 { font-size: 1.5rem; }
    .ch-header { margin-bottom: 2rem; padding-bottom: 1.25rem; }
    .ch-header h1 { font-size: 1.35rem; }
    .prose table { font-size: 12.5px; }
    .prose th, .prose td { padding: .55rem .6rem; }
    .hero-actions { flex-direction: column; }
    .btn { justify-content: center; }
}

@media print {
    .sidebar, .topbar, .overlay, .site-footer { display: none !important; }
    .content { max-width: 100%; padding: 0; }
}
/* ═══════════════════════════════════════════════
   بلوک کد و نمودار درختی
   ═══════════════════════════════════════════════ */

.prose pre {
    direction: ltr;
    text-align: left;
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    overflow-x: auto;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.65;
    margin: 1.25rem 0;
    tab-size: 4;
}

[data-theme="light"] .prose pre {
    background: #1e293b;
    color: #e2e8f0;
}

.prose pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    direction: ltr;
    display: block;
    white-space: pre;
    font-family: inherit;
}

/* کد درون خطی */
.prose code {
    background: var(--surface-2);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: .88em;
    direction: ltr;
    display: inline-block;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* جدول ها */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.prose th,
.prose td {
    padding: .7rem .9rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    line-height: 1.6;
}

.prose th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text-soft);
}

.prose tr:last-child td {
    border-bottom: 0;
}

/* ═══════════════════════════════════════════════
   فرمول های ریاضی — همیشه چپ چین
   ═══════════════════════════════════════════════ */

.katex,
.katex-display,
.katex-inline {
    direction: ltr !important;
    unicode-bidi: isolate !important;
}

.katex-display {
    text-align: center !important;
    margin: 1rem 0 !important;
}

.katex .mord,
.katex .mbin,
.katex .mrel,
.katex .mopen,
.katex .mclose,
.katex .mpunct,
.katex .minner,
.katex .mop {
    direction: ltr;
}

/* ═══════════════════════════════════════════════
   بلوک کد و نمودار درختی — چپ چین اجباری
   ═══════════════════════════════════════════════ */

.prose pre,
.prose pre code {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: plaintext !important;
}

.prose pre code {
    display: block;
    white-space: pre;
}
/* نمودار درختی */
.prose pre {
    direction: ltr !important;
    text-align: left !important;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace !important;
    background: #1e293b !important;
    color: #e2e8f0 !important;
    padding: 1rem 1.25rem !important;
    border-radius: 10px !important;
    overflow-x: auto !important;
    font-size: 13px !important;
    line-height: 1.7 !important;
    white-space: pre !important;
    tab-size: 4 !important;
}


/* ═══════════════════════════════════════════════
   نمودار درختی
   ═══════════════════════════════════════════════ */

.prose .tree {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    margin: 1.5rem 0;
    font-size: 14.5px;
    line-height: 1.9;
    overflow-x: auto;
}

[data-theme="light"] .prose .tree {
    background: #1e293b;
    color: #e2e8f0;
}

.prose .tree ul {
    list-style: none;
    padding-inline-start: 1.6rem;
    margin: .4rem 0;
    border-inline-start: 1px solid rgba(148, 163, 184, .3);
}

.prose .tree > ul {
    padding-inline-start: 0;
    border-inline-start: 0;
    margin: 0;
}

.prose .tree li {
    position: relative;
    padding-inline-start: 1.25rem;
    margin: .3rem 0;
    line-height: 1.85;
}

.prose .tree li::before {
    content: '';
    position: absolute;
    inset-inline-start: -1px;
    top: 1em;
    width: .9rem;
    height: 1px;
    background: rgba(148, 163, 184, .4);
}

.prose .tree > ul > li::before {
    display: none;
}

.prose .tree > ul > li {
    padding-inline-start: 0;
    font-weight: 700;
    color: #22d3ee;
    font-size: 1.05em;
    margin-bottom: .5rem;
}

.prose .tree strong {
    color: #22d3ee;
    font-weight: 700;
}

.prose .tree code {
    background: rgba(255, 255, 255, .1);
    color: #e2e8f0;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    direction: ltr;
    display: inline-block;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ═══════════════════════════════════════════════
   مایند مپ (Mind Map)
   ═══════════════════════════════════════════════ */

.mindmap-wrap {
    background: #0f172a;
    border-radius: 14px;
    padding: 1.5rem 1.75rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .12);
}

.mindmap-wrap::-webkit-scrollbar {
    height: 8px;
}
.mindmap-wrap::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.mm {
    display: inline-block;
    direction: rtl;
    padding: 1rem 1.5rem;
    font-size: 14px;
    line-height: 1.6;
    color: #e2e8f0;
    min-width: 100%;
}

/* ─── هر گره ─── */
.mm-node {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
    padding: .25rem 0;
}

/* ─── لیبل ─── */
.mm-label {
    flex-shrink: 0;
    display: inline-block;
    padding: .55rem 1.05rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 9px;
    white-space: nowrap;
    font-size: 13.5px;
    line-height: 1.55;
    color: #e2e8f0;
    position: relative;
    z-index: 2;
    transition: all .18s ease;
}

.mm-label:hover {
    border-color: #14b8a6;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(20, 184, 166, .18);
}

.mm-label strong {
    color: #5eead4;
    font-weight: 700;
}

.mm-label code {
    background: rgba(255, 255, 255, .1);
    color: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: .85em;
    direction: ltr;
    display: inline-block;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ─── رنگ ریشه ─── */
.mm > .mm-node > .mm-label {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    border-color: #2dd4bf;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    padding: .7rem 1.3rem;
    box-shadow: 0 6px 20px rgba(20, 184, 166, .35);
}
.mm > .mm-node > .mm-label strong { color: #fff; }

/* ─── رنگ سطح ۱ ─── */
.mm > .mm-node > .mm-children > .mm-node > .mm-label {
    background: #1e40af;
    border-color: #3b82f6;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}
.mm > .mm-node > .mm-children > .mm-node > .mm-label strong { color: #fff; }

/* ─── رنگ سطح ۲ ─── */
.mm > .mm-node > .mm-children > .mm-node > .mm-children > .mm-node > .mm-label {
    background: #4c1d95;
    border-color: #7c3aed;
    color: #f5f3ff;
}

/* ─── کانتینر فرزندان ─── */
.mm-children {
    --gap: 1rem;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    position: relative;
}

/* ─── خط افقی از والد به spine ─── */
.mm-children::before {
    content: '';
    position: absolute;
    right: -2rem;
    top: 50%;
    width: 1rem;
    height: 2px;
    background: #475569;
    transform: translateY(-50%);
}

/* ─── خط افقی از spine به هر فرزند (روی لیبل فرزند) ─── */
.mm-children > .mm-node > .mm-label::before {
    content: '';
    position: absolute;
    right: -1rem;
    top: 50%;
    width: 1rem;
    height: 2px;
    background: #475569;
    transform: translateY(-50%);
}

/* ─── بخش عمودی spine (روی هر فرزند) ─── */
.mm-children > .mm-node::after {
    content: '';
    position: absolute;
    right: -1rem;
    top: calc(-0.5 * var(--gap));
    bottom: calc(-0.5 * var(--gap));
    width: 2px;
    background: #475569;
}

.mm-children > .mm-node:first-child::after {
    top: 50%;
}

.mm-children > .mm-node:last-child::after {
    bottom: 50%;
}

/* ─── تک فرزند ─── */
.mm-children > .mm-node:only-child::after {
    display: none;
}
.mm-children > .mm-node:only-child > .mm-label::before {
    background: #475569;
}

/* ─── ریسپانسیو ─── */
@media (max-width: 700px) {
    .mindmap-wrap {
        padding: 1rem;
        border-radius: 10px;
    }
    .mm {
        font-size: 12.5px;
        padding: .5rem;
    }
    .mm-label {
        font-size: 12px;
        padding: .45rem .85rem;
    }
    .mm-node { gap: 1.25rem; }
    .mm-children { --gap: .75rem; }
    .mm-children::before { right: -1.25rem; width: .75rem; }
    .mm-children > .mm-node > .mm-label::before { right: -.75rem; width: .75rem; }
    .mm-children > .mm-node::after { right: -.75rem; }
}

/* ═══════════════════════════════════════════════
   آزمونک — رنگ پاسخ
   ═══════════════════════════════════════════════ */

.quiz-opt.correct {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
    font-weight: 600;
}

.quiz-opt.correct .opt-k {
    background: #10b981 !important;
    color: #fff !important;
}

.quiz-opt.wrong {
    background: #fee2e2 !important;
    border-color: #dc2626 !important;
    color: #991b1b !important;
}

.quiz-opt.wrong .opt-k {
    background: #dc2626 !important;
    color: #fff !important;
}

[data-theme="dark"] .quiz-opt.correct {
    background: rgba(16, 185, 129, .18) !important;
    color: #a7f3d0 !important;
    border-color: #10b981 !important;
}

[data-theme="dark"] .quiz-opt.wrong {
    background: rgba(220, 38, 38, .18) !important;
    color: #fecaca !important;
    border-color: #dc2626 !important;
}

/* دکمه غیرفعال بعد از جواب */
.quiz-opt:disabled {
    cursor: default;
    opacity: 1;
}

/* ═══════════════════════════════════════════════
   لیست تله ها و مثال ها
   ═══════════════════════════════════════════════ */

.block-trap ol.trap-list,
.block-example ol.trap-list {
    padding-inline-start: 1.5rem;
    margin: 1rem 0;
    list-style: none;
    counter-reset: trap-counter;
}

.block-trap ol.trap-list > li,
.block-example ol.trap-list > li {
    position: relative;
    padding-inline-start: 2.2rem;
    margin-bottom: .85rem;
    line-height: 1.85;
    counter-increment: trap-counter;
}

.block-trap ol.trap-list > li::before,
.block-example ol.trap-list > li::before {
    content: counter(trap-counter);
    position: absolute;
    inset-inline-start: 0;
    top: .2rem;
    width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--trap-border, #f59e0b);
    color: #fff;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
}

/* ═══════════════════════════════════════════════
   مدار الکترونی
   ═══════════════════════════════════════════════ */

.orb-wrap {
    background: #0f172a;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin: 1.25rem 0;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 14px;
    overflow-x: auto;
}

.orb-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}

.orb-row:last-child { margin-bottom: 0; }

.orb-label {
    color: #fbbf24;
    font-weight: 700;
    min-width: 2rem;
    direction: ltr;
    flex-shrink: 0;
}

.orb-boxes {
    display: flex;
    gap: .35rem;
}

.orb-box {
    display: inline-flex;
    width: 38px;
    height: 32px;
    border: 1.5px solid #475569;
    border-radius: 5px;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: rgba(30, 41, 59, .6);
    direction: ltr;
}

.orb-box.orb-pair {
    background: rgba(56, 189, 248, .18);
    border-color: #38bdf8;
}

.orb-box.orb-single {
    background: rgba(251, 191, 36, .15);
    border-color: #fbbf24;
}

.orb-arrow {
    color: #e2e8f0;
    font-size: 15px;
    line-height: 1;
}

.orb-pair .orb-arrow { color: #38bdf8; }
.orb-single .orb-arrow { color: #fbbf24; }

.orb-comment {
    color: #94a3b8;
    font-size: 12.5px;
    font-family: Vazirmatn, Tahoma, sans-serif;
    direction: rtl;
    margin-inline-start: .5rem;
}

.orb-plain {
    color: #cbd5e1;
    padding: .5rem 0;
    direction: ltr;
    text-align: left;
}

/* ═══════════════════════════════════════════════
   بزرگراه مول
   ═══════════════════════════════════════════════ */

.hw-wrap {
    background: #0f172a;
    border-radius: 14px;
    padding: 1.75rem 1.25rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.hw-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    flex-wrap: nowrap;
    min-width: max-content;
    margin-inline: auto;
}

.hw-node {
    padding: .55rem 1rem;
    border-radius: 10px;
    text-align: center;
    flex-shrink: 0;
    border: 1.5px solid #334155;
    background: #1e293b;
    min-width: 90px;
}

.hw-node.hw-center {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    border-color: #5eead4;
    min-width: 110px;
    box-shadow: 0 6px 20px rgba(20, 184, 166, .35);
}

.hw-node.hw-side {
    background: #1e40af;
    border-color: #3b82f6;
}

.hw-t {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    line-height: 1.3;
}

.hw-s {
    font-size: 11px;
    color: rgba(255, 255, 255, .75);
    margin-top: 2px;
    direction: ltr;
}

.hw-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 70px;
}

.hw-lbl {
    font-size: 11px;
    color: #fbbf24;
    font-family: ui-monospace, monospace;
    direction: ltr;
    font-weight: 600;
}

.hw-line {
    color: #64748b;
    font-size: 16px;
    line-height: 1;
}

.hw-branches {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px dashed #334155;
}

.hw-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
}

.hw-down {
    color: #64748b;
    font-size: 18px;
    line-height: 1;
}

.hw-node.hw-small {
    background: #4c1d95;
    border-color: #7c3aed;
    padding: .4rem .85rem;
    min-width: 90px;
    font-size: 12px;
    color: #f5f3ff;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════
   نمودار انرژی
   ═══════════════════════════════════════════════ */

.en-wrap {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.en-card {
    flex: 1;
    min-width: 260px;
    background: #0f172a;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.en-title {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: .5rem;
    font-weight: 600;
}

.en-svg {
    width: 100%;
    max-width: 320px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.en-svg text {
    font-family: Vazirmatn, Tahoma, sans-serif;
}
/* ═══════════════════════════════════════════════
   دیاگرام سلول گالوانی
   ═══════════════════════════════════════════════ */

.cell-wrap {
    background: #0f172a;
    border-radius: 14px;
    padding: 1.5rem 1rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

.cell-svg {
    width: 100%;
    max-width: 560px;
    height: auto;
    display: block;
}
/* ═══════════════════════════════════════════════
   نقشه قاره — ستون فقرات
   ═══════════════════════════════════════════════ */

.cs-wrap {
    background: #0f172a;
    border-radius: 14px;
    padding: 1.5rem 1.25rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.cs-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    margin-bottom: .5rem;
}

.cs-box {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    background: linear-gradient(135deg, #1e293b, #334155);
    border: 1.5px solid #475569;
    border-radius: 12px;
    min-width: 320px;
    max-width: 90%;
    position: relative;
    transition: all .18s;
}

.cs-box:hover {
    border-color: #22d3ee;
    box-shadow: 0 4px 16px rgba(34, 211, 238, .2);
}

.cs-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #22d3ee;
    color: #0f172a;
    border-radius: 8px;
    font-weight: 800;
    font-size: 15px;
    flex-shrink: 0;
}

.cs-name {
    color: #f1f5f9;
    font-weight: 700;
    font-size: 14.5px;
    line-height: 1.4;
}

.cs-desc {
    color: #5eead4;
    font-size: 12.5px;
    font-family: ui-monospace, monospace;
    direction: ltr;
    text-align: center;
    margin-bottom: .35rem;
}

.cs-note {
    color: #94a3b8;
    font-size: 12px;
    font-family: Vazirmatn, sans-serif;
    text-align: center;
    margin: -.3rem 0 .5rem;
    position: relative;
}

.cs-note::before {
    content: '│';
    display: block;
    color: #475569;
    font-size: 16px;
    line-height: .8;
    margin-bottom: -.3rem;
}

.cs-extra {
    color: #cbd5e1;
    font-size: 12.5px;
    font-family: ui-monospace, monospace;
    direction: ltr;
    text-align: center;
    margin: .5rem 0;
}

/* فلش بین مراحل */
.cs-step:not(:last-child) .cs-box::after {
    content: '↓';
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    color: #22d3ee;
    font-size: 20px;
    font-weight: 700;
}
.nuc-wrap {
    background: #0f172a;
    border-radius: 14px;
    padding: 1.25rem 1rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}
.nuc-svg {
    width: 100%;
    max-width: 640px;
    height: auto;
    display: block;
}
/* ═══════════════════════════════════════════════════════
   لوگو Lab Isomer
   ═══════════════════════════════════════════════════════ */

.brand {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease;
}

.brand:hover {
    transform: translateY(-1px);
    color: var(--text);
}

.brand-logo {
    height: 40px;
    width: auto;
    display: block;
}

.brand-logo > g {
    transform-origin: 24px 24px;
    animation: atomSpin 25s linear infinite;
}

@keyframes atomSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.brand:hover .brand-logo > g {
    animation-duration: 8s;
}

@media (max-width: 480px) {
    .brand-logo { height: 34px; }
}

/* ═══════════════════════════════════════════════════════
   ناوبری فصل قبلی/بعدی
   ═══════════════════════════════════════════════════════ */

.chapter-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin: 3rem 0 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.nav-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text);
    transition: all .18s ease;
    min-height: 76px;
    text-decoration: none;
}

.nav-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 118, 110, .12);
}

.nav-disabled {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
    opacity: 0;
}

.nav-arrow {
    flex-shrink: 0;
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
    transition: transform .18s;
}

.nav-card:hover .nav-arrow {
    transform: translateX(2px);
}

.nav-prev:hover .nav-arrow { transform: translateX(-2px); }

.nav-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-prev .nav-body { text-align: right; }
.nav-next .nav-body { text-align: left; }

.nav-label {
    font-size: 11.5px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.nav-title {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (max-width: 640px) {
    .chapter-nav { grid-template-columns: 1fr; }
    .nav-disabled { display: none; }
}

/* ═══════════════════════════════════════════════════════
   عکس داخل محتوا
   ═══════════════════════════════════════════════════════ */

.prose .md-img {
    margin: 1.75rem 0;
    text-align: center;
}

.prose .md-img img {
    max-width: 100%;
    height: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .06);
    display: inline-block;
}

.prose .md-img figcaption {
    margin-top: .65rem;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
    padding-inline: 1rem;
}

/* ═══════════════════════════════════════════════════════
   TOC شناور — فهرست فصل
   ═══════════════════════════════════════════════════════ */

.toc {
    display: none;
    position: fixed;
    top: 90px;
    left: 24px;
    width: 240px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 1rem .75rem 1rem 1.25rem;
    border-inline-start: 2px solid var(--border);
    z-index: 40;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 2px;
}

/* فقط در صفحات عریض نمایش داده شود */
@media (min-width: 1240px) {
    .toc { display: block; }
}

.toc-head {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .9rem;
    padding-inline-start: .35rem;
}

.toc-head-icon { font-size: 13px; }

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.toc-link {
    display: block;
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-soft);
    padding: .45rem .8rem;
    border-radius: 0 6px 6px 0;
    text-decoration: none;
    border-inline-start: 2px solid transparent;
    margin-inline-start: -2px;
    transition: all .15s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.toc-link:hover {
    color: var(--text);
    border-inline-start-color: var(--border-strong);
    background: var(--surface-2);
}

.toc-link.active {
    color: var(--primary);
    border-inline-start-color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

/* موبایل و تبلت — مخفی */
@media (max-width: 1239px) {
    .toc { display: none; }
}
/* ═══════════════════════════════════════════════
   لوگو Lab Isomer
   ═══════════════════════════════════════════════ */

.brand {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease;
}

.brand:hover {
    transform: translateY(-1px);
}

.brand-logo {
    height: 40px;
    width: auto;
    display: block;
}

.brand-logo .brand-isomer {
    fill: var(--text);
    transition: fill .18s ease;
}

.brand:hover .brand-logo .brand-isomer {
    fill: var(--primary);
}

@media (max-width: 480px) {
    .brand-logo { height: 34px; }
}
/* ═══════════════════════════════════════════════
   تم های رنگی — 4 پس زمینه
   ═══════════════════════════════════════════════ */

/* مولکولی (پیشفرض) — بنفش */
:root {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-soft: #ede9fe;
    --primary-text: #5b21b6;
}
[data-theme="dark"]:root,
:root[data-theme="dark"] {
    --primary: #a78bfa;
    --primary-hover: #c4b5fd;
    --primary-soft: #2e1065;
    --primary-text: #c4b5fd;
}

/* آزمایشگاه — فیروزه ای-سبز */
[data-accent="lab"] {
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-soft: #ccfbf1;
    --primary-text: #0f766e;
}
[data-theme="dark"][data-accent="lab"] {
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #042f2e;
    --primary-text: #5eead4;
}

/* شعله — نارنجی-قرمز */
[data-accent="flame"] {
    --primary: #ea580c;
    --primary-hover: #c2410c;
    --primary-soft: #ffedd5;
    --primary-text: #9a3412;
}
[data-theme="dark"][data-accent="flame"] {
    --primary: #fb923c;
    --primary-hover: #fdba74;
    --primary-soft: #431407;
    --primary-text: #fdba74;
}


/* کهربا — طلایی (برای مطالعه شبانه) */
[data-accent="amber"] {
    --primary: #d97706;
    --primary-hover: #b45309;
    --primary-soft: #fef3c7;
    --primary-text: #92400e;
}
[data-theme="dark"][data-accent="amber"] {
    --primary: #fbbf24;
    --primary-hover: #fcd34d;
    --primary-soft: #451a03;
    --primary-text: #fcd34d;
}

/* ═══════════════════════════════════════════════
   انتخابگر تم رنگی
   ═══════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════
   منوی انتخاب تم رنگی (position: fixed)
   ═══════════════════════════════════════════════ */
.theme-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    padding: .35rem;
    min-width: 170px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s;
    z-index: 99999;
    pointer-events: none;
}

.theme-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .55rem .8rem;
    background: transparent;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    text-align: right;
    font-family: inherit;
    transition: background .12s;
}

.theme-option:hover {
    background: var(--surface-2);
}

.theme-option.active {
    background: var(--primary-soft);
    color: var(--primary-text);
    font-weight: 600;
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    flex-shrink: 0;
}
/* ═══════════════════════════════════════════════
   لوگو Lab Isomer
   ═══════════════════════════════════════════════ */

.brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease;
}

.brand:hover { transform: translateY(-1px); }

.brand-atom {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: block;
}

.brand-text {
    display: flex;
    align-items: baseline;
    gap: .38rem;
    font-size: 17px;
    line-height: 1;
    letter-spacing: -.01em;
}

.brand-lab {
    font-weight: 800;
    background: linear-gradient(135deg, #22d3ee 0%, #14b8a6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.brand-isomer {
    font-weight: 700;
    color: var(--text);
    transition: color .18s ease;
}

.brand:hover .brand-isomer {
    color: var(--primary);
}

@media (max-width: 480px) {
    .brand-atom { width: 28px; height: 28px; }
    .brand-text { font-size: 15px; }
}
.topbar {
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 2rem;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;        /* ← این عدد 20 بود، بکنش 60 */
}
.topbar {
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 2rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

[data-theme="dark"] .topbar {
    background: var(--bg);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .25rem;
    position: relative;
    z-index: 210;
}
/* ═══════════════════════════════════════════════════════
   صفحهٔ قارهٔ Isomer
   ═══════════════════════════════════════════════════════ */

.continent-hero {
    text-align: center;
    padding: 2.5rem 1rem 3rem;
    max-width: 720px;
    margin: 0 auto;
}

.continent-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: .35rem .85rem;
    border-radius: 100px;
    margin-bottom: 1rem;
}

.continent-hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 .85rem;
    line-height: 1.3;
}

.continent-hero h1 .accent {
    color: var(--primary);
}

.continent-lead {
    font-size: 1rem;
    color: var(--text-soft);
    line-height: 1.85;
    margin: 0 0 1.75rem;
}

.continent-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.continent-stat {
    text-align: center;
}

.continent-stat b {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.continent-stat span {
    font-size: 12.5px;
    color: var(--muted);
}

/* ═══ نقشه ═══ */

.continent-map {
    position: relative;
    max-width: 1080px;
    margin: 1rem auto 3rem;
    padding: 2rem 1rem;
    min-height: 720px;
    background: var(--bg-subtle);
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1.25rem;
}

.continent-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.continent-lines path {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
    opacity: .55;
    transition: stroke .25s, opacity .25s, stroke-width .25s;
}

.continent-lines path.hot {
    stroke: var(--primary);
    opacity: 1;
    stroke-width: 2.5;
    stroke-dasharray: none;
}

/* ═══ جزیره ═══ */

.island {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .85rem .65rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    text-decoration: none;
    transition: all .22s ease;
    min-height: 90px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.island:hover {
    transform: translateY(-4px) scale(1.03);
    color: var(--text);
    box-shadow: 0 14px 32px rgba(0, 0, 0, .1);
    z-index: 10;
}

.island-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--bg-muted);
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 800;
    transition: all .22s;
}

.island-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
}

/* ═══ رنگ جزیره ها بر اساس بخش ═══ */

.island-part-1 { border-color: rgba(34, 211, 238, .35); }
.island-part-1:hover { border-color: #22d3ee; }
.island-part-1 .island-num { background: rgba(34, 211, 238, .15); color: #0891b2; }
.island-part-1:hover .island-num { background: #22d3ee; color: #0f172a; }

.island-part-2 { border-color: rgba(167, 139, 250, .35); }
.island-part-2:hover { border-color: #a78bfa; }
.island-part-2 .island-num { background: rgba(167, 139, 250, .15); color: #7c3aed; }
.island-part-2:hover .island-num { background: #a78bfa; color: #0f172a; }

.island-part-3 { border-color: rgba(52, 211, 153, .35); }
.island-part-3:hover { border-color: #34d399; }
.island-part-3 .island-num { background: rgba(52, 211, 153, .15); color: #059669; }
.island-part-3:hover .island-num { background: #34d399; color: #0f172a; }

.island-part-4 { border-color: rgba(251, 146, 60, .35); }
.island-part-4:hover { border-color: #fb923c; }
.island-part-4 .island-num { background: rgba(251, 146, 60, .15); color: #ea580c; }
.island-part-4:hover .island-num { background: #fb923c; color: #0f172a; }

.island-part-5 { border-color: rgba(244, 114, 182, .35); }
.island-part-5:hover { border-color: #f472b6; }
.island-part-5 .island-num { background: rgba(244, 114, 182, .15); color: #db2777; }
.island-part-5:hover .island-num { background: #f472b6; color: #0f172a; }

/* ═══ چیدمان نامنظم (شبیه جزیره) ═══ */

.island:nth-child(2)  { grid-column: 2; grid-row: 1; }
.island:nth-child(3)  { grid-column: 3; grid-row: 1; }
.island:nth-child(4)  { grid-column: 1; grid-row: 2; }
.island:nth-child(5)  { grid-column: 2; grid-row: 2; }
.island:nth-child(6)  { grid-column: 3; grid-row: 2; }
.island:nth-child(7)  { grid-column: 4; grid-row: 2; }
.island:nth-child(8)  { grid-column: 1; grid-row: 3; }
.island:nth-child(9)  { grid-column: 2; grid-row: 3; }
.island:nth-child(10) { grid-column: 3; grid-row: 3; }
.island:nth-child(11) { grid-column: 4; grid-row: 3; }
.island:nth-child(12) { grid-column: 1; grid-row: 4; }
.island:nth-child(13) { grid-column: 2; grid-row: 4; }
.island:nth-child(14) { grid-column: 3; grid-row: 4; }
.island:nth-child(15) { grid-column: 4; grid-row: 4; }

/* ═══ راهنمای بخش‌ها ═══ */

.continent-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 1.25rem 1rem;
    margin: 0 auto 3rem;
    max-width: 900px;
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: 13px;
    color: var(--text-soft);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ═══ موبایل ═══ */

@media (max-width: 900px) {
    .continent-map {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        min-height: auto;
        padding: 1.5rem 1rem;
        gap: 1rem;
    }

    .island:nth-child(n) {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    .continent-lines { display: none; }

    .continent-hero h1 { font-size: 1.75rem; }
    .continent-stats { gap: 1.25rem; }
}

@media (max-width: 480px) {
    .continent-map { grid-template-columns: 1fr; }
}
/* ═══════════════════════════════════════════════════════
   جدول تناوبی تعاملی (نسخه نهایی)
   ═══════════════════════════════════════════════════════ */

.pt-hero {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
    max-width: 720px;
    margin: 0 auto;
}

.pt-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: .35rem .85rem;
    border-radius: 100px;
    margin-bottom: 1rem;
}

.pt-hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 .75rem;
}

.pt-hero h1 .accent { color: var(--primary); }

.pt-lead {
    font-size: .95rem;
    color: var(--text-soft);
    line-height: 1.85;
    margin: 0;
}

/* ═══ راهنما ═══ */

.pt-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    padding: 0 1rem 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
}

.pt-legend-item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-soft);
    cursor: pointer;
    transition: all .15s;
}

.pt-legend-item:hover {
    border-color: var(--primary);
    color: var(--text);
}

.pt-legend-item.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-text);
    font-weight: 600;
}

.pt-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ═══ اسکرول افقی ═══ */

.pt-scroll {
    overflow-x: auto;
    padding: 0 .75rem 2rem;
    -webkit-overflow-scrolling: touch;
    direction: ltr;
}

/* ═══ جدول ═══ */

.pt-table {
    display: grid;
    grid-template-columns: 44px repeat(18, minmax(56px, 1fr)) 44px;
    grid-template-rows: 24px repeat(10, minmax(64px, 1fr));
    gap: 4px;
    max-width: 1200px;
    margin: 0 auto;
    min-width: 1050px;
    direction: ltr;
}

.pt-group-num {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
}

/* ═══ کارت عنصر — فقط ساختار، بدون رنگ ═══ */

.pt-el {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 2px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: transform .15s, box-shadow .15s;
    overflow: hidden;
    line-height: 1.15;
    text-align: center;
    direction: ltr;
    /* background رو اینجا نذار — از کلاس رنگ میاد */
}

.pt-el:hover {
    transform: translateY(-2px) scale(1.05);
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0,0,0,.18);
}

.pt-el.selected {
    outline: 3px solid var(--primary);
    outline-offset: 1px;
    z-index: 11;
    transform: translateY(-2px) scale(1.08);
}

.pt-el.dimmed {
    opacity: .15;
    pointer-events: none;
}

/* ═══ رنگ ها بر اساس دسته — با !important تا override نشن ═══ */

.pt-el.pt-cat-alkali     { background: rgba(244, 114, 182, .18) !important; border-color: rgba(244, 114, 182, .6) !important; }
.pt-el.pt-cat-alkaline   { background: rgba(251, 146, 60, .18)  !important; border-color: rgba(251, 146, 60, .6)  !important; }
.pt-el.pt-cat-transition { background: rgba(251, 191, 36, .18)  !important; border-color: rgba(251, 191, 36, .55) !important; }
.pt-el.pt-cat-post       { background: rgba(132, 204, 22, .18)  !important; border-color: rgba(132, 204, 22, .55) !important; }
.pt-el.pt-cat-metalloid  { background: rgba(16, 185, 129, .18)  !important; border-color: rgba(16, 185, 129, .55) !important; }
.pt-el.pt-cat-nonmetal   { background: rgba(34, 211, 238, .18)  !important; border-color: rgba(34, 211, 238, .55) !important; }
.pt-el.pt-cat-halogen    { background: rgba(59, 130, 246, .18)  !important; border-color: rgba(59, 130, 246, .55) !important; }
.pt-el.pt-cat-noble      { background: rgba(167, 139, 250, .18) !important; border-color: rgba(167, 139, 250, .55) !important; }
.pt-el.pt-cat-lanthanide { background: rgba(232, 121, 249, .18) !important; border-color: rgba(232, 121, 249, .55) !important; }
.pt-el.pt-cat-actinide   { background: rgba(244, 63, 94, .18)   !important; border-color: rgba(244, 63, 94, .55)   !important; }

/* ═══ محتوای کارت ═══ */

.pt-z {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 8.5px;
    color: var(--text-muted);
    font-weight: 600;
    font-family: ui-monospace, monospace;
}

.pt-sym {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1;
    margin-top: 4px;
}

.pt-name {
    font-size: 8.5px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
    direction: rtl;
    font-family: Vazirmatn, sans-serif;
}

.pt-mass {
    font-size: 7.5px;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
    line-height: 1;
}

/* ═══ placeholder لانتانید/اکتینید ═══ */

.pt-ph {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1.5px dashed var(--border-strong);
    border-radius: 7px;
    font-size: 9px;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
    line-height: 1.3;
    text-align: center;
    padding: 4px;
    direction: ltr;
}

.pt-ph small {
    font-family: Vazirmatn, sans-serif;
    font-size: 8.5px;
    direction: rtl;
}

/* ═══ پنل جزئیات ═══ */

.pt-panel {
    position: fixed;
    top: 50%;
    inset-inline-end: 24px;
    transform: translateY(-50%) translateX(120%);
    width: 300px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
    z-index: 150;
    padding: 1.5rem 1.25rem 1.25rem;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1), opacity .2s;
    opacity: 0;
    pointer-events: none;
}

.pt-panel.open {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.pt-panel-close {
    position: absolute;
    top: .6rem;
    inset-inline-end: .6rem;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border: 0;
    border-radius: 50%;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 13px;
}

.pt-panel-close:hover {
    background: var(--bg-muted);
    color: var(--text);
}

.pt-panel-sym {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--primary);
    margin-bottom: .35rem;
    font-family: ui-monospace, monospace;
}

.pt-panel-name {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.pt-panel-cat {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.pt-panel-grid {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.pt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem .6rem;
    background: var(--surface-2);
    border-radius: 8px;
    font-size: 13px;
}

.pt-row span { color: var(--text-muted); font-size: 12px; }
.pt-row b    { font-weight: 700; color: var(--text); }

/* ═══ آرایش الکترونی ═══ */

.pt-config-wrap {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pt-config-label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: .4rem;
}

.pt-config {
    background: var(--surface-2);
    padding: .65rem .8rem;
    border-radius: 8px;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 13px;
    color: var(--primary-text);
    font-weight: 600;
    letter-spacing: .02em;
    direction: ltr;
    text-align: left;
    line-height: 1.6;
}

/* ═══ موبایل ═══ */

@media (max-width: 900px) {
    .pt-hero h1 { font-size: 1.65rem; }
    .pt-legend-item { font-size: 11.5px; padding: .35rem .7rem; }
    .pt-table {
        grid-template-columns: 32px repeat(18, minmax(48px, 1fr)) 32px;
        grid-template-rows: 22px repeat(10, minmax(56px, 1fr));
        gap: 3px;
    }
    .pt-sym { font-size: 14px; }
    .pt-name { display: none; }
    .pt-mass { font-size: 7px; }
    .pt-panel {
        top: auto;
        bottom: 0;
        inset-inline: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        padding: 1.25rem 1.25rem 1.5rem;
    }
    .pt-panel.open { transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   پنل جدول تناوبی — Backdrop و پس زمینهٔ توپر
   ═══════════════════════════════════════════════ */

/* backdrop (لایهٔ تاریک پشت پنل) */
.pt-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

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

/* پنل — پس زمینه کاملاً توپر (نه شفاف) */
.pt-panel {
    background: var(--surface) !important;
    isolation: isolate;
}

/* تو حالت تاریک، واضح‌تر */
[data-theme="dark"] .pt-panel {
    background: #14151a !important;
    border-color: #2a2d35;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
/* ═══════════════════════════════════════════════
   پنل جدول تناوبی — Backdrop و پس زمینهٔ توپر
   ═══════════════════════════════════════════════ */

/* backdrop — بدون backdrop-filter */
.pt-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

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

/* پنل — پس زمینه کاملاً توپر */
.pt-panel {
    background: #ffffff !important;
    opacity: 1;
}

.pt-panel.open {
    opacity: 1;
}

[data-theme="dark"] .pt-panel {
    background: #14151a !important;
}

/* در موبایل هم پس زمینهٔ توپر */
@media (max-width: 900px) {
    .pt-panel {
        background: #ffffff !important;
    }
    [data-theme="dark"] .pt-panel {
        background: #14151a !important;
    }
}
/* ═══════════════════════════════════════════════
   پنل جدول تناوبی — فیکس نهایی
   ═══════════════════════════════════════════════ */

.pt-panel {
    position: fixed;
    top: 50%;
    right: 24px;             /* ← چپ-راست صریح */
    left: auto;
    transform: translateY(-50%) translateX(120%);
    width: 300px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
    z-index: 150;
    padding: 1.5rem 1.25rem 1.25rem;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1), opacity .2s;
    opacity: 0;
    pointer-events: none;
}

.pt-panel.open {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: auto;
}

[data-theme="dark"] .pt-panel {
    background: #14151a;
    border-color: #2a2d35;
}

/* backdrop — بدون backdrop-filter */
.pt-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

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

/* ─── موبایل: پنل از پایین ─── */
@media (max-width: 900px) {
    .pt-panel {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        padding: 1.25rem 1.25rem 1.5rem;
    }
    .pt-panel.open {
        transform: translateY(0);
    }
    [data-theme="dark"] .pt-panel {
        background: #14151a;
    }
}
/* ═══════════════════════════════════════════════
   فیکس سایدبار موبایل
   ═══════════════════════════════════════════════ */

@media (max-width: 1000px) {
    /* جلوگیری از کشیده شدن عرض صفحه */
    html, body {
        overflow-x: hidden !important;
        width: 100%;
        max-width: 100vw;
    }

    /* لایه بندی اصلی */
    .layout {
        display: block;
        overflow-x: hidden;
    }

    /* سایدبار — همیشه fixed */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        left: auto !important;
        width: 300px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1000 !important;
        transform: translateX(100%) !important;
        transition: transform .25s ease !important;
        box-shadow: -8px 0 40px rgba(0,0,0,.2) !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        display: flex !important;
        flex-direction: column;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* متناسب: در RTL، off-screen به راست = translateX(100%) */

    /* Overlay */
    .overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, .55) !important;
        z-index: 900 !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }

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

    /* محتوای اصلی */
    .main {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* محتوا داخل صفحه */
    .content {
        max-width: 100% !important;
        padding-inline: 1rem !important;
    }
}