/* ═══════════════════════════════════════════════════════════════════════
   LAWVAULT – PROFESSIONAL LAW BANK UI (v4.0)
   ✅ Dark/Light Mode: body.dark-mode (هماهنگ با کل سایت)
   ✅ RTL / فارسی بهینه‌شده
   ✅ انیمیشن‌های کامل + میکرو اینتراکشن
   ✅ فاصله‌گذاری اصولی (8px grid)
   ✅ رنگبندی حرفه‌ای + Accessibility
   ✅ ریسپانسیو کامل (320px → 1920px)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   §1.  DESIGN TOKENS  –  LIGHT MODE (پیش‌فرض)
───────────────────────────────────────────────────────────── */
:root {
  /* ── پس‌زمینه ── */
  --bg-page:      #f5f7fa;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f0f4f8;
  --bg-sunken:    #e8ecf2;
  --bg-glass:     rgba(255, 255, 255, 0.75);
  --bg-glass-sm:  rgba(255, 255, 255, 0.5);
  --bg-overlay:   rgba(15, 23, 42, 0.55);
  --bg-gradient:  linear-gradient(145deg, #fef9f0 0%, #eef2ff 50%, #f0f9ff 100%);

  /* ── Accent: طلایی (برند) ── */
  --gold-50:      #fffbeb;
  --gold-100:     #fef3c7;
  --gold-200:     #fde68a;
  --gold-300:     #fcd34d;
  --gold-400:     #fbbf24;
  --gold-500:     #f59e0b;
  --gold-600:     #d97706;
  --gold-700:     #b45309;
  --gold-glow:    rgba(245, 176, 66, 0.30);
  --gold-glow-sm: rgba(245, 176, 66, 0.15);
  --gold-dim:     rgba(245, 176, 66, 0.08);
  --gold-border:  rgba(245, 176, 66, 0.35);

  /* ── متن ── */
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-tertiary:  #64748b;
  --text-muted:     #94a3b8;
  --text-disabled:  #cbd5e1;
  --text-inverse:   #f8fafc;
  --text-link:      #d97706;

  /* ── حاشیه / کارت ── */
  --border-light:   rgba(0,0,0,0.06);
  --border-medium:  rgba(0,0,0,0.10);
  --border-strong:  rgba(0,0,0,0.16);
  --card-bg:        rgba(255,255,255,0.85);
  --card-border:    rgba(0,0,0,0.07);
  --card-shadow:    0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.06);

  /* ── وضعیت ── */
  --c-success:  #10b981;
  --c-info:     #3b82f6;
  --c-warning:  #f59e0b;
  --c-danger:   #ef4444;
  --c-success-bg: rgba(16,185,129,.08);
  --c-info-bg:    rgba(59,130,246,.08);
  --c-warning-bg: rgba(245,158,11,.08);
  --c-danger-bg:  rgba(239,68,68,.08);

  /* ── سایه‌ها ── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 36px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
  --shadow-xl:  0 20px 56px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.06);
  --shadow-gold: 0 4px 20px rgba(245,176,66,.25);

  /* ── ابعاد Shell ── */
  --topbar-h:    56px;
  --sidebar-w:   272px;
  --sidebar-sm:  60px;
  --toc-w:       212px;
  --content-max: 820px;

  /* ── Border-radius ── */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-pill: 9999px;

  /* ── Easing ── */
  --ease-out:    cubic-bezier(.25,.46,.45,.94);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-smooth: cubic-bezier(.4,0,.2,1);
  --ease-bounce: cubic-bezier(.68,-.55,.265,1.55);

  /* ── Transition shortcuts ── */
  --t-fast: 0.15s var(--ease-smooth);
  --t-base: 0.25s var(--ease-smooth);
  --t-slow: 0.40s var(--ease-out);

  /* ── z-index layers ── */
  --z-bg:      -1;
  --z-base:     1;
  --z-topbar:  100;
  --z-sidebar: 200;
  --z-toc:     150;
  --z-panel:   300;
  --z-modal:  9000;
  --z-toast:  9100;
  --z-loader: 9999;
}


/* ─────────────────────────────────────────────────────────────
✨  SEPIA MODE (کاغذ کاهی برای مطالعه شب)
═══════════════════════════════════════════════════════════════ */
body.sepia-mode {
    --bg-page: #f4ecd8;
    --bg-surface: #f9f3e3;
    --bg-elevated: #efe5d0;
    --text-primary: #5b4636;
    --text-secondary: #6b5744;
    --text-tertiary: #8b7355;
    --border-light: rgba(91, 70, 54, 0.08);
    --border-medium: rgba(91, 70, 54, 0.15);
    --card-bg: rgba(249, 243, 227, 0.85);
    --gold-500: #b8860b;
    --gold-600: #996f0a;
}

body.sepia-mode .law-reader-section {
    background: #f4ecd8;
}

body.sepia-mode .article-content {
    color: #5b4636;
}

body.sepia-mode .reader-sidebar,
body.sepia-mode .reader-toc {
    background: #efe5d0;
    border-color: rgba(91, 70, 54, 0.12);
}

body.sepia-mode .reader-toolbar {
    background: rgba(244, 236, 216, 0.85);
    border-bottom-color: rgba(91, 70, 54, 0.12);
}

/* Paper texture overlay */
body.sepia-mode::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.03'/%3E%3C/svg%3E");
}
/* ─────────────────────────────────────────────────────────────
   §2.  DARK MODE  –  body.dark-mode  (هماهنگ با کل سایت)
───────────────────────────────────────────────────────────── */
body.dark-mode {
  /* ── پس‌زمینه ── */
  --bg-page:     #0a0c15;
  --bg-surface:  #0f1222;
  --bg-elevated: #141829;
  --bg-sunken:   #080a12;
  --bg-glass:    rgba(20, 25, 40, 0.75);
  --bg-glass-sm: rgba(15, 18, 30, 0.55);
  --bg-overlay:  rgba(0,0,0,.75);
  --bg-gradient: linear-gradient(145deg, #0f1222 0%, #141829 50%, #0a0e1a 100%);

  /* ── Accent طلایی (کمی گرم‌تر در دارک) ── */
  --gold-400:    #fbbf24;
  --gold-500:    #f59e0b;
  --gold-glow:   rgba(251,191,36,.30);
  --gold-glow-sm:rgba(251,191,36,.12);
  --gold-dim:    rgba(251,191,36,.06);
  --gold-border: rgba(251,191,36,.22);

  /* ── متن ── */
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-tertiary:  #64748b;
  --text-muted:     #475569;
  --text-disabled:  #334155;
  --text-inverse:   #0f172a;
  --text-link:      #fbbf24;

  /* ── حاشیه / کارت ── */
  --border-light:  rgba(255,255,255,.05);
  --border-medium: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.14);
  --card-bg:       rgba(20,25,42,.80);
  --card-border:   rgba(255,255,255,.07);
  --card-shadow:   0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);

  /* ── سایه‌ها ── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.40), 0 2px 8px rgba(0,0,0,.30);
  --shadow-md: 0 4px 16px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.30);
  --shadow-lg: 0 10px 36px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.35);
  --shadow-xl: 0 20px 56px rgba(0,0,0,.65), 0 4px 16px rgba(0,0,0,.40);
}

/* System dark mode auto-apply */
@media (prefers-color-scheme: dark) {
  body:not(.light-mode) {
    --bg-page:     #0a0c15;
    --bg-surface:  #0f1222;
    --bg-elevated: #141829;
    --bg-sunken:   #080a12;
    --bg-glass:    rgba(20, 25, 40, 0.75);
    --bg-glass-sm: rgba(15, 18, 30, 0.55);
    --bg-overlay:  rgba(0,0,0,.75);
    --bg-gradient: linear-gradient(145deg, #0f1222 0%, #141829 50%, #0a0e1a 100%);
    --gold-glow:   rgba(251,191,36,.30);
    --gold-glow-sm:rgba(251,191,36,.12);
    --gold-dim:    rgba(251,191,36,.06);
    --gold-border: rgba(251,191,36,.22);
    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-tertiary:  #64748b;
    --text-muted:     #475569;
    --border-light:  rgba(255,255,255,.05);
    --border-medium: rgba(255,255,255,.09);
    --card-bg:       rgba(20,25,42,.80);
    --card-border:   rgba(255,255,255,.07);
    --shadow-md: 0 4px 16px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.30);
  }
}

/* ─────────────────────────────────────────────────────────────
   §3.  RESET & BASE
───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  font-size: 16px;
}
body {
  font-family: 'Vazir', 'Inter', system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  direction: rtl;
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-slow), color var(--t-base);
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }
img, video { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ─────────────────────────────────────────────────────────────
   §4.  SCROLLBAR
───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  transition: background var(--t-fast);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold-500); }

/* ─────────────────────────────────────────────────────────────
   §5.  ANIMATED BACKGROUND
───────────────────────────────────────────────────────────── */
.animated-bg {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  background: var(--bg-gradient);
  overflow: hidden;
  transition: background var(--t-slow);
}
.bg-layer {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  animation: bgFloat 40s ease-in-out infinite alternate;
}
.layer-1 {
  width: 800px; height: 800px;
  top: -300px; right: -150px;
  background: radial-gradient(circle, rgba(245,176,66,.18) 0%, transparent 65%);
  filter: blur(90px);
  animation-duration: 45s;
}
.layer-2 {
  width: 650px; height: 650px;
  bottom: -200px; left: -100px;
  background: radial-gradient(circle, rgba(59,130,246,.12) 0%, transparent 65%);
  filter: blur(80px);
  animation-duration: 55s;
  animation-direction: alternate-reverse;
}
.layer-3 {
  width: 500px; height: 500px;
  top: 40%; left: 30%;
  background: radial-gradient(circle, rgba(99,102,241,.08) 0%, transparent 65%);
  filter: blur(70px);
  animation-duration: 65s;
}
@keyframes bgFloat {
  0%   { transform: translate(0,0) scale(1); opacity: .7; }
  33%  { transform: translate(40px,-35px) scale(1.06); opacity: 1; }
  66%  { transform: translate(-25px,30px) scale(.96); opacity: .85; }
  100% { transform: translate(20px,-20px) scale(1.03); opacity: .9; }
}

body.dark-mode .layer-1 {
  background: radial-gradient(circle, rgba(245,176,66,.14) 0%, transparent 65%);
}
body.dark-mode .layer-2 {
  background: radial-gradient(circle, rgba(59,130,246,.12) 0%, transparent 65%);
}

.grain-overlay {
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─────────────────────────────────────────────────────────────
   §6.  GLOBAL LOADER
───────────────────────────────────────────────────────────── */
#globalLoader {
  position: fixed; inset: 0;
  background: var(--bg-page);
  z-index: var(--z-loader);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s var(--ease-out), visibility .6s;
}
#globalLoader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 1.75rem;
}
.loader-seal {
  position: relative; width: 110px; height: 110px;
  animation: loaderSpin 14s linear infinite;
}
.loader-seal svg { width: 100%; height: 100%; }
@keyframes loaderSpin { to { transform: rotate(360deg); } }
.loader-seal-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  animation: loaderSpin 14s linear infinite reverse;
}
.loader-seal-center i {
  font-size: 2rem; color: var(--gold-500);
  filter: drop-shadow(0 0 10px var(--gold-glow));
}
.loader-subtitle {
  font-size: .75rem; letter-spacing: .4em;
  color: var(--gold-500); opacity: .75; text-transform: uppercase;
}
.loader-bar-wrap {
  width: 180px; height: 2px;
  background: var(--border-medium); border-radius: var(--r-pill); overflow: hidden;
}
.loader-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-300));
  border-radius: var(--r-pill);
  animation: loaderFill 2.2s var(--ease-out) forwards;
}
@keyframes loaderFill { to { width: 100%; } }

/* ─────────────────────────────────────────────────────────────
   §7.  TOP BAR  (fixed)
───────────────────────────────────────────────────────────── */
.law-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: var(--z-topbar);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: background var(--t-slow), border-color var(--t-base);
  display: flex; align-items: center;
}
/* تاکید حاشیه پایین هدر در دارک */
body.dark-mode .law-header {
  background: rgba(10,12,21,.88);
  border-bottom-color: var(--border-medium);
  box-shadow: 0 1px 0 var(--border-medium), 0 4px 16px rgba(0,0,0,.35);
}

.header-content {
  width: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr auto;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
}

/* Logo */
.header-logo {
  display: flex; align-items: center; gap: .85rem; padding-right: .5rem;
}
.header-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
  box-shadow: 0 3px 12px var(--gold-glow);
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.header-logo-icon:hover {
  transform: scale(1.08) rotate(-5deg);
  box-shadow: 0 6px 20px var(--gold-glow);
}
.header-logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.header-logo-title {
  font-size: .9rem; font-weight: 800;
  color: var(--text-primary); letter-spacing: -.01em;
}
.header-logo-sub { font-size: .68rem; color: var(--text-muted); }

