/* ========================================== */
/* 🎨 Reset + Variables                       */
/* ========================================== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-primary: #07090d;
  --bg-secondary: #0b0f15;
  --bg-tertiary: #101620;
  --bg-elevated: #111720;

  --text-primary: #edf3f8;
  --text-secondary: #9aa8b5;
  --text-tertiary: #5d6975;

  --border-subtle: rgba(255,255,255,.07);
  --border-default: rgba(255,255,255,.11);
  --border-strong: rgba(255,255,255,.18);

  --accent: #62b8ff;
  --accent-hover: #8acaff;
  --accent-soft: rgba(98,184,255,.12);

  --cyan: #39e6ff;
  --blue: #4285ff;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --green: #2ee6a6;
  --yellow: #f6d365;

  --success: #10b981;
  --danger: #f87171;
  --warning: #fbbf24;

  --navbar-bg: rgba(7,9,13,.78);
  --modal-bg: #0c1118;
  --grid-color: rgba(105,160,210,.055);

  --book-bg: rgba(10,15,22,.88);
  --book-bg-hover: rgba(13,20,30,.96);
  --book-border: rgba(112,145,173,.09);
  --book-border-hover: rgba(84,157,215,.32);
}

html:not(.dark) {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  --border-subtle: #e2e8f0;
  --border-default: #cbd5e1;
  --border-strong: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37,99,235,.08);

  --cyan: #0891b2;
  --blue: #2563eb;
  --violet: #7c3aed;
  --pink: #db2777;
  --green: #059669;
  --yellow: #ca8a04;

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

  --navbar-bg: rgba(248,250,252,.88);
  --modal-bg: #ffffff;
  --grid-color: rgba(37,99,235,.05);

  --book-bg: #ffffff;
  --book-bg-hover: #fbfdff;
  --book-border: #e2e8f0;
  --book-border-hover: #93c5fd;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background .3s, color .3s;
  position: relative;
  min-height: 100vh;
  line-height: 1.6;
}

.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ========================================== */
/* 🌌 Background                              */
/* ========================================== */
.bg-decor {
  overflow: hidden;
  pointer-events: none;
}

.grid-pattern {
  background-image:
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse 90% 75% at 50% 15%, #000 10%, transparent 88%);
  -webkit-mask-image: radial-gradient(ellipse 90% 75% at 50% 15%, #000 10%, transparent 88%);
}

.scanlines {
  opacity: .018;
  background: repeating-linear-gradient(
    to bottom,
    #fff 0,
    #fff 1px,
    transparent 1px,
    transparent 5px
  );
}

.mesh-blob { display: none !important; }

/* ========================================== */
/* 🔝 Navbar                                  */
/* ========================================== */
.app-navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navbar-bg);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--border-subtle);
}

html:not(.dark) .app-navbar {
  border-bottom-color: #e2e8f0;
}

.navbar-inner {
  position: relative;
  max-width: 1100px !important;
  height: 58px !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

.brand { text-decoration: none; }

/* ========================================== */
/* ✨ App Logo                                */
/* ========================================== */
.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: transparent;
  border: 1.5px solid var(--accent);
  transition: .25s ease;
  flex-shrink: 0;
}

.app-logo:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.app-logo svg {
  color: var(--accent);
  transition: color .25s ease;
}

.app-logo:hover svg { color: #fff; }

.brand-name {
  font-weight: 750;
  font-size: 14px;
  letter-spacing: -.025em;
}

/* ========================================== */
/* 🔍 Search Button                           */
/* ========================================== */
.search-btn {
  height: 36px;
  min-height: 36px;
  width: 200px;
  padding: 0 12px;
  justify-content: flex-start;
  gap: 8px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  transition: .18s ease;
}

.search-btn svg {
  color: var(--text-tertiary);
  width: 14px;
  height: 14px;
}

.search-btn span { flex: 1; text-align: right; }
.search-btn kbd { display: none; }

.search-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.search-btn:hover svg { color: var(--accent); }

/* ========================================== */
/* 📊 Report Link                             */
/* ========================================== */
.report-link {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  transition: .18s ease;
}

.report-link svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  transition: transform .2s ease;
}

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

.report-link:hover svg { transform: translateY(-1px); }

/* ========================================== */
/* 🎨 Icon Button                             */
/* ========================================== */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: .18s ease;
}

.icon-btn:hover {
  color: var(--accent);
  background: var(--bg-tertiary);
}

/* ========================================== */
/* 🎯 Hero Banner                             */
/* ========================================== */
.hero-banner {
  position: relative;
  width: 100%;
  max-width: 1100px;
  height: 240px;
  min-height: 240px;
  margin: 0 auto 24px;
  padding: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  isolation: isolate;
  background: #070c13;
}

html:not(.dark) .hero-banner {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.hero-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 46%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
  clip-path: polygon(0 0, 100% 0, calc(100% - 50px) 100%, 0 100%);
  content: url('hero-dark.jpg');
}

html:not(.dark) .hero-img { content: url('hero-light.jpg'); }

.hero-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    -90deg,
    rgba(7,12,19,.99) 0%,
    rgba(7,12,19,.96) 42%,
    rgba(7,12,19,.55) 52%,
    rgba(7,12,19,0) 65%
  );
}

html:not(.dark) .hero-banner::after {
  background: linear-gradient(
    -90deg,
    rgba(248,250,252,.99) 0%,
    rgba(248,250,252,.96) 42%,
    rgba(248,250,252,.55) 52%,
    rgba(248,250,252,0) 65%
  );
}

.hero-line {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 47%;
  width: 2px;
  height: 120%;
  z-index: 3;
  transform: translateX(-50%) skewX(-10deg);
  transform-origin: center;
  background: linear-gradient(
    180deg,
    transparent 0%,
    #06b6d4 15%,
    #477cff 35%,
    #a855f7 55%,
    #ec4899 75%,
    #06b6d4 95%,
    transparent 100%
  );
  background-size: 100% 220%;
  animation: heroLineV 6s linear infinite;
  box-shadow: 0 0 8px rgba(57,230,255,.5);
  pointer-events: none;
}

@keyframes heroLineV {
  0% { background-position: 50% 0%; }
  100% { background-position: 50% 220%; }
}

.hero-content {
  position: absolute;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  z-index: 2;
  width: auto;
  max-width: 45%;
  padding: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.hero-title {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 11px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.04em;
  color: #f5f8fb;
  flex-direction: row-reverse;
}

html:not(.dark) .hero-title { color: #0f172a; }

.hero-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  box-shadow: none;
  flex-shrink: 0;
}

.hero-icon svg { color: var(--accent); }

.hero-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(226,235,243,.65);
  text-align: right;
}

