/* ==========================================================================
   Layout & Glassmorphic Component Styles (V2 Luxury Pro)
   ========================================================================== */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-persian);
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Root Shell */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background-color: var(--color-bg-base);
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Top Header (Glassmorphic & Segmented Controls)
   ========================================================================== */
.app-header {
  height: var(--header-height);
  background-color: var(--color-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.15rem;
  z-index: 50;
  position: relative;
  gap: 0.75rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: max-content;
  z-index: 2;
}

.btn-workspace-toggle {
  color: var(--color-primary);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-workspace-toggle:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.brand-logo-link {
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.brand-logo-link:hover {
  background-color: var(--color-bg-hover);
  transform: translateY(-1px);
}

.brand-logo-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 2px 8px var(--brand-gradient-glow));
}

.brand-title-group {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.brand-name-en {
  font-family: var(--font-english);
  font-weight: 800;
  font-size: 1.22rem;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.01em;
}

.brand-domain-badge {
  font-family: var(--font-english);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--brand-purple);
  background: var(--color-secondary-light);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(139, 36, 166, 0.25);
}

/* Document Title Capsule */
.doc-title-capsule {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.22rem 0.7rem;
  transition: all var(--transition-fast);
}

.doc-title-capsule:hover,
.doc-title-capsule:focus-within {
  background: var(--color-bg-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.doc-title-icon {
  color: var(--brand-purple);
  flex-shrink: 0;
}

.doc-title-input {
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.15rem 0.2rem;
  width: 140px;
  outline: none;
  transition: width var(--transition-normal);
}

.doc-title-input:focus {
  width: 200px;
}

.doc-saved-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
  flex-shrink: 0;
}

/* Center View Mode Switcher (Apple VisionOS / macOS Sequoia Floating Glass Pill) */
.header-center-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 10;
}

.view-modes-segmented {
  display: flex;
  align-items: center;
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.35rem 0.82rem;
  font-size: var(--text-xs);
  font-family: var(--font-persian);
  font-weight: 600;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segmented-btn:hover {
  color: var(--color-text-primary);
  background-color: rgba(0, 0, 0, 0.03);
}

.segmented-btn.active {
  background-color: var(--color-bg-surface);
  color: var(--color-primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(26, 54, 115, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Header Actions & Bento Capsules */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  z-index: 2;
}

/* Connected Glass Tool Capsule */
.header-tools-capsule {
  display: inline-flex;
  align-items: center;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px 4px;
  gap: 2px;
}

.header-tools-capsule .btn-icon {
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.header-tools-capsule .btn-icon:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-primary);
}

.btn-font-pill {
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  padding: 0.22rem 0.5rem;
  font-size: 0.72rem;
  font-family: var(--font-persian);
  font-weight: 700;
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-font-pill:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-primary);
}

/* Super-Powers Capsule (AI, Collab, Share) */
.header-power-capsule {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-collab-pill,
.btn-share-pill {
  border-radius: var(--radius-full);
  padding: 0.35rem 0.72rem;
  font-size: var(--text-xs);
  font-family: var(--font-persian);
  font-weight: 600;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-collab-pill:hover,
.btn-share-pill:hover {
  background: var(--color-bg-hover);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Master Split Export Capsule */
.split-export-master {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 16px var(--brand-gradient-glow);
  overflow: hidden;
}

.split-export-master .split-main-btn {
  border-radius: 0;
  padding: 0.42rem 0.95rem;
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--brand-gradient) !important;
  color: #ffffff !important;
  border: none !important;
  border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.split-export-master .split-dropdown-btn {
  border-radius: 0;
  padding: 0.42rem 0.55rem;
  background: var(--brand-gradient) !important;
  color: #ffffff !important;
  border: none !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.split-export-master:hover .split-main-btn,
.split-export-master:hover .split-dropdown-btn {
  filter: brightness(1.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  font-size: var(--text-xs);
  font-family: var(--font-persian);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

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

.btn-icon.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Dropdown Container */
.dropdown-wrap {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  padding: 0.4rem;
  min-width: 210px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
}

.dropdown-wrap.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: right;
  transition: background-color var(--transition-fast);
}

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

.dropdown-divider {
  height: 1px;
  background-color: var(--color-border);
  margin: 0.35rem 0;
}

.dropdown-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  flex: 1;
}

.dropdown-item-desc {
  font-size: 0.72rem;
  font-weight: normal;
  color: var(--color-text-tertiary);
  line-height: 1.35;
}

.dropdown-item:hover .dropdown-item-desc {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Formatting Toolbar (Obsidian Bento Ribbon)
   ========================================================================== */
.toolbar {
  height: var(--toolbar-height);
  background-color: var(--color-bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 30;
}

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

.toolbar-ribbon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.toolbar-island {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 2px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: all var(--transition-fast);
}

.toolbar-island:hover {
  border-color: var(--color-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.island-separator {
  width: 1px;
  height: 16px;
  background-color: var(--color-border);
  margin: 0 3px;
}

.heading-chip {
  font-family: var(--font-english);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: -0.02em;
  min-width: 26px;
}

/* Persian Excellence Suite Highlight */
.island-persian-suite {
  background: linear-gradient(135deg, rgba(26, 54, 115, 0.04), rgba(139, 36, 166, 0.06));
  border-color: rgba(139, 36, 166, 0.22);
}

.btn-persian-editorial {
  gap: 5px;
  padding: 0 7px;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.73rem;
}

.btn-farsi-digits {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--brand-purple);
}

.btn-voice-typing {
  color: var(--color-text-secondary);
  position: relative;
}

.btn-voice-typing.recording {
  color: #ef4444;
  animation: pulseRecording 1.4s infinite;
}

@keyframes pulseRecording {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.5)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.5)); }
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 0.35rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

.tool-btn:active {
  transform: scale(0.96);
}

.tool-btn.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

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

/* Tooltip on Toolbar buttons */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background-color: var(--color-bg-elevated);
  color: var(--color-text-primary);
  padding: 0.25rem 0.6rem;
  font-size: var(--text-2xs);
  font-family: var(--font-persian);
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: 200;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Find & Replace Slide Bar
   ========================================================================== */
.find-replace-bar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  z-index: 35;
  animation: slideDown 180ms ease-out forwards;
}

.find-replace-bar.open {
  display: flex;
}

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

.find-input-wrap {
  display: flex;
  align-items: center;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 0.5rem;
  gap: 0.4rem;
}

.find-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  padding: 0.4rem 0.2rem;
  width: 170px;
}

.find-count {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Workspace Layout & Resizer
   ========================================================================== */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  transition: width var(--transition-fast);
}

.pane-editor {
  width: 50%;
  background-color: var(--color-bg-surface);
}

.pane-preview {
  flex: 1;
  background-color: var(--color-bg-base);
  display: flex;
  flex-direction: column;
}

/* View Mode States */
.workspace.mode-editor-only .pane-editor {
  width: 100% !important;
}
.workspace.mode-editor-only .pane-preview,
.workspace.mode-editor-only .resizer {
  display: none !important;
}

.workspace.mode-preview-only .pane-preview {
  width: 100% !important;
}
.workspace.mode-preview-only .pane-editor,
.workspace.mode-preview-only .resizer {
  display: none !important;
}

.pane-header {
  height: 38px;
  background-color: var(--color-bg-elevated);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.pane-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pane-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.live-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* In Split View: hide edit toggle button from preview header */
.workspace.mode-split #btn-toggle-edit-mode {
  display: none !important;
}

.btn-edit-mode-toggle {
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  padding: 0.32rem 0.8rem;
  font-size: var(--text-xs);
  font-weight: 700;
  box-shadow: 0 3px 10px var(--color-primary-glow);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-edit-mode-toggle:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.pane-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Modern Resizer Gutter */
.resizer {
  width: 8px;
  background-color: var(--color-bg-base);
  cursor: col-resize;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.resizer-handle {
  width: 3px;
  height: 24px;
  background-color: var(--color-text-muted);
  border-radius: var(--radius-full);
  opacity: 0.5;
  transition: all var(--transition-fast);
}

.resizer:hover .resizer-handle,
.resizer.dragging .resizer-handle {
  opacity: 1;
  background-color: var(--color-primary);
  height: 36px;
}

.resizer:hover, .resizer.dragging {
  background-color: var(--color-primary-light);
}

/* Preview Scroll & Paper Wrapper */
.preview-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2.5rem 1.75rem;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Floating Quick Edit Button in Preview Mode */
.floating-edit-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  display: none;
  align-items: center;
  gap: 0.55rem;
  background-color: var(--color-primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  padding: 0.65rem 1.15rem;
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  font-weight: 700;
  box-shadow: 0 10px 25px -4px var(--color-primary-glow);
  cursor: pointer;
  z-index: 35;
  transition: all var(--transition-normal);
  backdrop-filter: blur(8px);
}

.floating-edit-btn:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 28px -4px var(--color-primary-glow);
}

.floating-edit-btn .shortcut-tag {
  background: rgba(255, 255, 255, 0.22);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
}

.workspace.mode-preview-only .floating-edit-btn {
  display: inline-flex;
}

.preview-wrapper {
  max-width: var(--preview-max-width, 860px);
  width: var(--preview-width, 100%);
  margin: 0 auto;
  background-color: var(--md-bg);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
  padding: 3.5rem 3rem;
  border: 1px solid var(--color-border);
  transition: max-width var(--transition-normal), width var(--transition-normal), background-color var(--transition-normal);
  min-height: calc(100% - 2rem);
  position: relative;
}

/* Width Control Bar in Preview Pane Header (Luxury Bento Capsule) */
.width-control-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.width-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.width-presets {
  display: flex;
  align-items: center;
  gap: 2px;
}

.width-preset-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  padding: 2px 7px;
  font-size: 0.72rem;
  font-family: var(--font-persian);
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.width-preset-btn.active {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 2px 6px var(--brand-gradient-glow);
}

.width-slider {
  width: 70px;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-border);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.width-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-purple);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.width-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px var(--brand-gradient-glow);
}

.width-val-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
  min-width: 44px;
  text-align: center;
  direction: ltr;
}

/* Outline / Table of Contents (TOC) Drawer */
.toc-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--color-bg-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl);
  z-index: 45;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
}

