/* ═══════════════════════════════════════════════
   ویراستو — ویراستار فارسی
   نسخه ۴ وب
   ═══════════════════════════════════════════════ */

:root {
  --bg: #f8faf8;
  --bg2: #f0f4f0;
  --surface: #ffffff;
  --surface2: #f5f7f5;
  --text: #1a2e1a;
  --text2: #5a6e5a;
  --border: #d4e4d4;
  --primary: #67AE6E;
  --primary2: #4a9a52;
  --primary3: #E1EEBC;
  --primary-glow: rgba(103,174,110,0.25);
  --danger: #e53935;
  --danger-light: #ffebee;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: 'dana', 'IRANSansX', 'IRANYekan', system-ui, sans-serif;
  --header-h: 52px;
  --toolbar-h: 46px;
  --panel-w: 300px;
  --max-w: 1200px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --bg: #0f120f;
  --bg2: #161b16;
  --surface: #1a201a;
  --surface2: #222a22;
  --text: #dce8dc;
  --text2: #8a9e8a;
  --border: #2e3e2e;
  --primary: #67AE6E;
  --primary2: #8cc892;
  --primary3: #1e3a1e;
  --primary-glow: rgba(103,174,110,0.15);
  --danger: #ef5350;
  --danger-light: #2a1515;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

@font-face { font-family: 'dana'; src: url('../assets/fonts/dana-regular.ttf') format('truetype'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'IRANSansX'; src: url('../assets/fonts/IRANSansXRegular.ttf') format('truetype'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'IRANYekan'; src: url('../assets/fonts/IRANyekan.ttf') format('truetype'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-VariableFont_slnt,wght.ttf') format('truetype'); font-weight: normal; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  direction: rtl;
  transition: background var(--transition), color var(--transition);
}
#app { display: flex; flex-direction: column; height: 100vh; max-width: var(--max-w); margin: 0 auto; }

/* ═══ هدر ═══ */
#topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--header-h);
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--primary);
  flex: 1;
  justify-content: center;
  letter-spacing: -0.5px;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
}
.icon-btn:hover { background: var(--primary3); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.95); }

/* ═══ منوی کناری ═══ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(2px); z-index: 200; opacity: 1; transition: opacity 0.25s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.side-menu {
  position: fixed; top: 0; right: 0;
  width: 280px; height: 100%;
  background: var(--surface);
  z-index: 300;
  box-shadow: var(--shadow-lg);
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.side-menu.hidden { transform: translateX(100%); }
.menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.menu-title { font-weight: bold; font-size: 1.05rem; }
.menu-section { padding: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: none; border: none; width: 100%;
  text-align: right; font-family: inherit; font-size: .9rem;
  color: var(--text); border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition), transform var(--transition);
}
.menu-item:hover { background: var(--primary3); transform: translateX(-4px); }
.menu-item:active { transform: scale(0.98); }
.menu-divider { border: none; border-top: 1px solid var(--border); margin: 4px 8px; }

/* ═══ ناحیه اصلی ═══ */
#mainArea { display: flex; flex: 1; overflow: hidden; padding-bottom: 36px; }
#editorSection { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ═══ تولبار ═══ */
#editorToolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--toolbar-h);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.tb-group { display: flex; gap: 2px; }
.tb-btn {
  background: none; border: none; color: var(--text2);
  padding: 6px 8px; height: 32px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-size: .85rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  min-width: 32px; position: relative;
}
.tb-btn:hover { background: var(--primary3); color: var(--primary); transform: scale(1.08); }
.tb-btn:active { transform: scale(0.95); }
.tb-btn.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-glow); }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }

/* ═══ ادیتور ═══ */
#editorWrap {
  flex: 1; position: relative; margin: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#editorWrap:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.editor {
  width: 100%; height: 100%;
  padding: 20px 24px;
  font-size: 1.25rem; line-height: 2.1;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  overflow-y: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
  transition: background var(--transition), color var(--transition);
}
.editor:empty:before {
  content: attr(data-placeholder);
  color: var(--text2);
  pointer-events: none;
  opacity: 0.5;
}
.editor b, .editor strong { font-weight: bold; }
.editor i, .editor em { font-style: italic; }
.editor u { text-decoration: underline; }