html:not(.dark) .hero-subtitle { color: #475569; }

/* ========================================== */
/* 📚 Book List                               */
/* ========================================== */
#subjects-list {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  height: 68px;
  padding: 12px 16px 12px 18px;
  overflow: hidden;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--book-border);
  background: var(--book-bg);
  backdrop-filter: blur(8px);
  transition: .25s cubic-bezier(.16,1,.3,1);
  text-decoration: none;
}

.book-row::after {
  content: '';
  position: absolute;
  right: 9px;
  left: 9px;
  bottom: 0;
  height: 1.5px;
  background: linear-gradient(90deg, #06b6d4, #477cff, #8b5cf6, #ec4899, #f6d365, #2ee6a6, #06b6d4);
  background-size: 480% 100%;
  animation: neonFlow 7s linear infinite;
  box-shadow: 0 0 6px rgba(57,230,255,.4);
  border-radius: 999px;
  opacity: .75;
}

@keyframes neonFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 480% 50%; }
}

.book-row:nth-child(1)::after { animation-duration: 7s; }
.book-row:nth-child(2)::after { animation-duration: 8.5s; animation-direction: reverse; }
.book-row:nth-child(3)::after { animation-duration: 6.3s; animation-delay: -2s; }
.book-row:nth-child(4)::after { animation-duration: 9.5s; animation-direction: reverse; animation-delay: -3s; }
.book-row:nth-child(5)::after { animation-duration: 7.7s; animation-delay: -1s; }
.book-row:nth-child(6)::after { animation-duration: 10s; animation-direction: reverse; animation-delay: -4s; }

.book-row:hover {
  transform: translateY(-1px);
  border-color: var(--book-border-hover);
  background: var(--book-bg-hover);
  box-shadow: 0 4px 12px -8px rgba(0,0,0,.4);
}

html:not(.dark) .book-row:hover {
  box-shadow: 0 4px 12px -8px rgba(37,99,235,.15);
}

.book-row:hover::after {
  height: 2px;
  opacity: 1;
  box-shadow: 0 0 10px rgba(57,230,255,.6);
}

.book-arrow-circle {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border: 1.5px solid var(--border-default);
  background: transparent;
  transition: .22s ease;
}

.book-row:hover .book-arrow-circle {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateX(-3px);
}

.book-arrow-circle svg { width: 15px; height: 15px; }

.book-number {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border: 1.5px solid var(--border-default);
  background: transparent;
  font: 500 10px 'JetBrains Mono', monospace;
  letter-spacing: .04em;
  transition: .22s ease;
}

.book-row:hover .book-number {
  color: var(--accent);
  border-color: var(--accent);
}

/* ========================================== */
/* 🃏 Card                                    */
/* ========================================== */
.card {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-secondary);
  transition: .22s ease;
  box-shadow: none;
}

html:not(.dark) .card {
  background: #ffffff;
  border-color: #e2e8f0;
}

.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

html:not(.dark) .card-hover:hover {
  border-color: var(--accent);
}

.card-icon-box {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover .card-icon-box,
.card-hover:hover .card-icon-box {
  transform: scale(1.08) rotate(-4deg);
}

/* ========================================== */
/* 🔘 Buttons                                 */
/* ========================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: 0;
  border-radius: 5px;
  color: #fff !important;
  background: linear-gradient(135deg, #287fff, #714cff);
  font: 600 13px 'Vazirmatn', inherit;
  cursor: pointer;
  transition: .2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -6px rgba(72,117,255,.5);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 5px;
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: .18s ease;
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

/* ========================================== */
/* 📑 Admin Tabs                              */
/* ========================================== */
.admin-tab {
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: .18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.admin-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-tab.active {
  color: #fff !important;
  background: linear-gradient(135deg, #287fff, #714cff);
}

/* ========================================== */
/* 🪟 Modal — با اسکرول درست                  */
/* ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,5,9,.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

html:not(.dark) .modal-overlay {
  background: rgba(15,23,42,.3);
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.4);
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  margin: auto;
}

html:not(.dark) .modal-content {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 60px -20px rgba(15,23,42,.15);
}

.modal-content > h3 {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  margin: 0;
}

.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding: 20px 22px;
  min-height: 0;
}

.modal-content > .flex.justify-end {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ========================================== */
/* 📝 Forms                                   */
/* ========================================== */
html body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]),
html body textarea,
html body select {
  width: 100% !important;
  padding: 10px 13px !important;
  font-size: 14px !important;
  font-family: 'Vazirmatn', sans-serif !important;
  border-radius: 5px !important;
  border: 1px solid var(--border-default) !important;
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  outline: none !important;
  box-shadow: none !important;
}

html body input::placeholder,
html body textarea::placeholder {
  color: var(--text-tertiary) !important;
  opacity: 1 !important;
}

html body input:focus,
html body textarea:focus,
html body select:focus {
  border-color: var(--accent) !important;
}

html body select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 12px center !important;
  background-size: 16px !important;
  padding-left: 40px !important;
  cursor: pointer !important;
}

html body input[type=number]::-webkit-inner-spin-button,
html body input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

html body input[type=number] { -moz-appearance: textfield !important; }

/* ========================================== */
/* 📋 Command Palette                         */
/* ========================================== */
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  margin: 0 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.cmd-item:hover,
.cmd-item.active { background: var(--accent-soft); }

/* ========================================== */
/* 🔍 Command Palette Overlay                 */
/* ========================================== */
.cmd-palette-overlay {
  background: rgba(2, 5, 9, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
  padding: 16px;
}

html:not(.dark) .cmd-palette-overlay {
  background: rgba(15, 23, 42, 0.4);
}

@media (max-width: 640px) {
  .cmd-palette-overlay {
    padding: 8px;
  }
}

/* ========================================== */
/* 👣 Footer                                  */
/* ========================================== */
.footer { border-top: 1px solid var(--border-subtle); }

.footer-logo {
  width: 23px;
  height: 23px;
  border-radius: 4px;
  background: transparent;
  border: 1.5px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.footer-logo svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

.footer-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.footer-sub {
  margin-top: 2px;
  color: var(--text-tertiary);
  font: 8px 'JetBrains Mono', monospace;
  letter-spacing: .1em;
}

.version { color: var(--text-tertiary); }

/* ========================================== */
/* ⏳ Spinner                                 */
/* ========================================== */
.spinner {
  width: 20px;
  height: 20px;
  display: inline-block;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.spinner-lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in { animation: fadeIn .25s ease-out both; }
.slide-up { animation: slideUp .35s cubic-bezier(.16,1,.3,1) both; }

.shake { animation: shake .3s ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ========================================== */
/* 🖼️ Note Image                              */
/* ========================================== */
.note-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

/* ========================================== */
/* 📜 Scrollbar                               */
/* ========================================== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #26313c;
  border-radius: 5px;
}

html:not(.dark) ::-webkit-scrollbar-thumb { background: #c8d1dc; }

::-webkit-scrollbar-thumb:hover { background: #3c4d5d; }

button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

[data-lucide] {
  display: inline-block;
  vertical-align: middle;
}

::selection {
  background: rgba(57,230,255,.16);
  color: inherit;
}

html:not(.dark) ::selection {
  background: rgba(37,99,235,.15);
}

/* ========================================== */
/* 🔍 Lightbox                                */
/* ========================================== */
img.note-image,
img.hero-img {
  cursor: zoom-in;
  transition: opacity 0.2s;
}

img.note-image:hover,
img.hero-img:hover { opacity: 0.9; }

/* ========================================== */
/* 🖱️ Context Menu                            */
/* ========================================== */
#context-menu {
  position: fixed;
  z-index: 99998;
  min-width: 200px;
  padding: 6px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 16px 40px -12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
  transform-origin: top right;
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
  direction: rtl;
  font-family: 'Vazirmatn', sans-serif;
}

html.dark #context-menu {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 16px 40px -12px rgba(0, 0, 0, 0.6);
}

#context-menu.show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.cm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.cm-item:hover { background: var(--bg-tertiary); }

.cm-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cm-item:hover svg { color: var(--accent); }

.cm-separator {
  height: 1px;
  margin: 4px 6px;
  background: var(--border-subtle);
}

.cm-item .cm-shortcut {
  margin-right: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-tertiary);
  direction: ltr;
}

/* ========================================== */
/* 📊 Tables + table-wrap                     */
/* ========================================== */
.note-content table,
.ql-editor table,
.reading-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
}