.back-link {
  display: flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 600;
  color: var(--text-tertiary);
  padding: .4rem .9rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-pill);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.back-link:hover {
  color: var(--gold-600); border-color: var(--gold-500);
  background: var(--gold-dim);
  transform: translateX(-2px);
}

/* Header search */
.header-search-wrap { display: flex; align-items: center; max-width: 460px; }
.header-search-box {
  width: 100%;
  display: flex; align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  padding: 0 .85rem;
  gap: .5rem; height: 36px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.header-search-box:focus-within {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px var(--gold-glow-sm);
  background: var(--bg-surface);
}
.header-search-box input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: .855rem; padding: 0;
}
.header-search-box input::placeholder { color: var(--text-muted); }
.header-search-box .search-icon { color: var(--text-muted); font-size: .82rem; }
.header-search-kbd {
  font-size: .62rem; padding: .12rem .4rem;
  background: var(--bg-sunken); border: 1px solid var(--border-medium);
  border-radius: 4px; color: var(--text-muted); white-space: nowrap;
}

/* Header actions */
.header-actions {
  display: flex; align-items: center; gap: .5rem;
}
.topbar-stat {
  display: flex; align-items: center; gap: .4rem;
  height: 32px; padding: 0 .8rem;
  border-radius: var(--r-sm);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary); font-size: .75rem;
  transition: all var(--t-fast);
}
.topbar-stat:hover { border-color: var(--gold-500); }
.topbar-stat b { color: var(--gold-600); font-weight: 800; }
body.dark-mode .topbar-stat b { color: var(--gold-400); }

.topbar-btn {
  height: 32px; display: flex; align-items: center; gap: .4rem;
  padding: 0 .85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-sm);
  color: var(--text-secondary); font-size: .78rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
}
.topbar-btn:hover {
  border-color: var(--gold-500); color: var(--gold-600);
  background: var(--gold-dim);
  transform: translateY(-1px);
}
body.dark-mode .topbar-btn:hover { color: var(--gold-400); }
.topbar-btn i { font-size: .82rem; }

.topbar-icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-sm);
  color: var(--text-tertiary); font-size: .88rem;
  cursor: pointer; flex-shrink: 0;
  transition: all var(--t-fast);
}
.topbar-icon-btn:hover {
  border-color: var(--gold-500); color: var(--gold-600);
  background: var(--gold-dim);
  transform: translateY(-1px) scale(1.05);
}
body.dark-mode .topbar-icon-btn:hover { color: var(--gold-400); }

/* ─────────────────────────────────────────────────────────────
   §8.  APP SHELL
───────────────────────────────────────────────────────────── */
#appShell {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* ─────────────────────────────────────────────────────────────
   §9.  NAV SIDEBAR  (چپ / راست در RTL)
───────────────────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: var(--topbar-h); right: 0; bottom: 0;
  width: var(--sidebar-w);
  z-index: var(--z-sidebar);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width var(--t-slow), background var(--t-slow);
  will-change: width;
}
body.dark-mode .app-sidebar {
  background: rgba(9,11,22,.96);
  border-left-color: var(--border-medium);
  box-shadow: -2px 0 16px rgba(0,0,0,.25);
}
.app-sidebar.collapsed { width: var(--sidebar-sm); }

/* Nav header */
.sidebar-nav-header {
  padding: .9rem .85rem .6rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0; min-height: 48px;
}
.sidebar-nav-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted);
  transition: opacity var(--t-base);
  white-space: nowrap;
}
.app-sidebar.collapsed .sidebar-nav-label { opacity: 0; }

.sidebar-collapse-btn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  color: var(--text-tertiary); font-size: .78rem;
  cursor: pointer; flex-shrink: 0;
  transition: all var(--t-fast);
}
.sidebar-collapse-btn:hover {
  color: var(--gold-600); border-color: var(--gold-500);
  background: var(--gold-dim);
}
body.dark-mode .sidebar-collapse-btn:hover { color: var(--gold-400); }
.app-sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* Category list */
.sidebar-categories {
  flex: 1; overflow-y: auto;
  padding: .5rem .55rem .85rem;
}
.sidebar-section-label {
  font-size: .62rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
  padding: .65rem .6rem .3rem;
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--t-base);
}
.app-sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-cat-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .65rem;
  border-radius: var(--r-sm); cursor: pointer;
  transition: all var(--t-fast);
  position: relative; overflow: hidden;
  white-space: nowrap; margin-bottom: 2px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  width: 100%; text-align: right;
}
.sidebar-cat-item::before {
  content: ''; position: absolute;
  inset: 0; opacity: 0;
  background: var(--gold-dim);
  border-radius: var(--r-sm);
  transition: opacity var(--t-fast);
}
.sidebar-cat-item:hover { color: var(--text-primary); }
.sidebar-cat-item:hover::before { opacity: 1; }
.sidebar-cat-item.active {
  color: var(--gold-600); border-color: var(--gold-border);
  background: var(--gold-dim);
}
body.dark-mode .sidebar-cat-item.active { color: var(--gold-400); }
.sidebar-cat-item.active::after {
  content: ''; position: absolute;
  right: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--gold-500);
  border-radius: 0 3px 3px 0;
}

.sidebar-cat-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  transition: all var(--t-fast);
}
.sidebar-cat-item.active .sidebar-cat-icon,
.sidebar-cat-item:hover .sidebar-cat-icon {
  background: var(--gold-dim);
  border-color: var(--gold-border);
}
.sidebar-cat-name {
  font-size: .845rem; font-weight: 600; flex: 1;
  transition: opacity var(--t-base);
}
.app-sidebar.collapsed .sidebar-cat-name { opacity: 0; pointer-events: none; }

.sidebar-cat-count {
  font-size: .68rem; color: var(--text-muted);
  background: var(--bg-elevated);
  padding: .1rem .5rem; border-radius: var(--r-pill);
  border: 1px solid var(--border-light);
  transition: opacity var(--t-base);
}
.app-sidebar.collapsed .sidebar-cat-count { opacity: 0; }

/* Tooltip در collapsed */
.app-sidebar.collapsed .sidebar-cat-item { justify-content: center; overflow: visible; }
.app-sidebar.collapsed .sidebar-cat-item::after { display: none; }
.app-sidebar.collapsed .sidebar-cat-item[data-label]::before {
  content: attr(data-label);
  position: absolute;
  right: calc(var(--sidebar-sm) + 8px);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  padding: .4rem .85rem;
  font-size: .8rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0; transform: translateX(8px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-md); z-index: 99;
  background: var(--bg-surface);
}
.app-sidebar.collapsed .sidebar-cat-item:hover[data-label]::before {
  opacity: 1; transform: translateX(0);
}

/* Sidebar bottom */
.sidebar-bottom {
  padding: .65rem .55rem;
  border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: .3rem; flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   §10.  MAIN CONTENT
───────────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-width: 0; min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-right var(--t-slow);
}
.app-sidebar.collapsed ~ .app-main { margin-right: var(--sidebar-sm); }

/* ─────────────────────────────────────────────────────────────
   §11.  PAGE HEADER
───────────────────────────────────────────────────────────── */
.page-header {
  padding: 2.25rem 2.5rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(180deg, var(--gold-dim) 0%, transparent 100%);
  animation: fadeUp .5s var(--ease-out) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-breadcrumb {
  display: flex; align-items: center; gap: .45rem;
  font-size: .75rem; color: var(--text-muted); margin-bottom: .85rem;
}
.page-breadcrumb a { color: var(--text-muted); transition: color var(--t-fast); }
.page-breadcrumb a:hover { color: var(--text-link); }
.page-breadcrumb .sep { opacity: .4; font-size: .65rem; }

.page-title-row {
  display: flex; align-items: center; gap: 1.1rem;
}
.page-title-icon {
  width: 46px; height: 46px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; flex-shrink: 0;
  box-shadow: var(--shadow-gold);
  animation: iconPop .5s var(--ease-spring) .1s both;
}
@keyframes iconPop {
  from { opacity: 0; transform: scale(.7) rotate(-10deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
.page-title {
  font-size: 1.65rem; font-weight: 800;
  color: var(--text-primary); line-height: 1.2;
}
.page-subtitle { font-size: .875rem; color: var(--text-tertiary); margin-top: .3rem; }

/* ─────────────────────────────────────────────────────────────
   §12.  POPULAR SEARCHES
───────────────────────────────────────────────────────────── */
.popular-searches {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  padding: .9rem 2.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
  animation: fadeUp .5s var(--ease-out) .05s both;
}
.searches-label { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
.search-tag {
  font-size: .74rem; font-weight: 600;
  padding: .28rem .8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-pill);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--t-fast);
}
.search-tag:hover {
  background: var(--gold-dim);
  border-color: var(--gold-500);
  color: var(--gold-600);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xs);
}
body.dark-mode .search-tag:hover { color: var(--gold-400); }

/* ─────────────────────────────────────────────────────────────
   §13.  GRID CONTAINER & SECTION HEADER
───────────────────────────────────────────────────────────── */
.grid-container {
  padding: 1.75rem 2.5rem;
  flex: 1;
  animation: fadeUp .5s var(--ease-out) .1s both;
}

.section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.35rem;
}
.section-title {
  font-size: 1.05rem; font-weight: 800; color: var(--text-primary);
  display: flex; align-items: center; gap: .5rem;
}
.section-title i { color: var(--gold-500); font-size: .9rem; }
.section-title-count {
  font-size: .72rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: .12rem .55rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-light);
}

.btn-back {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .8rem; font-weight: 700; color: var(--text-tertiary);
  padding: .42rem .95rem;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--r-pill); cursor: pointer;
  transition: all var(--t-fast);
}
.btn-back:hover {
  color: var(--gold-600); border-color: var(--gold-500);
  background: var(--gold-dim);
  transform: translateX(-3px);
}
body.dark-mode .btn-back:hover { color: var(--gold-400); }



/* ─────────────────────────────────────────────────────────────
   §14.  CATEGORY CARDS
───────────────────────────────────────────────────────────── */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 1.45rem;
  cursor: pointer;
  transition: transform var(--t-base), box-shadow var(--t-base),
              border-color var(--t-base), background var(--t-base);
  position: relative; overflow: hidden;
  animation: cardSlide .5s var(--ease-out) both;
  display: flex; flex-direction: column;
  backdrop-filter: blur(8px);
}
@keyframes cardSlide {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* شین هاور */
.category-card::after {
  content: ''; position: absolute;
  top: 0; right: -100%; bottom: 0; width: 50%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  transition: right .5s var(--ease-out);
  pointer-events: none;
}
.category-card:hover::after { right: 150%; }
.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--gold-border), var(--shadow-gold);
  border-color: var(--gold-border);
  background: var(--bg-glass);
}

.category-header {
  display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .95rem;
}
.category-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
  border: 1px solid var(--border-light);
  background: var(--bg-elevated);
  transition: all var(--t-base);
}
.category-card:hover .category-icon {
  border-color: var(--gold-border);
  background: var(--gold-dim);
  transform: scale(1.08) rotate(-4deg);
  box-shadow: 0 4px 12px var(--gold-glow-sm);
}
.category-info h3 {
  font-size: 1rem; font-weight: 800; color: var(--text-primary); margin-bottom: .2rem;
}
.category-count {
  font-size: .73rem; color: var(--text-muted);
  display: flex; align-items: center; gap: .3rem;
}
.category-count i { color: var(--gold-500); }

.category-description {
  font-size: .82rem; color: var(--text-secondary); line-height: 1.65;
  flex: 1; margin-bottom: 1.1rem;
}
.category-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: .8rem; border-top: 1px solid var(--border-light); margin-top: auto;
}
.category-arrow {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-dim); border: 1px solid var(--gold-border);
  border-radius: var(--r-sm); color: var(--gold-600); font-size: .82rem;
  transition: all var(--t-fast);
}
body.dark-mode .category-arrow { color: var(--gold-400); }
.category-card:hover .category-arrow {
  background: var(--gold-500); color: #fff; border-color: var(--gold-500);
  transform: translateX(-4px);
}

.categories-grid .category-card:nth-child(1) { animation-delay: .04s; }
.categories-grid .category-card:nth-child(2) { animation-delay: .08s; }
.categories-grid .category-card:nth-child(3) { animation-delay: .12s; }
.categories-grid .category-card:nth-child(4) { animation-delay: .16s; }
.categories-grid .category-card:nth-child(5) { animation-delay: .20s; }
.categories-grid .category-card:nth-child(6) { animation-delay: .24s; }

/* ─────────────────────────────────────────────────────────────
   §15.  LAW CARDS
───────────────────────────────────────────────────────────── */
.laws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 1rem;
}
.law-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform var(--t-base), box-shadow var(--t-base),
              border-color var(--t-base);
  display: flex; flex-direction: column;
  animation: cardSlide .5s var(--ease-out) both;
  backdrop-filter: blur(8px);
  position: relative; overflow: hidden;
}
.law-card::before {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
  transform: scaleX(0); transform-origin: right;
  transition: transform var(--t-base);
}
.law-card:hover::before { transform: scaleX(1); }
.law-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--gold-border);
  border-color: var(--gold-border);
}