.toc-sidebar.open {
  transform: translateX(0);
}

.toc-header {
  height: var(--toolbar-height);
  padding: 0 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: var(--text-sm);
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.5rem;
  list-style: none;
}

.toc-item {
  display: block;
  padding: 0.4rem 0.6rem;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition-fast);
}

.toc-item:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-primary);
}

.toc-item.level-1 { font-weight: 700; }
.toc-item.level-2 { padding-right: 1.4rem; }
.toc-item.level-3 { padding-right: 2.2rem; color: var(--color-text-muted); }

/* Table Matrix Grid Picker Dropdown */
.table-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 22px);
  grid-template-rows: repeat(6, 22px);
  gap: 4px;
  padding: 0.6rem;
}

.table-cell-pick {
  width: 22px;
  height: 22px;
  border: 1px solid var(--color-border-strong);
  border-radius: 2px;
  background-color: var(--color-bg-base);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.table-cell-pick.highlighted {
  background-color: var(--color-primary);
  border-color: var(--color-primary-hover);
}

/* ==========================================================================
   Bottom Status Bar (Bento-Pill Luxury Edition)
   ========================================================================== */
.status-bar {
  height: var(--statusbar-height);
  background-color: var(--color-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  font-family: var(--font-persian);
  z-index: 25;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 2.5px 9px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.status-item:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
  transform: translateY(-0.5px);
}

.status-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 10px var(--color-success);
}

/* ==========================================================================
   Modals & Dialogs (Glassmorphic Luxury)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-backdrop);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 620px;
  box-shadow: var(--shadow-xl);
  transform: translateY(24px) scale(0.96);
  transition: all var(--transition-normal);
  overflow: hidden;
  direction: rtl;
}

.modal-overlay.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.6rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--text-base);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-text-primary);
}

.modal-body {
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 72vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1.1rem 1.6rem;
  background-color: var(--color-bg-elevated);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-secondary);
}

.form-control, .form-select {
  padding: 0.65rem 0.85rem;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2.75rem;
  left: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  animation: slideIn 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   Advanced Sharing Modal & Encrypted Lock Screen
   ========================================================================== */
.share-segmented-tabs {
  display: flex;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.share-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-persian);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.share-tab-btn.active {
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.share-tab-content {
  display: none;
  flex-direction: column;
  gap: 1.15rem;
  animation: fadeIn 200ms ease;
}

.share-tab-content.active {
  display: flex;
}

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

.share-info-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  line-height: 1.6;
  border: 1px solid var(--color-border);
}

.share-card-public {
  background-color: var(--color-info-bg);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--color-text-primary);
}

