/* ============================================================
   زوریکس — برنامه آزاد | استایل سراسری
   هویت: آبی فیسبوکی #3b5998 (حفظ‌شده) با سیستم طراحی مدرن
   - توکن‌های CSS + پوسته روشن/تاریک
   - کامپوننت‌های کارت، جستجوی هوشمند، واکنش‌ها، فهرست مطالب
   ============================================================ */

:root {
    --brand: #3b5998;
    --brand-strong: #29487d;
    --brand-deep: #1e3a66;
    --brand-soft: #e8edf7;
    --brand-glow: rgba(59, 89, 152, 0.16);
    --accent: #4267b2;

    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --text: #1e2a44;
    --muted: #5d6b84;
    --line: #dfe5ee;

    --ok: #1f9d55;
    --ok-soft: #e3f5ea;
    --warn: #b7791f;
    --warn-soft: #fdf3dc;
    --danger: #d64545;
    --danger-soft: #fdeaea;
    --info: #2b6cb0;
    --info-soft: #e5f0fb;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(18, 32, 60, 0.06), 0 1px 6px rgba(18, 32, 60, 0.05);
    --shadow-md: 0 6px 20px rgba(18, 32, 60, 0.09);
    --shadow-lg: 0 16px 40px rgba(18, 32, 60, 0.14);
    --header-h: 66px;

    color-scheme: light;
}

html[data-theme="dark"] {
    --brand: #7d9bd9;
    --brand-strong: #5f7fbe;
    --brand-deep: #16203a;
    --brand-soft: #212d4d;
    --brand-glow: rgba(125, 155, 217, 0.18);
    --accent: #8db2ef;

    --bg: #0e1421;
    --surface: #161f31;
    --surface-2: #1b2540;
    --text: #e4e9f4;
    --muted: #97a3bd;
    --line: #27324c;

    --ok: #48bb78;
    --ok-soft: #16311f;
    --warn: #ecc94b;
    --warn-soft: #332a12;
    --danger: #fc8181;
    --danger-soft: #3d1a1a;
    --info: #63b3ed;
    --info-soft: #14283d;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);

    color-scheme: dark;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Vazirmatn, Tahoma, Arial, sans-serif;
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text);
    background-color: var(--bg);
    transition: background-color 0.25s ease, color 0.25s ease;
    position: relative;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 18px;
}

::selection {
    background: var(--brand);
    color: #fff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -48px;
    right: 12px;
    z-index: 200;
    background: var(--brand);
    color: #fff;
    padding: 8px 16px;
    border-radius: 0 0 10px 10px;
    text-decoration: none;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
}

/* ------------------------------------------------------------
   هدر
   ------------------------------------------------------------ */
.reading-progress {
    position: fixed;
    top: 0;
    right: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    z-index: 300;
    transition: width 0.08s linear;
    border-radius: 0 0 0 3px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid rgba(0, 0, 0, 0.14);
}

html[data-theme="dark"] .site-header {
    background: linear-gradient(180deg, #22304f 0%, #1a2540 100%);
    border-bottom-color: rgba(255, 255, 255, 0.07);
}

.header-inner {
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.14);
    padding: 3px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-text strong {
    font-size: 19px;
    font-weight: 800;
}

.brand-text small {
    font-size: 11px;
    opacity: 0.82;
    font-weight: 500;
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 4px;
}

.main-nav a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 13px;
    border-radius: 9px;
    transition: background 0.18s ease, color 0.18s ease;
    white-space: nowrap;
}

.main-nav a:hover,
.main-nav a:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    text-decoration: none;
}

.main-nav a.is-active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.18s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ------------------------------------------------------------
   چیدمان اصلی
   ------------------------------------------------------------ */
main {
    padding: 24px 0 40px;
    min-height: calc(100vh - 220px);
}