/* Wrapper برای اسکرول افقی جدول */
.note-content .table-wrap,
.reading-content .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  padding-bottom: 6px;
  border-radius: 8px;
}

.note-content .table-wrap table,
.reading-content .table-wrap table {
  margin: 0;
  min-width: 100%;
  width: auto;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .note-content .table-wrap table,
  .reading-content .table-wrap table {
    white-space: normal;
    width: 100%;
  }
}

.note-content thead,
.ql-editor thead,
.reading-content thead {
  background: var(--bg-tertiary);
}

.note-content th,
.ql-editor th,
.reading-content th {
  padding: 10px 12px;
  text-align: right;
  font-weight: 700;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  background: var(--bg-tertiary);
  font-size: 13px;
}

.note-content td,
.ql-editor td,
.reading-content td {
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.note-content tbody tr:nth-child(even),
.ql-editor tbody tr:nth-child(even),
.reading-content tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

html:not(.dark) .note-content tbody tr:nth-child(even),
html:not(.dark) .ql-editor tbody tr:nth-child(even),
html:not(.dark) .reading-content tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.note-content tbody tr:hover,
.ql-editor tbody tr:hover,
.reading-content tbody tr:hover {
  background: var(--accent-soft);
}

/* ========================================== */
/* 📐 Quill Full Formatting Support           */
/* ========================================== */

/* --- Alignment (Quill Editor) --- */
.ql-editor .ql-align-center { text-align: center !important; }
.ql-editor .ql-align-right { text-align: right !important; }
.ql-editor .ql-align-left { text-align: left !important; }
.ql-editor .ql-align-justify { text-align: justify !important; }

/* --- Alignment (Site) --- */
.note-content .ql-align-center,
.note-content .ql-align-center *,
.reading-content .ql-align-center,
.reading-content .ql-align-center * {
  text-align: center !important;
}

.note-content .ql-align-right,
.note-content .ql-align-right *,
.reading-content .ql-align-right,
.reading-content .ql-align-right * {
  text-align: right !important;
}

.note-content .ql-align-left,
.note-content .ql-align-left *,
.reading-content .ql-align-left,
.reading-content .ql-align-left * {
  text-align: left !important;
}

.note-content .ql-align-justify,
.note-content .ql-align-justify *,
.reading-content .ql-align-justify,
.reading-content .ql-align-justify * {
  text-align: justify !important;
}

/* --- Inline Style fallback --- */
.note-content [style*="text-align: center"],
.note-content [style*="text-align:center"],
.reading-content [style*="text-align: center"],
.reading-content [style*="text-align:center"] {
  text-align: center !important;
}

.note-content [style*="text-align: right"],
.note-content [style*="text-align:right"],
.reading-content [style*="text-align: right"],
.reading-content [style*="text-align:right"] {
  text-align: right !important;
}

.note-content [style*="text-align: left"],
.note-content [style*="text-align:left"],
.reading-content [style*="text-align: left"],
.reading-content [style*="text-align:left"] {
  text-align: left !important;
}

.note-content [style*="text-align: justify"],
.note-content [style*="text-align:justify"],
.reading-content [style*="text-align: justify"],
.reading-content [style*="text-align:justify"] {
  text-align: justify !important;
}

/* --- Font Sizes --- */
.ql-editor .ql-size-small { font-size: 0.75em !important; }
.ql-editor .ql-size-large { font-size: 1.5em !important; }
.ql-editor .ql-size-huge { font-size: 2.5em !important; }

.note-content .ql-size-small,
.reading-content .ql-size-small {
  font-size: 0.75em !important;
}

.note-content .ql-size-large,
.reading-content .ql-size-large {
  font-size: 1.5em !important;
}

.note-content .ql-size-huge,
.reading-content .ql-size-huge {
  font-size: 2.5em !important;
}

/* --- Headers --- */
.ql-editor h1, .note-content h1, .reading-content h1 {
  font-size: 2em !important;
  font-weight: 700 !important;
  margin: 0.67em 0 !important;
  line-height: 1.3 !important;
}

.ql-editor h2, .note-content h2, .reading-content h2 {
  font-size: 1.5em !important;
  font-weight: 700 !important;
  margin: 0.75em 0 !important;
  line-height: 1.3 !important;
}

.ql-editor h3, .note-content h3, .reading-content h3 {
  font-size: 1.17em !important;
  font-weight: 700 !important;
  margin: 0.83em 0 !important;
  line-height: 1.3 !important;
}

.ql-editor h4, .note-content h4, .reading-content h4 {
  font-size: 1em !important;
  font-weight: 700 !important;
  margin: 1em 0 !important;
}

.ql-editor h5, .note-content h5, .reading-content h5 {
  font-size: 0.83em !important;
  font-weight: 700 !important;
  margin: 1.17em 0 !important;
}

.ql-editor h6, .note-content h6, .reading-content h6 {
  font-size: 0.67em !important;
  font-weight: 700 !important;
  margin: 1.5em 0 !important;
}

/* --- Bold / Italic / Underline / Strike --- */
.ql-editor strong,
.note-content strong,
.reading-content strong {
  font-weight: 700 !important;
}

.ql-editor em,
.note-content em,
.reading-content em {
  font-style: italic !important;
}

.ql-editor u,
.note-content u,
.reading-content u {
  text-decoration: underline !important;
}

.ql-editor s,
.note-content s,
.reading-content s {
  text-decoration: line-through !important;
  opacity: 0.7;
}

/* --- Lists --- */
.ql-editor ul,
.note-content ul,
.reading-content ul {
  padding-right: 24px !important;
  margin: 12px 0 !important;
  list-style: disc !important;
}

.ql-editor ol,
.note-content ol,
.reading-content ol {
  padding-right: 24px !important;
  margin: 12px 0 !important;
  list-style: decimal !important;
}

.ql-editor li,
.note-content li,
.reading-content li {
  margin-bottom: 6px;
  line-height: 1.8;
}

/* --- Blockquote --- */
.ql-editor blockquote,
.note-content blockquote,
.reading-content blockquote {
  border-right: 4px solid var(--accent) !important;
  padding: 8px 16px !important;
  margin: 16px 0 !important;
  color: var(--text-tertiary) !important;
  font-style: italic !important;
  background: var(--bg-tertiary) !important;
  border-radius: 0 8px 8px 0 !important;
}

/* --- Code --- */
.ql-editor pre.ql-syntax,
.note-content pre,
.reading-content pre {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  overflow-x: auto !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 13px !important;
  margin: 16px 0 !important;
  direction: ltr !important;
  text-align: left !important;
  color: var(--text-primary) !important;
}

.ql-editor code,
.note-content code,
.reading-content code {
  background: var(--bg-tertiary) !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 0.9em !important;
  direction: ltr !important;
  color: var(--text-primary) !important;
}

/* --- Links --- */
.ql-editor a,
.note-content a,
.reading-content a {
  color: var(--accent) !important;
  text-decoration: underline !important;
}

/* --- Indent --- */
.ql-editor .ql-indent-1:not(.ql-direction-rtl) { padding-left: 3em; }
.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right { padding-right: 3em; }
.ql-editor .ql-indent-2:not(.ql-direction-rtl) { padding-left: 6em; }
.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right { padding-right: 6em; }
.ql-editor .ql-indent-3:not(.ql-direction-rtl) { padding-left: 9em; }
.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right { padding-right: 9em; }

/* ========================================== */
/* 📥 Drag & Drop                             */
/* ========================================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 5, 9, 0.9);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  pointer-events: none;
  padding: 16px;
}

.drop-overlay-inner {
  border: 3px dashed var(--accent);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  background: var(--bg-secondary);
  animation: slideUp 0.3s ease;
  max-width: 90vw;
}

.drop-overlay-inner svg {
  width: 56px;
  height: 56px;
  color: var(--accent);
  margin-bottom: 16px;
}

.drop-overlay-inner h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.drop-overlay-inner p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========================================== */
/* 📊 Table Editor Panel                      */
/* ========================================== */
#table-editor-panel {
  position: fixed;
  z-index: 99997;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
}