.share-card-protected {
  background-color: var(--color-warning-bg);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--color-text-primary);
}

.share-info-icon-badge {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

.share-card-protected .share-info-icon-badge {
  color: #f59e0b;
}

.share-info-text {
  flex: 1;
}

.share-view-mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.radio-card:hover {
  border-color: var(--color-primary-hover);
  background-color: var(--color-bg-hover);
}

.radio-card.active {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.radio-card input {
  margin-top: 3px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.radio-card-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-card-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-primary);
}

.radio-card-desc {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.share-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.share-input-group .form-control {
  flex: 1;
  text-overflow: ellipsis;
}

.share-qr-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
}

.qr-preview-box {
  width: 130px;
  height: 130px;
  min-width: 130px;
  background: #ffffff;
  padding: 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

#public-qr-container, #protected-qr-container {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#public-qr-container svg, #protected-qr-container svg {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.qr-hint-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  direction: rtl;
}

.share-social-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.social-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.social-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: var(--text-2xs);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.social-share-btn.tg { color: #229ed9; }
.social-share-btn.wa { color: #25d366; }
.social-share-btn.email { color: #ea4335; }
.social-share-btn.native { color: var(--color-primary); }

/* Humanized Password Field & Eye Toggle */
.password-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.btn-text-action {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-family: var(--font-persian);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.btn-text-action:hover {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
}

.password-field-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.password-input {
  width: 100%;
  padding-left: 42px !important;
  padding-right: 14px !important;
}

.btn-eye-toggle {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  padding: 0;
  transition: all var(--transition-fast);
}

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

.password-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.password-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background-color: var(--color-border);
  transition: all var(--transition-normal);
}

.password-strength-bar.weak { background-color: var(--color-danger); }
.password-strength-bar.medium { background-color: var(--color-warning); }
.password-strength-bar.strong { background-color: var(--color-success); }

.password-strength-text {
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-persian);
  min-width: 110px;
  text-align: left;
  direction: rtl;
}

.protected-notice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

.notice-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notice-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.notice-desc {
  font-size: 0.76rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin: 0;
}

/* ==========================================================================
   Full Glassmorphic Decrypt Lock Screen
   ========================================================================== */
.decrypt-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 15, 29, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 1rem;
}

.decrypt-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.decrypt-card {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 480px;
  padding: 2.5rem 2.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  direction: rtl;
  transform: translateY(20px) scale(0.97);
  transition: all var(--transition-normal);
}

.decrypt-overlay.open .decrypt-card {
  transform: translateY(0) scale(1);
}

.lock-icon-badge {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12) 0%, rgba(124, 58, 237, 0.12) 100%);
  border: 1.5px solid var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  margin-bottom: 1.25rem;
  box-shadow: 0 0 25px var(--color-primary-glow);
}