.section {
    background: var(--surface);
    padding: 24px;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.section h2,
.section-head h2 {
    font-size: 20px;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: 9px;
}

.section h2::after,
.section-head h2::after {
    content: "";
    display: none;
}

.section-head .section-link {
    font-size: 12.5px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    background: var(--brand-soft);
    padding: 6px 12px;
    border-radius: 999px;
    transition: background 0.18s ease;
}

.section-head .section-link:hover {
    background: var(--brand-glow);
}

/* ------------------------------------------------------------
   هیرو
   ------------------------------------------------------------ */
.hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand) 55%, #4c74b8 100%);
    color: #fff;
    padding: 44px 34px;
    margin-bottom: 22px;
    border-radius: 22px;
    box-shadow: var(--shadow-md);
}

html[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #131c33 0%, #22304f 60%, #2c4070 100%);
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
}

.hero::before {
    width: 300px;
    height: 300px;
    top: -140px;
    left: -80px;
}

.hero::after {
    width: 220px;
    height: 220px;
    bottom: -110px;
    right: -60px;
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero h2 {
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 800;
    margin-bottom: 10px;
}

.hero p {
    font-size: 15.5px;
    color: rgba(255, 255, 255, 0.88);
    max-width: 640px;
    margin-bottom: 18px;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-chip {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 10px 18px;
    min-width: 104px;
    text-align: center;
}

.stat-chip b {
    display: block;
    font-size: 21px;
    font-weight: 800;
}

.stat-chip span {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.78);
}

/* ------------------------------------------------------------
   کارت‌ها
   ------------------------------------------------------------ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0 0 14px;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand);
}

.card-media {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-2);
    position: relative;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.card:hover .card-media img {
    transform: scale(1.05);
}

.card-media .card-media-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 40px;
    opacity: 0.35;
}

.card-inner {
    padding: 13px 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card .category,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: var(--brand-soft);
    color: var(--brand);
}

html[data-theme="dark"] .card .category,
html[data-theme="dark"] .chip {
    color: var(--accent);
}

.chip.tone-article { background: var(--info-soft); color: var(--info); }
.chip.tone-video { background: #fdeaf3; color: #c0307c; }
.chip.tone-course { background: #fdf3dc; color: #9c6b1b; }
html[data-theme="dark"] .chip.tone-video { background: #3a1a2c; color: #f191c2; }
html[data-theme="dark"] .chip.tone-course { background: #34290f; color: #e8c069; }

.card h3 {
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
}

.card h3 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.card h3 a:hover {
    color: var(--brand);
}

.card p {
    color: var(--muted);
    font-size: 13px;
    flex: 1;
}

.card .meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    color: var(--muted);
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
}

.meta-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ------------------------------------------------------------
   دکمه‌ها و نشان‌ها
   ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--brand);
    color: #fff;
    padding: 9px 18px;
    text-decoration: none;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.5;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
    background: var(--brand-strong);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    color: #fff;
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--brand-soft);
    color: var(--brand);
}

html[data-theme="dark"] .btn-secondary {
    color: var(--accent);
}

.btn-secondary:hover {
    background: var(--brand-glow);
    color: inherit;
}

.btn-danger {
    background: var(--danger);
}
.btn-danger:hover {
    background: #b83838;
}

.btn-success {
    background: var(--ok);
}
.btn-success:hover {
    background: #17804a;
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}
.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 9px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
}

.ai-badge {
    background: linear-gradient(120deg, #6d5df1, #9b5df1);
    color: #fff;
    border: 0;
}

.status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-published { background: var(--ok-soft); color: var(--ok); }
.status-draft { background: var(--surface-2); color: var(--muted); }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-approved { background: var(--ok-soft); color: var(--ok); }
.status-rejected { background: var(--danger-soft); color: var(--danger); }

mark {
    background: #ffe98a;
    color: #5c4400;
    border-radius: 4px;
    padding: 0 3px;
}

html[data-theme="dark"] mark {
    background: #7a6410;
    color: #ffe98a;
}

/* ------------------------------------------------------------
   جستجو
   ------------------------------------------------------------ */
.search-wrap {
    position: relative;
}

.search-form,
.global-search-form {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.global-search-form {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-glow);
}

.search-form input[type="search"],
.global-search-form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 46px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.search-form input[type="search"]:focus,
.global-search-form input[type="search"]:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--brand-glow);
}