.law-card-top { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: .8rem; }
.law-number-badge {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800; color: #fff; flex-shrink: 0;
  box-shadow: 0 3px 10px var(--gold-glow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.law-card:hover .law-number-badge {
  transform: scale(1.1) rotate(3deg);
  box-shadow: 0 6px 16px var(--gold-glow);
}
.law-title { font-size: .92rem; font-weight: 800; color: var(--text-primary); line-height: 1.4; flex: 1; }
.law-description {
  font-size: .79rem; color: var(--text-secondary); line-height: 1.65; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: .8rem;
}
.law-meta-row {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding-top: .8rem; border-top: 1px solid var(--border-light); margin-top: auto;
  font-size: .71rem; color: var(--text-muted);
}
.law-meta-item { display: flex; align-items: center; gap: .28rem; }
.law-meta-item i { color: var(--gold-500); }

.laws-grid .law-card:nth-child(1) { animation-delay: .03s; }
.laws-grid .law-card:nth-child(2) { animation-delay: .06s; }
.laws-grid .law-card:nth-child(3) { animation-delay: .09s; }
.laws-grid .law-card:nth-child(4) { animation-delay: .12s; }
.laws-grid .law-card:nth-child(5) { animation-delay: .15s; }
.laws-grid .law-card:nth-child(6) { animation-delay: .18s; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 4.5rem 2rem; text-align: center;
  grid-column: 1/-1; color: var(--text-muted);
}
.empty-state i {
  font-size: 2.8rem; margin-bottom: 1.1rem; opacity: .35;
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.empty-state h3 { font-size: 1.05rem; color: var(--text-tertiary); margin-bottom: .4rem; }
.empty-state p  { font-size: .83rem; color: var(--text-muted); }

/* Search results */
.search-results {
  margin: 0 2.5rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-lg);
  max-height: 400px; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s var(--ease-out);
}
body.dark-mode .search-results { background: var(--bg-elevated); }
.search-results-header {
  padding: .65rem 1.2rem;
  border-bottom: 1px solid var(--border-light);
  font-size: .74rem; color: var(--text-muted); font-weight: 700;
}
.search-result-item {
  display: block; padding: .85rem 1.2rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background var(--t-fast);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--gold-dim); }
.result-title { font-size: .86rem; font-weight: 700; color: var(--gold-600); margin-bottom: .18rem; }
body.dark-mode .result-title { color: var(--gold-400); }
.result-breadcrumb { font-size: .7rem; color: var(--text-muted); margin-bottom: .3rem; }
.result-content  { font-size: .8rem; color: var(--text-secondary); line-height: 1.55; }

/* ─────────────────────────────────────────────────────────────
   §16.  LAW READER  –  Full-screen overlay
───────────────────────────────────────────────────────────── */
.law-reader-section {
  position: fixed; inset: 0; top: var(--topbar-h);
  z-index: 1500;
  background: var(--bg-page);
  display: none; flex-direction: row; overflow: hidden;
}
.law-reader-section.active { display: flex; }

/* ── Reader Sidebar ── */
.reader-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
  transition: width var(--t-slow);
}
body.dark-mode .reader-sidebar {
  background: rgba(9,11,22,.97);
  border-left-color: var(--border-medium);
}
.reader-sidebar.collapsed { width: var(--sidebar-sm); }

.reader-sidebar-header {
  padding: .85rem 1rem; min-height: 48px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: .6rem; flex-shrink: 0;
}
.reader-sidebar-header i { color: var(--gold-500); font-size: .88rem; }
.reader-sidebar-title {
  font-size: .8rem; font-weight: 700; color: var(--text-secondary); flex: 1;
  transition: opacity var(--t-base);
}
.reader-sidebar.collapsed .reader-sidebar-title { opacity: 0; }

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-elevated); flex-shrink: 0;
}
.sidebar-tab {
  flex: 1; padding: .62rem 0;
  background: transparent; border: none;
  color: var(--text-muted); font-size: .73rem; font-weight: 700;
  cursor: pointer; position: relative; transition: color var(--t-fast);
}
.sidebar-tab:hover { color: var(--gold-600); }
body.dark-mode .sidebar-tab:hover { color: var(--gold-400); }
.sidebar-tab.active { color: var(--gold-600); }
body.dark-mode .sidebar-tab.active { color: var(--gold-400); }
.sidebar-tab.active::after {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
}

.sidebar-tab-content { display: none; flex: 1; overflow-y: auto; }
.sidebar-tab-content.active { display: block; }

/* Chapters tree */
.chapters-tree { padding: .55rem .45rem; }
.chapter-item {
  display: block; padding: .58rem .75rem;
  border-radius: var(--r-sm); cursor: pointer;
  transition: all var(--t-fast);
  font-size: .79rem; color: var(--text-secondary);
  border: 1px solid transparent; margin-bottom: 2px;
  line-height: 1.5; position: relative;
}
.chapter-item:hover { background: var(--gold-dim); color: var(--text-primary); }
.chapter-item.active {
  background: var(--gold-dim);
  border-color: var(--gold-border);
  color: var(--gold-600); font-weight: 700;
}
body.dark-mode .chapter-item.active { color: var(--gold-400); }
.chapter-item.active::before {
  content: ''; position: absolute;
  right: 0; top: 20%; bottom: 20%;
  width: 2px; background: var(--gold-500);
  border-radius: 0 2px 2px 0;
}

/* Bookmarks & Notes lists */
.bookmarks-list, .notes-list {
  padding: .55rem .45rem; display: flex; flex-direction: column; gap: .3rem;
}
.bookmark-item, .note-item-mini {
  padding: .6rem .75rem;
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: var(--r-sm); cursor: pointer;
  transition: all var(--t-fast); font-size: .75rem;
}
.bookmark-item:hover, .note-item-mini:hover {
  background: var(--gold-dim); border-color: var(--gold-border);
  transform: translateX(-3px);
}
.bookmark-article-number { font-weight: 700; color: var(--gold-600); display: block; margin-bottom: .14rem; }
body.dark-mode .bookmark-article-number { color: var(--gold-400); }
.note-preview { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar search */
.sidebar-search {
  padding: .6rem .65rem;
  border-top: 1px solid var(--border-light);
  position: relative; flex-shrink: 0;
}
.sidebar-search i {
  position: absolute; right: 1.15rem; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); font-size: .78rem;
}
.sidebar-search input {
  width: 100%;
  padding: .48rem 2rem .48rem .65rem;
  background: var(--bg-elevated); border: 1px solid var(--border-medium);
  border-radius: var(--r-sm); color: var(--text-primary); font-size: .78rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.sidebar-search input:focus {
  outline: none; border-color: var(--gold-500);
  box-shadow: 0 0 0 3px var(--gold-glow-sm);
}
.inlaw-search-results { max-height: 190px; overflow-y: auto; padding: .3rem .45rem; }
.search-result-mini {
  padding: .5rem .7rem; border-radius: var(--r-sm); cursor: pointer;
  transition: all var(--t-fast); font-size: .75rem; color: var(--text-secondary);
}
.search-result-mini:hover { background: var(--gold-dim); color: var(--gold-600); }
body.dark-mode .search-result-mini:hover { color: var(--gold-400); }

.sidebar-footer-tip {
  padding: .55rem .9rem; border-top: 1px solid var(--border-light);
  font-size: .68rem; color: var(--text-muted);
  display: flex; align-items: center; gap: .4rem;
  flex-shrink: 0; white-space: nowrap; overflow: hidden;
  transition: opacity var(--t-base);
}
.reader-sidebar.collapsed .sidebar-footer-tip { opacity: 0; }
.sidebar-footer-tip i { color: var(--gold-500); flex-shrink: 0; }

/* ── Reader Main ── */
.reader-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Reader toolbar */
.reader-toolbar {
  height: 52px; display: flex; align-items: center; gap: .65rem;
  padding: 0 1.35rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-shrink: 0;
  transition: background var(--t-slow);
}
body.dark-mode .reader-toolbar {
  background: rgba(9,11,22,.88);
  border-bottom-color: var(--border-medium);
}

.reader-law-title { flex: 1; min-width: 0; }
.reader-law-title h2 {
  font-size: .92rem; font-weight: 800; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}
.reader-law-meta { display: flex; gap: .5rem; align-items: center; margin-top: .15rem; }
.reader-meta-badge {
  font-size: .63rem; padding: .14rem .5rem;
  border-radius: var(--r-pill); font-weight: 700;
}
.badge-amber {
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  color: var(--gold-600);
}
body.dark-mode .badge-amber { color: var(--gold-400); }
.badge-sky {
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.22);
  color: #3b82f6;
}
body.dark-mode .badge-sky { color: #60a5fa; }

/* Progress ring */
.progress-ring-wrap { position: relative; width: 40px; height: 40px; flex-shrink: 0; }
.progress-ring-wrap svg { transform: rotate(-90deg); }
.progress-ring-bg { stroke: var(--border-strong); fill: none; }
.progress-ring-fill {
  stroke: var(--gold-500); fill: none; stroke-linecap: round;
  transition: stroke-dashoffset .5s var(--ease-spring);
}
.progress-ring-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .58rem; font-weight: 800; color: var(--gold-600);
}
body.dark-mode .progress-ring-label { color: var(--gold-400); }

/* Progress bar */
.reader-progress-bar {
  height: 3px; background: var(--border-light); flex-shrink: 0;
}
.reader-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400), var(--gold-300));
  transition: width .4s var(--ease-spring);
  position: relative; overflow: hidden;
}
.reader-progress-fill::after {
  content: ''; position: absolute;
  top: 0; left: -100%; bottom: 0; width: 50%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: shimmer 2.5s infinite;
}
@keyframes shimmer { to { left: 200%; } }

/* Article content area */
.reader-content {
  flex: 1; overflow-y: auto;
  scroll-behavior: smooth;
  padding: 2rem 2rem 3rem;
  transition: padding var(--t-slow);
}

/* Reader TOC (right panel – large screens) */
.reader-toc {
  width: var(--toc-w);
  border-right: 1px solid var(--border-light);
  background: var(--bg-surface);
  overflow-y: auto; flex-shrink: 0;
  padding: 1.2rem .7rem;
  display: flex; flex-direction: column; gap: .28rem;
  transition: background var(--t-slow);
}
body.dark-mode .reader-toc {
  background: rgba(9,11,22,.92);
  border-right-color: var(--border-medium);
}
.reader-toc-label {
  font-size: .62rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0 .4rem .55rem;
}
.reader-toc-item {
  font-size: .76rem; padding: .38rem .7rem;
  border-radius: var(--r-sm); color: var(--text-tertiary);
  cursor: pointer; transition: all var(--t-fast);
  border: 1px solid transparent; line-height: 1.45;
}
.reader-toc-item:hover { color: var(--text-primary); background: var(--bg-elevated); }
.reader-toc-item.active {
  color: var(--gold-600); background: var(--gold-dim);
  border-color: var(--gold-border); font-weight: 700;
}
body.dark-mode .reader-toc-item.active { color: var(--gold-400); }

/* ═══════════════════════════════════════════════════════════
§17. ARTICLE CARDS — Document-Centric Final
═══════════════════════════════════════════════════════════ */
.articles-container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

/* ── Chapter Heading ── */
.chapter-heading {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: 2.5rem 0 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border-light);
}
.chapter-heading:first-child { margin-top: 0; }
.chapter-heading-num {
    font-size: .68rem;
    font-weight: 800;
    color: var(--gold-600);
    background: var(--gold-dim);
    border: 1px solid var(--gold-border);
    padding: .22rem .65rem;
    border-radius: var(--r-pill);
    white-space: nowrap;
}
body.dark-mode .chapter-heading-num { color: var(--gold-400); }
.chapter-heading h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* ── Article Card (داکیومنتی، بدون کارت) ── */
.article-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    padding: 2.5rem 1rem 2rem;
    border-bottom: 1px dashed var(--border-medium);
    position: relative;
    animation: articleDocIn .5s var(--ease-out) both;
    scroll-margin-top: 80px;
    transition: background var(--t-base);
}
.article-card:last-child {
    border-bottom: none;
}

@keyframes articleDocIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* هایلایت */
.article-card.active-highlight {
    background: linear-gradient(90deg, var(--gold-dim) 0%, transparent 85%);
    border-radius: var(--r-lg);
    animation: docHighlight 2.5s var(--ease-out);
}
@keyframes docHighlight {
    0%, 70% { background: linear-gradient(90deg, var(--gold-dim) 0%, transparent 85%); }
    100%    { background: transparent; }
}

/* مواد مهم */
.article-card.important::before {
    content: '';
    position: absolute;
    top: 1.5rem;
    right: 0;
    width: 4px;
    height: calc(100% - 3rem);
    background: linear-gradient(180deg, var(--gold-500), var(--gold-300));
    border-radius: 2px;
}