.decrypt-title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text-primary);
  margin: 0 0 0.5rem;
}

.decrypt-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.decrypt-recipient-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.95rem;
  font-size: var(--text-xs);
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.decrypt-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.decrypt-field-container .decrypt-input {
  text-align: center;
  font-size: var(--text-base) !important;
  letter-spacing: 0.1em;
  padding: 0.8rem 44px !important;
  border-radius: var(--radius-lg) !important;
}

.decrypt-error {
  color: var(--color-danger);
  font-size: var(--text-xs);
  font-weight: 700;
  background-color: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.8rem;
}

.decrypt-btn {
  padding: 0.85rem !important;
  font-size: var(--text-sm) !important;
  border-radius: var(--radius-lg) !important;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.decrypt-footer-hint {
  font-size: 0.72rem;
  color: var(--color-text-subtle);
  margin-top: 1.5rem;
}

/* Shake Animation for Wrong Password */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.decrypt-card.shake {
  animation: shake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ==========================================================================
   Reader Mode Top Banner (Shared Document Presentation)
   ========================================================================== */
.reader-mode-banner {
  background-color: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  z-index: 30;
  direction: rtl;
  position: relative;
}

.reader-banner-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reader-badge {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-2xs);
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-primary);
}

.reader-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-primary);
}

.reader-recipient-badge {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-xs);
}

.reader-banner-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Responsive */
@media (max-width: 860px) {
  .view-modes-segmented {
    display: none;
  }
  .brand-section {
    min-width: auto;
  }
  .doc-title-input {
    width: 120px;
  }
}

/* ==========================================================================
   Real-Time Multi-User Collaboration Styling
   ========================================================================== */