.misspelled {
  text-decoration: underline wavy var(--danger);
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
  cursor: pointer;
  background: var(--danger-light);
  border-radius: 3px;
  padding: 0 1px;
  transition: background var(--transition);
}
.misspelled:hover { background: rgba(229,57,53,0.2); }
.misspelled.current {
  background: rgba(229,57,53,0.25);
  box-shadow: 0 0 0 2px var(--danger);
}

/* ═══ باکس پیشنهادات inline ═══ */
.suggestion-box {
  position: fixed; z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  min-width: 180px;
  animation: sugFadeIn 0.15s ease;
}
.suggestion-box.hidden { display: none; }
@keyframes sugFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.sug-item {
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.sug-item:last-child { border-bottom: none; }
.sug-item:hover, .sug-item.selected { background: var(--primary3); }

/* ═══ پنل کناری ═══ */
#panel {
  width: var(--panel-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  box-shadow: -2px 0 8px rgba(0,0,0,0.04);
  position: relative;

  /* این دو خط را تغییر بده */
  top: 0;
  margin-top: 0px;
}

#panel.collapsed {
  margin-right: calc(var(--panel-w) * -1);
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  font-weight: bold;
  font-size: .95rem;
  border-bottom: 1px solid var(--border);
}

.panel-toggle {
  margin-right: auto;
}

