/* =========================================================
   Vienix Markdown Editor - Modern Arabic Markdown Design System
   ========================================================= */

@import url('../../assets/fonts/tajawal.css');
@import url('../../assets/vendor/prism-tomorrow.min.css');

:root {
  --font-arabic: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Light Theme Palette */
  --bg-app: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-header: #ffffff;
  --bg-toolbar: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  --border-color: #e2e8f0;
  --border-light: #edf2f7;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --accent-glow: rgba(59, 130, 246, 0.15);

  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-dropdown: 0 12px 28px rgba(0, 0, 0, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
}

[data-theme="dark"] {
  /* Dark Theme Palette */
  --bg-app: #0b0f17;
  --bg-surface: #131b26;
  --bg-surface-elevated: #1a2434;
  --bg-header: #101722;
  --bg-toolbar: #131b26;
  --bg-hover: #1f2b3e;
  --bg-active: #28374f;
  --border-color: #1e293b;
  --border-light: #182232;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  --accent-glow: rgba(59, 130, 246, 0.25);

  --success-color: #34d399;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning-color: #fbbf24;
  --danger-color: #f87171;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);
  --shadow-dropdown: 0 14px 32px rgba(0, 0, 0, 0.7);

  --scrollbar-thumb: #334155;
  --scrollbar-thumb-hover: #475569;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-arabic);
}

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  direction: rtl;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: normal;
}

/* ضبط تباعد الأحرف للنصوص واللغات اللاتينية فقط لحماية تشابك الحروف العربية */
[dir="ltr"] body,
html[lang="en"] body,
html[lang="de"] body,
:lang(en),
:lang(de),
.ltr-content {
  letter-spacing: -0.012em;
}

/* تفعيل خصائص الخط البرمجي والـ Ligatures للأكواد */
code, pre, kbd, samp, .font-mono {
  font-family: var(--font-mono);
  font-feature-settings: "liga" 1, "calt" 1;
}

/* الأرقام المتساوية العرض (Tabular Numbers) لمنع اهتزاز العدادات والأسطر وجداول البيانات */
.tabular-nums,
.status-bar,
.status-item,
.line-numbers,
.line-number,
.stat-badge,
.badge-count,
.markdown-body table,
code,
pre {
  font-variant-numeric: tabular-nums;
}

/* عزل النصوص ثنائية اللغة لمنع تداخل علامات الترقيم */
bdi, .bidi-isolate {
  unicode-bidi: isolate;
}

/* 1. تخصيص لون تظليل النصوص الفاخر (Text Selection) */
::selection {
  background: rgba(59, 130, 246, 0.22);
  color: inherit;
}

::-moz-selection {
  background: rgba(59, 130, 246, 0.22);
  color: inherit;
}

[data-theme="dark"] ::selection {
  background: rgba(59, 130, 246, 0.35);
  color: inherit;
}

[data-theme="dark"] ::-moz-selection {
  background: rgba(59, 130, 246, 0.35);
  color: inherit;
}

/* تظليل نصوص الأكواد البرمجية */
pre code::selection,
pre::selection {
  background: rgba(59, 130, 246, 0.45);
  color: #ffffff;
}

/* 2. تحسين مظهر التركيز والتنقل النظيف (Focus-Visible) */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-color, #3b82f6);
  outline-offset: 2px;
}

/* استثناء حقول الإدخال ومحرر النصوص من الإطار المزدوج */
.editor-textarea:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
}

/* 3. احترام تفضيلات المستخدم لتقليل الحركة (Accessibility & Reduced Motion) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* App Container */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.brand-title {
  direction: ltr;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-tag {
  font-size: 0.68rem;
  background: var(--accent-light);
  color: var(--accent-color);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Main Action Controls (Copy & Export) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group {
  display: inline-flex;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  position: relative;
}

/* Primary Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  user-select: none;
  text-decoration: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

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

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-outline-classic {
  background: transparent;
  border: 1.5px solid #6366f1;
  color: #4f46e5;
  font-weight: 600;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.18s ease-in-out;
}

.btn-outline-classic:hover {
  background: #eef2ff;
  border-color: #4338ca;
  color: #4338ca;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-outline-classic {
  border-color: #818cf8;
  color: #a5b4fc;
}

[data-theme="dark"] .btn-outline-classic:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #c7d2fe;
  color: #c7d2fe;
}

.btn-icon-only {
  padding: 7px;
  border-radius: var(--radius-md);
}

/* Dropdown Menu styling */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
  animation: fadeInDown 0.15s ease-out;
}

.dropdown-container.open .dropdown-menu {
  display: flex;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: right;
  width: 100%;
  transition: all 0.15s ease;
}

.dropdown-item svg {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent-color);
}

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

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

/* Secondary Toolbar (Formatting & View controls) */
.toolbar-container {
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
}

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  min-width: 32px;
  height: 32px;
  transition: all 0.15s;
}

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

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

.tool-btn.active {
  background: var(--accent-light);
  color: var(--accent-color);
  border-color: rgba(59, 130, 246, 0.3);
}

.tool-btn.danger:hover {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger-color, #ef4444);
}

[data-theme="dark"] .tool-btn.danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}

/* Workspace Panels (Editor & Preview) */
.workspace-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background: var(--bg-app);
}

.panel {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  position: relative;
}

.panel-editor {
  width: var(--editor-pane-width, 50%);
  flex: 0 0 var(--editor-pane-width, 50%);
  max-width: calc(100% - 140px);
  min-width: 140px;
  border-left: none;
}

.panel-preview {
  flex: 1 1 0%;
  min-width: 140px;
}

/* Workspace Split Resizer Gutter (خط مقبض السحب وتعديل المقاس) */
.workspace-resizer {
  width: 7px;
  height: 100%;
  background: var(--border-color);
  cursor: col-resize;
  position: relative;
  flex: 0 0 7px;
  z-index: 25;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* زيادة مساحة اللمس والسحب لتسهيل الإمساك بالمقبض */
.workspace-resizer::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  right: -5px;
  z-index: 26;
  cursor: col-resize;
}

/* خط الإشارة المرئي الصغير بوسط المقبض */
.workspace-resizer .resizer-handle-line {
  width: 3px;
  height: 32px;
  background: var(--text-faint);
  border-radius: 4px;
  opacity: 0.5;
  transition: all 0.18s ease;
}