#table-editor-panel.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tep-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.tep-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.tep-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.tep-sep {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
  flex-shrink: 0;
}

.tep-btn svg {
  width: 15px;
  height: 15px;
}

/* ========================================== */
/* 📖 Reading Mode                            */
/* ========================================== */

body.reading-mode .app-navbar,
body.reading-mode footer.footer,
body.reading-mode #cmd-palette {
  display: none !important;
}

body.reading-mode {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
}

body.reading-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: -1;
  pointer-events: none;
}

body.reading-mode main#app {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
  min-height: 100vh;
}

.reading-exit-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
  backdrop-filter: blur(12px);
}

.reading-exit-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--danger);
  color: var(--danger);
  transform: translateY(-2px);
}

.reading-exit-btn svg {
  width: 16px;
  height: 16px;
}

.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 10000;
  pointer-events: none;
}

.reading-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
  transition: width 0.1s ease;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

.reading-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px 120px;
  animation: readingFadeIn 0.4s ease-out;
  position: relative;
  z-index: 1;
}

@keyframes readingFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reading-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1.3;
}

.reading-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}

.reading-meta-badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.reading-content {
  font-size: 18px;
  line-height: 1.9;
  color: var(--text-secondary);
}

.reading-content.reading-size-s { font-size: 16px; }
.reading-content.reading-size-m { font-size: 18px; }
.reading-content.reading-size-l { font-size: 21px; }
.reading-content.reading-size-xl { font-size: 24px; }

.reading-content h1,
.reading-content h2,
.reading-content h3,
.reading-content h4 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.4;
  margin: 32px 0 16px;
}

.reading-content h1 { font-size: 1.6em; }
.reading-content h2 { font-size: 1.4em; }
.reading-content h3 { font-size: 1.2em; }
.reading-content h4 { font-size: 1.05em; }

.reading-content p {
  margin: 0 0 20px;
}

.reading-content ul,
.reading-content ol {
  padding-right: 30px;
  margin: 0 0 20px;
}

.reading-content li {
  margin-bottom: 8px;
}

.reading-content blockquote {
  border-right: 4px solid var(--accent);
  padding: 4px 20px;
  margin: 24px 0;
  color: var(--text-tertiary);
  font-style: italic;
  background: var(--bg-tertiary);
  border-radius: 0 8px 8px 0;
}

.reading-content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8em;
  margin: 20px 0;
  direction: ltr;
  text-align: left;
}

.reading-content code {
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  direction: ltr;
}

.reading-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 24px 0;
  display: block;
}

.reading-toolbar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  animation: slideUp 0.3s ease-out;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
}

.reading-tool-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.reading-tool-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.reading-tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.reading-tool-btn svg {
  width: 18px;
  height: 18px;
}

.read-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.read-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.read-btn svg {
  width: 14px;
  height: 14px;
}

html:not(.dark) .reading-exit-btn,
html:not(.dark) .reading-toolbar {
  background: rgba(255, 255, 255, 0.95);
}

/* ========================================== */
/* 📤 Share Modal                             */
/* ========================================== */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.share-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.share-btn svg {
  width: 14px;
  height: 14px;
}

.share-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(2, 5, 9, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: shareFadeIn 0.2s ease-out;
  overflow-y: auto;
}

html:not(.dark) .share-modal-overlay {
  background: rgba(15, 23, 42, 0.4);
}

@keyframes shareFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.share-modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: shareSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  margin: auto;
}

html:not(.dark) .share-modal {
  box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.2);
}

@keyframes shareSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.share-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.share-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
}

.share-modal-title > div { min-width: 0; }

.share-modal-title > div > div:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-modal-title-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  flex-shrink: 0;
}

.share-modal-title-icon svg {
  width: 18px;
  height: 18px;
}

.share-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.share-modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.share-modal-close svg {
  width: 16px;
  height: 16px;
}

.share-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.share-modal-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.share-link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.share-link-input {
  flex: 1;
  padding: 10px 14px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 12px !important;
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: 8px !important;
  color: var(--text-secondary) !important;
  direction: ltr !important;
  text-align: left !important;
  outline: none !important;
  min-width: 0;
}

.share-link-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}