/* ═══ نوار اصلاح همه ═══ */
.fix-all-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--primary3), rgba(103,174,110,0.1));
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.25s ease;
}
.fix-all-bar.hidden { display: none; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.btn-fix-all {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .85rem;
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-fix-all:hover { background: var(--primary2); transform: scale(1.02); box-shadow: var(--shadow-glow); }
.btn-fix-all:active { transform: scale(0.98); }
.btn-fix-all:active svg { animation: checkBounce 0.3s ease; }
@keyframes checkBounce { 0%{transform:scale(1)} 50%{transform:scale(1.3) rotate(10deg)} 100%{transform:scale(1)} }
.btn-clear-all {
  width: 32px; height: 32px;
  background: none; border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-clear-all:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ═══ لیست پیشنهادات ═══ */
#suggestionsList { flex: 1; overflow-y: auto; padding: 8px; }
.suggestion-group {
  margin-bottom: 10px;
  padding: 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.suggestion-group:hover { border-color: var(--primary); }
.word-label {
  font-weight: bold;
  color: var(--danger);
  font-size: .85rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sug-btn {
  display: inline-block;
  padding: 4px 12px;
  margin: 3px;
  background: var(--primary3);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
  transition: all var(--transition);
}
.sug-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
}
.dict-btn {
  display: block;
  margin-top: 6px;
  padding: 4px 10px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text2);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: .78rem;
  transition: all var(--transition);
}
.dict-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary3); }

/* ═══ آمار ═══ */
.stats-box {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  text-align: center;
}
.stat-item {
  padding: 8px 4px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stat-num {
  display: block;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--primary);
}
.stat-label {
  font-size: .72rem;
  color: var(--text2);
}

/* ═══ دکمه‌های بررسی ═══ */
.spell-actions {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.btn-primary {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .85rem;
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary:hover { background: var(--primary2); transform: scale(1.02); box-shadow: var(--shadow-glow); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--primary3); border-color: var(--primary); transform: scale(1.02); }

/* ═══ دراپ‌داون ═══ */
.dropdown {
  position: absolute;
  top: calc(var(--toolbar-h) - 2px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: sugFadeIn 0.15s ease;
  overflow: hidden;
}
.dropdown.hidden { display: none; }
.dropdown button {
  display: block;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}
.dropdown button:last-child { border-bottom: none; }
.dropdown button:hover { background: var(--primary3); }

/* ═══ مودال ═══ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 400px; max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { transform: scale(0.95) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px; font-weight: bold;
  border-bottom: 1px solid var(--border);
}
.modal-header .icon-btn { margin-right: auto; }
.modal-body { padding: 16px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row span { color: var(--text); }
.toggle {
  width: 42px; height: 22px;
  appearance: none; -webkit-appearance: none;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  outline: none;
  border: none;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.toggle:checked { background: var(--primary); }
.toggle:checked::after { transform: translateX(-20px); }
.range {
  width: 120px;
  accent-color: var(--primary);
}
.select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.select:focus { border-color: var(--primary); }
.about-body { text-align: center; line-height: 2; }
.about-body .about-logo {
  font-size: 2.2rem; font-weight: bold;
  color: var(--primary);
  margin-bottom: 8px;
  text-shadow: 0 2px 8px var(--primary-glow);
}
.about-body ul { list-style: none; padding: 12px 0; }
.about-body ul li::before { content: "✓ "; color: var(--primary); font-weight: bold; }
.about-body small { color: var(--text2); display: block; margin-top: 4px; }

/* ═══ مودال یادگیری ═══ */
.learn-desc { font-size: .88rem; color: var(--text2); margin-bottom: 12px; line-height: 1.8; }
.learn-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface2);
  resize: vertical;
  outline: none;
  direction: rtl;
  line-height: 1.8;
  transition: border-color var(--transition);
}
.learn-textarea:focus { border-color: var(--primary); }
.learn-textarea::placeholder { color: var(--text2); opacity: .6; }
.learn-progress {
  display: flex; align-items: center; gap: 8px;
  padding: 12px;
  background: var(--primary3);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: .88rem;
  color: var(--primary2);
}
.learn-progress.hidden { display: none; }
.learn-result {
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: .88rem;
  line-height: 1.8;
  animation: sugFadeIn 0.2s ease;
}
.learn-result.hidden { display: none; }
.learn-result.success { background: var(--primary3); border: 1px solid var(--primary); color: var(--text); }
.learn-result.info { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.learn-actions { display: flex; gap: 8px; margin-top: 12px; }
.learn-actions .btn-primary { flex: 2; }
.learn-actions .btn-secondary { flex: 1; }
.added-words { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.added-word-tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-size: .8rem;
  animation: tagPop 0.2s ease;
}
@keyframes tagPop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ═══ توست ═══ */
.toast {
  position: fixed;
  bottom: 50px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
  z-index: 600;
  font-size: .88rem;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 340px;
}
.toast.hidden { opacity: 0; transform: translateY(16px) scale(0.95); pointer-events: none; }
.toast.success { border-right: 4px solid var(--primary); }
.toast.error { border-right: 4px solid var(--danger); }
.toast.show { animation: toastIn 0.3s ease; }
@keyframes toastIn { from { transform: translateY(16px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* ═══ اسکرولبار ═══ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ═══ Context Menu ═══ */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  max-width: 300px;
  animation: sugFadeIn 0.12s ease;
}
.context-menu.hidden { display: none; }
.context-menu-header {
  padding: 8px 12px;
  font-size: .8rem;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.ctx-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.ctx-suggestions {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}
.ctx-suggestion {
  display: block;
  width: 100%;
  text-align: right;
  padding: 8px 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.ctx-suggestion:hover { background: var(--primary3); }
.ctx-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 8px 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.ctx-item:hover { background: var(--danger-light); color: var(--danger); }

/* ═══ Status Bar ═══ */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  font-size: .75rem;
  color: var(--text2);
}
.status-left, .status-center, .status-right { display: flex; align-items: center; gap: 8px; }
.status-sep { opacity: .4; }
.status-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .7rem;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.status-btn:hover { background: var(--primary3); border-color: var(--primary); color: var(--primary); }

/* ═══ Auto-Correct Indicator ═══ */
.auto-corrected {
  background: rgba(103,174,110,0.2);
  border-radius: 3px;
  padding: 0 2px;
  animation: autoCorrectFlash 1s ease;
}
@keyframes autoCorrectFlash {
  0% { background: rgba(103,174,110,0.4); }
  100% { background: rgba(103,174,110,0); }
}

/* ═══ اسکرولبار ═══ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ═══ اسپینر ═══ */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ═══ ریسپانسیو ═══ */
@media (max-width: 768px) {
  :root { --panel-w: 260px; }
  #panel { position: fixed; top: var(--header-h); left: 0; bottom: 36px; z-index: 50; border-right: none; border-left: 1px solid var(--border); }
  #panel.collapsed { margin-right: 0; transform: translateX(100%); }
  .editor { padding: 12px; font-size: 1.05rem; }
  #editorWrap { margin: 8px; }
  #topbar { padding: 0 6px; }
  .status-bar { font-size: .7rem; padding: 0 8px; }
  .toast { bottom: 40px; right: 10px; left: 10px; max-width: none; }
}
@media (max-width: 480px) {
  .logo { font-size: 1rem; }
  #editorToolbar { gap: 4px; padding: 4px 6px; }
  .tb-btn { padding: 4px 6px; min-width: 28px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .stat-item { padding: 6px 2px; }
  .status-btn { font-size: .65rem; padding: 3px 6px; }
}