.workspace-resizer:hover,
.workspace-resizer.is-dragging {
  background: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

.workspace-resizer:hover .resizer-handle-line,
.workspace-resizer.is-dragging .resizer-handle-line {
  background: #ffffff;
  opacity: 1;
  height: 48px;
}

/* نمط الخط الرفيع الفاصل (Slim Divider Mode) */
.workspace-resizer.is-slim {
  width: 2px;
  flex: 0 0 2px;
  background: var(--border-color);
  box-shadow: none;
}

.workspace-resizer.is-slim .resizer-handle-line {
  display: none !important;
}

.workspace-resizer.is-slim::before {
  left: -7px;
  right: -7px;
}

.workspace-resizer.is-slim:hover,
.workspace-resizer.is-slim.is-dragging {
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* حالة الصفحة أثناء السحب */
body.is-resizing-workspace {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.is-resizing-workspace * {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  pointer-events: none !important;
}

body.is-resizing-workspace .workspace-resizer {
  pointer-events: auto !important;
}

.panel-header {
  padding: 8px 16px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.panel-header .badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-light);
  color: var(--text-secondary);
}

/* ترويسة نافذة المعاينة مع أزرار التحكم للموبايل */
.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-header-btn {
  display: none; /* مخفي على الكمبيوتر افتراضياً */
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.16s ease;
  line-height: 1.25;
  user-select: none;
}

.preview-header-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.preview-header-btn.active {
  background: #6366f1;
  color: #ffffff !important;
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.preview-header-btn.active svg {
  color: #ffffff !important;
}

[data-theme="dark"] .preview-header-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .preview-header-btn.active {
  background: #6366f1;
  color: #ffffff !important;
}

/* كونتينر الأدوات العائم في شاشة العرض المعاينة عند تفعيل Edit */
.preview-floating-dock {
  position: absolute !important;
  bottom: 24px !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  z-index: 50 !important;
  margin: 0 !important;
  animation: previewDockSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.preview-floating-dock .editor-floating-actions {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 6px 12px !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 30px !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .preview-floating-dock .editor-floating-actions {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06) !important;
}

@keyframes previewDockSlideIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}


/* Editor Input Area */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  overflow-clip-margin: 0;   /* الـ overflow:hidden يقطع المحتوى خارج الحدود */
}

.editor-textarea {
  width: 100%;
  height: 100%;
  padding: 18px 24px 75px 24px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-arabic);
  font-size: 1.02rem;
  line-height: 1.85;
  direction: rtl;
  unicode-bidi: plaintext;
  tab-size: 4;
  overflow-y: auto;
}

.editor-textarea::placeholder {
  color: var(--text-faint);
}

/* حامل التحرير العائم القابل للسحب */
.floating-dock-wrapper {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 30;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.floating-dock-wrapper:active {
  cursor: grabbing;
}

/* أيقونة أعلى شريط الأدوات العائم بدون حدود (clipboard-plus) */
.floating-dock-top-btn {
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 3px;
  transition: color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  opacity: 0.75;
}

.floating-dock-top-btn:hover {
  opacity: 1;
  color: var(--accent-color, #3b82f6);
  transform: scale(1.1);
}

[data-theme="dark"] .floating-dock-top-btn {
  color: var(--text-muted, #94a3b8);
}

[data-theme="dark"] .floating-dock-top-btn:hover {
  color: #60a5fa;
}

/* أيقونة مقبض السحب فوق الكونتينر */
.floating-dock-handle {
  margin-bottom: 6px;      /* المقبض فوق الكونتينر — بعيد بمسافة بسيطة */
  margin-top: 0;
  color: var(--text-muted, #94a3b8);
  opacity: 0.5;
  padding: 3px 6px;
  border-radius: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  -webkit-user-drag: none;
}

.floating-dock-wrapper:hover .floating-dock-handle {
  opacity: 1;
  color: var(--accent-color, #3b82f6);
  transform: scale(1.12);
}

[data-theme="dark"] .floating-dock-handle {
  color: var(--text-muted, #475569);
  opacity: 0.6;
}

[data-theme="dark"] .floating-dock-wrapper:hover .floating-dock-handle {
  color: #60a5fa;
  opacity: 1;
}

/* أدوات التحرير السريعة — بدون position مستقلة (ال wrapper يتحكم بالموضع) */
.editor-floating-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-surface-elevated, #ffffff);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  user-select: none;
  cursor: default; /* لا يورث ال grab من ال wrapper على البودر نفسه */
}

.floating-tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: var(--bg-surface, #ffffff);
  color: var(--text-secondary, #334155);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.floating-tool-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.floating-tool-btn:hover:not(:disabled) {
  background: var(--accent-light, #eff6ff);
  color: var(--accent-color, #3b82f6);
  border-color: rgba(59, 130, 246, 0.25);
  transform: scale(1.06);
}

.floating-tool-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.floating-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.floating-tool-btn.danger {
  color: var(--text-muted, #64748b);
}

.floating-tool-btn.danger:hover:not(:disabled) {
  background: #fef2f2;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(1.06);
}

[data-theme="dark"] .editor-floating-actions {
  background: var(--bg-surface-elevated, #1a2434);
  border-color: var(--border-color, #1e293b);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .floating-tool-btn {
  background: var(--bg-surface, #131b26);
  color: var(--text-secondary, #cbd5e1);
}

[data-theme="dark"] .floating-tool-btn:hover:not(:disabled) {
  background: var(--accent-light, rgba(59, 130, 246, 0.15));
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
}

[data-theme="dark"] .floating-tool-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
}

/* Preview Output Area */
.preview-container {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 24px 32px;
  direction: rtl;
  scroll-behavior: smooth;
  background: var(--bg-surface);
}

/* View Mode Toggles */
.workspace-container.mode-editor-only .panel-preview {
  display: none !important;
}

.workspace-container.mode-editor-only .workspace-resizer {
  display: none !important;
}

.workspace-container.mode-editor-only .panel-editor {
  width: 100% !important;
  flex: 1 1 100% !important;
  max-width: 100% !important;
  border-left: none;
}

.workspace-container.mode-preview-only .panel-editor {
  display: none !important;
}

.workspace-container.mode-preview-only .workspace-resizer {
  display: none !important;
}

.workspace-container.mode-preview-only .panel-preview {
  width: 100% !important;
  flex: 1 1 100% !important;
  max-width: 100% !important;
}

/* Markdown Styled Output */
.markdown-body {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text-primary);
  word-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-family: var(--font-arabic);
  font-weight: 700;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
  line-height: 1.35;
  color: var(--text-primary);
}

.markdown-body h1 {
  font-size: 1.95rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.35em;
}

.markdown-body h2 {
  font-size: 1.55rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.25em;
}

.markdown-body h3 {
  font-size: 1.25rem;
}

.markdown-body p {
  margin-bottom: 1.1em;
}

.markdown-body a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-color);
  transition: all 0.15s;
}

.markdown-body a:hover {
  color: var(--accent-hover);
  border-bottom-style: solid;
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1.2em;
  padding-right: 1.8em;
  padding-left: 0;
}

.markdown-body li {
  margin-bottom: 0.4em;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}

.markdown-body blockquote {
  margin: 1.4em 0;
  padding: 12px 18px;
  background: var(--bg-hover);
  border-right: 4px solid var(--accent-color);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 2em 0;
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.95rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  text-align: right;
}

.markdown-body th {
  background: var(--bg-hover);
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body tr:nth-child(even) {
  background: var(--bg-hover);
}

/* Code & Syntax Highlighting */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: #d946ef;
  direction: ltr;
  display: inline-block;
}

.markdown-body pre {
  margin: 1.4em 0;
  background: #1e1e1e !important;
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.markdown-body pre code {
  background: transparent !important;
  border: none !important;
  padding: 0;
  color: #f8fafc;
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Mermaid Diagrams Container */
.mermaid-wrapper {
  position: relative;
  margin: 1.6em auto 1.6em 0; /* محاذاة يسارية تثبت الزاوية اليسارية العليا 100% تحت الماوس */
  padding: 30px 24px 22px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  width: fit-content;
  max-width: 100%;
  min-width: 220px;
  box-sizing: border-box;
  transition: width 0.2s ease, max-width 0.2s ease, padding 0.2s ease;
}

/* أزرار تكبير وتصغير المخطط بالزاوية اليسارية العليا تظهر عند تمرير الماوس */
.diagram-zoom-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 3px 6px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(-4px);
}

.mermaid-wrapper:hover .diagram-zoom-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.diagram-zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary, #475569);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diagram-zoom-btn:hover {
  background: var(--bg-hover, #f1f5f9);
  color: var(--primary, #2563eb);
  transform: scale(1.15);
}

.diagram-zoom-btn:active {
  transform: scale(0.92);
}

/* زر نسخ الكود البرمجي بالكامل في خانة الكود */
.code-copy-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font-arabic), sans-serif;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, background 0.15s ease, color 0.15s ease;
  z-index: 5;
}

.markdown-body pre:hover .code-copy-btn {
  opacity: 1;
  pointer-events: auto;
}

.code-copy-btn:hover {
  background: #334155;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.code-copy-btn:active {
  transform: scale(0.95);
}

.mermaid {
  direction: ltr !important;
  text-align: center;
}

.mermaid svg {
  max-width: 100% !important;
  height: auto !important;
  font-family: var(--font-arabic) !important;
}

.mermaid-error {
  color: var(--danger-color);
  background: rgba(239, 68, 68, 0.1);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
  font-family: var(--font-mono);
}

/* Task Lists */
.markdown-body input[type="checkbox"] {
  margin-left: 8px;
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--accent-color);
}

/* تنسيق الصور المدرجة في المعاينة لتكون متجاوبة وأنيقة (باستثناء الإيموجي المضمن) */
.markdown-body img:not(.inline-emoji) {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
  margin: 12px auto;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  display: block;
}

/* ==========================================
   IMAGE RESIZING SYSTEM (مقابض تحجيم وتكبير/تصغير الصور)
   ========================================== */
.image-resizer-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 16px auto;
  transition: outline 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  vertical-align: middle;
}

.image-resizer-wrapper[data-align="center"] {
  display: block;
  margin: 16px auto;
  text-align: center;
}

.image-resizer-wrapper[data-align="right"] {
  display: block;
  margin: 16px 0 16px auto;
}

.image-resizer-wrapper[data-align="left"] {
  display: block;
  margin: 16px auto 16px 0;
}

.image-resizer-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  pointer-events: auto;
  cursor: pointer;
}

/* إزالة الظلال والحدود عن الإيموجي والستيكرات داخل حاوية التحجيم */
.image-resizer-wrapper img.inline-emoji,
.emoji-resizer-wrapper img {
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* حالة التركيز واختيار الصورة العادية */
.image-resizer-wrapper:hover,
.image-resizer-wrapper.active {
  outline: 2px solid var(--accent-color, #2563eb);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
  border-radius: 8px;
}

/* تنسيق حاوية تحجيم الإيموجي والستيكرات لتكون مدمجة بانسيابية */
.image-resizer-wrapper.is-emoji-wrapper {
  display: inline-block;
  margin: 2px 4px;
  vertical-align: middle;
  outline: none;
  box-shadow: none;
  border: none;
  background: transparent;
}

.image-resizer-wrapper.is-emoji-wrapper[data-align="center"] {
  display: block;
  margin: 12px auto;
  text-align: center;
}

.image-resizer-wrapper.is-emoji-wrapper[data-align="right"] {
  display: block;
  margin: 12px 0 12px auto;
}

.image-resizer-wrapper.is-emoji-wrapper[data-align="left"] {
  display: block;
  margin: 12px auto 12px 0;
}

.image-resizer-wrapper.is-emoji-wrapper[data-align="inline"] {
  display: inline-block !important;
  margin: 2px 4px !important;
  vertical-align: middle !important;
}

/* حالة التركيز للإيموجي والستيكرات: بدون أي إطار أزرق عريض أو ظلال */
/* حالة التركيز للإيموجي والستيكرات: بدون أي إطار أو خط منقط وبدون أي ظلال نهائياً بناءً على طلب المستخدم */
.emoji-resizer-wrapper,
.emoji-resizer-wrapper:hover,
.emoji-resizer-wrapper.active,
.image-resizer-wrapper.is-emoji-wrapper,
.image-resizer-wrapper.is-emoji-wrapper:hover,
.image-resizer-wrapper.is-emoji-wrapper.active,
.image-resizer-wrapper.is-floating {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* شريط الأدوات المصغر فوق الصورة */
.image-resizer-toolbar {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  padding: 4px 10px;
  display: none;
  align-items: center;
  gap: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 100;
  white-space: nowrap;
}

.image-resizer-wrapper:hover .image-resizer-toolbar,
.image-resizer-wrapper.active .image-resizer-toolbar {
  display: flex;
}

.resizer-btn {
  background: transparent;
  border: none;
  color: #f1f5f9;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.resizer-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.resizer-btn.active {
  background: var(--accent-color, #2563eb);
  color: #ffffff;
}

.resizer-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}

.resizer-size-badge {
  color: #94a3b8;
  font-size: 0.7rem;
  direction: ltr;
  padding: 0 4px;
  font-family: 'Fira Mono', monospace;
}

/* مقابض التحجيم (Resize Handles) */
.resizer-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 2px solid var(--accent-color, #2563eb);
  border-radius: 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  display: none;
  z-index: 90;
  touch-action: none;
}

.image-resizer-wrapper:hover .resizer-handle,
.image-resizer-wrapper.active .resizer-handle {
  display: block;
}

/* الزوايا الأربع */
.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* أطراف الجوانب */
.handle-w { top: 50%; left: -6px; transform: translateY(-50%); cursor: ew-resize; height: 18px; border-radius: 6px; }
.handle-e { top: 50%; right: -6px; transform: translateY(-50%); cursor: ew-resize; height: 18px; border-radius: 6px; }

/* Bottom Status Bar */
.status-bar {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  user-select: none;
  z-index: 10;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-copyright {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.status-copyright strong {
  color: var(--accent-color);
  font-weight: 700;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.save-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success-color);
  font-weight: 500;
}

.save-badge.saving {
  color: var(--warning-color);
}

/* Toast Notifications (مخفية كلياً بناءً على طلب المستخدم الصريح) */
.toast-container,
.toast {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  background: #064e3b;
  color: #ecfdf5;
}

.toast-success svg {
  color: #34d399;
}

.toast-info {
  border-color: rgba(59, 130, 246, 0.4);
  background: #1e3a8a;
  color: #eff6ff;
}

.toast-info svg {
  color: #60a5fa;
}

.toast-warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: #78350f;
  color: #fffbeb;
}

.toast-warning svg {
  color: #fbbf24;
}

@keyframes toastDrop {
  from {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* =========================================================
   Print Styles (Optimized for PDF export & high quality printing)
   ========================================================= */
@media print {
  @page {
    margin: 15mm 15mm;
    size: A4 portrait;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    overflow: visible !important;
    height: auto !important;
    font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif !important;
  }

  /* 1. إخفاء كل واجهة التطبيق وشاشة التحرير نهائياً وبشكل قاطع */
  .app-header,
  .toolbar-container,
  .panel-editor,
  #panel-editor,
  .editor-container,
  #markdown-editor,
  .panel-header,
  .status-bar,
  .toast-container,
  .dropdown-menu,
  .gutter,
  .diagram-zoom-controls,
  .code-copy-btn,
  .image-resizer-toolbar,
  .resizer-handle,
  .floating-dock-wrapper,
  .editor-floating-actions {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
  }

  .image-resizer-wrapper {
    outline: none !important;
    box-shadow: none !important;
  }

  /* 2. إظهار قسم المعاينة فقط على كامل الصفحة */
  .app-wrapper,
  .workspace-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: #ffffff !important;
  }

  .panel-preview,
  #panel-preview,
  .preview-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    border: none !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .preview-content,
  .markdown-body {
    zoom: 1 !important;
    font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif !important;
    font-size: 11pt !important;
    line-height: 1.85 !important;
    color: #0f172a !important;
    direction: rtl !important;
    text-align: right !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ألوان العناوين الحية والأنيقة */
  .markdown-body h1 {
    color: #1e3a8a !important;
    border-bottom: 2px solid #3b82f6 !important;
    padding-bottom: 8px !important;
    margin-top: 10px !important;
    margin-bottom: 16px !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  .markdown-body h2 {
    color: #1d4ed8 !important;
    border-bottom: 1px solid #cbd5e1 !important;
    padding-bottom: 6px !important;
    margin-top: 20px !important;
    margin-bottom: 14px !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  .markdown-body h3 {
    color: #2563eb !important;
    margin-top: 18px !important;
    margin-bottom: 10px !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  .markdown-body h4 {
    color: #3b82f6 !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  /* تلوين الأكواد البرمجية بالكامل (Syntax Highlighting) لتعود حية وبألوانها الحقيقية */
  .markdown-body pre {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border-radius: 8px !important;
    padding: 14px 18px !important;
    direction: ltr !important;
    text-align: left !important;
    margin: 16px 0 !important;
  }

  .markdown-body pre code {
    font-family: 'Fira Code', 'Consolas', monospace !important;
    font-size: 9.5pt !important;
    color: #0f172a;
  }

  .token.comment, .token.prolog, .token.doctype, .token.cdata { color: #64748b !important; font-style: italic; }
  .token.punctuation { color: #334155 !important; }
  .token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: #0284c7 !important; }
  .token.selector, .token.attr-name, .token.string, .token.char, .token.builtin { color: #16a34a !important; }
  .token.operator, .token.entity, .token.url { color: #d97706 !important; }
  .token.atrule, .token.attr-value, .token.keyword { color: #7c3aed !important; font-weight: bold; }
  .token.function, .token.class-name { color: #2563eb !important; font-weight: 600; }

  /* المخططات فقط هي التي تكون صوراً ثابتة */
  .mermaid-wrapper {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin: 16px 0 !important;
    padding: 14px !important;
    display: flex !important;
    justify-content: center !important;
  }

  .mermaid-wrapper img,
  .mermaid img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* الجداول منسقة مع الألوان والحواف */
  .markdown-body table {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border: 1px solid #cbd5e1 !important;
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 18px 0 !important;
  }

  .markdown-body th {
    background: #f1f5f9 !important;
    color: #1e3a8a !important;
    font-weight: 700 !important;
    border: 1px solid #cbd5e1 !important;
    padding: 8px 12px !important;
  }

  .markdown-body td {
    border: 1px solid #cbd5e1 !important;
    padding: 8px 12px !important;
  }

  .markdown-body tr:nth-child(even) td {
    background: #f8fafc !important;
  }

  .markdown-body blockquote {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border-right: 4px solid #3b82f6 !important;
    background: #eff6ff !important;
    color: #1e40af !important;
    padding: 12px 16px !important;
    border-radius: 0 8px 8px 0 !important;
    margin: 16px 0 !important;
  }
}

/* =========================================================
   PDF Export Container Styling (Hygienic Margins & Borders)
   ========================================================= */
.pdf-export-container {
  box-sizing: border-box !important;
  font-family: 'Tajawal', sans-serif !important;
  background-color: #ffffff !important;
}

.pdf-export-container img {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
  margin: 16px auto !important;
  border-radius: 8px !important;
}

.pdf-export-container table {
  width: 100% !important;
  table-layout: auto !important;
  border-collapse: collapse !important;
  margin: 18px 0 !important;
  word-break: break-word !important;
}

.pdf-export-container pre {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  border-radius: 8px !important;
  padding: 14px 18px !important;
}

.pdf-export-container h1,
.pdf-export-container h2,
.pdf-export-container h3 {
  margin-top: 24px !important;
  margin-bottom: 12px !important;
}

/* =========================================================
   Mobile Tabs Switcher (Hidden on Desktop)
   ========================================================= */
.mobile-tabs-bar {
  display: none;
}

/* =========================================================
   Responsive Design & Mobile Optimization
   ========================================================= */

/* Tablet & Mobile Screens (<= 768px) */
@media (max-width: 768px) {

  /* ترويسة المعاينة على الموبايل: إظهار زري المستكشف و Edit وإخفاء شارة ميرميد */
  .panel-header #preview-mode-badge {
    display: none !important;
  }
  .preview-header-btn {
    display: inline-flex !important;
  }

  html, body, .app-wrapper {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Header Optimization */
  .app-header {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }

  .brand-section {
    gap: 8px;
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .brand-logo svg {
    width: 17px;
    height: 17px;
  }

  .brand-title {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .badge-tag {
    display: none !important;
  }

  .brand-subtitle {
    display: none !important;
  }

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

  .header-actions .btn-text {
    display: none !important;
  }

  .btn {
    padding: 6px 8px;
    font-size: 0.8rem;
    gap: 4px;
    min-height: 32px;
  }

  .btn-outline-classic {
    padding: 6px 8px;
    font-size: 0.78rem;
    min-height: 32px;
  }

  /* Mobile Tabs Switcher */
  .mobile-tabs-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 40;
    box-shadow: var(--shadow-sm);
  }

  .mobile-tab-btn {
    flex: 1;
    max-width: 240px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease-in-out;
  }

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

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

  .mobile-tab-btn.active {
    background: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px var(--accent-glow);
  }

  /* Toolbar: Single Horizontal Scrollable Row */
  .toolbar-container {
    padding: 6px 10px;
    gap: 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--border-color);
  }

  .toolbar-container::-webkit-scrollbar {
    display: none;
  }

  .toolbar-group {
    flex-shrink: 0;
    gap: 4px;
  }

  .tool-btn {
    min-width: 34px;
    height: 34px;
    padding: 6px;
    flex-shrink: 0;
  }

  /* Hide redundant desktop view buttons inside toolbar on mobile */
  #btn-mode-cycle,
  #btn-zoom-out,
  #btn-zoom-in,
  #btn-sync-scroll,
  #btn-reset-split,
  #btn-toggle-resizer-style {
    display: none !important;
  }

  /* Workspace Single-Pane Mode */
  .workspace-container {
    flex-direction: column;
    overflow: hidden;
  }

  /* Hide split resizer on mobile */
  .workspace-resizer {
    display: none !important;
  }

  /* By default on mobile or in mode-editor-only: Show editor only */
  .panel-editor {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-left: none;
    display: flex !important;
  }

  .panel-preview {
    display: none !important;
  }

  /* In preview mode: Show preview only */
  .workspace-container.mode-preview-only .panel-editor {
    display: none !important;
  }

  .workspace-container.mode-preview-only .panel-preview {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
  }

  .panel-header {
    padding: 6px 12px;
    font-size: 0.74rem;
  }

  .editor-textarea {
    padding: 12px 14px 60px 14px;
    font-size: 0.96rem;
    line-height: 1.75;
  }

  .preview-container {
    padding: 16px 14px;
  }

  /* Floating Dock Wrapper: compact position on mobile */
  .floating-dock-wrapper {
    bottom: 10px;
    left: 10px;
    z-index: 35;
  }

  /* Floating Actions: Horizontal Compact Row */
  .editor-floating-actions {
    flex-direction: row;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 8px;
  }

  /* Handle goes to the left of the container on mobile (row layout) */
  .floating-dock-wrapper {
    flex-direction: row;
    align-items: center;
  }

  .floating-dock-handle {
    margin-bottom: 0;
    margin-right: 6px;
  }

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

  /* Status Bar: Compact Single Row */
  .status-bar {
    padding: 4px 10px;
    min-height: 28px;
    font-size: 0.75rem;
    justify-content: space-between;
  }

  .status-copyright,
  .status-bar .status-group:last-child {
    display: none !important;
  }

  /* Dropdown positioning safety */
  .dropdown-menu {
    max-width: 90vw;
    right: 0;
    left: auto;
  }

  /* Markdown Elements: Tables, Code & Diagrams Scroll Safely */
  .markdown-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
  }

  .markdown-body pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-break: normal;
  }

  .markdown-body pre code {
    white-space: pre;
  }

  .markdown-body img,
  .mermaid-wrapper svg,
  .mermaid svg {
    max-width: 100% !important;
    height: auto !important;
  }

  .mermaid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Small Smartphone Screens (<= 480px) */
@media (max-width: 480px) {

  .brand-suffix {
    display: none !important;
  }
  .header-actions .btn-outline-classic {
    display: none !important;
  }

  .app-header {
    padding: 6px 8px;
    gap: 6px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand-logo svg {
    width: 16px;
    height: 16px;
  }

  .brand-title {
    font-size: 0.88rem;
  }

  .badge-tag {
    display: none;
  }

  /* Hide button text on extra small screens, keep icons */
  .header-actions .btn-text {
    display: none;
  }

  .header-actions .btn {
    padding: 6px 8px;
  }

  .header-actions .btn-outline-classic {
    padding: 6px 8px;
  }

  .mobile-tab-btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .editor-textarea {
    padding: 10px 10px 60px 10px;
    font-size: 0.92rem;
  }

  .preview-container {
    padding: 12px 10px;
  }
}

/* ==========================================
   BOOK EXPORT MODAL (نافذة تصدير الكتاب)
   ========================================== */
.book-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  animation: bookFadeIn 0.25s ease;
}

.book-modal-overlay.active {
  display: flex;
}

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

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

.book-modal {
  background: var(--bg-surface, #ffffff);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255,255,255,0.1);
  animation: bookSlideIn 0.3s ease;
  direction: rtl;
}

.book-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.book-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.book-modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.15s;
}

.book-modal-close:hover {
  background: var(--bg-hover, #f1f5f9);
  color: var(--danger-color, #ef4444);
}

.book-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.book-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.book-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.book-checkboxes-inline {
  display: flex;
  align-items: center;
  gap: 14px;
}

.book-checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  user-select: none;
}

.book-checkbox-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color, #3b82f6);
  cursor: pointer;
}

.book-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #475569);
}

.book-field input[type="text"],
.book-field select {
  padding: 10px 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-app, #f8fafc);
  color: var(--text-primary, #0f172a);
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
}

.book-field input[type="text"]:focus,
.book-field select:focus {
  outline: none;
  border-color: var(--accent-color, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.book-field-row {
  display: flex;
  gap: 14px;
}

.book-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.book-color-row input[type="color"] {
  width: 44px;
  height: 38px;
  border: 2px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: transparent;
}

.book-color-label {
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.5px;
}

.book-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
}

.book-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color, #3b82f6);
  cursor: pointer;
}

.book-numbering-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.book-numbering-format-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.book-inline-label {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}

.book-select-compact {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface, #ffffff);
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.book-select-compact:focus {
  border-color: var(--accent-color, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .book-select-compact {
  background: var(--bg-surface-elevated, #1e293b);
  color: var(--text-primary, #f8fafc);
  border-color: var(--border-color, #334155);
}

.book-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.book-export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
  border: none !important;
  color: #fff !important;
  border-radius: 10px !important;
  cursor: pointer;
  transition: all 0.2s;
}

.book-export-btn:hover {
  background: linear-gradient(135deg, #7c3aed, #5b21b6) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

/* Dark mode overrides */
[data-theme="dark"] .book-modal {
  background: var(--bg-surface, #1e293b);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
}

[data-theme="dark"] .book-field input[type="text"],
[data-theme="dark"] .book-field select {
  background: var(--bg-app, #0f172a);
  border-color: var(--border-color, #334155);
  color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .book-color-row input[type="color"] {
  border-color: var(--border-color, #334155);
}

/* Responsive */
@media (max-width: 600px) {
  .book-modal {
    width: 96%;
    max-height: 92vh;
  }
  .book-field-row {
    flex-direction: column;
    gap: 12px;
  }
  .book-modal-body {
    padding: 16px;
  }
}

/* ===================================================
   CHAMBERS SYSTEM (نظام الحجرات التخزينية والمطابقة)
   =================================================== */

.chambers-container {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover, rgba(0, 0, 0, 0.03));
  padding: 3px 8px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border-color, #e2e8f0);
  user-select: none;
  flex-shrink: 0;
}

[data-theme="dark"] .chambers-container {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.chambers-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary, #64748b);
  margin-left: 2px;
  letter-spacing: -0.2px;
}

.chambers-slider-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  position: relative;
}

.chambers-list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* مجموعة التنقل للحجرة المتجاوزة لـ 7 (الصورة 2) */
.chambers-overflow-nav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chamber-active-overflow-slot {
  display: inline-flex;
  align-items: center;
}

/* أسهم التنقل للشريط المتحرك */
.chamber-nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  transition: all 0.16s ease;
  user-select: none;
}

.chamber-nav-arrow svg {
  display: block;
  pointer-events: none;
}

/* السهم الأيسر للوضع العادي (<= 7) */
.chamber-nav-end {
  color: var(--text-muted, #94a3b8);
  opacity: 0.75;
}

.chamber-nav-end:hover {
  color: var(--accent-color, #3b82f6);
  opacity: 1;
  background: rgba(59, 130, 246, 0.08);
  transform: scale(1.1);
}

/* أسهم الوضع المتجاوز لـ 7 (حول الحجرة النشطة كما في الصورة 2) */
.chamber-nav-prev,
.chamber-nav-next {
  color: var(--accent-color, #4f46e5);
}

.chamber-nav-prev:hover,
.chamber-nav-next:hover {
  background: rgba(79, 70, 229, 0.12);
  color: #3730a3;
  transform: scale(1.12);
}

[data-theme="dark"] .chamber-nav-end {
  color: #64748b;
}

[data-theme="dark"] .chamber-nav-end:hover {
  color: #60a5fa;
}

[data-theme="dark"] .chamber-nav-prev,
[data-theme="dark"] .chamber-nav-next {
  color: #818cf8;
}

[data-theme="dark"] .chamber-nav-prev:hover,
[data-theme="dark"] .chamber-nav-next:hover {
  background: rgba(129, 140, 248, 0.16);
  color: #a5b4fc;
}

/* Individual Chamber Button */
.chamber-btn {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  outline: none;
}

/* 1. الحجرة الفارغة (Empty Slot) */
.chamber-btn.empty {
  border: 1.5px dashed rgba(148, 163, 184, 0.5);
  color: var(--text-muted, #94a3b8);
  background: transparent;
  opacity: 0.7;
}

.chamber-btn.empty:hover {
  opacity: 1;
  border-color: var(--accent-color, #3b82f6);
  color: var(--accent-color, #3b82f6);
  background: rgba(59, 130, 246, 0.06);
  transform: translateY(-1px);
}

.chamber-btn.empty .chamber-dot {
  display: none;
}

/* 2. الحجرة الممتلئة (Filled Slot) */
.chamber-btn.filled {
  border: 1.5px solid rgba(59, 130, 246, 0.45);
  color: var(--text-primary, #1e293b);
  background: rgba(59, 130, 246, 0.08);
  font-weight: 700;
  opacity: 1;
}

[data-theme="dark"] .chamber-btn.filled {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
}

.chamber-btn.filled:hover {
  background: rgba(59, 130, 246, 0.16);
  border-color: var(--accent-color, #3b82f6);
  transform: translateY(-1px);
}

/* علامة/نقطة المحتوى بالحجرة الممتلئة (أعلى يمين الحجرة) */
.chamber-dot {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.7);
}

/* 3. الحجرة النشطة المحددة حالياً (Active Slot) */
.chamber-btn.active {
  background: var(--accent-color, #5c67f2) !important;
  color: #ffffff !important;
  border: 1.5px solid var(--accent-color, #5c67f2) !important;
  box-shadow: 0 2px 8px rgba(92, 103, 242, 0.38);
  transform: translateY(-1px);
  z-index: 2;
  opacity: 1;
}

.chamber-btn.active .chamber-dot {
  background: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.9);
}

/* زر المقارنة والمطابقة */
.chamber-diff-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--accent-color, #2563eb);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.16s ease;
  margin-right: 4px;
}

.chamber-diff-btn:hover {
  background: var(--accent-color, #2563eb);
  color: #ffffff;
  border-color: var(--accent-color, #2563eb);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.chamber-diff-label {
  display: inline-block;
}

/* زر مجلد الويندوز الأصفر (Windows Yellow Folder Button) */
.win-folder-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #b45309;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  margin-right: 3px;
  flex-shrink: 0;
}

[data-theme="dark"] .win-folder-btn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.win-folder-btn:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.win-folder-svg {
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.15));
  flex-shrink: 0;
}

.win-folder-svg.sm {
  width: 15px;
  height: 15px;
}

.win-folder-label {
  display: inline-block;
  letter-spacing: -0.2px;
}

/* Context Menu for Chambers */
.chamber-context-menu {
  position: fixed;
  z-index: 10005;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  padding: 4px;
  min-width: 175px;
  animation: contextFadeIn 0.12s ease-out;
}

[data-theme="dark"] .chamber-context-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

@keyframes contextFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.chamber-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  text-align: right;
  transition: background 0.12s;
  font-family: inherit;
}

[data-theme="dark"] .chamber-menu-item {
  color: #f1f5f9;
}

.chamber-menu-item:hover {
  background: var(--bg-hover, #f1f5f9);
  color: var(--accent-color, #2563eb);
}

[data-theme="dark"] .chamber-menu-item:hover {
  background: #334155;
}

.context-divider {
  height: 1px;
  background: var(--border-color, #e2e8f0);
  margin: 3px 0;
}

[data-theme="dark"] .context-divider {
  background: rgba(255, 255, 255, 0.08);
}

.chamber-menu-item.danger {
  color: #ef4444;
}

.chamber-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ===================================================
   CHAMBERS & FOLDERS EXPLORER DRAWER (درج مستكشف الفصول والمجلدات)
   =================================================== */

.explorer-drawer-overlay {
  position: fixed;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  pointer-events: auto;
  border-radius: 4px;
}

.explorer-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.explorer-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: 320px;
  max-width: 90vw;
  height: 100vh;
  background: #fbfbfc;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: right 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  text-align: right;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  user-select: none;
}

[data-theme="dark"] .explorer-drawer {
  background: #18191e;
  border-left-color: rgba(255, 255, 255, 0.07);
  box-shadow: -6px 0 28px rgba(0, 0, 0, 0.5);
}

.explorer-drawer.active {
  right: 0;
}

/* الرأس الهادئ بنمط أوبسيديان Obsidian Header */
.obsidian-header {
  height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: transparent;
  flex-shrink: 0;
}

[data-theme="dark"] .obsidian-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.obsidian-title-section {
  display: flex;
  align-items: center;
  gap: 7px;
}

.obsidian-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #d97706;
}

[data-theme="dark"] .obsidian-title-icon {
  color: #fbbf24;
}

.obsidian-app-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-secondary, #64748b);
}

[data-theme="dark"] .obsidian-app-title {
  color: #94a3b8;
}

.obsidian-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.obsidian-tool-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}

[data-theme="dark"] .obsidian-tool-btn {
  color: #94a3b8;
}

.obsidian-tool-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .obsidian-tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.obsidian-tool-btn.spinning svg {
  animation: spin 0.6s linear infinite;
}

/* حقل البحث والتصفية الهادئ بنمط أوبسيديان */
.obsidian-search {
  margin: 8px 12px 6px 12px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 0 8px;
  height: 28px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

[data-theme="dark"] .obsidian-search {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.07);
}

.obsidian-search:focus-within {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .obsidian-search:focus-within {
  border-color: #3b82f6;
  background: #1e2028;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.obsidian-search svg {
  color: #94a3b8;
  flex-shrink: 0;
  margin-left: 6px;
}

.obsidian-search input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  color: var(--text-primary, #0f172a);
  outline: none;
  font-family: inherit;
  padding: 0;
}

[data-theme="dark"] .obsidian-search input {
  color: #e2e8f0;
}

.obsidian-search input::placeholder {
  color: #94a3b8;
  font-size: 0.76rem;
}

.explorer-search-clear {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.explorer-search-clear:hover {
  color: #ef4444;
}

/* شجرة التفرعات بنمط أوبسيديان Obsidian Tree View */
.obsidian-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* مجلد أوبسيديان بدون كروت مفرغة وبدون حواف ثقيلة */
.obsidian-folder {
  margin-bottom: 2px;
}

.obsidian-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
  color: var(--text-primary, #334155);
}

[data-theme="dark"] .obsidian-folder-header {
  color: #cbd5e1;
}

.obsidian-folder-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .obsidian-folder-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.obsidian-folder-arrow {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

/* سهم المجلد: 90 درجة للمفتوح، 180 أو 0 للمطوي */
.obsidian-folder.collapsed .obsidian-folder-arrow {
  transform: rotate(180deg);
}

.obsidian-folder:not(.collapsed) .obsidian-folder-arrow {
  transform: rotate(90deg);
}

.obsidian-folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.obsidian-folder-name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.obsidian-folder-count {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 500;
  padding: 0 4px;
}

/* خط التفرع الشجري اللطيف (Indentation Guide Line) */
.obsidian-folder-children {
  margin-right: 12px;
  padding-right: 8px;
  border-right: 1px solid rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
  margin-bottom: 4px;
  transition: all 0.2s ease;
}

[data-theme="dark"] .obsidian-folder-children {
  border-right-color: rgba(255, 255, 255, 0.08);
}

.obsidian-folder.collapsed .obsidian-folder-children {
  display: none;
}

/* المجلدات الفرعية المتفرعة (Sub-folders inside Tree) */
.obsidian-folder.sub-folder {
  margin-top: 2px;
  margin-bottom: 2px;
}

.obsidian-folder.sub-folder .obsidian-folder-header {
  padding: 4px 6px;
  font-size: 0.79rem;
  border-radius: 4px;
}

.obsidian-folder.sub-folder .obsidian-folder-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .obsidian-folder.sub-folder .obsidian-folder-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* عنصر الحجرة الشجري بنمط أوبسيديان Obsidian Tree Item */
.obsidian-tree-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
  min-height: 30px;
}

.obsidian-tree-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .obsidian-tree-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* سحب وإفلات الملفات لتغيير ترتيبها ومجلدها Drag and Drop */
.obsidian-tree-item[draggable="true"] {
  cursor: grab;
}

.obsidian-tree-item.is-dragging {
  opacity: 0.35;
  background: rgba(37, 99, 235, 0.08) !important;
  outline: 1.5px dashed #2563eb;
  cursor: grabbing;
}

.obsidian-tree-item.drag-over-top {
  border-top: 2px solid #2563eb !important;
  transform: translateY(1px);
}

.obsidian-tree-item.drag-over-bottom {
  border-bottom: 2px solid #2563eb !important;
  transform: translateY(-1px);
}

.obsidian-folder-children.folder-drag-over,
.obsidian-folder-header.folder-drag-over {
  background: rgba(37, 99, 235, 0.08);
  border-radius: 4px;
}

/* سحب وإفلات المجلدات (Folder Drag & Drop) */
.obsidian-folder-header[draggable="true"] {
  cursor: grab;
}

.obsidian-folder-header[draggable="true"]:active {
  cursor: grabbing;
}

.obsidian-folder.is-folder-dragging {
  opacity: 0.45;
  outline: 1.5px dashed #2563eb;
  border-radius: 6px;
}

.obsidian-tree.root-drag-over {
  background: rgba(37, 99, 235, 0.04);
  outline: 2px dashed rgba(37, 99, 235, 0.4);
  outline-offset: -2px;
}

/* شارة الحجرة المتزامنة حياً */
.obsidian-link-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

[data-theme="dark"] .obsidian-link-badge {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.18);
}

/* تمييز الحجرة النشطة بالنمط الهادئ */
.obsidian-tree-item.active {
  background: rgba(37, 99, 235, 0.08);
}

[data-theme="dark"] .obsidian-tree-item.active {
  background: rgba(59, 130, 246, 0.15);
}

.obsidian-tree-item.active::before {
  content: "";
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: #2563eb;
}

[data-theme="dark"] .obsidian-tree-item.active::before {
  background: #60a5fa;
}

.obsidian-item-num {
  font-size: 0.73rem;
  font-weight: 600;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
  opacity: 0.85;
}

.obsidian-tree-item.active .obsidian-item-num {
  color: #2563eb;
  opacity: 1;
}

[data-theme="dark"] .obsidian-tree-item.active .obsidian-item-num {
  color: #93c5fd;
  opacity: 1;
}

.obsidian-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.obsidian-item-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

[data-theme="dark"] .obsidian-item-title {
  color: #e2e8f0;
}

.obsidian-tree-item.active .obsidian-item-title {
  font-weight: 700;
  color: #1d4ed8;
}

[data-theme="dark"] .obsidian-tree-item.active .obsidian-item-title {
  color: #93c5fd;
}

.obsidian-active-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2563eb;
  flex-shrink: 0;
}

[data-theme="dark"] .obsidian-active-indicator {
  background: #60a5fa;
}

.obsidian-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: #94a3b8;
}

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

.obsidian-dot.filled {
  background: #10b981;
}

.obsidian-dot.empty {
  background: #cbd5e1;
}

[data-theme="dark"] .obsidian-dot.empty {
  background: #475569;
}

.obsidian-meta-sep {
  opacity: 0.5;
}

/* أزرار الإجراءات السريعة (تظهر عند التحويم فقط دون تشويش) */
.obsidian-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}

.obsidian-tree-item:hover .obsidian-item-actions,
.obsidian-tree-item.active .obsidian-item-actions {
  opacity: 1;
}

.obsidian-action-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

[data-theme="dark"] .obsidian-action-btn {
  color: #94a3b8;
}

.obsidian-action-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

[data-theme="dark"] .obsidian-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.obsidian-action-btn.danger:hover {
  background: #fee2e2;
  color: #ef4444;
}

[data-theme="dark"] .obsidian-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* إدخال إعادة التسمية المباشرة النظيف */
.obsidian-inline-edit-box {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
}

.obsidian-rename-input {
  flex: 1;
  padding: 2px 6px;
  font-size: 0.78rem;
  border: 1px solid #2563eb;
  border-radius: 3px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  font-family: inherit;
}

[data-theme="dark"] .obsidian-rename-input {
  background: #0f172a;
  color: #f8fafc;
  border-color: #3b82f6;
}

.obsidian-edit-save-btn, .obsidian-edit-cancel-btn {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0;
}

.obsidian-edit-save-btn {
  background: #10b981;
  color: #ffffff;
}

.obsidian-edit-cancel-btn {
  background: #ef4444;
  color: #ffffff;
}

/* ===================================================
   CHAMBERS MINI MODALS (نوافذ المسودة الجديدة ونقل المجلد)
   =================================================== */

.chamber-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: contextFadeIn 0.15s ease-out;
}

.chamber-modal-dialog {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  direction: rtl;
  text-align: right;
  display: flex;
  flex-direction: column;
}

.chamber-modal-dialog.sm {
  max-width: 390px;
}

[data-theme="dark"] .chamber-modal-dialog {
  background: #182234;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.55);
}

.chamber-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-theme="dark"] .chamber-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.chamber-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chamber-modal-title h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .chamber-modal-title h4 {
  color: #f8fafc;
}

.chamber-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chamber-modal-footer {
  padding: 12px 18px;
  background: var(--bg-hover, rgba(0, 0, 0, 0.02));
  border-top: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

[data-theme="dark"] .chamber-modal-footer {
  background: #131b2a;
  border-top-color: rgba(255, 255, 255, 0.08);
}

.folder-pick-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.folder-pick-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface, #ffffff);
  cursor: pointer;
  text-align: right;
  transition: all 0.15s ease;
  font-family: inherit;
}

[data-theme="dark"] .folder-pick-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.folder-pick-btn:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--accent-color, #2563eb);
  transform: translateY(-1px);
}

.folder-pick-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.folder-pick-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-pick-info strong {
  font-size: 0.85rem;
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .folder-pick-info strong {
  color: #f1f5f9;
}

.folder-pick-info small {
  font-size: 0.72rem;
  color: var(--text-secondary, #64748b);
}

.folder-pick-btn.is-current {
  border-color: rgba(37, 99, 235, 0.4);
  background: rgba(37, 99, 235, 0.04);
}

.folder-pick-current-badge {
  font-size: 0.7rem;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .folder-pick-btn.is-current {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(96, 165, 250, 0.06);
}

[data-theme="dark"] .folder-pick-current-badge {
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.15);
}

/* تذييل المستكشف الهادئ بنمط أوبسيديان Obsidian Footer */
.obsidian-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

[data-theme="dark"] .obsidian-footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

.obsidian-summary-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #64748b;
}

[data-theme="dark"] .obsidian-summary-line {
  color: #94a3b8;
}

.obsidian-stat-sep {
  opacity: 0.45;
}

.obsidian-stat-point {
  font-weight: 600;
}

.explorer-footer-actions {
  display: flex;
  gap: 6px;
}

.obsidian-action-btn-main,
.obsidian-action-btn-sub {
  flex: 1;
  font-size: 0.78rem !important;
  padding: 6px 10px !important;
  border-radius: 6px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ===================================================
   DIFF & COMPARISON MODAL (نافذة مطابقة الحجرات)
   =================================================== */

.diff-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 16px;
}

.diff-modal-overlay.active {
  display: flex;
  animation: diffModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes diffModalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.diff-modal {
  background: var(--bg-surface, #ffffff);
  border-radius: var(--radius-lg, 14px);
  width: 95%;
  max-width: 1100px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color, #e2e8f0);
  overflow: hidden;
  direction: rtl;
}

[data-theme="dark"] .diff-modal {
  background: #151e2e;
  border-color: #2b394f;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
}

.diff-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-toolbar, #f8fafc);
}

[data-theme="dark"] .diff-modal-header {
  background: #111827;
  border-color: #283548;
}

.diff-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-color, #2563eb);
}

.diff-modal-title h2 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .diff-modal-title h2 {
  color: #f8fafc;
}

.diff-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.diff-modal-close:hover {
  color: #ef4444;
}

.diff-modal-toolbar {
  padding: 10px 20px;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

[data-theme="dark"] .diff-modal-toolbar {
  background: #151e2e;
  border-color: #283548;
}

.diff-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diff-select-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
}

.diff-select-box select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-app, #f8fafc);
  color: var(--text-primary, #0f172a);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
}

[data-theme="dark"] .diff-select-box select {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.diff-swap-btn {
  background: var(--bg-hover, #f1f5f9);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  transition: all 0.15s;
}

[data-theme="dark"] .diff-swap-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.diff-swap-btn:hover {
  background: var(--accent-light, #eff6ff);
  color: var(--accent-color, #2563eb);
  border-color: var(--accent-color, #2563eb);
}

.diff-view-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-hover, #f1f5f9);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
}

[data-theme="dark"] .diff-view-toggles {
  background: #0f172a;
  border-color: #334155;
}

.diff-view-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: inherit;
}

.diff-view-btn.active {
  background: var(--bg-surface, #ffffff);
  color: var(--accent-color, #2563eb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .diff-view-btn.active {
  background: #1e293b;
  color: #60a5fa;
}

.diff-modal-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
}

/* Split Pane View */
.diff-split-container {
  display: flex;
  width: 100%;
  height: 100%;
}

.diff-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border-color, #e2e8f0);
}

.diff-pane:first-child {
  border-left: none;
}

[data-theme="dark"] .diff-pane {
  border-color: #283548;
}

.diff-pane-header {
  padding: 8px 14px;
  background: var(--bg-toolbar, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  display: flex;
  justify-content: space-between;
}

[data-theme="dark"] .diff-pane-header {
  background: #111827;
  border-color: #283548;
  color: #f1f5f9;
}

.diff-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Line-by-Line Diff View */
.diff-lines-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  font-family: 'Fira Code', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  background: var(--bg-app, #f8fafc);
}

[data-theme="dark"] .diff-lines-container {
  background: #0b1120;
}

.diff-line-row {
  display: flex;
  padding: 2px 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line-row.diff-line-added {
  background: rgba(16, 185, 129, 0.15);
  color: #065f46;
}

[data-theme="dark"] .diff-line-row.diff-line-added {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.diff-line-row.diff-line-removed {
  background: rgba(239, 68, 68, 0.15);
  color: #991b1b;
}

[data-theme="dark"] .diff-line-row.diff-line-removed {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.diff-line-row.diff-line-unchanged {
  color: var(--text-secondary, #64748b);
}

.diff-line-prefix {
  user-select: none;
  width: 22px;
  font-weight: 700;
  display: inline-block;
  opacity: 0.7;
}

.diff-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-toolbar, #f8fafc);
  flex-wrap: wrap;
  gap: 10px;
}

[data-theme="dark"] .diff-modal-footer {
  background: #111827;
  border-color: #283548;
}

.diff-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diff-summary-info {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
}

/* ===================================================
   BOOK MODAL CHAMBERS SCOPE (خيارات الحجرات في الكتاب)
   =================================================== */

.book-scope-options {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.book-radio-pill {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color, #cbd5e1);
  background: var(--bg-app, #f8fafc);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

[data-theme="dark"] .book-radio-pill {
  background: var(--bg-app, #0f172a);
  border-color: #334155;
  color: #f1f5f9;
}

.book-radio-pill:hover {
  border-color: var(--accent-color, #3b82f6);
}

.book-radio-pill.active {
  border-color: var(--accent-color, #2563eb);
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-color, #2563eb);
}

[data-theme="dark"] .book-radio-pill.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: #60a5fa;
}

.book-chambers-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-app, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 8px 12px;
  max-height: 180px;
  overflow-y: auto;
}

[data-theme="dark"] .book-chambers-checklist {
  background: #0f172a;
  border-color: #283548;
}

.book-chamber-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.12s;
  cursor: pointer;
}

.book-chamber-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}

[data-theme="dark"] .book-chamber-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.book-chamber-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-color, #2563eb);
}

.book-chamber-title-text {
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

[data-theme="dark"] .book-chamber-title-text {
  color: #f1f5f9;
}

/* ===================================================
   MOBILE RESPONSIVE ADJUSTMENTS FOR CHAMBERS & DIFF
   =================================================== */

@media (max-width: 768px) {
  /* 1. شريط الحجرات على الموبايل */
  .chambers-container {
    padding: 2px 5px;
    gap: 3px;
  }

  /* إخفاء كلمة "الحجرات:" لتوفير المساحة للشاشة الصغيرة */
  .chambers-label {
    display: none;
  }

  .chamber-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 0.85rem;
    -webkit-tap-highlight-color: transparent;
  }

  /* زر مجلد الويندوز على الموبايل */
  .win-folder-btn {
    height: 28px;
    padding: 0 6px;
    margin-right: 2px;
  }

  .win-folder-label {
    display: none;
  }

  /* درج المستكشف على الموبايل */
  .explorer-drawer {
    width: 92vw;
    max-width: 92vw;
    right: -95vw;
  }

  /* زر المطابقة على الموبايل */
  .chamber-diff-btn {
    height: 28px;
    padding: 0 6px;
    font-size: 0.75rem;
  }

  /* 2. نافذة المطابقة والمقارنة على الموبايل */
  .diff-modal {
    width: 98%;
    height: 94vh;
    border-radius: var(--radius-md, 10px);
  }

  .diff-modal-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
  }

  .diff-selector-row {
    justify-content: space-between;
    width: 100%;
  }

  .diff-select-box {
    flex: 1;
  }

  .diff-select-box select {
    width: 100%;
    max-width: 135px;
  }

  .diff-view-toggles {
    width: 100%;
    justify-content: center;
  }

  .diff-view-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
  }

  /* العرض جنباً إلى جنب يتحول لعمودي مريح في الموبايل */
  .diff-split-container {
    flex-direction: column;
  }

  .diff-pane {
    border-left: none;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    height: 50%;
  }

  [data-theme="dark"] .diff-pane {
    border-bottom-color: #283548;
  }

  .diff-modal-footer {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .diff-summary-info {
    text-align: center;
    font-size: 0.78rem;
  }

  .diff-footer-actions {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .diff-footer-actions .btn {
    flex: 1;
    padding: 7px 8px;
    font-size: 0.78rem;
    justify-content: center;
  }

  /* 3. خيارات الحجرات في نافذة تصدير الكتاب */
  .book-scope-options {
    flex-direction: column;
  }

  .book-radio-pill {
    min-width: unset;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .chamber-diff-btn .chamber-diff-label {
    display: none;
  }

  .chamber-diff-btn {
    padding: 0 7px;
  }
}

/* ===================================================
   LEGAL PAGES & DROPDOWN & MODAL (الصفحات القانونية لـ AdSense)
   =================================================== */

.status-left-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-sep {
  opacity: 0.35;
  font-size: 0.85rem;
}

.legal-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.legal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover, #f1f5f9);
  color: var(--accent-color, #2563eb);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  user-select: none;
}

.legal-btn:hover {
  background: var(--accent-light, #eff6ff);
  border-color: var(--accent-color, #2563eb);
  transform: translateY(-1px);
}

[data-theme="dark"] .legal-btn {
  background: #1e293b;
  border-color: #334155;
  color: #60a5fa;
}

[data-theme="dark"] .legal-btn:hover {
  background: #273549;
  border-color: #60a5fa;
}

.legal-caret {
  transition: transform 0.2s ease;
}

.legal-dropdown-wrap.open .legal-caret {
  transform: rotate(180deg);
}

/* Popover Menu (تنبثق للأعلى Drop-up) */
.legal-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: 290px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
  z-index: 1000;
  display: none;
  overflow: hidden;
  direction: rtl;
  text-align: right;
  animation: legalPopUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .legal-popover {
  background: #151e2e;
  border-color: #2b394f;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.legal-dropdown-wrap.open .legal-popover {
  display: block;
}

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

.legal-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-toolbar, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary, #475569);
}

[data-theme="dark"] .legal-popover-header {
  background: #111827;
  border-color: #283548;
  color: #94a3b8;
}

.legal-popover-all {
  color: var(--accent-color, #2563eb);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
}

.legal-popover-all:hover {
  text-decoration: underline;
}

.legal-popover-list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legal-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}

.legal-popover-item:hover {
  background: var(--bg-hover, #f1f5f9);
}

[data-theme="dark"] .legal-popover-item:hover {
  background: #1e293b;
}

.legal-popover-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.legal-popover-texts {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.legal-popover-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .legal-popover-title {
  color: #f1f5f9;
}

.legal-popover-desc {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
}

/* ===================================================
   LEGAL MODAL READER (نافذة قراءة الصفحات داخل الموقع)
   =================================================== */

.legal-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.legal-modal-overlay.active {
  display: flex;
  animation: legalModalFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes legalModalFade {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.legal-modal-dialog {
  background: var(--bg-surface, #ffffff);
  border-radius: var(--radius-lg, 16px);
  width: 95%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color, #e2e8f0);
  overflow: hidden;
  direction: rtl;
  text-align: right;
}

[data-theme="dark"] .legal-modal-dialog {
  background: #151e2e;
  border-color: #2b394f;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.legal-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-toolbar, #f8fafc);
}

[data-theme="dark"] .legal-modal-header {
  background: #111827;
  border-color: #283548;
}

.legal-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legal-modal-icon {
  font-size: 1.5rem;
}

.legal-modal-header-texts h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary, #0f172a);
}

[data-theme="dark"] .legal-modal-header-texts h3 {
  color: #f1f5f9;
}

.legal-modal-sub {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
}

.legal-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary, #1e293b);
}

[data-theme="dark"] .legal-modal-body {
  color: #e2e8f0;
}

.legal-modal-body h4 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--accent-color, #2563eb);
}

.legal-modal-body p {
  margin-bottom: 12px;
}

.legal-modal-body ul {
  margin: 10px 20px 16px;
}

.legal-modal-body li {
  margin-bottom: 6px;
}

.legal-modal-highlight {
  background: var(--bg-hover, #f8fafc);
  border-right: 4px solid var(--accent-color, #2563eb);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 0.92rem;
}

[data-theme="dark"] .legal-modal-highlight {
  background: #1e293b;
}

.legal-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-toolbar, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

[data-theme="dark"] .legal-modal-footer {
  background: #111827;
  border-color: #283548;
}

.legal-modal-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.legal-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  transition: all 0.15s ease;
  font-family: inherit;
}

.legal-tab-btn:hover {
  background: var(--bg-hover, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

.legal-tab-btn.active {
  background: var(--accent-color, #2563eb);
  color: #ffffff;
  border-color: var(--accent-color, #2563eb);
}

[data-theme="dark"] .legal-tab-btn {
  color: #94a3b8;
}

[data-theme="dark"] .legal-tab-btn:hover {
  background: #1e293b;
  color: #f1f5f9;
}

[data-theme="dark"] .legal-tab-btn.active {
  background: #3b82f6;
  color: #ffffff;
}

@media (max-width: 600px) {
  .status-left-group {
    flex-wrap: wrap;
    gap: 6px;
  }
  .legal-popover {
    left: auto;
    right: 0;
    width: 260px;
  }
  .legal-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .legal-modal-nav {
    justify-content: center;
  }
}

/* =========================================================
   Mermaid Diagrams - Node Text Clipping Fix
   يمنع اقتصاص النص خاصة السطر الثاني بعد <br/>
   ========================================================= */

/* تطبيق خط التطبيق على كل عناصر Mermaid */
.mermaid,
.mermaid svg,
.mermaid svg text,
.mermaid svg .label,
.mermaid svg .nodeLabel,
.mermaid svg .edgeLabel {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* إصلاح foreignObject داخل عقد Mermaid - السبب الرئيسي للاقتصاص */
.mermaid svg .node foreignObject,
.mermaid svg foreignObject {
  overflow: visible !important;
}

/* إصلاح div و p داخل foreignObject */
.mermaid svg .node foreignObject > *,
.mermaid svg .node foreignObject div,
.mermaid svg .node foreignObject p,
.mermaid svg foreignObject > *,
.mermaid svg foreignObject div {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  direction: rtl;
  text-align: center;
  white-space: normal !important;
  overflow: visible !important;
  word-break: break-word;
  line-height: 1.5;
}

/* إصلاح تسمية العقدة (nodeLabel) */
.mermaid svg .nodeLabel,
.mermaid svg .label {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* ضمان عدم قص النص في أي عقدة */
.mermaid svg .node rect,
.mermaid svg .node polygon,
.mermaid svg .node circle,
.mermaid svg .node ellipse {
  overflow: visible !important;
}

/* مجموعة العقدة الكاملة */
.mermaid svg .nodes .node,
.mermaid svg g.node {
  overflow: visible !important;
}

/* مخطط الانسياب - wrapper */
.mermaid-wrapper {
  text-align: center;
  margin: 24px 0;
  padding: 20px 16px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  overflow: visible;
  position: relative;
}

.mermaid-wrapper svg {
  max-width: 100%;
  height: auto;
  overflow: visible !important;
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

[data-theme="dark"] .mermaid-wrapper {
  background: var(--bg-surface-elevated, #1a2434);
  border-color: var(--border-color, #1e293b);
}

/* ========================================================
   زر تحرير المعاينة المباشر (Neumorphic WYSIWYG Toggle Button)
   مستوحى من تصميم زر PUSH النيومورفي بالكامل
   ======================================================== */
.wysiwyg-preview-btn {
  position: relative;
  height: 28px;
  min-width: 32px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #efefef;
  border: none;
  border-radius: 7px;
  /* تظليل نيومورفي ناعم ومطابق لزر PUSH: ضوء أبيض علوي-يساري وظل رمادي سفلي-يميني */
  box-shadow: -2.5px -2.5px 6px rgba(255, 255, 255, 0.95), 2.5px 2.5px 5.5px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  margin-right: 4px;
  flex-shrink: 0;
  outline: none;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #515151; /* لون الخط الخاص بزر PUSH تماماً */
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.35px;
}

.wysiwyg-preview-btn:hover {
  background: #f5f5f5;
  box-shadow: -3px -3px 7px rgba(255, 255, 255, 1), 3px 3px 7px rgba(0, 0, 0, 0.15);
}

/* حالة التفعيل: لا يتغير شكله أبداً (بدون غؤور ولا إطار)، فقط لون الخط والظل يتحولان للأزرق */
.wysiwyg-preview-btn.active {
  background: #efefef;
  color: #2563eb; /* تحول لون الكتابة للأزرق */
  box-shadow: -2.5px -2.5px 6px rgba(255, 255, 255, 0.95), 2.5px 2.5px 7.5px rgba(37, 99, 235, 0.42); /* تحول الظل للأزرق */
}

.wysiwyg-preview-btn.active:hover {
  background: #f5f5f5;
  color: #1d4ed8;
  box-shadow: -3px -3px 7px rgba(255, 255, 255, 1), 3px 3px 8.5px rgba(37, 99, 235, 0.55);
}

.wysiwyg-btn-text {
  display: inline-block;
  line-height: 1;
  pointer-events: none;
}

/* دعم الوضع الليلي */
[data-theme="dark"] .wysiwyg-preview-btn {
  background: #232730;
  color: #cbd5e1;
  box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 2px 2px 6px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .wysiwyg-preview-btn:hover {
  background: #282d38;
  box-shadow: -2.5px -2.5px 6px rgba(255, 255, 255, 0.08), 2.5px 2.5px 7px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .wysiwyg-preview-btn.active {
  background: #232730;
  color: #60a5fa; /* تحول لون الخط للأزرق الفاتح في الوضع الليلي */
  box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.05), 2px 2px 8px rgba(96, 165, 250, 0.55); /* تحول الظل للأزرق في الوضع الليلي */
}

[data-theme="dark"] .wysiwyg-preview-btn.active:hover {
  background: #282d38;
  color: #93c5fd;
  box-shadow: -2.5px -2.5px 6px rgba(255, 255, 255, 0.08), 2.5px 2.5px 9px rgba(96, 165, 250, 0.7);
}

/* ========================================================
   تنسيقات منطقة المعاينة عند تفعيل التحرير المباشر
   ======================================================== */
#preview-content.preview-editable {
  outline: none;
  cursor: text;
  caret-color: var(--accent-color, #2563eb);
  min-height: 100%;
}

#preview-content.preview-editable > p:hover,
#preview-content.preview-editable > h1:hover,
#preview-content.preview-editable > h2:hover,
#preview-content.preview-editable > h3:hover,
#preview-content.preview-editable > h4:hover,
#preview-content.preview-editable > h5:hover,
#preview-content.preview-editable > h6:hover,
#preview-content.preview-editable > ul:hover,
#preview-content.preview-editable > ol:hover,
#preview-content.preview-editable > blockquote:hover,
#preview-content.preview-editable > table:hover {
  background: rgba(37, 99, 235, 0.035);
  border-radius: 4px;
  outline: 1px dashed rgba(37, 99, 235, 0.25);
  outline-offset: 3px;
  transition: background 0.15s ease, outline 0.15s ease;
}

[data-theme="dark"] #preview-content.preview-editable > p:hover,
[data-theme="dark"] #preview-content.preview-editable > h1:hover,
[data-theme="dark"] #preview-content.preview-editable > h2:hover,
[data-theme="dark"] #preview-content.preview-editable > h3:hover,
[data-theme="dark"] #preview-content.preview-editable > h4:hover,
[data-theme="dark"] #preview-content.preview-editable > h5:hover,
[data-theme="dark"] #preview-content.preview-editable > h6:hover,
[data-theme="dark"] #preview-content.preview-editable > ul:hover,
[data-theme="dark"] #preview-content.preview-editable > ol:hover,
[data-theme="dark"] #preview-content.preview-editable > blockquote:hover,
[data-theme="dark"] #preview-content.preview-editable > table:hover {
  background: rgba(96, 165, 250, 0.05);
  outline-color: rgba(96, 165, 250, 0.3);
}

.wysiwyg-active-badge {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
  animation: pulseBadge 2.2s infinite ease-in-out;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); opacity: 0.85; }
}

/* ========================================================
   شريط التنسيق العائم (Floating Formatting Toolbar)
   ======================================================== */
.wysiwyg-floating-toolbar {
  position: fixed;
  z-index: 10050;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.45), 0 0 1px rgba(255, 255, 255, 0.25);
  transform: translate(-50%, -6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  user-select: none;
  direction: ltr;
}

.wysiwyg-floating-toolbar.visible {
  display: flex;
  transform: translate(-50%, 0);
}

.wysiwyg-tool-btn {
  width: 27px;
  height: 27px;
  border: none;
  background: transparent;
  color: #cbd5e1;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
  padding: 0;
  font-family: inherit;
}

.wysiwyg-tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  transform: translateY(-1px);
}

.wysiwyg-tool-btn.active {
  background: var(--accent-color, #2563eb);
  color: #ffffff;
}

.wysiwyg-tool-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.wysiwyg-toolbar-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 3px;
}

/* أيقونة زر لون الخط (A مع مؤشر لوني سفلي) */
.wysiwyg-color-icon-a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.wysiwyg-color-icon-a .letter-a {
  font-size: 11px;
  font-weight: 800;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f1f5f9;
  line-height: 1;
}

.wysiwyg-color-icon-a .color-bar {
  width: 13px;
  height: 2.5px;
  border-radius: 1px;
  margin-top: 1.5px;
  background-color: #ef4444;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}

/* لوحة الألوان المنبثقة للشريط العائم (Color Palette Popover) */
.wysiwyg-color-popover {
  position: fixed;
  z-index: 10060;
  width: 236px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.3);
  user-select: none;
  direction: rtl;
  font-family: inherit;
  animation: popoverFadeIn 0.14s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.wysiwyg-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wysiwyg-popover-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #94a3b8;
}

.wysiwyg-clear-color-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wysiwyg-clear-color-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.wysiwyg-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.wysiwyg-color-swatch {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  padding: 0;
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.wysiwyg-color-swatch:hover {
  transform: scale(1.18);
  z-index: 2;
  border-color: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), 0 0 6px rgba(255, 255, 255, 0.4);
}

.wysiwyg-custom-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.wysiwyg-custom-color-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
}

.wysiwyg-custom-color-picker {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

/* ========================================================
   أيقونات وإيموجي فلات ملونة (Rich Flat Emoji & Badges)
   ======================================================== */
.inline-emoji,
.markdown-body img.inline-emoji:not([width]):not([style*="width"]),
#preview-content img.inline-emoji:not([width]):not([style*="width"]),
#wysiwyg-editor img.inline-emoji:not([width]):not([style*="width"]) {
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.22em;
  display: inline-block;
  margin: 0 3px;
  padding: 0;
  border: none !important;
  outline: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  object-fit: contain;
}

/* احترام أي حجم مخصص محدد على الأيقونة بالماركداون أو بأداة التحجيم */
.inline-emoji[width],
.inline-emoji[style*="width"],
#preview-content img.inline-emoji[width],
#preview-content img.inline-emoji[style*="width"],
#wysiwyg-editor img.inline-emoji[width],
#wysiwyg-editor img.inline-emoji[style*="width"],
.markdown-body img.inline-emoji[width],
.markdown-body img.inline-emoji[style*="width"] {
  height: auto !important;
  max-width: 100%;
  vertical-align: middle;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* داخل حاوية التحجيم تملأ الأيقونة حجم الحاوية وتتحكم بها بسلاسة */
.image-resizer-wrapper img.inline-emoji,
.image-resizer-wrapper.is-emoji-wrapper img {
  width: 100% !important;
  height: auto !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* لوحة منتقي الأيقونات والإيموجي الملونة (Emoji Popover) */
.emoji-picker-popover {
  position: fixed;
  z-index: 10065;
  width: 350px;
  max-height: 430px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 20px 48px -4px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.3);
  user-select: none;
  direction: rtl;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: popoverFadeIn 0.14s ease-out;
}

.emoji-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emoji-search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 5px 9px;
  gap: 6px;
}

.emoji-search-wrapper svg {
  color: #94a3b8;
  flex-shrink: 0;
}

.emoji-search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-size: 0.78rem;
  outline: none;
  direction: rtl;
}

.emoji-search-input::placeholder {
  color: #64748b;
}

.emoji-picker-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.emoji-picker-close-btn:hover {
  color: #ef4444;
}

.emoji-category-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-width: thin;
}

.emoji-category-tabs::-webkit-scrollbar {
  height: 4px;
}

.emoji-category-tabs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.emoji-cat-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.71rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.emoji-cat-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #f1f5f9;
}

.emoji-cat-btn.active {
  background: var(--accent-color, #2563eb);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  overflow-y: auto;
  max-height: 275px;
  padding: 2px 2px 8px 2px;
}

.emoji-picker-grid::-webkit-scrollbar {
  width: 4px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.emoji-grid-item {
  width: 38px;
  height: 38px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.emoji-grid-item:hover {
  transform: scale(1.18);
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.emoji-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}


/* ==========================================================================
   SETTINGS MODAL — شاشة الإعدادات الاحترافية
   ========================================================================== */

/* Gear Button Animation */
.settings-gear-btn svg {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.settings-gear-btn:hover svg {
  transform: rotate(90deg);
}

/* Overlay */
.settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: settingsFadeIn 0.25s ease;
}
.settings-modal-overlay.active {
  display: flex;
}

@keyframes settingsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes settingsSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal Container */
.settings-modal {
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-color, rgba(0,0,0,0.1));
  border-radius: 16px;
  width: 90vw;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255,255,255,0.05);
  animation: settingsSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

[data-theme="dark"] .settings-modal {
  background: #1a1b2e;
  border-color: rgba(255,255,255,0.08);
}

/* Header */
.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.03));
}
[data-theme="dark"] .settings-modal-header {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
  border-color: rgba(255,255,255,0.06);
}
.settings-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-modal-title svg {
  color: #6366f1;
}
.settings-modal-title h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
}
[data-theme="dark"] .settings-modal-title h2 {
  color: #e2e8f0;
}
.settings-modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}
.settings-modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Body: Sidebar + Content */
.settings-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Sidebar Tabs */
.settings-sidebar {
  width: 180px;
  min-width: 180px;
  border-left: 1px solid var(--border-color, rgba(0,0,0,0.08));
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.015);
  overflow-y: auto;
}
[data-theme="dark"] .settings-sidebar {
  background: rgba(255, 255, 255, 0.02);
  border-left-color: rgba(255,255,255,0.06);
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  transition: all 0.2s;
  text-align: start;
  font-family: inherit;
  position: relative;
}
.settings-tab-btn:hover {
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-primary, #1e293b);
}
.settings-tab-btn.active {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  font-weight: 600;
}
[data-theme="dark"] .settings-tab-btn.active {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
}
.settings-tab-btn svg {
  flex-shrink: 0;
}
.settings-tab-badge {
  font-size: 0.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  margin-right: auto;
  letter-spacing: 0.3px;
}

/* Content Area */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  scroll-behavior: smooth;
}

.settings-panel {
  display: none;
}
.settings-panel.active {
  display: block;
  animation: settingsPanelIn 0.2s ease;
}
@keyframes settingsPanelIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Section Titles */
.settings-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text-primary, #1e293b);
}
[data-theme="dark"] .settings-section-title {
  color: #e2e8f0;
}
.settings-section-desc {
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
  margin: 0 0 18px;
  line-height: 1.6;
}

/* Settings Groups */
.settings-group {
  margin-bottom: 20px;
}
.settings-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  margin-bottom: 6px;
}
[data-theme="dark"] .settings-label {
  color: #cbd5e1;
}
.settings-hint {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
  margin: 2px 0 8px;
  line-height: 1.5;
}
.settings-hint a {
  color: #6366f1;
  text-decoration: none;
}
.settings-hint a:hover {
  text-decoration: underline;
}

/* Toggle Switch */
.settings-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.settings-toggle input { display: none; }
.settings-toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.settings-toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  right: 3px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.settings-toggle input:checked + .settings-toggle-slider {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.settings-toggle input:checked + .settings-toggle-slider::before {
  transform: translateX(-20px);
}

/* Large Toggle for Master Switch */
.settings-toggle-lg {
  width: 56px;
  height: 30px;
}
.settings-toggle-lg .settings-toggle-slider::before {
  width: 24px;
  height: 24px;
}
.settings-toggle-lg input:checked + .settings-toggle-slider::before {
  transform: translateX(-26px);
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-toggle-desc {
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
}
.settings-toggle-desc code {
  background: rgba(99, 102, 241, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.settings-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Master Toggle Card */
.settings-master-toggle {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.04));
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  padding: 16px;
}
[data-theme="dark"] .settings-master-toggle {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
  border-color: rgba(99, 102, 241, 0.25);
}

/* Sub-settings group */
.settings-sub-group {
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.06));
  padding-top: 16px;
  margin-top: 16px;
}

/* Radio Pill Group */
.settings-radio-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.settings-radio-pill {
  cursor: pointer;
}
.settings-radio-pill input { display: none; }
.settings-radio-pill span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  color: var(--text-secondary, #64748b);
  transition: all 0.2s;
  background: transparent;
}
.settings-radio-pill:hover span {
  border-color: #6366f1;
  color: #6366f1;
}
.settings-radio-pill input:checked + span {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Slider */
.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
[data-theme="dark"] .settings-slider {
  background: #334155;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s;
}
.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  cursor: pointer;
  border: none;
}
.settings-slider-value {
  min-width: 40px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
}
.settings-slider-label-start,
.settings-slider-label-end {
  font-size: 0.72rem;
  color: var(--text-secondary, #94a3b8);
  white-space: nowrap;
}

/* Select */
.settings-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  transition: border-color 0.2s;
}
.settings-select:focus {
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .settings-select {
  background: #1e293b;
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}

/* Input */
.settings-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1e293b);
  transition: border-color 0.2s;
}
.settings-input:focus {
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .settings-input {
  background: #1e293b;
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}

/* Color Picker */
.settings-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-color-picker {
  width: 40px;
  height: 32px;
  border: 2px solid var(--border-color, rgba(0,0,0,0.1));
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}
.settings-color-label {
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
  font-family: 'Fira Code', monospace;
}

/* API Row */
.settings-api-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.settings-api-row .settings-input {
  flex: 1;
}

/* Voice Row */
.settings-voice-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.settings-voice-row .settings-select {
  flex: 1;
}

/* Mini Buttons */
.settings-mini-btn {
  padding: 6px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.settings-mini-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}

/* Action Buttons */
.settings-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 10px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1e293b);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.settings-action-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .settings-action-btn {
  background: #1e293b;
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}

.settings-danger-btn {
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}
.settings-danger-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.settings-danger-zone {
  border-top: 1px dashed rgba(239, 68, 68, 0.25);
  padding-top: 16px;
  margin-top: 24px;
}

/* Info Box */
.settings-info-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-primary, #1e293b);
}
[data-theme="dark"] .settings-info-box {
  background: rgba(99, 102, 241, 0.1);
  color: #e2e8f0;
}
.settings-info-icon { font-size: 1.2rem; }

/* About Section */
.settings-about-card {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.04));
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 14px;
  margin-bottom: 20px;
}
[data-theme="dark"] .settings-about-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
}
.settings-about-logo {
  flex-shrink: 0;
}
.settings-about-info h4 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
}
[data-theme="dark"] .settings-about-info h4 { color: #e2e8f0; }
.settings-about-version {
  font-size: 0.78rem;
  color: #6366f1;
  font-weight: 600;
  margin: 0 0 8px;
}
.settings-about-desc {
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
  line-height: 1.6;
  margin: 0;
}
.settings-about-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 10px;
  overflow: hidden;
}
.settings-about-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.83rem;
  background: rgba(0, 0, 0, 0.02);
}
.settings-about-row:nth-child(even) { background: rgba(0, 0, 0, 0.04); }
[data-theme="dark"] .settings-about-row { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .settings-about-row:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
.settings-about-row span:first-child { color: var(--text-secondary, #64748b); }
.settings-about-row span:last-child { font-weight: 600; color: var(--text-primary, #1e293b); }
[data-theme="dark"] .settings-about-row span:last-child { color: #e2e8f0; }

/* Footer */
.settings-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
  background: rgba(0, 0, 0, 0.015);
}
[data-theme="dark"] .settings-modal-footer {
  background: rgba(255, 255, 255, 0.02);
  border-top-color: rgba(255,255,255,0.06);
}

/* ==========================================================================
   PRONUNCIATION ASSISTANT — مساعد النطق في المعاينة
   ========================================================================== */

/* Isolated phrase wrapper with strict LTR direction - strictly on baseline */
.pronunciation-phrase {
  display: inline;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
  margin: 0 2px;
  vertical-align: baseline;
  line-height: inherit;
}

/* Pronunciation-enabled words (dotted underline) */
.pronunciation-word {
  display: inline;
  vertical-align: baseline;
  text-decoration: underline dotted;
  text-decoration-color: rgba(99, 102, 241, 0.45);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  padding: 0 1px;
  position: relative;
}
.pronunciation-word:hover {
  text-decoration-color: #6366f1;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
}
[data-theme="dark"] .pronunciation-word:hover {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.22);
}
.pronunciation-word.speaking {
  background: rgba(99, 102, 241, 0.25) !important;
  color: #4338ca !important;
  text-decoration-color: #6366f1 !important;
  animation: wordPulse 0.7s infinite alternate;
}
[data-theme="dark"] .pronunciation-word.speaking {
  background: rgba(99, 102, 241, 0.4) !important;
  color: #e0e7ff !important;
}

@keyframes wordPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  100% { transform: scale(1.05); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0); }
}

/* Synchronized word highlighting in parallel with speech */
.pronunciation-word.word-sync-active {
  background: rgba(99, 102, 241, 0.12) !important;
  color: #4f46e5 !important;
  text-decoration-color: #6366f1 !important;
  border-radius: 4px;
  transition: background 0.08s ease, color 0.08s ease;
}
[data-theme="dark"] .pronunciation-word.word-sync-active {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #c7d2fe !important;
  text-decoration-color: #6366f1 !important;
}

/* No underline variant */
.pronunciation-word.no-underline {
  text-decoration: none;
}

/* Speaker icon button - Beautiful circular design */
.pronunciation-speaker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.08);
  color: #6366f1;
  border-radius: 50%;
  cursor: pointer;
  margin: 0 3px;
  padding: 0;
  vertical-align: -2.5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[data-theme="dark"] .pronunciation-speaker-btn {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}
.pronunciation-speaker-btn:hover {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.pronunciation-speaker-btn.speaking {
  background: #6366f1 !important;
  color: #ffffff !important;
  border-color: #6366f1 !important;
  animation: speakerPulse 0.5s infinite alternate;
}
@keyframes speakerPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
  100% { transform: scale(1.22); box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}
.pronunciation-speaker-btn svg {
  width: 12px;
  height: 12px;
}

/* Translation icon button (文A) - Beautiful rounded rectangle */
.pronunciation-trans-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0 3px;
  padding: 0;
  background: var(--bg-hover, #f1f5f9);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  vertical-align: -2.5px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pronunciation-trans-btn:hover {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #059669;
  transform: scale(1.12);
}

.pronunciation-trans-btn.is-active {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #16a34a !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25) !important;
}

[data-theme="dark"] .pronunciation-trans-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

[data-theme="dark"] .pronunciation-trans-btn:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

[data-theme="dark"] .pronunciation-trans-btn.is-active {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  color: #4ade80 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25) !important;
}

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

/* Quick speed presets */
.settings-speed-presets {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.settings-preset-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  border: 1px solid var(--border-color, rgba(0,0,0,0.1));
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
[data-theme="dark"] .settings-preset-btn {
  background: rgba(99, 102, 241, 0.12);
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}
.settings-preset-btn:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

/* ==========================================================================
   PRONUNCIATION SPEAKER CONTEXT MENU (قائمة زر الماوس الأيمن لمساعد النطق)
   ========================================================================== */

.pronunciation-context-menu {
  position: fixed;
  z-index: 10050;
  width: 295px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
  padding: 6px;
  font-family: inherit;
  direction: rtl;
  backdrop-filter: blur(14px);
  animation: pronMenuScaleIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

[data-theme="dark"] .pronunciation-context-menu {
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

@keyframes pronMenuScaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pcm-header {
  padding: 6px 10px 8px 10px;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  margin-bottom: 4px;
}

[data-theme="dark"] .pcm-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.pcm-phrase-preview {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  direction: ltr;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

[data-theme="dark"] .pcm-phrase-preview {
  color: #f1f5f9;
}

.pcm-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.pcm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  white-space: nowrap;
}

[data-theme="dark"] .pcm-badge {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}

.pcm-quick-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pcm-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.22);
  color: #334155;
  cursor: pointer;
  transition: all 0.14s ease;
  line-height: 1.2;
}

.pcm-quick-btn:hover {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
  transform: translateY(-1px);
}

.pcm-quick-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

[data-theme="dark"] .pcm-quick-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

[data-theme="dark"] .pcm-quick-btn:hover,
[data-theme="dark"] .pcm-quick-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
}

.pcm-qflag {
  font-size: 0.8rem;
  line-height: 1;
}

.pcm-qcode {
  letter-spacing: 0.3px;
}

.pcm-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  padding: 4px 8px 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pcm-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-align: right;
  direction: rtl;
}

[data-theme="dark"] .pcm-item {
  color: #e2e8f0;
}

.pcm-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  transform: translateX(-2px);
}

[data-theme="dark"] .pcm-item:hover {
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
}

.pcm-item svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  flex-shrink: 0;
  color: #6366f1;
}

[data-theme="dark"] .pcm-item svg {
  color: #a5b4fc;
}

.pcm-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.pcm-item.danger svg {
  color: #ef4444;
}

.pcm-speed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 3px 6px 6px 6px;
}

.pcm-speed-btn {
  padding: 4px 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-primary, #334155);
  transition: all 0.15s ease;
  font-family: inherit;
}

[data-theme="dark"] .pcm-speed-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.pcm-speed-btn:hover {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
}

.pcm-speed-btn.active {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.pcm-divider {
  height: 1px;
  background: var(--border-color, rgba(0, 0, 0, 0.08));
  margin: 4px 6px;
}

[data-theme="dark"] .pcm-divider {
  background: rgba(255, 255, 255, 0.08);
}

/* Hide speaker buttons and context menus when printing/exporting */
@media print {
  .pronunciation-context-menu,
  .pronunciation-speaker-btn {
    display: none !important;
  }
  .pronunciation-word {
    text-decoration: none !important;
  }
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .settings-modal {
    width: 96vw;
    max-height: 92vh;
    border-radius: 12px;
  }
  .settings-modal-body {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    overflow-x: auto;
    border-left: none;
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
    padding: 8px;
    gap: 2px;
  }
  .settings-tab-btn {
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    font-size: 0.72rem;
    min-width: max-content;
  }
  .settings-tab-btn span:not(.settings-tab-badge) {
    white-space: nowrap;
  }
  .settings-tab-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.5rem;
    padding: 0 4px;
  }
  .settings-content {
    padding: 16px;
  }
  .settings-radio-group {
    flex-direction: column;
  }
}


/* Mobile Bottom Sheet Modal for Touch Devices */
@media (max-width: 640px) {
  .pronunciation-context-menu.pcm-mobile-sheet {
    border-radius: 16px;
    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.4);
    animation: pcmSheetSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: none;
  }
}
@keyframes pcmSheetSlideUp {
  from { opacity: 0; transform: translate(-50%, 25px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}


/* إخفاء كونتينر أدوات المعاينة على الكمبيوتر (مخصص لوضع الموبايل فقط) */
@media (min-width: 769px) {
  .preview-floating-dock {
    display: none !important;
  }
  .preview-header-btn {
    display: none !important;
  }
  .panel-header #preview-mode-badge {
    display: inline-block !important;
  }
}


/* تنبيه ذكي عند قيود النطق في متصفحات الموبايل (مثل متصفح شاومي) */
.speech-alert-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 41, 59, 0.96);
  color: #fef3c7;
  border: 1px solid rgba(245, 158, 11, 0.5);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.2);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 600;
  direction: rtl;
  backdrop-filter: blur(12px);
  max-width: 92vw;
  width: max-content;
  text-align: center;
  animation: speechToastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  line-height: 1.4;
}

[data-theme="dark"] .speech-alert-toast {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fef08a;
}

.speech-alert-toast svg {
  width: 18px;
  height: 18px;
  color: #f59e0b;
  flex-shrink: 0;
}

.speech-alert-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  margin-right: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.speech-alert-close:hover {
  opacity: 1;
}

@keyframes speechToastSlide {
  from { opacity: 0; transform: translate(-50%, 15px) scale(0.94); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}


/* زر Edit النيومورفي في ترويسة المعاينة بحجم أصغر متناسق */
.preview-wysiwyg-btn {
  height: 24px !important;
  min-width: 28px !important;
  padding: 0 6px !important;
  font-size: 8.5px !important;
  margin: 0 !important;
}

.preview-explorer-btn {
  height: 26px !important;
  padding: 2px 8px !important;
  font-size: 0.74rem !important;
  border-radius: 6px !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  cursor: pointer;
}

.preview-explorer-btn .win-folder-label {
  display: inline-block !important;
  font-size: 0.74rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

@media (min-width: 769px) {
  .preview-header-actions {
    display: none !important;
  }
}



/* =========================================================
   فقاعة الترجمة الفورية الهجينة للكلمات (Word Translation Bubble)
   ========================================================= */
.word-trans-bubble {
  position: fixed;
  z-index: 100000;
  width: 220px;
  max-width: calc(100vw - 24px);
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 9px 12px;
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  user-select: none;
  animation: wtbFadeScale 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

[data-theme="dark"] .word-trans-bubble {
  background: rgba(30, 41, 59, 0.98);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

@keyframes wtbFadeScale {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.word-trans-bubble .wtb-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-surface, #ffffff);
  transform: rotate(45deg);
  z-index: 2;
}

[data-theme="dark"] .word-trans-bubble .wtb-arrow {
  background: rgba(30, 41, 59, 0.98);
}

.word-trans-bubble.arrow-bottom .wtb-arrow {
  bottom: -6px;
  border-right: 1px solid var(--border-color, #e2e8f0);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  border-top: none;
  border-left: none;
}

[data-theme="dark"] .word-trans-bubble.arrow-bottom .wtb-arrow {
  border-color: rgba(99, 102, 241, 0.35);
}

.word-trans-bubble.arrow-top .wtb-arrow {
  top: -6px;
  border-left: 1px solid var(--border-color, #e2e8f0);
  border-top: 1px solid var(--border-color, #e2e8f0);
  border-bottom: none;
  border-right: none;
}

[data-theme="dark"] .word-trans-bubble.arrow-top .wtb-arrow {
  border-color: rgba(99, 102, 241, 0.35);
}

.wtb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  gap: 8px;
}

[data-theme="dark"] .wtb-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.wtb-term-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.wtb-flag {
  font-size: 0.95rem;
  line-height: 1;
}

.wtb-word {
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-color, #6366f1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wtb-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.wtb-slow-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: var(--bg-hover, #f1f5f9);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  transition: all 0.15s ease;
}

.wtb-slow-btn:hover,
.wtb-slow-btn.playing {
  background: var(--accent-light, #e0e7ff);
  color: var(--accent-color, #6366f1);
  border-color: var(--accent-color, #6366f1);
}

[data-theme="dark"] .wtb-slow-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

[data-theme="dark"] .wtb-slow-btn:hover,
[data-theme="dark"] .wtb-slow-btn.playing {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.wtb-close-btn {
  background: transparent;
  border: none;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
}

.wtb-close-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.wtb-body {
  min-height: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.wtb-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted, #64748b);
  padding: 2px 0;
}

.wtb-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-color, #cbd5e1);
  border-top-color: var(--accent-color, #6366f1);
  border-radius: 50%;
  animation: wtbSpin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.wtb-arabic {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  line-height: 1.35;
  margin: 0;
}

[data-theme="dark"] .wtb-arabic {
  color: #f8fafc;
}


/* =========================================================
   Unified SVG UI Icon Standard (نظام أيقونات الواجهة الموحد)
   ========================================================= */
.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  margin-left: 6px;
  line-height: 1;
}

.legal-popover-icon .ui-icon {
  margin-left: 0;
  width: 18px;
  height: 18px;
  color: var(--accent-color, #6366f1);
}

.settings-section-title .ui-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-color, #6366f1);
  margin-left: 8px;
}

.settings-radio-pill .ui-icon,
.settings-preset-btn .ui-icon,
.settings-mini-btn .ui-icon {
  margin-left: 5px;
}

.settings-about-row .ui-icon {
  width: 15px;
  height: 15px;
  color: var(--accent-color, #6366f1);
  margin-left: 6px;
}


/* =========================================================
   نظام النطق والترجمة الطافي (Floating Pronunciation & Translation Pill)
   عناصر طافية عائمة لا تؤثر في المحتوى ولا تشوه الماركداون
   ========================================================= */

.pronunciation-floating-pill {
  position: fixed;
  z-index: 10000;
  display: none;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 9999px;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.15), 0 3px 8px -2px rgba(15, 23, 42, 0.08);
  opacity: 0;
  transform: translateY(4px) scale(0.96);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  user-select: none;
  direction: ltr;
}

[data-theme="dark"] .pronunciation-floating-pill {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.pronunciation-floating-pill.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.pfp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-primary, #0f172a);
  font-family: var(--font-arabic, sans-serif);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
  line-height: 1;
}

[data-theme="dark"] .pfp-btn {
  color: #f8fafc;
}

.pfp-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

[data-theme="dark"] .pfp-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.pfp-btn.pfp-speak {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
}

[data-theme="dark"] .pfp-btn.pfp-speak {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.18);
}

.pfp-btn.pfp-speak:hover {
  background: #6366f1;
  color: #ffffff;
}

.pfp-btn.pfp-trans {
  color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

[data-theme="dark"] .pfp-btn.pfp-trans {
  color: #34d399;
  background: rgba(16, 185, 129, 0.18);
}

.pfp-btn.pfp-trans:hover {
  background: #10b981;
  color: #ffffff;
}

.pfp-btn.pfp-slow {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  padding: 3px 5px;
}

.pfp-btn.pfp-more {
  padding: 3px 5px;
  color: var(--text-muted, #64748b);
}

/* شارات الترجمة الفورية للمقال دون تشويه التنسيق */
.bilingual-trans-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--font-arabic, sans-serif);
  font-weight: 500;
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 4px;
  vertical-align: middle;
  line-height: 1.3;
  user-select: none;
}

[data-theme="dark"] .bilingual-trans-tag {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

/* زر الترجمة الشاملة في شريط الأدوات */
.global-trans-tool-btn.active,
.global-trans-tool-btn.is-active {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #16a34a !important;
}

[data-theme="dark"] .global-trans-tool-btn.active,
[data-theme="dark"] .global-trans-tool-btn.is-active {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  color: #4ade80 !important;
}


/* =========================================================
   ترقيات حاوية التحجيم للإيموجي والصور: تحريك حر، تدوير، ومنع اقتطاع الفقاعة
   ========================================================= */

.image-resizer-wrapper {
  overflow: visible !important;
}

/* شريط الأدوات المصغر فوق الصورة - محسّن ليظل دائماً داخل الإطار المرئي */
.image-resizer-toolbar {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  padding: 5px 12px;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 1000 !important;
  white-space: nowrap;
  pointer-events: auto;
  max-width: 95vw;
}

.image-resizer-wrapper:hover .image-resizer-toolbar,
.image-resizer-wrapper.active .image-resizer-toolbar {
  display: flex !important;
}

/* وضع التحريك الحر فوق العناصر (Free Floating Mode) - نظيف بدون أي ظلال أو إطارات */
.image-resizer-wrapper.is-floating {
  position: relative !important;
  z-index: 60 !important;
  display: inline-block !important;
  cursor: grab !important;
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.image-resizer-wrapper.is-floating:active {
  cursor: grabbing !important;
}

/* مقبض تدوير بجانب الزاوية لتدوير يدوي حر على مزاج المستخدم */
.resizer-corner-rotate-handle {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 24px;
  height: 24px;
  background: #ffffff;
  border: 1.5px solid #6366f1;
  border-radius: 50%;
  color: #6366f1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 150;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

[data-theme="dark"] .resizer-corner-rotate-handle {
  background: #1e293b;
  border-color: #818cf8;
  color: #a5b4fc;
}

.resizer-corner-rotate-handle:hover {
  transform: scale(1.25);
  background: #6366f1;
  color: #ffffff;
}

.resizer-corner-rotate-handle:active {
  cursor: grabbing;
}

.image-resizer-wrapper.active .resizer-corner-rotate-handle {
  display: flex !important;
}

/* زر التحريك الحر النشط وزر التدوير */
.resizer-btn.active-tool {
  background: #6366f1 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* ==========================================================================
   VIENIX STORAGE HEALTH MONITOR & WORKSPACE BACKUP STYLES (PHASE 0)
   ========================================================================== */

/* 1. Status Bar Storage Item */
.status-storage-item {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-storage-item:hover {
  background: var(--bg-surface-hover, rgba(99, 102, 241, 0.08));
}

.status-storage-safe {
  color: var(--text-muted);
}
.status-storage-safe:hover {
  color: var(--text-primary);
}

.status-storage-warning {
  color: #f59e0b !important;
  background: rgba(245, 158, 11, 0.1) !important;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-storage-danger {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.15) !important;
  border: 1px solid rgba(239, 68, 68, 0.35);
  animation: vienixPulseAlert 1.8s infinite;
}

@keyframes vienixPulseAlert {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* 2. Settings Modal Storage Interactive Box */
.storage-meter-box {
  background: var(--bg-canvas, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 16px;
  margin-top: 6px;
  transition: border-color 0.2s ease;
}

[data-theme="dark"] .storage-meter-box {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(51, 65, 85, 0.6);
}

.storage-meter-head {
  margin-bottom: 12px;
}

.storage-meter-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.storage-meter-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.storage-meter-numbers {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.storage-meter-numbers strong {
  color: var(--text-primary);
  font-weight: 700;
}

.storage-meter-subdesc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.storage-progress-track {
  width: 100%;
  height: 9px;
  background: var(--border-color, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  margin: 10px 0 16px 0;
}

[data-theme="dark"] .storage-progress-track {
  background: #334155;
}

.storage-progress-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Storage breakdown cards */
.storage-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.storage-breakdown-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 9px 12px;
  transition: transform 0.15s ease;
}

[data-theme="dark"] .storage-breakdown-card {
  background: #1e293b;
  border-color: rgba(51, 65, 85, 0.8);
}

.storage-breakdown-card:hover {
  transform: translateY(-1px);
}

.storage-breakdown-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.storage-breakdown-info {
  display: flex;
  flex-direction: column;
}

.storage-breakdown-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.storage-breakdown-val {
  font-size: 0.84rem;
  color: var(--text-primary);
  font-weight: 700;
}

/* Full Backup Action Cards */
.backup-action-card {
  background: var(--bg-canvas, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

[data-theme="dark"] .backup-action-card {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(51, 65, 85, 0.6);
}

.backup-action-info {
  flex: 1;
}

.backup-action-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.backup-action-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.btn-backup-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
  font-weight: 600;
  white-space: nowrap;
}

.btn-backup-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%) !important;
  transform: translateY(-1px);
}

.btn-restore-action {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
  font-weight: 600;
  white-space: nowrap;
}

.btn-restore-action:hover {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%) !important;
  transform: translateY(-1px);
}

/* 3. Floating Quota Exceeded Alert Banner */
.vienix-quota-alert-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #ffffff;
  padding: 10px 20px;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
  animation: slideDownQuotaBanner 0.3s ease-out;
}

@keyframes slideDownQuotaBanner {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.quota-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.quota-banner-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.quota-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.quota-banner-text strong {
  font-size: 0.95rem;
}

.quota-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quota-banner-btn-backup {
  background: #ffffff;
  color: #b91c1c;
  font-weight: 700;
  border: none;
  padding: 7px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.quota-banner-btn-backup:hover {
  background: #fef2f2;
  transform: translateY(-1px);
}

.quota-banner-btn-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.quota-banner-btn-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 4. Custom Vienix Modal Dialog */
.vienix-custom-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.vienix-custom-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.vienix-custom-modal {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.vienix-custom-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vienix-custom-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.vienix-custom-modal-close:hover {
  color: var(--text-primary);
}

.vienix-custom-modal-body {
  padding: 20px;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.vienix-custom-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-canvas);
}

/* ==========================================================================
   GOOGLE DRIVE CLOUD SYNC STYLES (PHASE 2)
   ========================================================================== */

/* 1. Header Cloud Button & Status Dot */
.cloud-sync-btn {
  position: relative;
}

.cloud-sync-status-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-surface);
  transition: all 0.25s ease;
}

.cloud-sync-status-dot.status-disconnected {
  background: #94a3b8;
}

.cloud-sync-status-dot.status-connected {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.cloud-sync-status-dot.status-syncing {
  background: #0284c7;
  animation: driveSyncPulse 1s infinite;
}

@keyframes driveSyncPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* 2. Cloud Account Card in Settings */
.cloud-account-card {
  background: var(--bg-canvas, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 14px;
  padding: 18px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-theme="dark"] .cloud-account-card {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(51, 65, 85, 0.7);
}

.cloud-connect-prompt {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cloud-drive-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-google-connect {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  padding: 10px 18px !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  transition: all 0.2s ease !important;
  cursor: pointer;
}

[data-theme="dark"] .btn-google-connect {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

.btn-google-connect:hover {
  background: #f9fafb !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12) !important;
}

[data-theme="dark"] .btn-google-connect:hover {
  background: #334155 !important;
}

/* Connected profile display */
.cloud-profile-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cloud-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--accent-color, #6366f1);
  object-fit: cover;
}

.cloud-profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cloud-user-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cloud-user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cloud-badge-connected {
  font-size: 0.72rem;
  color: #10b981;
  font-weight: 700;
  margin-top: 2px;
}

.cloud-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.btn-sync-now {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: 7px !important;
  font-weight: 600 !important;
}

.btn-sync-now.loading {
  opacity: 0.75;
  pointer-events: none;
}

.btn-disconnect {
  color: #ef4444 !important;
}

.btn-disconnect:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}