.share-link-copy:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(99, 102, 241, 0.5);
}

.share-link-copy:active { transform: translateY(0); }

.share-link-copy svg {
  width: 14px;
  height: 14px;
}

.share-link-copy.copied {
  background: linear-gradient(135deg, #10b981, #059669);
}

.share-socials {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .share-socials { grid-template-columns: repeat(4, 1fr); }
}

.share-social-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}

.share-social-btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-default);
  background: var(--bg-tertiary);
}

.share-social-btn .share-social-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.share-social-btn .share-social-icon svg {
  width: 18px;
  height: 18px;
}

.share-social-btn[data-network="telegram"] .share-social-icon {
  background: linear-gradient(135deg, #0088cc, #00a3e0);
}
.share-social-btn[data-network="telegram"]:hover {
  border-color: #0088cc;
  color: #0088cc;
}

.share-social-btn[data-network="whatsapp"] .share-social-icon {
  background: linear-gradient(135deg, #25D366, #128C7E);
}
.share-social-btn[data-network="whatsapp"]:hover {
  border-color: #25D366;
  color: #25D366;
}

.share-social-btn[data-network="twitter"] .share-social-icon {
  background: linear-gradient(135deg, #1DA1F2, #0d8bd9);
}
.share-social-btn[data-network="twitter"]:hover {
  border-color: #1DA1F2;
  color: #1DA1F2;
}

.share-social-btn[data-network="native"] .share-social-icon {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.share-social-btn[data-network="native"]:hover {
  border-color: #6366f1;
  color: #6366f1;
}

/* ========================================== */
/* 🛡️ Secure Exam Mode                        */
/* ========================================== */
body.secure-exam-mode {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

body.secure-exam-mode input,
body.secure-exam-mode textarea {
  user-select: text !important;
  -webkit-user-select: text !important;
}

body.secure-exam-mode img {
  pointer-events: none;
  -webkit-user-drag: none;
}

#violation-warning {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 99999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

#violation-warning.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.violation-warning-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  box-shadow: 0 20px 60px -12px rgba(220, 38, 38, 0.6),
              0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  animation: violationShake 0.5s ease-in-out;
  min-width: 280px;
  max-width: 100%;
}

@keyframes violationShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.violation-warning-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.violation-warning-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.violation-warning-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
  margin-bottom: 2px;
}

.violation-warning-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.violation-warning-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  margin-right: auto;
  flex-shrink: 0;
}

.violation-warning-count span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.violation-warning-count small {
  font-size: 9px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.violation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.15);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(220, 38, 38, 0.3);
  animation: violationPulse 2s ease-in-out infinite;
  white-space: nowrap;
}

@keyframes violationPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.violations-card {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
}

.violations-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 12px;
}

.violations-card-header svg {
  width: 16px;
  height: 16px;
}

.violations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.violation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.violation-item-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-right: auto;
  direction: ltr;
}