.search-form .btn,
.global-search-form .btn {
    min-height: 46px;
    padding: 10px 22px;
    white-space: nowrap;
}

.search-suggest {
    position: absolute;
    top: calc(100% - 6px);
    right: 12px;
    left: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 60;
    display: none;
}

.search-suggest.is-open {
    display: block;
}

.search-suggest a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    border-bottom: 1px solid var(--line);
}

.search-suggest a:last-child {
    border-bottom: 0;
}

.search-suggest a:hover,
.search-suggest a:focus {
    background: var(--brand-soft);
}

.search-suggest .sug-type {
    font-size: 10.5px;
    color: var(--muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.search-results {
    margin: 12px 0 16px;
    color: var(--muted);
}

.trending-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.trending-chips .trending-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

.trending-chips a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.trending-chips a:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    transform: translateY(-1px);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-chips a {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 700;
    background: var(--surface);
    transition: all 0.15s ease;
}

.filter-chips a:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.filter-chips a.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.empty-state {
    padding: 26px 18px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
}

/* ------------------------------------------------------------
   صفحه مقاله/محتوا
   ------------------------------------------------------------ */
.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 20px;
    align-items: start;
}

.article-layout.has-toc .content {
    margin-bottom: 0;
}

.content {
    background: var(--surface);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.content h1 {
    font-size: clamp(23px, 3.4vw, 30px);
    margin-bottom: 12px;
    color: var(--text);
    line-height: 1.45;
}

.content .meta,
.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12.5px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.meta-row .dot {
    opacity: 0.5;
}

.content .thumbnail {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
}

.content .body {
    line-height: 1.9;
    font-size: 15px;
    color: var(--text);
}

.content .body h2,
.content .body h3 {
    color: var(--brand);
    margin: 26px 0 12px;
    scroll-margin-top: calc(var(--header-h) + 16px);
}

.content .body h2 {
    font-size: 22px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand-soft);
}

.content .body h3 {
    font-size: 18px;
}

.content .body p {
    margin-bottom: 14px;
}

.content .body ul,
.content .body ol {
    margin: 14px 0;
    padding-inline-start: 26px;
}

.content .body li {
    margin-bottom: 7px;
}

.content .body li::marker {
    color: var(--brand);
}

.content .body code {
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}

.content .body pre {
    position: relative;
    background: #101827;
    color: #dbe4f3;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid #1f2b45;
}

.content .body pre code {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    font-size: 13px;
    line-height: 1.8;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #cdd9ec;
    border: 0;
    border-radius: 8px;
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.content .body blockquote {
    border-inline-start: 4px solid var(--brand);
    background: var(--brand-soft);
    border-radius: 0 10px 10px 0;
    padding: 12px 16px;
    margin: 16px 0;
    color: var(--muted);
    font-style: italic;
}

html[data-theme="dark"] .content .body blockquote {
    border-radius: 10px 0 0 10px;
}

.content .body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 26px 0;
}

.content .body img {
    max-width: 100%;
    height: auto;
    margin: 15px 0;
    border-radius: var(--radius-sm);
}

.content .body a {
    color: var(--accent);
}

/* فهرست مطالب */
.toc {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
}

.toc h3 {
    font-size: 14px;
    color: var(--brand);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.toc ol {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    border-inline-start: 3px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.6;
}

.toc a:hover {
    color: var(--brand);
    background: var(--brand-soft);
}

.toc a.is-active {
    color: var(--brand);
    background: var(--brand-soft);
    border-inline-start-color: var(--brand);
    font-weight: 700;
}

.toc .toc-empty {
    color: var(--muted);
    font-size: 12px;
}

/* واکنش‌ها */
.reactions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.reactions-bar .reactions-title {
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
    margin-inline-end: 4px;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.16s ease;
}

.reaction-btn .emoji {
    font-size: 16px;
    transition: transform 0.2s ease;
}

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

.reaction-btn:hover .emoji {
    transform: scale(1.2);
}

.reaction-btn.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.reaction-btn .count {
    background: rgba(125, 125, 125, 0.14);
    border-radius: 999px;
    padding: 0 8px;
    font-size: 11.5px;
    min-width: 18px;
    text-align: center;
}

.reaction-btn.is-active .count {
    background: rgba(255, 255, 255, 0.22);
}

/* ------------------------------------------------------------
   نظرات
   ------------------------------------------------------------ */
.comments-section {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.comments-section > h2 {
    font-size: 18px;
    color: var(--brand);
    margin-bottom: 16px;
}

.comment-form {
    background: var(--surface-2);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.comment-form h3 {
    margin-bottom: 14px;
    color: var(--brand);
    font-size: 16px;
}

.comment-form button[type="submit"] {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--brand);
    color: #fff;
    padding: 10px 22px;
    border: 0;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s ease;
}

.comment-form button[type="submit"]:hover {
    background: var(--brand-strong);
}

.comments-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    transition: border-color 0.15s ease;
}

.comment:hover {
    border-color: var(--brand-glow);
}

.comment-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    background: var(--brand);
}

.comment-main {
    min-width: 0;
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.comment-header strong {
    color: var(--text);
    font-size: 13.5px;
}

.sentiment-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.sentiment-tag.positive { background: var(--ok-soft); color: var(--ok); }
.sentiment-tag.negative { background: var(--danger-soft); color: var(--danger); }
.sentiment-tag.neutral { background: var(--surface-2); color: var(--muted); }

.comment-date {
    color: var(--muted);
    font-size: 11px;
}

.comment-body {
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.no-comments {
    text-align: center;
    color: var(--muted);
    padding: 22px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--line);
}

/* ------------------------------------------------------------
   صفحه‌بندی
   ------------------------------------------------------------ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    transition: all 0.15s ease;
}

.pagination a:hover {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.pagination .current {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* ------------------------------------------------------------
   هشدارها و فرم‌ها
   ------------------------------------------------------------ */
.alert {
    padding: 14px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.alert-info {
    background: var(--info-soft);
    color: var(--info);
    border-color: color-mix(in srgb, var(--info) 25%, transparent);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--text);
    font-size: 13px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.form-group textarea {
    resize: vertical;
}

.form-hint {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 4px;
}

/* ------------------------------------------------------------
   جدول (عمومی)
   ------------------------------------------------------------ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

table th,
table td {
    padding: 11px 12px;
    text-align: right;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table thead th {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 800;
    font-size: 12.5px;
    border-bottom: 2px solid var(--brand);
}

html[data-theme="dark"] table thead th {
    color: var(--accent);
}

table tbody tr {
    background: var(--surface);
    transition: background 0.12s ease;
}

table tbody tr:nth-child(even) {
    background: var(--surface-2);
}

table tbody tr:hover {
    background: var(--brand-glow);
}

/* ------------------------------------------------------------
   فوتر
   ------------------------------------------------------------ */
.site-footer {
    background: linear-gradient(180deg, var(--brand-strong), var(--brand-deep));
    color: rgba(255, 255, 255, 0.88);
    padding: 36px 0 0;
    margin-top: 40px;
}

html[data-theme="dark"] .site-footer {
    background: linear-gradient(180deg, #17223c, #101828);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 30px;
    padding-bottom: 28px;
}

.footer-col h3 {
    color: #fff;
    font-size: 15px;
    margin-bottom: 12px;
}

.footer-col p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.72);
}

.footer-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-col a {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s ease;
}

.footer-col a:hover {
    color: #fff;
    text-decoration: underline;
}

.footer-bottom {
    text-align: center;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.65);
}

/* ------------------------------------------------------------
   ارتباط با ما (صفحه اصلی)
   ------------------------------------------------------------ */
.contact-section p {
    margin-bottom: 12px;
    color: var(--muted);
}

.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.16s ease;
}