.btn-collab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-normal);
}

.btn-collab.btn-collab-active {
  background-color: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success);
  font-weight: 700;
}

.collab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-success);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 12px;
  line-height: 1.2;
}

.collab-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  transition: all var(--transition-normal);
}

.collab-banner.connected {
  background-color: var(--color-success-bg);
  border-color: var(--color-success);
}

.collab-banner.disconnected {
  background-color: var(--color-bg-elevated);
  border-color: var(--color-border);
}

.status-pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: collab-pulse 1.8s infinite;
}

.collab-banner.disconnected .status-pulse-dot {
  background-color: var(--color-text-muted);
  box-shadow: none;
  animation: none;
}

@keyframes collab-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.collab-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.collab-banner-text strong {
  font-size: 0.88rem;
  color: var(--color-text-primary);
}

.collab-banner-text span {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

.collab-color-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--color-text-primary);
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--color-bg-surface);
}

.collab-users-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 48px;
  align-items: center;
}

.collab-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.78rem;
}

.user-avatar-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}

.user-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
}

.collab-log-box {
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.75rem;
  max-height: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--color-text-secondary);
}

.collab-log-entry {
  line-height: 1.4;
}

.collab-log-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  opacity: 0.7;
}

/* Remote Cursors Floating In Editor Top Bar */
.remote-cursors-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px;
  background-color: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  min-height: 28px;
  align-items: center;
  transition: all var(--transition-normal);
}

.remote-user-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  animation: tag-fade-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition-fast);
}

.remote-user-tag:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.remote-user-tag .user-cursor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ffffff;
}

.remote-user-tag.typing .user-cursor-dot {
  animation: pulse-dot 0.8s infinite;
}

.remote-user-tag-typing-text {
  font-size: 0.68rem;
  opacity: 0.92;
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

@keyframes tag-fade-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Inline Live Remote Caret & Typing Flag (Google Docs / Notion Style)
   ========================================================================== */
.remote-caret {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  transition: top 70ms ease-out, left 70ms ease-out;
  will-change: top, left;
}

.remote-caret-bar {
  width: 2.5px;
  height: 21px;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 2px;
  animation: remoteCaretBlink 1.15s infinite;
}

@keyframes remoteCaretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.remote-caret-flag {
  position: absolute;
  bottom: calc(100% + 2px);
  right: -2px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-persian);
  color: #ffffff;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  user-select: none;
  pointer-events: none;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
}

.remote-caret-name {
  display: inline-block;
  line-height: 1.2;
}

/* Live Typing Snippet Pill */
.remote-caret-snippet {
  display: none;
  align-items: center;
  gap: 4px;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.32);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0;
  transform: scale(0.9);
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.remote-caret-snippet.active {
  display: inline-flex;
  opacity: 1;
  transform: scale(1);
}

.remote-caret-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
}

.remote-caret-dots span {
  width: 3px;
  height: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  animation: typingDot 0.9s infinite;
}

.remote-caret-dots span:nth-child(2) { animation-delay: 0.2s; }
.remote-caret-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

/* ==========================================================================
   Ephemeral Subtle Typing Highlight (Fades smoothly after a few seconds)
   ========================================================================== */
.remote-edit-highlight-chip {
  position: absolute;
  pointer-events: none;
  z-index: 6;
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.08);
  animation: remoteHighlightFade 3.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes remoteHighlightFade {
  0% {
    opacity: 1;
    transform: scaleY(1.05);
  }
  65% {
    opacity: 0.85;
    transform: scaleY(1);
  }
  100% {
    opacity: 0;
    transform: scaleY(0.98);
  }
}

/* ==========================================================================
   Live Preview Glowing Pulse on Remote Edit
   ========================================================================== */
@keyframes remotePreviewGlow {
  0% {
    background-color: var(--pulse-color, rgba(16, 185, 129, 0.22));
    outline: 2px solid var(--pulse-color-border, rgba(16, 185, 129, 0.45));
    border-radius: 4px;
  }
  65% {
    background-color: var(--pulse-color, rgba(16, 185, 129, 0.1));
    outline: 1px solid var(--pulse-color-border, rgba(16, 185, 129, 0.25));
  }
  100% {
    background-color: transparent;
    outline: 0 solid transparent;
  }
}

.remote-preview-pulse {
  animation: remotePreviewGlow 2.8s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  transition: all 0.3s ease;
}