/* ── Article Header ── */
.article-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0 0 1.25rem 0;
    border-bottom: none;
    background: transparent;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
body.dark-mode .article-header { background: transparent; }

/* شماره ماده badge */
.article-number {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: transparent;
    color: var(--gold-600);
    padding: .35rem .85rem;
    border-radius: var(--r-pill);
    border: 1.5px solid var(--gold-border);
    box-shadow: none;
    flex-shrink: 0;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--t-fast);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.article-number::before {
    content: '§';
    font-size: .9rem;
    opacity: .75;
    font-weight: 900;
}
.article-number:hover {
    background: var(--gold-500);
    color: #fff;
    border-color: var(--gold-500);
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold);
}
body.dark-mode .article-number { color: var(--gold-400); }

/* عنوان ماده */
.article-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.5;
    letter-spacing: -.015em;
    padding-top: .15rem;
}

/* ── Action Buttons (دکمه‌های bookmark, note, share, audio) ── */
.article-actions {
    display: flex;
    gap: .35rem;
    margin-right: auto;
    margin-left: 0;
    opacity: .25;
    transition: opacity var(--t-fast);
}
.article-card:hover .article-actions { opacity: 1; }

.btn-icon-sm {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    transition: all var(--t-fast);
    padding: 0;
}
.btn-icon-sm:hover {
    background: var(--gold-dim);
    border-color: var(--gold-500);
    color: var(--gold-600);
    transform: scale(1.08);
}
body.dark-mode .btn-icon-sm:hover { color: var(--gold-400); }
.btn-icon-sm.active {
    color: var(--gold-500);
    background: var(--gold-dim);
    border-color: var(--gold-border);
}

/* ── Read Checkbox ── */
.read-checkbox {
    display: flex;
    align-items: center;
    gap: .45rem;
    cursor: pointer;
    background: transparent;
    padding: .35rem .85rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-medium);
    transition: all var(--t-fast);
    user-select: none;
    font-size: .72rem;
    color: var(--text-tertiary);
    font-weight: 600;
}
.read-checkbox:hover {
    border-color: var(--gold-500);
    color: var(--gold-600);
    background: var(--gold-dim);
}
.read-checkbox input { display: none; }
.checkmark {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    transition: all var(--t-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.read-checkbox input:checked + .checkmark {
    background: var(--gold-500);
    border-color: var(--gold-500);
    box-shadow: 0 0 8px var(--gold-glow-sm);
    animation: checkPop .25s var(--ease-spring);
}
@keyframes checkPop {
    from { transform: scale(.7); }
    to   { transform: scale(1); }
}
.read-checkbox input:checked + .checkmark::after {
    content: '✓';
    font-size: .55rem;
    color: #fff;
    font-weight: 900;
}

/* ── Article Body (تایپوگرافی کتاب) ── */
.article-body { padding: 0; }

.article-content {
    font-size: 1.05rem;
    line-height: 2.15;
    color: var(--text-primary);
    text-align: justify;
    letter-spacing: 0;
    word-spacing: .02em;
}
body.dark-mode .article-content { color: var(--text-primary); }

.article-content p {
    margin-bottom: 1.5rem;
}
.article-content p:last-child { margin-bottom: 0; }
.article-content ul,
.article-content ol {
    margin-right: 1.8rem;
    margin-bottom: 1.5rem;
}
.article-content li {
    margin-bottom: .65rem;
    line-height: 2.1;
}

/* ── Drop Cap ظریف ── */
.article-content > p:first-of-type::first-letter {
    font-size: 1.6em;
    float: right;
    line-height: 1;
    margin: .08em .12em 0 0;
    padding: 0;
    font-weight: 800;
    color: var(--gold-600);
    font-family: 'Vazirmatn', serif;
}
body.dark-mode .article-content > p:first-of-type::first-letter {
    color: var(--gold-400);
}

/* ── Blockquote ── */
.article-content blockquote {
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    border-right: 4px solid var(--gold-500);
    background: linear-gradient(90deg, var(--gold-dim), transparent);
    border-radius: var(--r-md);
    font-style: italic;
    color: var(--text-secondary);
    position: relative;
}
.article-content blockquote::before {
    content: '❝';
    position: absolute;
    top: -.5rem;
    right: 1rem;
    font-size: 4rem;
    color: var(--gold-400);
    opacity: .2;
    font-family: Georgia, serif;
    line-height: 1;
}

/* ── Tables ── */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: .92rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--r-md);
    overflow: hidden;
}
.article-content th {
    background: linear-gradient(135deg, var(--gold-dim), transparent);
    font-weight: 800;
    padding: .9rem 1.1rem;
    text-align: right;
    border-bottom: 2px solid var(--gold-border);
}
.article-content td {
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border-light);
}
.article-content tr:last-child td { border-bottom: none; }
.article-content tr:nth-child(even) td { background: var(--bg-elevated); }
.article-content tr:hover td { background: var(--gold-dim); }

/* ── Article Notes (استایل‌های بازطراحی‌شده) ── */
.article-note {
    margin-top: 1.75rem;
    margin-bottom: 0;
    padding: 1.25rem 1.5rem;
    border-radius: var(--r-lg);
    border: none;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    font-size: .88rem;
    line-height: 1.85;
    position: relative;
    overflow: hidden;
    animation: noteSlideIn .5s var(--ease-out) both;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-base), box-shadow var(--t-base);
}
.article-note:hover {
    transform: translateX(-4px);
    box-shadow: var(--shadow-md);
}
@keyframes noteSlideIn {
    from { opacity: 0; transform: translateX(20px) scale(.98); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

.note-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.note-body { flex: 1; min-width: 0; }
.note-title {
    font-size: .92rem;
    font-weight: 800;
    margin-bottom: .35rem;
}
.note-content { color: inherit; opacity: .92; }

/* Warning */
.article-note.warning {
    background: linear-gradient(135deg, rgba(239,68,68,.08), rgba(249,115,22,.06));
    border-right: 4px solid var(--c-danger);
    color: #dc2626;
}
body.dark-mode .article-note.warning {
    background: linear-gradient(135deg, rgba(239,68,68,.12), rgba(249,115,22,.08));
    color: #fca5a5;
}
.article-note.warning .note-icon-wrap { background: linear-gradient(135deg, #ef4444, #f97316); }

/* Info */
.article-note.info {
    background: linear-gradient(135deg, rgba(59,130,246,.08), rgba(99,102,241,.06));
    border-right: 4px solid var(--c-info);
    color: #2563eb;
}
body.dark-mode .article-note.info {
    background: linear-gradient(135deg, rgba(59,130,246,.12), rgba(99,102,241,.08));
    color: #93c5fd;
}
.article-note.info .note-icon-wrap { background: linear-gradient(135deg, #3b82f6, #6366f1); }

/* Tip */
.article-note.tip {
    background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(20,184,166,.06));
    border-right: 4px solid var(--c-success);
    color: #059669;
}
body.dark-mode .article-note.tip {
    background: linear-gradient(135deg, rgba(16,185,129,.12), rgba(20,184,166,.08));
    color: #6ee7b7;
}
.article-note.tip .note-icon-wrap { background: linear-gradient(135deg, #10b981, #14b8a6); }

/* Important */
.article-note.important {
    background: linear-gradient(135deg, var(--gold-dim), rgba(245,176,66,.08));
    border-right: 4px solid var(--gold-500);
    color: var(--gold-700);
}
body.dark-mode .article-note.important {
    background: linear-gradient(135deg, rgba(251,191,36,.1), rgba(245,158,11,.06));
    color: var(--gold-300);
}
.article-note.important .note-icon-wrap { background: linear-gradient(135deg, var(--gold-500), var(--gold-600)); }

/* Tabssora */
.article-note.tabssora {
    background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(168,85,247,.06));
    border-right: 4px solid #8b5cf6;
    color: #7c3aed;
}
body.dark-mode .article-note.tabssora {
    background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(168,85,247,.08));
    color: #c4b5fd;
}
.article-note.tabssora .note-icon-wrap { background: linear-gradient(135deg, #8b5cf6, #a855f7); }

/* Case */
.article-note.case {
    background: linear-gradient(135deg, rgba(100,116,139,.08), rgba(71,85,105,.06));
    border-right: 4px solid #64748b;
    color: #475569;
}
body.dark-mode .article-note.case {
    background: linear-gradient(135deg, rgba(148,163,184,.1), rgba(100,116,139,.08));
    color: #cbd5e1;
}
.article-note.case .note-icon-wrap { background: linear-gradient(135deg, #64748b, #475569); }

/* ── Article Navigation ── */
.article-navigation {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 1rem 1rem;
    border-top: 1px dashed var(--border-medium);
    margin-top: 2rem;
}
.nav-article-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.35rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--r-pill);
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast);
}
.nav-article-btn:hover:not(:disabled) {
    border-color: var(--gold-500);
    color: var(--gold-600);
    background: var(--gold-dim);
}
body.dark-mode .nav-article-btn:hover:not(:disabled) { color: var(--gold-400); }
.nav-article-btn:disabled { opacity: .3; cursor: not-allowed; }
#articlePositionIndicator {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Reading Info Bar ── */
.reader-reading-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(90deg, var(--gold-dim), transparent 85%);
    border-bottom: 1px dashed var(--border-medium);
    font-size: .82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.reader-reading-info .reading-stat {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
}
.reader-reading-info .reading-stat i { color: var(--gold-500); }
.reader-reading-info .reading-stat b { color: var(--gold-600); font-weight: 900; }
body.dark-mode .reader-reading-info .reading-stat b { color: var(--gold-400); }
.reader-reading-info .divider {
    width: 1px;
    height: 18px;
    background: var(--border-medium);
    opacity: .5;
}
.reader-reading-info .law-summary {
    flex: 1;
    font-size: .8rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ─── بهینه‌سازی چیدمان مطالعه ─────────────────────────── */
.articles-container {
    max-width: 72ch; /* عرض استاندارد برای خوانایی بالا */
    margin: 0 auto;
    padding: 2.5rem 1rem 4rem;
}

.article-card {
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    transition: background var(--t-base);
}

.article-header {
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: none;
}

.article-content {
    font-size: 1.08rem;
    line-height: 2.25;
    color: var(--text-primary);
    text-align: justify;
    hyphens: auto;
    letter-spacing: 0;
    word-spacing: .02em;
}

.article-content p {
    margin-bottom: 1.6rem;
}

.article-content p:last-child {
    margin-bottom: 0;
}

/* حذف پس‌زمینه‌ها و حاشیه‌های غیرضروری */
.article-body { padding: 0; }
.article-note { margin-top: 1.5rem; }

/* در حالت فوکوس، همه‌چیز مینیمال‌تر بشه */
body.focus-mode .reader-toc,
body.focus-mode .reader-toolbar,
body.focus-mode .reader-reading-info,
body.focus-mode .article-actions,
body.focus-mode .read-checkbox {
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}
body.focus-mode .articles-container {
    max-width: 65ch;
    padding-top: 3rem;
}

/* ─────────────────────────────────────────────────────────────
✨ FIX: فاصله مناسب بین محتوا و خط طلایی ماده مهم
═══════════════════════════════════════════════════════════════ */
.article-card.important {
    padding-right: 2.25rem !important; /* فاصله بیشتر محتوا از لبه */
    position: relative;
}

.article-card.important::before {
    right: .85rem !important; /* خط طلایی داخل‌تر از لبه */
    top: 1.5rem;
    width: 3px; /* کمی نازک‌تر و ظریف‌تر */
    height: calc(100% - 3rem);
    border-radius: 2px;
    box-shadow: 
        0 0 8px var(--gold-glow-sm),
        0 0 0 4px rgba(245, 176, 66, 0.04); /* هاله ملایم دور خط */
}

/* فاصله بیشتر برای عنوان و شماره ماده */
.article-card.important .article-header {
    padding-right: .5rem;
}

/* Glow ملایم روی کل کارت مهم */
.article-card.important::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, 
        rgba(245, 176, 66, 0.02) 0%, 
        transparent 30%);
    pointer-events: none;
    border-radius: var(--r-sm);
}

/* ── ریسپانسیو برای موبایل ── */
@media (max-width: 768px) {
    .article-card.important {
        padding-right: 1.75rem !important;
    }
    .article-card.important::before {
        right: .5rem !important;
        width: 2.5px;
    }
}

/* ─────────────────────────────────────────────────────────────
   §18.  READER SETTINGS PANEL  (floating)
───────────────────────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────────────
✨ FIX 2: READER SETTINGS PANEL (مودال تنظیمات نمایش)
═══════════════════════════════════════════════════════════════ */
.reader-settings-panel {
    position: fixed !important;
    top: calc(var(--topbar-h) + 65px) !important;
    left: 1.5rem !important;
    width: 290px !important;
    z-index: 99990 !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-medium) !important;
    border-radius: var(--r-xl) !important;
    padding: 0 !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25), 0 0 0 1px var(--border-light) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    overflow: hidden !important;
    animation: settingsSlideIn .3s var(--ease-spring) !important;
}
body.dark-mode .reader-settings-panel {
    background: rgba(15, 18, 30, 0.95) !important;
    border-color: var(--border-strong) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 0 1px var(--border-medium) !important;
}
@keyframes settingsSlideIn {
    from { opacity: 0; transform: translateY(-15px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* هدر مودال تنظیمات */
.settings-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem 1.25rem !important;
    border-bottom: 1px solid var(--border-light) !important;
    background: linear-gradient(135deg, var(--gold-dim), transparent) !important;
}
.settings-header h4 {
    font-size: .9rem !important;
    font-weight: 800 !important;
    color: var(--gold-600) !important;
    display: flex !important;
    align-items: center !important;
    gap: .5rem !important;
    margin: 0 !important;
}
body.dark-mode .settings-header h4 { color: var(--gold-400) !important; }

/* بدنه مودال تنظیمات */
.settings-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    padding: .5rem 0 !important;
    max-height: 65vh !important;
    overflow-y: auto !important;
}

/* هر ردیف تنظیمات */
.setting-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 1rem !important;
    padding: .85rem 1.25rem !important;
    transition: background var(--t-fast) !important;
}
.setting-item:hover {
    background: var(--bg-elevated) !important;
}
.setting-item label {
    font-size: .82rem !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    display: flex !important;
    align-items: center !important;
    gap: .5rem !important;
    margin: 0 !important;
}
.setting-item label i {
    color: var(--gold-500) !important;
    font-size: .85rem !important;
    width: 16px !important;
    text-align: center !important;
}

/* کنترل‌های + و - و اسلایدر */
.setting-control {
    display: flex !important;
    align-items: center !important;
    gap: .25rem !important;
    background: var(--bg-sunken) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--r-pill) !important;
    padding: .15rem .25rem !important;
}
.setting-control button {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-tertiary) !important;
    cursor: pointer !important;
    font-weight: 800 !important;
    font-size: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all var(--t-fast) !important;
}
.setting-control button:hover {
    background: var(--gold-dim) !important;
    color: var(--gold-600) !important;
}
.setting-control span {
    font-size: .78rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    min-width: 32px !important;
    text-align: center !important;
}

/* دکمه‌های Toggle (فعال/غیرفعال) */
.btn-toggle {
    padding: .35rem .9rem !important;
    border-radius: var(--r-pill) !important;
    background: var(--bg-sunken) !important;
    border: 1px solid var(--border-medium) !important;
    color: var(--text-secondary) !important;
    font-size: .76rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all var(--t-fast) !important;
    white-space: nowrap !important;
}
.btn-toggle:hover {
    border-color: var(--gold-500) !important;
    color: var(--gold-600) !important;
}
.btn-toggle.on {
    background: linear-gradient(135deg, var(--gold-500), var(--gold-600)) !important;
    border-color: var(--gold-500) !important;
    color: #fff !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 12px var(--gold-glow-sm) !important;
}

/* ─────────────────────────────────────────────────────────────
   §19.  FLOATING QUIZ BUTTON
───────────────────────────────────────────────────────────── */
.floating-quiz-btn {
  position: fixed; bottom: 1.65rem; left: 1.65rem; z-index: 2500;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff; border: none; border-radius: var(--r-pill);
  padding: .65rem 1.35rem;
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  font-weight: 800; font-size: .83rem;
  box-shadow: 0 6px 20px rgba(239,68,68,.45);
  cursor: pointer; transition: all var(--t-base);
  animation: fabFloat 3s ease-in-out infinite;
}
@keyframes fabFloat {
  0%,100% { box-shadow: 0 6px 20px rgba(239,68,68,.45); transform: translateY(0); }
  50%     { box-shadow: 0 10px 30px rgba(239,68,68,.65), 0 0 0 6px rgba(239,68,68,.08); transform: translateY(-3px); }
}
.floating-quiz-btn:hover {
  transform: translateY(-4px) scale(1.04) !important;
  animation: none;
  box-shadow: 0 14px 38px rgba(239,68,68,.75);
}
.floating-quiz-btn .neon-glow { display: none; }

/* ─────────────────────────────────────────────────────────────
   §20.  MODALS
───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-modal);
  display: none; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-overlay.active { display: flex; animation: modalBg .22s ease; }
@keyframes modalBg { from { opacity: 0; } to { opacity: 1; } }

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
  max-width: 500px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalSlide .3s var(--ease-spring);
  overflow: hidden;
  transition: background var(--t-slow);
}
body.dark-mode .modal-container {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-xl), 0 0 40px rgba(0,0,0,.5);
}
.modal-container.modal-xl { max-width: 940px; }
@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(.92) translateY(24px);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.45rem;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(135deg, var(--gold-dim), transparent);
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 1rem; font-weight: 800; color: var(--text-primary);
  display: flex; align-items: center; gap: .55rem;
}
.modal-header h3 i { color: var(--gold-500); font-size: .88rem; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.2);
  color: var(--c-danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .82rem;
  transition: all var(--t-fast);
}
.modal-close:hover { background: rgba(239,68,68,.16); transform: rotate(90deg) scale(1.05); }

.modal-body { padding: 1.4rem 1.45rem; overflow-y: auto; flex: 1; color: var(--text-secondary); }
.modal-footer {
  padding: .95rem 1.45rem;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: .65rem; flex-shrink: 0;
}
.modal-body textarea {
  width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border-medium); border-radius: var(--r-md);
  padding: .85rem 1rem; color: var(--text-primary);
  font-size: .86rem; line-height: 1.7; resize: vertical; min-height: 135px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.modal-body textarea:focus {
  outline: none; border-color: var(--gold-500);
  box-shadow: 0 0 0 3px var(--gold-glow-sm);
}

/* Buttons */
.btn-primary {
  padding: .58rem 1.45rem;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  border: none; border-radius: var(--r-pill); color: #fff;
  font-weight: 700; font-size: .83rem; cursor: pointer;
  box-shadow: var(--shadow-gold);
  transition: all var(--t-fast);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--gold-glow); filter: brightness(1.05); }