.contact-link:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    transform: translateY(-1px);
}

.contact-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    font-size: 15px;
}

.telegram-logo { background: #229ed9; }
.email-logo { background: var(--brand); }

.contact-config-note {
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

.section-actions {
    text-align: center;
    margin-top: 22px;
}

.content-type-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* ------------------------------------------------------------
   دکمه بازگشت به بالا
   ------------------------------------------------------------ */
.back-to-top {
    position: fixed;
    bottom: 22px;
    left: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: var(--brand);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.22s ease;
    z-index: 90;
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--brand-strong);
}

/* ------------------------------------------------------------
   منابع (resources.php) — حفظ کلاس‌های موجود با ظاهر جدید
   ------------------------------------------------------------ */
.resources-page { max-width: 940px; margin: 0 auto; }
.resources-heading { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:28px 30px; border-radius:22px; background:linear-gradient(135deg, var(--brand-deep), var(--brand)); color:#fff; margin-bottom:18px; box-shadow: var(--shadow-md); }
.resources-heading h2 { color:#fff; font-size:clamp(25px,4vw,34px); margin:5px 0 8px; }
.resources-heading p { color:rgba(255,255,255,.85); margin:0; }
.resources-kicker { font-size:11px; letter-spacing:1.5px; color:#a9c9f4; font-weight:700; direction:ltr; display:inline-block; }
.resources-mark { width:66px; height:66px; flex-shrink:0; border:1px solid rgba(255,255,255,.32); background:rgba(255,255,255,.08); border-radius:20px; display:grid; place-items:center; font-size:36px; }
.resources-notice { display:flex; align-items:center; gap:13px; background:var(--ok-soft); border:1px solid color-mix(in srgb, var(--ok) 25%, transparent); color:var(--ok); padding:16px 18px; border-radius:14px; margin-bottom:22px; }
.resources-notice p { margin:0; }
.resources-notice-icon { display:grid; place-items:center; flex-shrink:0; width:38px; height:38px; border-radius:11px; background:color-mix(in srgb, var(--ok) 18%, transparent); font-size:24px; }
.resources-toolbar { display:flex; gap:10px; margin-bottom:16px; }
.resources-search { flex:1; min-width:0; display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:0 13px; color:var(--muted); }
.resources-search span { font-size:25px; }
.resources-search input { width:100%; min-width:0; border:0; outline:0; padding:13px 0; font:inherit; background:transparent; color:var(--text); }
.resources-search:focus-within { border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-glow); }
.resources-breadcrumb { display:flex; flex-wrap:wrap; align-items:center; gap:7px; padding:11px 14px; background:var(--surface-2); border-radius:11px; margin-bottom:12px; color:var(--muted); }
.resources-breadcrumb button { border:0; background:transparent; color:var(--accent); font:inherit; font-weight:600; cursor:pointer; }
.resources-status { padding:23px 15px; text-align:center; color:var(--muted); background:var(--surface-2); border:1px dashed var(--line); border-radius:14px; margin-bottom:12px; }
.resources-list { display:flex; flex-direction:column; gap:9px; }
.resource-item { display:flex; align-items:center; gap:13px; padding:13px 15px; background:var(--surface); border:1px solid var(--line); border-radius:14px; transition:border-color .15s, transform .15s, box-shadow .15s; }
.resource-item:hover { border-color:var(--brand); transform:translateY(-1px); box-shadow:var(--shadow-sm); }
.resource-file-icon { width:44px; height:44px; flex-shrink:0; border-radius:11px; background:var(--brand-soft); color:var(--brand); display:grid; place-items:center; font-size:22px; }
.resource-file-icon.is-folder { background:var(--warn-soft); }
.resource-file-info { display:flex; flex:1; min-width:0; flex-direction:column; gap:3px; }
.resource-file-info strong { overflow-wrap:anywhere; color:var(--text); }
.resource-file-info span { color:var(--muted); font-size:12px; }
.resource-actions { display:flex; align-items:center; gap:7px; flex-shrink:0; }
.resources-page .btn { display:inline-flex; align-items:center; justify-content:center; text-decoration:none; border:0; cursor:pointer; font:inherit; font-size:12px; padding:8px 12px; border-radius:9px; white-space:nowrap; }
.resources-page .btn-primary { color:#fff; background:var(--brand); }
.resources-page .btn-primary:hover { background:var(--brand-strong); }
.resources-page .btn-secondary { color:var(--brand); background:var(--brand-soft); }
html[data-theme="dark"] .resources-page .btn-secondary { color:var(--accent); }
.resources-footer-note { margin-top:18px; color:var(--muted); font-size:12px; line-height:1.9; }
.resources-footer-note code { direction:ltr; display:inline-block; background:var(--surface-2); padding:1px 5px; border-radius:4px; }

/* ------------------------------------------------------------
   پوسته ادمین — نمایش راحت‌تر روی استایل جدید
   ------------------------------------------------------------ */
body.admin {
    user-select: none;
    background: var(--bg);
}

body.admin input,
body.admin textarea,
body.admin [contenteditable] {
    user-select: text;
}

/* ------------------------------------------------------------
   وضعیت‌ها
   ------------------------------------------------------------ */
a:focus, button:focus, input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

button:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.input-error { border-color: var(--danger) !important; }
.input-success { border-color: var(--ok) !important; }

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    background: #000;
}

.video-container video,
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-responsive { position:relative; width:100%; padding-top:56.25%; margin:12px 0 24px; background:#111; border-radius:12px; overflow:hidden; }
.video-responsive iframe { position:absolute; inset:0; width:100%; height:100%; border:0; }
.course-lessons ol { padding-inline-start:24px; }
.course-lessons li { margin:16px 0; }

/* ------------------------------------------------------------
   واکنش‌گرایی
   ------------------------------------------------------------ */
@media (max-width: 900px) {
    .article-layout {
        grid-template-columns: 1fr;
    }
    .toc {
        position: static;
        order: -1;
        margin-bottom: 4px;
    }
}

@media (max-width: 820px) {
    .nav-toggle {
        display: flex;
    }

    .main-nav {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: var(--brand-strong);
        box-shadow: var(--shadow-lg);
        border-radius: 0 0 18px 18px;
        padding: 10px 14px 14px;
        display: none;
    }

    html[data-theme="dark"] .main-nav {
        background: #1c2846;
    }

    .main-nav.is-open {
        display: block;
        animation: navDrop 0.22s ease;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 2px;
    }

    .main-nav a {
        display: block;
        padding: 11px 14px;
        font-size: 14.5px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }
}

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

@media (max-width: 700px) {
    .hero {
        padding: 30px 22px;
    }
    .section {
        padding: 18px 16px;
    }
    .content {
        padding: 22px 18px;
    }
    .grid {
        grid-template-columns: 1fr;
    }
    .brand-text small {
        display: none;
    }
    .table-wrapper {
        overflow-x: auto;
    }
    table {
        font-size: 12.5px;
    }
    table th, table td {
        padding: 8px 6px;
    }
}

@media (max-width: 600px) {
    .search-form,
    .global-search-form {
        flex-direction: column;
        padding: 10px;
    }
    .search-form input[type="search"],
    .global-search-form input[type="search"],
    .search-form .btn,
    .global-search-form .btn {
        width: 100%;
    }
    .resources-heading { padding: 22px 18px; }
    .resources-mark { width:48px; height:48px; font-size:27px; }
    .resources-toolbar { align-items: stretch; }
    .resource-item { flex-wrap: wrap; gap:10px; }
    .resource-file-info { flex-basis: calc(100% - 60px); }
    .resource-actions { width:100%; padding-inline-start:54px; }
    .resources-page .btn { flex:1; }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* صفحه جستجوی هوشمند */
.search-page .trending-chips a { white-space: nowrap; }

/* معرفی و جلسات دوره */
.course-intro { margin: 24px 0; }
.course-intro h2,
.course-lessons h2 { font-size: 19px; margin-bottom: 12px; }