/* ==========================================================================
   Presentation Slide Deck Overlay
   ========================================================================== */
.presentation-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg-base);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.presentation-progress-track {
  width: 100%;
  height: 4px;
  background-color: var(--color-border);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
}

.presentation-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #10b981);
  transition: width 250ms ease;
}

.presentation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2.5rem;
  z-index: 50;
}

.presentation-counter {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  background: var(--color-bg-surface);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
}

.presentation-actions {
  display: flex;
  gap: 8px;
}

.pres-btn {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.pres-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

.presentation-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 4rem 5rem 4rem;
  overflow-y: auto;
}

.presentation-slide-card {
  width: 100%;
  max-width: 1100px;
  min-height: 480px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16);
  padding: 3.5rem 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.presentation-markdown {
  font-size: 1.3rem;
  line-height: 2;
  user-select: text;
}

.presentation-markdown h1 {
  font-size: 2.6rem !important;
  margin-bottom: 1.5rem !important;
  color: var(--color-primary) !important;
  border: none !important;
  padding: 0 !important;
}

.presentation-markdown h2 {
  font-size: 2rem !important;
  margin-bottom: 1.2rem !important;
}

.presentation-markdown h3 {
  font-size: 1.6rem !important;
}

.presentation-markdown pre {
  font-size: 1.05rem !important;
  padding: 1.25rem !important;
}

.presentation-nav-pill {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 30px;
  padding: 6px 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.pres-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-persian);
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 20px;
  transition: all var(--transition-fast);
}

.pres-nav-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-primary);
}

.pres-nav-divider {
  width: 1px;
  height: 18px;
  background-color: var(--color-border);
}

/* ==========================================================================
   Multi-Document Workspace & File Explorer Drawer (Feature 4)
   ========================================================================== */
.workspace-docs-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background-color: var(--color-bg-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.25);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  direction: rtl;
}

.workspace-docs-sidebar.open {
  transform: translateX(0);
}

.workspace-sidebar-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-text-primary);
}

.workspace-sidebar-title .badge {
  background-color: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace-sidebar-actions {
  padding: 0.85rem 1rem 0.5rem 1rem;
}

.workspace-sidebar-actions .btn-full {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  padding: 0.6rem;
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

.workspace-sidebar-search {
  position: relative;
  padding: 0 1rem 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.workspace-sidebar-search svg {
  position: absolute;
  right: 1.75rem;
  top: 50%;
  transform: translateY(-70%);
  color: var(--color-text-muted);
}

.workspace-sidebar-search input {
  width: 100%;
  padding: 0.45rem 2.2rem 0.45rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-bg-input);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: 0.8rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.workspace-sidebar-search input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.workspace-docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workspace-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background-color: var(--color-bg-elevated);
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.workspace-doc-item:hover {
  background-color: var(--color-bg-hover);
  border-color: var(--color-border);
  transform: translateX(-2px);
}

.workspace-doc-item.active {
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.12) 0%, rgba(99, 102, 241, 0.05) 100%);
  border-color: var(--color-primary);
  box-shadow: 0 2px 10px var(--color-primary-glow);
}

.workspace-doc-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
}

.workspace-doc-icon {
  color: var(--color-primary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.workspace-doc-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 2px;
}

.workspace-doc-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-doc-time {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.workspace-doc-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.workspace-doc-item:hover .workspace-doc-actions {
  opacity: 1;
}

.doc-action-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.doc-action-btn.pinned {
  color: var(--color-warning);
}

.doc-action-btn.delete-btn:hover {
  color: var(--color-danger);
  background-color: rgba(239, 68, 68, 0.15);
}

.workspace-sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-bg-elevated);
}

/* ==========================================================================
   Voice Typing / Speech-to-Text Button & Recording State (Feature 5)
   ========================================================================== */
.btn-voice-typing {
  position: relative;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.btn-voice-typing.recording {
  color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.12) !important;
  animation: pulse-voice 1.5s infinite;
}

@keyframes pulse-voice {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ef4444;
  display: inline-block;
  margin-left: 5px;
  animation: blink-dot 1s infinite;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ==========================================================================
   Persian AI Copilot (Feature 6)
   ========================================================================== */
.btn-ai-gradient {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-ai-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
  filter: brightness(1.08);
}

.ai-prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.ai-prompt-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.85rem 1rem;
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: right;
  direction: rtl;
}