.btn-secondary {
  padding: .58rem 1.45rem;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--r-pill); color: var(--text-secondary);
  font-weight: 600; font-size: .83rem; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-secondary:hover { border-color: var(--gold-500); color: var(--gold-600); background: var(--gold-dim); }
body.dark-mode .btn-secondary:hover { color: var(--gold-400); }
.btn-small { padding: .38rem .9rem; font-size: .76rem; }

/* Confirm modal */
.confirm-modal-overlay {
  position: fixed; inset: 0; z-index: calc(var(--z-modal) + 1);
  background: var(--bg-overlay); backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  opacity: 0; visibility: hidden;
  transition: opacity .22s, visibility .22s;
}
.confirm-modal-overlay.active { opacity: 1; visibility: visible; }
.confirm-modal {
  max-width: 380px; width: 100%;
  background: var(--bg-surface); border: 1px solid var(--border-medium);
  border-radius: var(--r-xl); overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: scale(.93) translateY(14px);
  transition: transform .3s var(--ease-spring);
}
body.dark-mode .confirm-modal { background: var(--bg-elevated); }
.confirm-modal-overlay.active .confirm-modal { transform: scale(1) translateY(0); }
.confirm-modal-header {
  padding: 1.65rem 1.4rem 1.15rem; text-align: center;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(135deg, var(--gold-dim), transparent);
}
.confirm-modal-icon {
  width: 52px; height: 52px; margin: 0 auto .9rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--gold-dim); border: 1.5px solid var(--gold-border); color: var(--gold-600);
}
body.dark-mode .confirm-modal-icon { color: var(--gold-400); }
.confirm-modal-title { font-size: 1rem; font-weight: 800; color: var(--text-primary); margin-bottom: .28rem; }
.confirm-modal-subtitle { color: var(--text-tertiary); font-size: .8rem; line-height: 1.6; }
.confirm-modal-footer { padding: .9rem 1.4rem; display: flex; gap: .65rem; justify-content: center; }
.confirm-btn { padding: .55rem 1.4rem; border-radius: var(--r-pill); font-weight: 700; font-size: .82rem; cursor: pointer; border: none; transition: all var(--t-fast); }
.confirm-btn-primary { background: linear-gradient(135deg, var(--gold-500), var(--gold-600)); color: #fff; box-shadow: var(--shadow-gold); }
.confirm-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--gold-glow); }
.confirm-btn-secondary { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-secondary); }
.confirm-btn-secondary:hover { border-color: var(--gold-500); color: var(--gold-600); }

/* ─────────────────────────────────────────────────────────────
   §21.  DASHBOARD MODAL
───────────────────────────────────────────────────────────── */
.dashboard-stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: .9rem; margin-bottom: 1.6rem; }
.stat-card-dash {
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: var(--r-lg); padding: 1rem;
  display: flex; align-items: center; gap: .8rem;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.stat-card-dash:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-card-dash i { font-size: 1.5rem; color: var(--gold-500); }
.stat-card-dash span { font-size: 1.45rem; font-weight: 800; color: var(--text-primary); display: block; line-height: 1.2; }
.stat-card-dash small { color: var(--text-muted); font-size: .7rem; }
.dashboard-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.35rem; margin-bottom: 1.35rem; }
.chart-container h4, .activity-container h4 {
  font-size: .86rem; font-weight: 700; color: var(--text-primary); margin-bottom: .8rem;
}
.progress-list { display: flex; flex-direction: column; gap: .7rem; }
.progress-item { display: flex; align-items: center; gap: .8rem; }
.progress-item .law-name { flex: 1; font-size: .8rem; color: var(--text-secondary); }
.progress-bar-container { width: 110px; height: 4px; background: var(--border-medium); border-radius: var(--r-pill); overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold-600), var(--gold-400)); border-radius: var(--r-pill); }
.progress-item .percent { min-width: 36px; text-align: left; font-size: .76rem; font-weight: 700; color: var(--gold-600); }
body.dark-mode .progress-item .percent { color: var(--gold-400); }
.activity-feed { max-height: 175px; overflow-y: auto; }
.activity-item-dash { padding: .58rem .35rem; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: .55rem; font-size: .78rem; color: var(--text-secondary); }
.activity-item-dash i { color: var(--gold-500); width: 16px; }
.activity-time { margin-right: auto; font-size: .7rem; color: var(--text-muted); }
.reminder-section { background: var(--bg-elevated); border-radius: var(--r-lg); padding: 1rem; border: 1px solid var(--border-light); }
.reminder-section h4 { font-size: .86rem; font-weight: 700; color: var(--text-primary); margin-bottom: .8rem; display: flex; align-items: center; gap: .38rem; }
.reminder-section h4 i { color: var(--gold-500); }
.reminder-controls { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.reminder-controls select, .reminder-controls input[type="time"] {
  padding: .48rem .85rem; background: var(--bg-sunken);
  border: 1px solid var(--border-medium); border-radius: var(--r-sm);
  color: var(--text-primary); font-size: .8rem; flex: 1 1 110px;
  transition: border-color var(--t-fast);
}
.reminder-controls select:focus, .reminder-controls input:focus { outline: none; border-color: var(--gold-500); }
#reminderStatus { font-size: .76rem; color: var(--text-muted); margin-top: .55rem; }

/* ─────────────────────────────────────────────────────────────
   §22.  AUDIO PLAYER
───────────────────────────────────────────────────────────── */
#audioPlayer {
  position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 2400;
  background: var(--bg-surface); backdrop-filter: blur(16px);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl); padding: .7rem .95rem;
  display: flex; align-items: center; gap: .55rem;
  box-shadow: var(--shadow-lg);
  animation: audioSlide .3s var(--ease-spring);
}
body.dark-mode #audioPlayer { background: var(--bg-elevated); }
@keyframes audioSlide { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
#audioPlayer button {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .82rem;
  transition: all var(--t-fast);
}
#audioPlayer button:hover { background: var(--gold-dim); border-color: var(--gold-500); color: var(--gold-600); }
body.dark-mode #audioPlayer button:hover { color: var(--gold-400); }
#audioStatus { font-size: .76rem; color: var(--text-muted); white-space: nowrap; }
#voiceSelect {
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: var(--r-sm); color: var(--text-secondary); font-size: .73rem;
  padding: .28rem .5rem; max-width: 115px;
}