/* ========================================== */
/* ✍️ Quill Toolbar                           */
/* ========================================== */
.ql-toolbar {
  border-radius: 8px 8px 0 0 !important;
  border-color: var(--border-default) !important;
  background: var(--bg-tertiary) !important;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.ql-container {
  border-radius: 0 0 8px 8px !important;
  border-color: var(--border-default) !important;
  font-family: 'Vazirmatn', sans-serif !important;
  font-size: 15px !important;
  background: var(--bg-secondary);
}

.ql-editor {
  min-height: 200px;
  line-height: 1.9 !important;
  direction: rtl;
  text-align: right;
  font-family: 'Vazirmatn', sans-serif !important;
}

.ql-editor.ql-blank::before {
  color: var(--text-tertiary) !important;
  font-style: normal !important;
}

html.dark .ql-toolbar {
  background: var(--bg-tertiary) !important;
}

html.dark .ql-container {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

html.dark .ql-editor { color: var(--text-primary); }

html.dark .ql-snow .ql-stroke { stroke: #9aa8b5 !important; }
html.dark .ql-snow .ql-fill { fill: #9aa8b5 !important; }
html.dark .ql-snow .ql-picker { color: #9aa8b5 !important; }

html.dark .ql-snow .ql-picker-options {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-default) !important;
}

html.dark .ql-snow .ql-active .ql-stroke,
html.dark .ql-snow .ql-active .ql-fill {
  stroke: #62b8ff !important;
  fill: #62b8ff !important;
}

html.dark .ql-snow .ql-active .ql-picker-label {
  color: #62b8ff !important;
}

html.dark .ql-snow .ql-tooltip {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  z-index: 10000;
}

html.dark .ql-snow .ql-tooltip input[type="text"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}

/* ========================================== */
/* 📱 Responsive — Tablet (≤ 900px)           */
/* ========================================== */
@media (max-width: 900px) {
  main {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .navbar-inner {
    height: 54px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .search-btn {
    width: 160px;
    height: 34px;
    min-height: 34px;
  }

  .hero-banner {
    height: 180px;
    min-height: 180px;
  }

  .hero-img {
    width: 50%;
    clip-path: polygon(0 0, 100% 0, calc(100% - 30px) 100%, 0 100%);
    content: url('hero-dark-mobile.jpg');
  }

  html:not(.dark) .hero-img {
    content: url('hero-light-mobile.jpg');
  }

  .hero-line { left: 47%; }

  .hero-content {
    right: 20px;
    max-width: 48%;
  }

  .hero-title {
    font-size: 22px;
    gap: 8px;
  }

  .hero-icon {
    width: 34px;
    height: 34px;
  }

  .hero-subtitle {
    font-size: 11px;
    line-height: 1.7;
  }

  .reading-container {
    padding: 90px 20px 110px;
  }

  .reading-title { font-size: 26px; }
  .reading-content { font-size: 16px; }

  .modal-content {
    max-width: calc(100vw - 32px);
  }
}

/* ========================================== */
/* 📱 Responsive — Mobile (≤ 640px)           */
/* ========================================== */
@media (max-width: 640px) {
  body { font-size: 14px; }

  .navbar-inner {
    height: 52px !important;
    padding: 0 10px !important;
    gap: 8px !important;
  }

  .brand-name { font-size: 13px; }

  .search-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
    justify-content: center;
  }

  .search-btn span,
  .search-btn kbd { display: none; }

  .search-btn svg {
    width: 16px;
    height: 16px;
  }

  .report-link {
    padding: 0 8px;
    font-size: 11px;
  }

  .report-link span { display: none; }

  .hero-banner {
    height: 140px;
    min-height: 140px;
    border-radius: 6px;
  }

  .hero-img {
    width: 42%;
    clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%);
  }

  .hero-line { left: 44%; }

  .hero-content {
    right: 12px;
    max-width: 55%;
  }

  .hero-title {
    font-size: 18px;
    gap: 6px;
    margin-bottom: 6px;
  }

  .hero-icon {
    width: 28px;
    height: 28px;
    border-radius: 5px;
  }

  .hero-icon svg { width: 16px; height: 16px; }

  .hero-subtitle {
    font-size: 10px;
    line-height: 1.5;
  }

  .book-row {
    height: auto;
    min-height: 60px;
    padding: 10px 12px;
    gap: 10px;
  }

  .book-arrow-circle,
  .book-number {
    width: 30px;
    height: 30px;
  }

  .book-arrow-circle svg { width: 13px; height: 13px; }

  .book-number { font-size: 9px; }

  .card { border-radius: 5px; }

  .btn-primary,
  .btn-secondary {
    padding: 9px 14px;
    font-size: 12px;
  }

  /* Admin Tabs */
  .flex.gap-1\.5.mb-8 {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    margin-bottom: 20px !important;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
    scrollbar-width: thin;
  }

  .admin-tab {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* Modal */
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-content {
    max-height: calc(100vh - 16px);
    border-radius: 12px 12px 0 0;
    max-width: 100%;
  }

  .modal-content > h3 {
    padding: 14px 16px;
    font-size: 14px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-content > .flex.justify-end {
    padding: 12px 16px;
  }

  /* Tables */
  .note-content table,
  .ql-editor table,
  .reading-content table {
    font-size: 12px;
  }

  .note-content th,
  .note-content td,
  .ql-editor th,
  .ql-editor td,
  .reading-content th,
  .reading-content td {
    padding: 8px 10px;
  }

  /* Reading Mode */
  .reading-container {
    padding: 70px 16px 100px;
  }

  .reading-title {
    font-size: 22px;
    margin-bottom: 14px;
  }

  .reading-meta {
    font-size: 11px;
    margin-bottom: 24px;
    padding-bottom: 16px;
  }

  .reading-content {
    font-size: 15px;
  }

  .reading-content.reading-size-s { font-size: 14px; }
  .reading-content.reading-size-m { font-size: 15px; }
  .reading-content.reading-size-l { font-size: 17px; }
  .reading-content.reading-size-xl { font-size: 20px; }

  .reading-exit-btn {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 8px;
  }

  .reading-toolbar {
    bottom: 12px;
    right: 12px;
    left: 12px;
    padding: 4px;
    gap: 2px;
    justify-content: center;
    max-width: none;
  }

  .reading-tool-btn {
    width: 36px;
    height: 36px;
  }

  .reading-tool-btn svg { width: 16px; height: 16px; }

  /* Share Modal */
  .share-modal-overlay { padding: 10px; }

  .share-modal {
    border-radius: 14px;
    max-height: calc(100vh - 20px);
  }

  .share-modal-header { padding: 14px 16px; }
  .share-modal-body { padding: 16px; }
  .share-modal-title { font-size: 14px; }
  .share-modal-title-icon { width: 32px; height: 32px; }

  .share-link-box {
    flex-direction: column;
  }

  .share-link-copy {
    justify-content: center;
  }

  .share-socials {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Violation Warning */
  #violation-warning { top: 10px; max-width: calc(100vw - 20px); }

  .violation-warning-inner {
    padding: 10px 14px;
    gap: 10px;
    border-radius: 12px;
    min-width: 0;
  }

  .violation-warning-icon { width: 32px; height: 32px; }
  .violation-warning-icon svg { width: 18px; height: 18px; }
  .violation-warning-text { font-size: 12px; }

  .violation-warning-count { padding: 4px 8px; }
  .violation-warning-count span { font-size: 16px; }

  /* Table Editor Panel */
  #table-editor-panel {
    padding: 4px;
    gap: 2px;
  }

  .tep-btn {
    width: 30px;
    height: 30px;
  }

  .tep-btn svg { width: 13px; height: 13px; }

  /* Footer */
  .footer {
    padding: 20px 14px !important;
    margin-top: 30px !important;
  }

  .footer-title { font-size: 12px; }
  .footer-sub { font-size: 8px; }
  .version { font-size: 10px; }

  /* Quill Toolbar */
  .ql-toolbar {
    padding: 4px !important;
    gap: 0;
  }

  .ql-toolbar .ql-formats {
    margin-right: 4px !important;
    margin-left: 4px !important;
  }

  .ql-editor {
    min-height: 150px;
  }

  /* Drop Overlay */
  .drop-overlay-inner {
    padding: 30px 20px;
    max-width: 90vw;
  }

  .drop-overlay-inner svg {
    width: 44px;
    height: 44px;
  }

  .drop-overlay-inner h3 { font-size: 15px; }
  .drop-overlay-inner p { font-size: 12px; }

  .note-image { max-height: 300px; }
}

/* ========================================== */
/* 📱 Responsive — Small Mobile (≤ 380px)     */
/* ========================================== */
@media (max-width: 380px) {
  .navbar-inner {
    height: 48px !important;
    padding: 0 8px !important;
  }

  .brand-name { font-size: 12px; }

  .hero-banner {
    height: 120px;
    min-height: 120px;
  }

  .hero-title { font-size: 15px; }
  .hero-icon { width: 24px; height: 24px; }
  .hero-subtitle { font-size: 9px; }

  .book-row {
    min-height: 54px;
    padding: 8px 10px;
  }

  .book-arrow-circle,
  .book-number {
    width: 28px;
    height: 28px;
  }

  .card { border-radius: 4px; }

  .modal-content > h3 { font-size: 13px; }

  .reading-tool-btn {
    width: 32px;
    height: 32px;
  }

  .reading-title { font-size: 20px; }
  .reading-content { font-size: 14px; }
}

/* ========================================== */
/* 🖨️ Print — فشرده و بهینه                   */
/* ========================================== */
@media print {
  /* ====== مخفی کردن المان‌های غیرضروری ====== */
  .share-modal-overlay,
  .share-btn,
  .read-btn,
  .reading-exit-btn,
  .reading-toolbar,
  .reading-progress-bar,
  .app-navbar,
  .footer,
  #context-menu,
  .drop-overlay,
  .controls,
  #cmd-btn,
  #theme-toggle,
  .report-link,
  .bg-decor,
  #confetti-canvas,
  #loading-screen,
  .q-icon,
  .video-card,
  .video-lazy-container {
    display: none !important;
  }

  /* ====== صفحه کاغذ ====== */
  @page {
    margin: 0.8cm;
    size: A4;
  }

  /* ====== بدنه ====== */
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
  }

  main, .container, #app, .max-w-6xl, .max-w-2xl {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ====== کارت‌ها بدون سایه و حاشیه اضافه ====== */
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    padding: 8px !important;
    margin-bottom: 6px !important;
    border-radius: 4px !important;
  }

  /* ====== هر سوال و جوابش با هم در یک صفحه ====== */
  .q-item {
    margin-bottom: 4px !important;
    padding-bottom: 4px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* ====== متن سوال — فشرده و کوچک ====== */
  .q-item .note-content,
  .q-btn {
    font-size: 11px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    padding: 2px 0 !important;
  }

  .q-btn {
    padding: 4px 0 !important;
  }

  /* ====== پاسخ — همیشه باز و فشرده ====== */
  .q-answer {
    display: block !important;
    font-size: 10.5px !important;
    line-height: 1.5 !important;
    padding: 2px 10px 2px 0 !important;
    margin-top: 2px !important;
  }

  .q-answer .note-content {
    font-size: 10.5px !important;
    line-height: 1.5 !important;
  }

  /* ====== عکس داخل سوال — کوچک ====== */
  .q-item img.note-image {
    max-height: 180px !important;
    margin: 4px 0 !important;
  }

  /* ====== حفظ ترازبندی ====== */
  .reading-content .ql-align-center,
  .note-content .ql-align-center { text-align: center !important; }
  .reading-content .ql-align-right,
  .note-content .ql-align-right { text-align: right !important; }
  .reading-content .ql-align-left,
  .note-content .ql-align-left { text-align: left !important; }
  .reading-content .ql-align-justify,
  .note-content .ql-align-justify { text-align: justify !important; }

  /* ====== در حالت مطالعه هم همینطور ====== */
  body.reading-mode::before { display: none; }
  body.reading-mode .app-navbar,
  body.reading-mode .footer { display: none !important; }

  /* ====== حذف فاصله‌های اضافی لیست‌ها ====== */
  ul, ol {
    margin: 4px 0 !important;
    padding-right: 18px !important;
  }
  li {
    margin-bottom: 2px !important;
    line-height: 1.5 !important;
  }

  /* ====== جدول‌ها کوچک و فشرده ====== */
  table {
    font-size: 10px !important;
    margin: 4px 0 !important;
  }
  th, td {
    padding: 3px 5px !important;
    line-height: 1.4 !important;
  }

  /* ====== جلوگیری از شکستن پاراگراف‌ها ====== */
  p, h1, h2, h3, h4, h5, h6 {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* ====== لینک‌ها ====== */
  a {
    color: #000 !important;
    text-decoration: none !important;
  }
}

/* ========================================== */
/* ♿ Reduced Motion                          */
/* ========================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/*
  راه توسعه — اصلاحات فقط برای موبایل
  این فایل را در انتهای style.css فعلی اضافه کنید.
  خارج از عرض 640px هیچ استایلی تغییر نمی‌کند.
*/
@media (max-width: 640px) {
  /* جلوگیری از بیرون‌زدگی، بدون تغییر رنگ‌ها یا هویت بصری */
  *, *::before, *::after { box-sizing: border-box; }
  html, body { max-width: 100%; overflow-x: clip; }
  main, header, footer, section, article, .card, .modal-content,
  .modal-body, .reading-container, .reading-content, .note-content,
  .ql-editor, .ql-container { min-width: 0; }
  img, video, canvas, iframe, svg { max-width: 100%; }
  p, li, a, blockquote, td, th, code { overflow-wrap: anywhere; }

  /* فاصله‌های صفحه و کارت‌ها؛ رنگ، سایه و گوشه‌ها همان قبلی می‌مانند */
  main { padding-left: 12px !important; padding-right: 12px !important; }
  .card { min-width: 0; }
  .card p, .card h1, .card h2, .card h3 { max-width: 100%; }

  /* سربرگ: جلوگیری از فشرده‌شدن یا بیرون‌زدن دکمه‌ها */
  .navbar-inner { min-width: 0; }
  .brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .navbar-inner button, .navbar-inner a { flex-shrink: 0; }

  /* جدول‌ها: اسکرول فقط داخل خود جدول، نه کل صفحه */
  .note-content .table-wrap,
  .reading-content .table-wrap,
  .ql-editor .table-wrap {
    display: block;
    width: 100%; max-width: 100%;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }
  .note-content .table-wrap table,
  .reading-content .table-wrap table,
  .ql-editor .table-wrap table {
    width: max-content; min-width: 100%; max-width: none;
    white-space: nowrap;
  }
  /* اگر جدول در ادیتور هنوز wrapper ندارد، خود ادیتور اسکرول‌پذیر باشد */
  .ql-editor { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .note-content table, .reading-content table, .ql-editor table {
    font-size: 12px;
  }
  .note-content th, .note-content td,
  .reading-content th, .reading-content td,
  .ql-editor th, .ql-editor td { padding: 7px 9px; }

  /* تصاویر جزوه: حفظ نسبت تصویر و جلوگیری از برش محتوای مهم فقط در موبایل */
  .note-image { width: 100%; max-width: 100%; height: auto; object-fit: contain; }
  .note-content img, .reading-content img, .ql-editor img { max-width: 100%; height: auto; }

  /* محتوای طولانی و قطعه‌کد */
  .note-content pre, .reading-content pre, .ql-editor pre,
  .note-content .ql-syntax, .reading-content .ql-syntax {
    max-width: 100%; overflow-x: auto; white-space: pre;
    -webkit-overflow-scrolling: touch;
  }

  /* فرم‌ها و ورودی‌ها: قابل استفاده با لمس */
  input, select, textarea { max-width: 100%; min-width: 0; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  button, .btn-primary, .btn-secondary { touch-action: manipulation; }

  /* مودال‌ها با ارتفاع واقعی صفحه موبایل */
  .modal-overlay { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
  .modal-content {
    width: 100%; max-width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow: hidden;
  }
  .modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .share-modal { max-width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); overflow-y: auto; }

  /* مطالعه: فضای بیشتر برای متن، بدون تغییر تایپوگرافی اصلی */
  .reading-container { width: 100%; max-width: 100%; padding-left: 14px; padding-right: 14px; }
  .reading-content { overflow-wrap: anywhere; }
  .reading-toolbar {
    max-width: calc(100vw - 16px);
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    overflow-x: auto; justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  .ql-toolbar { max-width: 100%; overflow-x: auto; }

  /* نوار تب‌های مدیریت به‌جای شکستن نامرتب، افقی حرکت کند */
  .admin-tab { flex: 0 0 auto; }
}

@media (max-width: 380px) {
  main { padding-left: 9px !important; padding-right: 9px !important; }
  .navbar-inner { gap: 6px !important; }
  .note-content th, .note-content td,
  .reading-content th, .reading-content td,
  .ql-editor th, .ql-editor td { padding: 6px 8px; }
  .modal-body { padding-left: 12px; padding-right: 12px; }
  .reading-container { padding-left: 10px; padding-right: 10px; }
}


/* ========================================== */
/* 🎬 Video Card                              */
/* ========================================== */
.video-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-secondary);
  padding: 16px;
  overflow: hidden;
}

html:not(.dark) .video-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.video-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-card-title::before {
  content: '';
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(to bottom, #6366f1, #4f46e5);
}

.video-card-player {
  margin-bottom: 12px;
}

.video-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.video-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.video-download-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.video-download-btn svg {
  width: 14px;
  height: 14px;
}
/* ========================================== */
/* 📄 Note Custom Content (از فایل HTML)      */
/* ========================================== */
.note-content-custom {
  /* پاک کردن استایل‌های پیش‌فرض که ممکنه تداخل کنن */
  font-family: 'Vazirmatn', sans-serif;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* جلوگیری از بیرون‌زدگی */
.note-content-custom * {
  max-width: 100%;
  box-sizing: border-box;
}

/* جدول‌ها */
.note-content-custom table {
  width: 100%;
  border-collapse: collapse;
}

/* کد */
.note-content-custom pre,
.note-content-custom code {
  direction: ltr;
  text-align: left;
}

/* تصاویر */
.note-content-custom img {
  max-width: 100%;
  height: auto;
}

/* حذف بک‌گراند از همه المان‌ها (اگه چیزی جا مونده) */
.note-content-custom [style*="background"] {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* دکمه back-to-top توی جزوه رو مخفی کن */
.note-content-custom .back-to-top {
  display: none !important;
}

/* مخفی کردن دکمه‌های اضافی از فایل HTML */
.note-content-custom button:not(.btn-primary):not(.btn-secondary) {
  /* اگه فایل HTML خودش دکمه داشت */
  /* این خط رو نگه دار اگه می‌خوای دکمه‌های فایل ظاهر نشن */
}


/* ========================================== */
/* 📖 حالت مطالعه — سایزهای فونت جدید         */
/* ========================================== */

/* ⭐ درجه‌ی xs (جدید) — خیلی کوچک */
.reading-content.reading-size-xs { font-size: 14px; line-height: 1.9; }

/* ⭐ بازتعریف s — کوچک‌تر از قبل */
.reading-content.reading-size-s { font-size: 16px; line-height: 1.9; }

/* m — پیش‌فرض (بدون تغییر) */
.reading-content.reading-size-m { font-size: 18px; line-height: 1.9; }

/* l — بزرگ */
.reading-content.reading-size-l { font-size: 21px; line-height: 1.9; }

/* xl — خیلی بزرگ */
.reading-content.reading-size-xl { font-size: 24px; line-height: 1.9; }

/* ========================================== */
/* 📱 فونت جزوه — کوچک‌تر در موبایل و تبلت    */
/* ========================================== */

/* تبلت */
@media (max-width: 900px) {
  .note-content.note-content-custom,
  .note-content {
    font-size: 14px !important;
    line-height: 1.85 !important;
  }
}

/* موبایل */
@media (max-width: 640px) {
  .note-content.note-content-custom,
  .note-content {
    font-size: 13px !important;
    line-height: 1.85 !important;
  }

  /* در حالت مطالعه هم کوچک‌تر */
  .reading-content.reading-size-xs { font-size: 12px; }
  .reading-content.reading-size-s { font-size: 14px; }
  .reading-content.reading-size-m { font-size: 15px; }
  .reading-content.reading-size-l { font-size: 17px; }
  .reading-content.reading-size-xl { font-size: 20px; }

  /* جدول‌ها توی موبایل */
  .note-content table,
  .note-content-custom table {
    font-size: 12px !important;
  }

  .note-content th,
  .note-content td,
  .note-content-custom th,
  .note-content-custom td {
    padding: 7px 9px !important;
  }

  /* کد بلاک‌ها توی موبایل */
  .note-content pre,
  .note-content code,
  .note-content-custom pre,
  .note-content-custom code {
    font-size: 12px !important;
  }
}

/* موبایل کوچک */
@media (max-width: 380px) {
  .note-content.note-content-custom,
  .note-content {
    font-size: 12.5px !important;
  }

  .reading-content.reading-size-m { font-size: 14px; }
}

/* ========================================== */
/* 🎯 استایل‌های اضافی برای MathJax           */
/* ========================================== */

/* جلوگیری از سرریز فرمول‌های طولانی */
.note-content-custom mjx-container,
.reading-content mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 4px 0;
}

/* فرمول‌های inline کوچک‌تر */
.note-content-custom mjx-container:not([display="true"]),
.reading-content mjx-container:not([display="true"]) {
  font-size: 1em !important;
}

/* ========================================== */
/* 🖼️ عکس سوالات                              */
/* ========================================== */

/* عکس توی سوال — اندازه‌ی بهینه */
.q-item img.note-image {
  max-height: 350px;
  object-fit: contain;
  background: var(--bg-tertiary);
  margin: 12px 0;
}

/* توی موبایل کوچک‌تر */
@media (max-width: 640px) {
  .q-item img.note-image {
    max-height: 220px;
  }
}

/* ========================================== */
/* 🎬 ویدیو — توی موبایل بهتر                  */
/* ========================================== */

@media (max-width: 640px) {
  .video-card {
    padding: 12px;
    border-radius: 10px;
  }

  .video-card-title {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .video-download-btn {
    padding: 7px 12px;
    font-size: 11px;
  }
}

/* ========================================== */
/* 📐 MathJax — کدهای داخل جزوه               */
/* ========================================== */

/* تگ‌های pre و code داخل جزوه — LTR */
.note-content-custom pre,
.note-content-custom code {
  direction: ltr !important;
  text-align: left !important;
  font-family: 'JetBrains Mono', ui-monospace, monospace !important;
}

/* ========================================== */
/* 🎨 اسکوپ امن — جلوگیری از تداخل            */
/* ========================================== */

/* هر چیزی که توی note-content-custom هست، از بیرون ارث نبره */
.note-content-custom {
  isolation: isolate;
  contain: layout style;
}

/* اگه HTML جزوه از .container استفاده کرد، خنثی کن */
.note-content-custom .container {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* دکمه back-to-top یا چیزای اضافی رو مخفی کن */
.note-content-custom .back-to-top,
.note-content-custom .back-top,
.note-content-custom button:not(.btn-primary):not(.btn-secondary):not(.video-download-btn) {
  display: none !important;
}

/* ========================================== */
/* 🎬 ویدیو کارت — اگه چند ویدیو باشه         */
/* ========================================== */

.note-content-custom + .mt-6 .video-card,
article .video-card + .video-card {
  margin-top: 12px;
}

/* ========================================== */
/* 📱 ریسپانسیو بهتر — جدول‌های بزرگ          */
/* ========================================== */

@media (max-width: 768px) {
  .note-content-custom .table-wrap,
  .note-content .table-wrap {
    border-radius: 6px;
    box-shadow: inset -8px 0 8px -8px rgba(0, 0, 0, 0.15);
  }

  .note-content-custom .table-wrap::after,
  .note-content .table-wrap::after {
    content: '← بکش';
    display: block;
    text-align: center;
    font-size: 10px;
    color: var(--text-tertiary);
    padding: 4px;
    opacity: 0.6;
  }
}