.ai-prompt-card:hover {
  background-color: var(--color-bg-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.ai-prompt-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.ai-prompt-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-prompt-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.ai-prompt-desc {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

.ai-custom-prompt-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-textarea {
  width: 100%;
  min-height: 85px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-input);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: 0.86rem;
  resize: vertical;
  line-height: 1.7;
}

.ai-textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ==========================================================================
   Social Card Snippet Image Generator (Feature 7)
   ========================================================================== */
.social-card-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.social-card-canvas-preview {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.social-card-themes-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.social-theme-btn {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-elevated);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.social-theme-btn.active, .social-theme-btn:hover {
  background-color: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

/* ==========================================================================
   Rastify Brand Custom Scrollbar
   ========================================================================== */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-base);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--brand-blue) 0%, var(--brand-purple) 100%);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  filter: brightness(1.25);
}

/* ==========================================================================
   Component A: The Immersive Loading Screen (Rastify Dual-Color Preloader)
   ========================================================================== */
.preloader-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-bg-base);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.preloader-overlay.preloader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}

.preloader-logo-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preloader-emblem {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 16px;
  z-index: 2;
  filter: drop-shadow(0 10px 25px rgba(139, 36, 166, 0.35));
  animation: preloader-pulse 2.2s ease-in-out infinite;
}

.preloader-orbital-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--brand-blue);
  border-right-color: var(--brand-purple);
  border-bottom-color: var(--brand-indigo);
  animation: preloader-spin 1.4s linear infinite;
  filter: drop-shadow(0 0 12px rgba(139, 36, 166, 0.5));
}

.preloader-orbital-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed rgba(26, 54, 115, 0.35);
  animation: preloader-spin-reverse 3s linear infinite;
}

.preloader-glow-orb {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 36, 166, 0.25) 0%, rgba(26, 54, 115, 0) 70%);
  animation: preloader-breathe 2.4s ease-in-out infinite alternate;
}

@keyframes preloader-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes preloader-spin-reverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes preloader-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes preloader-breathe {
  0% { transform: scale(0.85); opacity: 0.5; }
  100% { transform: scale(1.25); opacity: 0.9; }
}

.preloader-brand-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 0.25rem;
}

.preloader-brand-title .brand-en {
  font-family: var(--font-english);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.preloader-brand-title .brand-fa {
  font-family: var(--font-persian);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.preloader-track {
  width: 180px;
  height: 4px;
  border-radius: 10px;
  background-color: var(--color-border);
  overflow: hidden;
  position: relative;
}

.preloader-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  background: var(--brand-gradient);
  border-radius: 10px;
  animation: preloader-loading-bar 1.6s ease-in-out infinite;
}

@keyframes preloader-loading-bar {
  0% { left: -50%; width: 30%; }
  50% { width: 60%; }
  100% { left: 100%; width: 30%; }
}

.preloader-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ==========================================================================
   Component B: Landing / Welcome View (Rastify Showcase Hero)
   ========================================================================== */
.landing-hero-overlay {
  position: absolute;
  inset: var(--header-height) 0 0 0;
  background-color: var(--color-bg-base);
  z-index: 40;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3rem 1.5rem 4rem 1.5rem;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
}

.landing-hero-overlay.hero-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  pointer-events: none;
}

.hero-container {
  max-width: 920px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 0 auto;
}

.hero-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  direction: rtl;
}

.hero-pill-badge .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-purple);
  box-shadow: 0 0 10px var(--brand-purple);
  animation: pulse-dot 1.8s infinite;
}

.hero-brand-logo-wrap {
  margin-bottom: 1.5rem;
  max-width: 280px;
}

.hero-brand-logo {
  width: 100%;
  height: auto;
  max-height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px var(--brand-gradient-glow));
}

.hero-headline {
  font-size: 2.75rem;
  font-weight: 900;
  line-height: 1.45;
  margin-bottom: 1.25rem;
  color: var(--color-text-primary);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  direction: rtl;
}

.hero-subheadline {
  font-size: 1.12rem;
  line-height: 2;
  color: var(--color-text-secondary);
  max-width: 760px;
  margin-bottom: 2.25rem;
  direction: rtl;
}

.hero-cta-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
}

.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0.85rem 2.2rem;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: var(--font-persian);
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  color: #FFFFFF !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 30px var(--brand-gradient-glow);
  transition: all var(--transition-fast);
}