/* ─────────────────────────────────────────────────────────────
   §23.  TOASTS
───────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: .45rem; max-width: 320px;
}
.toast {
  display: flex; align-items: flex-start; gap: .7rem;
  background: var(--bg-surface); border: 1px solid var(--border-medium);
  border-radius: var(--r-md); padding: .88rem .95rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s var(--ease-spring);
  transition: background var(--t-slow);
}
body.dark-mode .toast { background: var(--bg-elevated); }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-right: 3px solid var(--c-success); }
.toast.error   { border-right: 3px solid var(--c-danger); }
.toast.info    { border-right: 3px solid var(--c-info); }
.toast.warning { border-right: 3px solid var(--c-warning); }
.toast-icon { font-size: 1.05rem; margin-top: .06rem; }
.toast.success .toast-icon { color: var(--c-success); }
.toast.error   .toast-icon { color: var(--c-danger); }
.toast.info    .toast-icon { color: var(--c-info); }
.toast.warning .toast-icon { color: var(--c-warning); }
.toast-content { flex: 1; }
.toast-content h4 { font-size: .8rem; font-weight: 700; color: var(--text-primary); margin-bottom: .13rem; }
.toast-content p  { font-size: .76rem; color: var(--text-secondary); line-height: 1.5; }
.toast-close {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: .78rem; padding: .08rem;
  transition: color var(--t-fast);
}
.toast-close:hover { color: var(--text-primary); }

/* ─────────────────────────────────────────────────────────────
   §24.  LOADING SPINNER
───────────────────────────────────────────────────────────── */
.loading-spinner {
  position: fixed; inset: 0;
  background: var(--bg-overlay); backdrop-filter: blur(6px);
  z-index: calc(var(--z-modal) - 1);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: .9rem;
}
.loading-spinner.active { display: flex; }
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--border-medium); border-top-color: var(--gold-500);
  animation: spin .8s linear infinite;
  display: flex; align-items: center; justify-content: center;
}
.spinner i { color: var(--gold-500); font-size: 1.1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { font-size: .82rem; color: var(--text-secondary); }

/* ─────────────────────────────────────────────────────────────
§25.  FOCUS / READING MODE  ✨ بهبود یافته
───────────────────────────────────────────────────────────── */
body.focus-mode .app-sidebar,
body.focus-mode .reader-toc,
body.focus-mode .reader-toolbar,
body.focus-mode .reader-reading-info,
body.focus-mode .article-actions,
body.focus-mode .read-checkbox,
body.focus-mode .article-navigation,
body.focus-mode .article-anchor-link {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity var(--t-base);
}

/* حذف padding زیاد که محتوا رو کوچیک می‌کرد */
body.focus-mode .reader-content {
    padding: 3rem 2rem 4rem !important;
    max-width: 100%;
}

/* ✨ بزرگ‌تر کردن محتوا در focus mode */
body.focus-mode .articles-container {
    max-width: 900px; /* از 820px به 900px */
    padding: 2rem 0 4rem;
}

/* ✨ فاصله بیشتر بین مواد */
body.focus-mode .article-card {
    padding: 3.5rem 0 3rem !important;
    border-bottom: 1px solid var(--border-light) !important;
}

/* ✨ فونت بزرگ‌تر و خواناتر */
body.focus-mode .article-content {
    font-size: 1.18rem !important; /* از 1.05rem به 1.18rem */
    line-height: 2.4 !important; /* از 2.15 به 2.4 */
    letter-spacing: 0.01em;
    word-spacing: 0.03em;
}

/* ✨ فاصله بیشتر بین پاراگراف‌ها */
body.focus-mode .article-content p {
    margin-bottom: 2rem !important; /* از 1.5rem به 2rem */
}

/* ✨ عنوان بزرگ‌تر */
body.focus-mode .article-title {
    font-size: 1.5rem !important; /* از 1.25rem به 1.5rem */
    margin-bottom: 1.5rem;
}

/* ✨ شماره ماده بزرگ‌تر */
body.focus-mode .article-number {
    font-size: .85rem !important;
    padding: .45rem 1.1rem !important;
}

/* ✨ هدر با فاصله بیشتر */
body.focus-mode .article-header {
    padding-bottom: 2rem !important;
    margin-bottom: 2.5rem !important;
    border-bottom: 1px solid var(--border-light);
}

/* ✨ بدنه با padding مناسب */
body.focus-mode .article-body {
    padding: 0 1rem;
}

/* ✨ دکمه خروج بزرگ‌تر و واضح‌تر */
body.focus-mode .focus-mode-exit {
    padding: .6rem 1.4rem !important;
    font-size: .85rem !important;
    box-shadow: var(--shadow-lg), 0 0 0 4px var(--gold-glow-sm) !important;
}

/* ✨ نکات بزرگ‌تر */
body.focus-mode .article-note {
    padding: 1.5rem 1.75rem !important;
    font-size: .95rem !important;
    margin-top: 2.5rem !important;
}

/* ✨ لیست‌ها با فاصله بیشتر */
body.focus-mode .article-content ul,
body.focus-mode .article-content ol {
    margin-bottom: 2rem !important;
}

body.focus-mode .article-content li {
    margin-bottom: .85rem !important;
    line-height: 2.3 !important;
}

/* ✨ Blockquote بزرگ‌تر */
body.focus-mode .article-content blockquote {
    padding: 1.75rem 2.25rem !important;
    margin: 2.5rem 0 !important;
    font-size: 1.08rem !important;
}

/* ✨ جداول با فونت بزرگ‌تر */
body.focus-mode .article-content table {
    font-size: 1rem !important;
}

body.focus-mode .article-content th,
body.focus-mode .article-content td {
    padding: 1rem 1.25rem !important;
}
.focus-mode-exit {
    position: fixed !important;
    top: calc(var(--topbar-h) + 15px) !important;
    left: 1.5rem !important;
    z-index: 99999 !important; /* بالاتر از همه چیز حتی Reader و Modal */
    display: none; /* به صورت پیش‌فرض مخفی */
    align-items: center;
    gap: .5rem;
    font-size: .82rem !important;
    font-weight: 700 !important;
    padding: .6rem 1.2rem !important;
    background: var(--bg-surface) !important;
    border: 1.5px solid var(--gold-500) !important;
    border-radius: var(--r-pill) !important;
    color: var(--gold-600) !important;
    cursor: pointer !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 0 0 4px var(--gold-glow-sm) !important;
    transition: all var(--t-fast) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}
body.dark-mode .focus-mode-exit {
    background: rgba(20, 25, 40, 0.95) !important;
    color: var(--gold-400) !important;
}
.focus-mode-exit:hover {
    background: var(--gold-500) !important;
    color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 28px rgba(245,176,66,0.4) !important;
}
body.focus-mode .focus-mode-exit {
    display: flex !important;
    animation: focusExitPop .4s var(--ease-spring) !important;
}
@keyframes focusExitPop {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─────────────────────────────────────────────────────────────
   §26.  HIGHLIGHT (mark)
───────────────────────────────────────────────────────────── */
mark {
  background: rgba(245,176,66,.2);
  border-radius: 3px; padding: 0 3px;
  color: var(--text-primary);
  box-shadow: inset 0 -2px 0 rgba(245,176,66,.35);
}

/* ─────────────────────────────────────────────────────────────
   §27.  THEME TOGGLE BUTTON  (btn-theme – هماهنگ با بقیه سایت)
───────────────────────────────────────────────────────────── */
.btn-theme {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  height: 32px; padding: 0 .75rem;
  display: flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-theme:hover {
  border-color: var(--gold-500); color: var(--gold-600); background: var(--gold-dim);
}
body.dark-mode .btn-theme:hover { color: var(--gold-400); }
.btn-theme i { font-size: .9rem; transition: transform .35s var(--ease-spring); }
.btn-theme:hover i { transform: rotate(20deg) scale(1.15); }

/* ─────────────────────────────────────────────────────────────
   §28.  MOBILE SIDEBAR TOGGLE (inside reader)
───────────────────────────────────────────────────────────── */
.reader-sidebar-toggle-mobile {
  display: none; position: fixed;
  bottom: 5rem; right: 1rem; z-index: 3000;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-surface); border: 1px solid var(--gold-border);
  color: var(--gold-600); font-size: 1rem; cursor: pointer;
  box-shadow: var(--shadow-md);
  align-items: center; justify-content: center; transition: all var(--t-fast);
}
body.dark-mode .reader-sidebar-toggle-mobile { color: var(--gold-400); }
.reader-sidebar-toggle-mobile:hover { background: var(--gold-dim); }
.sidebar-mobile-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg-overlay); z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(3px);
}

/* ─────────────────────────────────────────────────────────────
   §29.  PRESENTATION MODE
───────────────────────────────────────────────────────────── */
.presentation-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem; animation: fadeInPage .3s ease;
}
@keyframes fadeInPage { from { opacity: 0; } to { opacity: 1; } }
.presentation-content {
  max-width: 880px; width: 100%; max-height: 86vh; overflow-y: auto;
  background: var(--bg-glass); backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium); border-radius: var(--r-2xl);
  padding: 2.75rem;
  box-shadow: var(--shadow-xl), 0 0 30px var(--gold-glow);
  animation: slideUpPane .4s var(--ease-spring);
}
@keyframes slideUpPane { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
.presentation-article h2 { font-size: 1.9rem; font-weight: 900; color: var(--gold-600); margin-bottom: .4rem; }
body.dark-mode .presentation-article h2 { color: var(--gold-400); }
.presentation-article h3 { font-size: 1.25rem; color: var(--text-primary); margin-bottom: 1.65rem; }
.presentation-controls { display: flex; align-items: center; justify-content: center; gap: 1.65rem; margin-top: 2.1rem; }
.presentation-controls button {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--card-bg); border: 1px solid var(--gold-border);
  color: var(--gold-600); font-size: 1.1rem; cursor: pointer;
  transition: all var(--t-base); display: flex; align-items: center; justify-content: center;
}
body.dark-mode .presentation-controls button { color: var(--gold-400); }
.presentation-controls button:hover {
  background: var(--gold-500); color: #fff; border-color: var(--gold-500);
  transform: scale(1.1); box-shadow: var(--shadow-gold);
}
#presentationCounter { font-size: .95rem; color: var(--text-muted); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────
   §30.  UTILITY CLASSES
───────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.glass {
  background: var(--bg-glass); backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
}
.empty-message { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: .8rem; }
.inlaw-search-results { max-height: 185px; overflow-y: auto; }

/* ─────────────────────────────────────────────────────────────
   §31.  RESPONSIVE  –  Breakpoints
───────────────────────────────────────────────────────────── */
/* 1280px: hide right TOC */
@media (max-width: 1280px) {
  .reader-toc { display: none; }
}

/* 1024px: smaller sidebar */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .header-content { grid-template-columns: var(--sidebar-w) 1fr auto; }
  .dashboard-stats-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-charts { grid-template-columns: 1fr; }
}

/* 768px: collapse sidebar to icon-only */
@media (max-width: 768px) {
  :root { --topbar-h: 52px; }
  .header-search-wrap { display: none; }
  .header-content { grid-template-columns: auto 1fr auto; }
  .header-logo-sub { display: none; }
  .topbar-btn span { display: none; }
  .topbar-stat span { display: none; }

  .app-sidebar {
    width: var(--sidebar-sm);
  }
  .app-sidebar .sidebar-cat-name,
  .app-sidebar .sidebar-cat-count,
  .app-sidebar .sidebar-section-label,
  .app-sidebar .sidebar-nav-label { opacity: 0; pointer-events: none; }

  .app-main { margin-right: var(--sidebar-sm); }
  .grid-container { padding: 1.2rem 1.2rem; }
  .page-header { padding: 1.35rem 1.2rem .95rem; }
  .popular-searches { padding: .75rem 1.2rem; }
  .categories-grid, .laws-grid { grid-template-columns: 1fr; }
  .search-results { margin: 0 1.2rem 1rem; }

  .reader-sidebar {
    position: fixed; top: var(--topbar-h); right: -100%;
    height: calc(100vh - var(--topbar-h)); width: 272px;
    transition: right var(--t-slow); z-index: calc(var(--z-sidebar) + 5);
  }
  .reader-sidebar.mobile-open { right: 0; }
  .reader-sidebar-toggle-mobile { display: flex; }
  .sidebar-mobile-overlay.active { display: block; }

  .reader-toolbar { padding: 0 .9rem; gap: .45rem; }
  .reader-content { padding: 1.1rem 1.1rem 2.5rem; }
  body.focus-mode .reader-content { padding: 1.35rem; }
  .article-header { padding: .7rem .95rem; }
  .article-body { padding: .95rem 1rem; }
  .article-navigation { padding: .95rem 0; }

  .floating-quiz-btn { padding: .6rem; border-radius: 50%; }
  .floating-quiz-btn span { display: none; }
  .reader-settings-panel { width: 250px; left: .75rem; }
  .modal-container.modal-xl { max-width: 100%; }
}

/* 480px */
@media (max-width: 480px) {
  :root { --content-max: 100%; }
  .page-title { font-size: 1.3rem; }
  .page-title-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .article-header { gap: .45rem; }
  .article-actions { order: 3; width: 100%; }
  .read-checkbox span { display: none; }
  .confirm-modal-footer { flex-direction: column; }
  .confirm-btn { width: 100%; }
  .dashboard-stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-footer { flex-direction: column-reverse; }
}

/* ─────────────────────────────────────────────────────────────
   §32.  REDUCED MOTION  (accessibility)
───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════
   ✨  EXTRA ANIMATIONS & EFFECTS
═══════════════════════════════════════════════════════ */

/* ── Ripple روی کارت‌ها ── */
.category-card,
.law-card {
  isolation: isolate;
}
.category-card::after,
.law-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--mx,50%) var(--my,50%),
    rgba(245,176,66,.18) 0%, transparent 65%);
  opacity: 0;
  transition: opacity .5s;
  pointer-events: none;
}
.category-card:hover::after,
.law-card:hover::after { opacity: 1; }

/* ── Glow pulse روی sidebar active item ── */
.sidebar-cat-item.active {
  animation: sidebarGlow 2.5s ease-in-out infinite;
}
@keyframes sidebarGlow {
  0%,100% { box-shadow: none; }
  50%      { box-shadow: inset 0 0 12px rgba(245,176,66,.12); }
}

/* ── Stagger fade-in برای sidebar items ── */
.sidebar-cat-item:nth-child(1)  { animation: sidebarItemIn .3s .04s both; }
.sidebar-cat-item:nth-child(2)  { animation: sidebarItemIn .3s .07s both; }
.sidebar-cat-item:nth-child(3)  { animation: sidebarItemIn .3s .10s both; }
.sidebar-cat-item:nth-child(4)  { animation: sidebarItemIn .3s .13s both; }
.sidebar-cat-item:nth-child(5)  { animation: sidebarItemIn .3s .16s both; }
.sidebar-cat-item:nth-child(6)  { animation: sidebarItemIn .3s .19s both; }
.sidebar-cat-item:nth-child(7)  { animation: sidebarItemIn .3s .22s both; }
.sidebar-cat-item:nth-child(8)  { animation: sidebarItemIn .3s .25s both; }
@keyframes sidebarItemIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Smooth page transition ── */
.categories-section,
.laws-section {
  animation: pageIn .35s var(--ease-out) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Number badge bounce هنگام hover ── */
.law-card:hover .law-number-badge {
  animation: badgeBounce .4s var(--ease-spring);
}
@keyframes badgeBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25) rotate(5deg); }
  70%  { transform: scale(.92) rotate(-3deg); }
  100% { transform: scale(1.08) rotate(3deg); }
}

/* ── Shimmer روی category icon ── */
.category-card:hover .category-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,.25) 50%, transparent 70%);
  border-radius: inherit;
  animation: iconShimmer .6s var(--ease-out);
}
@keyframes iconShimmer {
  from { opacity: 0; transform: translateX(-100%) rotate(10deg); }
  to   { opacity: 1; transform: translateX(100%) rotate(10deg); }
}

/* ── Collapse sidebar smooth transition ── */
.app-sidebar .sidebar-cat-name,
.app-sidebar .sidebar-cat-count,
.app-sidebar .sidebar-section-label,
.app-sidebar .sidebar-nav-label {
  transition: opacity var(--t-base), transform var(--t-base);
  transform-origin: right;
}
.app-sidebar.collapsed .sidebar-cat-name,
.app-sidebar.collapsed .sidebar-cat-count,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-nav-label {
  opacity: 0;
  transform: scaleX(.8);
  pointer-events: none;
}

/* ── Sidebar collapse btn rotate ── */
.app-sidebar .sidebar-collapse-btn i {
  display: inline-block;
  transition: transform var(--t-base) var(--ease-spring);
}

/* ── Toast slide-in بهبود یافته ── */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(.94); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── Reader progress bar pulse ── */
.reader-progress-fill {
  box-shadow: 2px 0 8px var(--gold-glow-sm);
}

/* ── Article card active highlight ── */
.article-card.active-highlight {
  animation: articleHighlight 1.8s var(--ease-out);
}
@keyframes articleHighlight {
  0%   { border-color: var(--gold-500); box-shadow: 0 0 0 3px var(--gold-glow); }
  60%  { border-color: var(--gold-border); box-shadow: 0 0 0 1px var(--gold-glow-sm); }
  100% { border-color: var(--card-border); box-shadow: none; }
}

/* ── Floating quiz button improved ── */
.floating-quiz-btn::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: linear-gradient(135deg, #ef4444, #f97316, #ef4444);
  background-size: 200% 200%;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--t-base);
  animation: gradientRotate 3s linear infinite;
}
.floating-quiz-btn:hover::before { opacity: 1; }
@keyframes gradientRotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Scroll reveal (با JS کنترل میشه) ── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}




/* ═══════════════════════════════════════════════
   SIDEBAR TOGGLE BUTTON – همیشه visible
═══════════════════════════════════════════════ */
.sidebar-toggle-fixed {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 14px;
  z-index: calc(var(--z-sidebar) + 10);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: .9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
  /* همیشه روی sidebar میاد */
}
.sidebar-toggle-fixed:hover {
  background: var(--gold-dim);
  border-color: var(--gold-500);
  color: var(--gold-600);
  transform: scale(1.06);
}
body.dark-mode .sidebar-toggle-fixed:hover {
  color: var(--gold-400);
}

/* آیکون rotate هنگام collapse */
.sidebar-toggle-fixed i {
  transition: transform var(--t-base) var(--ease-spring);
}
.sidebar-collapsed-state .sidebar-toggle-fixed i {
  transform: rotate(180deg);
}

/* ── Sidebar collapsed: فقط آیکون‌ها ── */
.app-sidebar.collapsed {
  width: var(--sidebar-sm);
}
.app-sidebar.collapsed .sidebar-cat-name,
.app-sidebar.collapsed .sidebar-cat-count,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity var(--t-base), width var(--t-base);
}
/* tooltip در collapsed */
.app-sidebar.collapsed .sidebar-cat-item {
  justify-content: center;
}
.app-sidebar.collapsed .sidebar-cat-item::after {
  content: attr(data-label);
  position: absolute;
  right: calc(var(--sidebar-sm) + 8px);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  padding: .4rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 999;
}
.app-sidebar.collapsed .sidebar-cat-item:hover::after {
  opacity: 1;
  transform: translateX(0);
}

/* sidebar-nav-header بدون دکمه */
.sidebar-nav-header {
  padding: .9rem .85rem .6rem;
  display: flex;
  align-items: center;
  /* دیگه justify-content: space-between نداره */
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  min-height: 48px;
  padding-right: 3rem; /* فضا برای دکمه toggle خارجی */
}

@media (max-width: 768px) {
  .sidebar-toggle-fixed {
    top: calc(var(--topbar-h) + 6px);
    right: 10px;
    width: 30px;
    height: 30px;
    font-size: .8rem;
  }
  
  .article-card {
    padding: 2rem 0 1.75rem;
}

.article-header {
    gap: .85rem;
    margin-bottom: 1.35rem;
}

.article-title {
    font-size: 1.1rem;
}

.article-content {
    font-size: .95rem;
    line-height: 2;
}

.article-content > p:first-of-type::first-letter {
    font-size: 3em;
}

.article-actions {
    opacity: 1; /* همیشه visible در موبایل */
    order: 3;
    width: 100%;
    justify-content: flex-start;
}

.reader-reading-info {
    padding: .7rem 1rem;
    gap: .75rem;
    font-size: .75rem;
}

.reader-reading-info .law-summary {
    width: 100%;
    flex-basis: 100%;
}
}



/* ─────────────────────────────────────────────────────────────
§33.  PRINT (چاپ حرفه‌ای A4)
═══════════════════════════════════════════════════════════════ */
@media print {
    /* حذف کامل المان‌های غیرضروری */
    .app-sidebar, .law-header, .floating-quiz-btn,
    .reader-toolbar, .reader-toc, #audioPlayer,
    .toasts, .loading-spinner, .reader-settings-panel,
    .reader-sidebar, .article-actions, .read-checkbox,
    .focus-mode-exit, .reader-sidebar-toggle-mobile,
    .sidebar-mobile-overlay, .animated-bg, .grain-overlay,
    #globalLoader, .reader-progress-bar, .reader-reading-info,
    .article-navigation, .article-anchor-link,
    .glossary-tooltip, .confirm-modal-overlay,
    .modal-overlay, .presentation-overlay {
        display: none !important;
    }

    /* ریست کامل رنگ‌ها برای چاپ */
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        font-family: 'Vazirmatn', 'B Nazanin', Tahoma, serif !important;
        font-size: 11pt !important;
        line-height: 1.6 !important;
        direction: rtl;
        margin: 0;
        padding: 0;
    }

    /* تنظیمات صفحه A4 */
    @page {
        size: A4;
        margin: 2cm 2.5cm;
    }

    .app-main {
        margin: 0 !important;
        padding: 0 !important;
    }

    .reader-content {
        padding: 0 !important;
        overflow: visible !important;
    }

    /* هدر چاپی */
    .law-reader-section::before {
        content: 'بانک جامع قوانین و مقررات';
        display: block;
        text-align: center;
        font-size: 18pt;
        font-weight: bold;
        color: #000 !important;
        padding-bottom: 0.5cm;
        border-bottom: 2px solid #000;
        margin-bottom: 0.8cm;
    }

    /* عنوان قانون */
    .reader-law-title h2 {
        font-size: 16pt !important;
        text-align: center;
        margin-bottom: 0.5cm;
        page-break-after: avoid;
    }

    /* هر ماده */
    .article-card {
        page-break-inside: avoid;
        border: none !important;
        border-bottom: 1px solid #ccc !important;
        padding: 0.3cm 0 !important;
        margin-bottom: 0.3cm !important;
    }

    .article-header {
        padding: 0 !important;
        margin-bottom: 0.2cm !important;
    }

    .article-number {
        font-weight: bold !important;
        font-size: 11pt !important;
        border: 1px solid #000 !important;
        padding: 2px 8px !important;
        display: inline-block !important;
    }

    .article-title {
        font-size: 13pt !important;
        font-weight: bold !important;
        display: inline-block !important;
        margin-right: 0.3cm !important;
    }

    .article-content {
        font-size: 11pt !important;
        line-height: 1.8 !important;
        text-align: justify !important;
    }

    .article-content p {
        margin-bottom: 0.2cm !important;
        orphans: 3;
        widows: 3;
    }

    /* Drop Cap حذف بشه در چاپ */
    .article-content > p:first-of-type::first-letter {
        font-size: inherit !important;
        float: none !important;
        font-weight: inherit !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* نکات */
    .article-note {
        border: 1px solid #999 !important;
        padding: 0.2cm !important;
        margin-top: 0.2cm !important;
        page-break-inside: avoid;
    }

    .note-icon-wrap {
        display: none !important;
    }

    .note-title::before {
        content: '▪ ';
    }

    /* جداول */
    .article-content table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: avoid;
    }

    .article-content th,
    .article-content td {
        border: 1px solid #000 !important;
        padding: 4px 8px !important;
    }

    /* نقل قول */
    .article-content blockquote {
        border-right: 3px solid #000 !important;
        padding-right: 0.3cm !important;
        font-style: italic !important;
        margin: 0.3cm 0 !important;
    }

    .article-content blockquote::before {
        display: none !important;
    }

    /* فوتر هر صفحه */
    @page :footer {
        content: 'صفحه ' counter(page) ' از ' counter(pages);
    }

    /* جلوگیری از شکستن در وسط عناصر */
    h2, h3, h4 {
        page-break-after: avoid;
    }

    .article-content img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    /* لینک‌ها نمایش URL */
    .article-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666 !important;
    }

    /* فوتر نهایی */
    .articles-container::after {
        content: 'این سند در تاریخ ' attr(data-print-date) ' از بانک جامع قوانین استخراج شده است.';
        display: block;
        text-align: center;
        margin-top: 1cm;
        padding-top: 0.5cm;
        border-top: 1px solid #000;
        font-size: 9pt;
        color: #666 !important;
    }
}

/* ─────────────────────────────────────────────────────────────
✨  READING INFO BAR (بالای reader)
───────────────────────────────────────────────────────────── */
.reader-reading-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: .85rem 1.5rem;
    background: linear-gradient(90deg, var(--gold-dim), transparent);
    border-bottom: 1px solid var(--border-light);
    font-size: .82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.reader-reading-info .reading-stat {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
}

.reader-reading-info .reading-stat i {
    color: var(--gold-500);
    font-size: .9rem;
}

.reader-reading-info .reading-stat b {
    color: var(--text-primary);
    font-weight: 800;
}

.reader-reading-info .divider {
    width: 1px;
    height: 16px;
    background: var(--border-medium);
}