.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px var(--brand-gradient-glow);
  filter: brightness(1.1);
}

.btn-hero-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.85rem 1.8rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-persian);
  border-radius: var(--radius-full);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.btn-hero-secondary:hover {
  background: var(--color-bg-elevated);
  border-color: var(--brand-purple);
  transform: translateY(-2px);
}

.hero-features-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  width: 100%;
}

.hero-feature-card {
  padding: 1.5rem 1.25rem;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.hero-feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--brand-purple);
  box-shadow: 0 12px 28px rgba(139, 36, 166, 0.15);
}

.hero-feature-icon {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.hero-feature-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text-primary);
}

.hero-feature-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* Dedicated Header "Export to PDF" Primary Button */
.btn-brand-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--brand-gradient) !important;
  color: #FFFFFF !important;
  border: none !important;
  font-weight: 700;
  font-family: var(--font-persian);
  padding: 0.45rem 1.05rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px var(--brand-gradient-glow);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-brand-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--brand-gradient-glow);
  filter: brightness(1.1);
}

/* ==========================================================================
   Spotlight & Command Palette (Obsidian Luxury Glassmorphism)
   ========================================================================== */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(6, 10, 20, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.command-palette-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.command-palette-dialog {
  width: 100%;
  max-width: 600px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 36, 166, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.97) translateY(-8px);
  transition: transform var(--transition-normal);
}

.command-palette-overlay.open .command-palette-dialog {
  transform: scale(1) translateY(0);
}

.command-palette-search-wrap {
  display: flex;
  align-items: center;
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.command-palette-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}

.command-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-persian);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.command-palette-input::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 0.88rem;
}

.command-palette-esc {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
}

.command-palette-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-primary);
  font-family: var(--font-persian);
  font-size: 0.88rem;
  user-select: none;
}

.command-palette-item.active,
.command-palette-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  transform: translateX(-2px);
}

.command-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.command-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.command-palette-item.active .command-item-icon {
  background: var(--color-primary);
  color: #FFFFFF;
}

.command-item-title {
  font-weight: 600;
}

.command-item-desc {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.command-item-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.command-palette-footer {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.55rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.command-hint {
  display: flex;
  align-items: center;
  gap: 5px;
}

.command-hint span {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}

/* Header Command Pill Trigger Button */
.btn-command-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.75rem;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-family: var(--font-persian);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-command-pill:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 14px var(--color-primary-glow);
}

.btn-command-pill .shortcut-tag {
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Keyboard Shortcuts Cheatsheet Modal (Obsidian Bento Style)
   ========================================================================== */
.shortcuts-dialog {
  max-width: 840px;
  width: 95%;
}

.shortcuts-body {
  padding: 1.5rem;
  max-height: 74vh;
  overflow-y: auto;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}

.shortcut-bento-card {
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.shortcut-bento-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.shortcut-card-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 0.6rem;
}

.shortcut-card-header .card-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.shortcut-card-header h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  gap: 0.75rem;
}

.shortcut-desc {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  direction: ltr;
}

.shortcut-keys kbd,
.status-kbd {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  padding: 1.5px 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-primary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  display: inline-block;
  line-height: 1.3;
}

.status-btn {
  cursor: pointer;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.status-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-0.5px);
}

.status-btn:hover .status-kbd {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ==========================================================================
   Advanced Responsive Breakpoints (Tablets, Laptops, Mobile)
   ========================================================================== */
@media (max-width: 1200px) {
  .btn-command-pill span {
    display: none;
  }
  .btn-command-pill {
    padding: 0.35rem 0.55rem;
  }
  .btn-font-pill span {
    max-width: 75px;
  }
  .header-power-capsule .btn-label {
    display: none;
  }
}

@media (max-width: 992px) {
  .app-header {
    height: auto;
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
    gap: 0.65rem;
  }
  .header-center-nav {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .brand-section {
    order: 1;
  }
  .header-actions {
    order: 2;
    margin-right: auto;
  }
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
  .toolbar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 640px) {
  .doc-title-input {
    width: 110px;
  }
  .btn-command-pill,
  .btn-font-pill {
    display: none;
  }
  .status-bar {
    height: auto;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
  }
  #stat-chars,
  #stat-lines,
  #stat-cursor {
    display: none;
  }
}