.reader-reading-info .law-summary {
    flex: 1;
    font-size: .82rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ── Deep Link Anchor ── */
.article-anchor-link {
    opacity: 0;
    margin-right: .35rem;
    color: var(--text-muted);
    font-size: .82rem;
    transition: opacity var(--t-fast);
    cursor: pointer;
}

.article-card:hover .article-anchor-link {
    opacity: 1;
}

.article-anchor-link:hover {
    color: var(--gold-500);
}

/* ─────────────────────────────────────────────────────────────
✨  GLOSSARY TOOLTIP (اصطلاحات حقوقی)
═══════════════════════════════════════════════════════════════ */
.glossary-term {
    color: var(--gold-600);
    font-weight: 600;
    border-bottom: 1.5px dashed var(--gold-border);
    cursor: help;
    position: relative;
    transition: all var(--t-fast);
}

body.dark-mode .glossary-term { color: var(--gold-400); }

.glossary-term:hover {
    color: var(--gold-700);
    background: var(--gold-dim);
    border-radius: 3px;
    padding: 0 2px;
}

.glossary-tooltip {
    position: fixed;
    max-width: 320px;
    background: var(--bg-surface);
    border: 1px solid var(--gold-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    padding: 0;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: tooltipFadeIn .25s var(--ease-spring);
    direction: rtl;
}

body.dark-mode .glossary-tooltip {
    background: rgba(20, 25, 40, 0.95);
    border-color: var(--gold-border);
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.glossary-tooltip-header {
    padding: .65rem 1rem;
    background: linear-gradient(135deg, var(--gold-dim), transparent);
    border-bottom: 1px solid var(--border-light);
    font-size: .85rem;
    font-weight: 800;
    color: var(--gold-600);
    display: flex;
    align-items: center;
    gap: .5rem;
}

body.dark-mode .glossary-tooltip-header { color: var(--gold-400); }

.glossary-tooltip-header i {
    font-size: .9rem;
    opacity: .7;
}

.glossary-tooltip-body {
    padding: .85rem 1rem;
    font-size: .82rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.editor-btn.active {
    background: var(--gold-dim); 
    border-color: var(--gold-border); 
    color: var(--gold-600);
}

/* ─────────────────────────────────────────────────────────────
§34.  ACCESSIBILITY (WCAG 2.1 AA)
═══════════════════════════════════════════════════════════════ */
/* Skip Links */
.skip-link {
    position: absolute;
    top: -100px;
    right: 0;
    background: var(--gold-500);
    color: #fff;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 700;
    z-index: 99999;
    border-radius: 0 0 var(--r-md) 0;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Focus Visible - واضح برای keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--gold-500) !important;
    outline-offset: 2px !important;
    border-radius: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .article-card {
        border: 2px solid #000 !important;
    }
    
    .btn-icon-sm,
    .nav-article-btn,
    .read-checkbox {
        border-width: 2px !important;
    }
    
    .article-number {
        border-width: 2px !important;
    }
}

/* Reduced Motion برای کاربران حساس */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Screen Reader Only - محتوای مخفی برای SR */
.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;
}

/* Live Region برای اعلان‌ها */
[aria-live="polite"] {
    position: relative;
}

/* ─── Focus Mode Exit Button ─────────────────────────────── */
.focus-mode-exit-btn {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    z-index: 9998; padding: .65rem 1.6rem; background: var(--gold-500);
    color: #fff; border: none; border-radius: var(--r-pill); font-weight: 700;
    font-size: .85rem; cursor: pointer; box-shadow: var(--shadow-lg);
    transition: all var(--t-fast); display: none; align-items: center; gap: .5rem;
}
.focus-mode-exit-btn:hover {
    background: var(--gold-600); transform: translateX(-50%) translateY(-2px);
}
body.focus-mode .focus-mode-exit-btn { display: inline-flex !important; }

/* ─── حذف کامل Drop Cap ─────────────────────────────────── */
.article-content > p:first-of-type::first-letter,
.article-content p::first-letter {
    all: unset !important;
    font-size: inherit !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    font-weight: inherit !important;
    color: inherit !important;
    text-shadow: none !important;
    background: transparent !important;
}


/* ─────────────────────────────────────────────────────────────
✨ FIX: فاصله‌گذاری بهتر و عرض بیشتر محتوا
═══════════════════════════════════════════════════════════════ */

/* افزایش عرض محتوا از 820px به 960px */
:root {
    --content-max: 960px; /* قبلاً 820px بود */
}

/* Container اصلی - عرض بیشتر */
.articles-container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 2rem 2rem 4rem; /* padding افقی بیشتر */
}

/* Article Card - فاصله‌گذاری بهتر */
.article-card {
    background: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    padding: 3.5rem 2.5rem 3rem; /* padding بیشتر از همه طرف */
    border-bottom: 1px dashed var(--border-medium);
    position: relative;
    animation: articleDocIn .5s var(--ease-out) both;
    scroll-margin-top: 80px;
    transition: background var(--t-base);
}

/* Article Header - فاصله بهتر بین اجزا */
.article-header {
    display: flex;
    align-items: center; /* وسط‌چین عمودی */
    gap: 1.5rem; /* فاصله بیشتر بین اجزا */
    padding: 0 0 2rem 0;
    border-bottom: none;
    background: transparent;
    flex-wrap: wrap;
    margin-bottom: 2rem; /* فاصله بیشتر از بدنه */
}

/* شماره ماده - فاصله بهتر */
.article-number {
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: transparent;
    color: var(--gold-600);
    padding: .45rem 1.1rem; /* padding بیشتر */
    border-radius: var(--r-pill);
    border: 1.5px solid var(--gold-border);
    flex-shrink: 0;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--t-fast);
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

/* عنوان ماده - فضای بیشتر */
.article-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.5;
    letter-spacing: -.015em;
    padding: .25rem 0; /* padding عمودی */
    min-width: 200px; /* حداقل عرض */
}

/* اکشن‌ها - فاصله بهتر */
.article-actions {
    display: flex;
    gap: .5rem; /* فاصله بیشتر بین دکمه‌ها */
    margin-right: auto;
    margin-left: 1rem; /* فاصله از چک‌باکس */
    opacity: .3;
    transition: opacity var(--t-fast);
    padding: .25rem 0;
}

.article-card:hover .article-actions { opacity: 1; }

/* دکمه‌های آیکونی - کمی بزرگ‌تر */
.btn-icon-sm {
    width: 34px; /* قبلاً 30px بود */
    height: 34px;
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    transition: all var(--t-fast);
}

/* چک‌باکس خوانده شد - فاصله بهتر */
.read-checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    background: transparent;
    padding: .45rem 1.1rem; /* padding بیشتر */
    border-radius: var(--r-pill);
    border: 1px solid var(--border-medium);
    transition: all var(--t-fast);
    user-select: none;
    font-size: .75rem;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-left: .5rem; /* فاصله از دکمه‌ها */
}

/* Article Body - فاصله بهتر */
.article-body { 
    padding: 0 1rem; /* padding افقی برای تنفس متن */
}

/* Article Content - فاصله خطوط و پاراگراف‌ها */
.article-content {
    font-size: 1.08rem;
    line-height: 2.3; /* فاصله خطوط بیشتر */
    color: var(--text-primary);
    text-align: justify;
    letter-spacing: 0;
    word-spacing: .03em;
    font-weight: 400;
}

.article-content p {
    margin-bottom: 1.75rem; /* فاصله بیشتر بین پاراگراف‌ها */
    text-indent: 0;
}

.article-content p:last-child { 
    margin-bottom: 0; 
}

/* لیست‌ها - فاصله بهتر */
.article-content ul, 
.article-content ol {
    margin-right: 2rem;
    margin-bottom: 1.75rem;
}

.article-content li {
    margin-bottom: .75rem;
    line-height: 2.2;
}

/* Notes - فاصله بهتر از محتوا */
.article-note {
    margin-top: 2.5rem; /* فاصله بیشتر از متن */
    margin-bottom: 0;
}

/* Article Navigation - فاصله بهتر */
.article-navigation {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5rem 2rem 1.5rem;
    border-top: 1px dashed var(--border-medium);
    margin-top: 3rem;
}

/* ── ریسپانسیو برای موبایل ── */
@media (max-width: 768px) {
    .articles-container {
        padding: 1.5rem 1rem 3rem;
    }
    
    .article-card {
        padding: 2.5rem 1rem 2rem;
    }
    
    .article-header {
        gap: 1rem;
        padding-bottom: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .article-title {
        font-size: 1.15rem;
        min-width: 150px;
    }
    
    .article-actions {
        opacity: 1;
        order: 3;
        width: 100%;
        justify-content: flex-start;
        margin: 1rem 0 0 0;
    }
    
    .read-checkbox {
        margin-left: 0;
    }
    
    .article-body {
        padding: 0;
    }
}

/* ─────────────────────────────────────────────────────────────
✨  CODE BLOCK STYLES (برای <pre> و <code> در مواد قانونی)
═══════════════════════════════════════════════════════════════ */

/* بلاک کد کامل (<pre>) - چپ‌چین برای محتوای انگلیسی */
.article-content pre {
    direction: ltr !important;
    text-align: left !important;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: var(--r-md);
    font-family: 'Fira Code', 'Courier New', 'Consolas', monospace;
    font-size: .88rem;
    line-height: 1.7;
    margin: 1.5rem 0;
    overflow-x: auto;
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
}

/* نوار بالا بلاک کد با آیکون */
.article-content pre::before {
    content: '\f121'; /* آیکون code از Font Awesome */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: .5rem;
    right: .75rem;
    font-size: .85rem;
    color: #64748b;
    opacity: .6;
    pointer-events: none;
}

/* نوار رنگی پایین بلاک کد */
.article-content pre::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        #f59e0b 0%, 
        #10b981 50%, 
        #3b82f6 100%);
    border-radius: 0 0 var(--r-md) var(--r-md);
}

/* کد inline (<code>) داخل پاراگراف */
.article-content code {
    direction: ltr;
    display: inline-block;
    background: var(--bg-elevated);
    color: #d97706;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: .88em;
    border: 1px solid var(--border-light);
    font-weight: 600;
    white-space: nowrap;
}

body.dark-mode .article-content code {
    background: rgba(30, 41, 59, 0.6);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.2);
}

/* کد داخل بلاک کد (<code> داخل <pre>) */
.article-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
    font-weight: 400;
    white-space: pre-wrap;
    display: block;
}

body.dark-mode .article-content pre {
    background: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.1);
}

/* Syntax highlighting پایه برای کلمات کلیدی در بلاک کد */
.article-content pre .keyword   { color: #c084fc; font-weight: 600; }
.article-content pre .string    { color: #86efac; }
.article-content pre .number    { color: #fbbf24; }
.article-content pre .comment   { color: #64748b; font-style: italic; }
.article-content pre .function  { color: #60a5fa; }

/* ریسپانسیو */
@media (max-width: 768px) {
    .article-content pre {
        font-size: .8rem;
        padding: 1rem 1rem 1rem 1rem;
        margin: 1rem 0;
    }
    .article-content pre::before {
        top: .35rem;
        right: .5rem;
        font-size: .75rem;
    }
}

.article-content ul, 
.article-content ol {
    list-style-position: outside;
    margin-right: 2rem;
    margin-bottom: 1.5rem;
    padding-right: .5rem;
}

.article-content ul { list-style-type: disc; }
.article-content ol { list-style-type: decimal; }

.article-content ul ul { list-style-type: circle; }
.article-content ul ul ul { list-style-type: square; }
.article-content ol ol { list-style-type: lower-alpha; }
.article-content ol ol ol { list-style-type: lower-roman; }

.article-content li {
    display: list-item;
    margin-bottom: .55rem;
    line-height: 2.1;
    padding-right: .25rem;
}

.article-content li::marker {
    color: var(--gold-600);
    font-weight: 700;
}

body.dark-mode .article-content li::marker {
    color: var(--gold-400);
}

/* ─────────────────────────────────────────────────────────────
✨  UPDATE BADGE (نشانگر آپدیت اخیر)
═══════════════════════════════════════════════════════════════ */
.update-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .68rem;
    font-weight: 700;
    padding: .28rem .7rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-radius: var(--r-pill);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    animation: updateBadgePop .5s var(--ease-spring) both;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    letter-spacing: .02em;
}

.update-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    animation: updateBadgeShimmer 3s ease-in-out infinite;
}

.update-badge i {
    font-size: .72rem;
    animation: updateBadgePulse 2s ease-in-out infinite;
}

@keyframes updateBadgePop {
    from { opacity: 0; transform: scale(.6) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes updateBadgeShimmer {
    0%, 100% { left: -100%; }
    50%      { left: 100%; }
}

@keyframes updateBadgePulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.2); }
}

/* Dark mode */
body.dark-mode .update-badge {
    background: linear-gradient(135deg, #34d399, #10b981);
    box-shadow: 0 2px 10px rgba(52, 211, 153, 0.4);
}

/* Tooltip هنگام hover */
.update-badge[title] {
    cursor: help;
}

/* Responsive: موبایل */
@media (max-width: 768px) {
    .update-badge {
        font-size: .62rem;
        padding: .22rem .55rem;
    }
    .update-badge i {
        font-size: .65rem;
    }
}

/* Focus mode: Badge رو پنهان نکن (چون مهمه) */
body.focus-mode .update-badge {
    opacity: 1 !important;
}

/* Print: Badge رو چاپ نکن */
@media print {
    .update-badge {
        display: none !important;
    }
}