:root {
  color-scheme: light;
  font-family: "Inter", system-ui, sans-serif;
  background: #f3f4f6;
  color: #111827;
  
  /* Light mode colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
  --border: #e5e7eb;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --surface-hover: #f3f4f6;
}

/* Dark mode */
body.theme-dark {
  color-scheme: dark;
  background: #111827;
  color: #f9fafb;
  
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;
  --bg-hover: #4b5563;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-color: #374151;
  --border: #374151;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --surface-hover: #374151;
}

body.theme-dark .page {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.theme-dark .page::before {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 1117px,
    #4b5563 1117px,
    #4b5563 1119px,
    transparent 1119px,
    transparent 1121px,
    #4b5563 1121px,
    #4b5563 1123px
  );
}

/* Light mode: ensure document text is always dark (override any errant white inheritance) */
body:not(.theme-dark) .page-editor {
  color: #111827;
}

body:not(.theme-dark) .page-editor h1,
body:not(.theme-dark) .page-editor h2,
body:not(.theme-dark) .page-editor h3,
body:not(.theme-dark) .page-editor h4,
body:not(.theme-dark) .page-editor h5,
body:not(.theme-dark) .page-editor h6,
body:not(.theme-dark) .page-editor p,
body:not(.theme-dark) .page-editor li,
body:not(.theme-dark) .page-editor blockquote,
body:not(.theme-dark) .page-editor span,
body:not(.theme-dark) .page-editor strong,
body:not(.theme-dark) .page-editor em,
body:not(.theme-dark) .page-editor u,
body:not(.theme-dark) .page-editor div {
  color: #111827;
}

body:not(.theme-dark) .page-editor a {
  color: #2563eb;
}

body:not(.theme-dark) .page-editor a:hover {
  color: #1d4ed8;
}

/* Dark mode: revert monochromatic text to light; user-chosen colors (inline) remain unchanged */
body.theme-dark .page-editor {
  color: #f9fafb;
}

body.theme-dark .page-editor h1,
body.theme-dark .page-editor h2,
body.theme-dark .page-editor h3,
body.theme-dark .page-editor h4,
body.theme-dark .page-editor h5,
body.theme-dark .page-editor h6,
body.theme-dark .page-editor p,
body.theme-dark .page-editor li,
body.theme-dark .page-editor blockquote,
body.theme-dark .page-editor span,
body.theme-dark .page-editor strong,
body.theme-dark .page-editor em,
body.theme-dark .page-editor u,
body.theme-dark .page-editor div {
  color: #f9fafb;
}

body.theme-dark .page-editor a {
  color: #60a5fa;
}

body.theme-dark .page-editor a:hover {
  color: #93c5fd;
}

body.theme-dark .page-editor mark {
  background: rgba(251, 191, 36, 0.4);
  color: #111827;
}

body.theme-dark .app-header {
  background: rgba(31, 41, 55, 0.95);
  border-color: #374151;
}

body.theme-dark .ribbon {
  background: rgba(31, 41, 55, 0.95);
  border-color: #374151;
}

body.theme-dark .doc-sidebar {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .ribbon-btn,
body.theme-dark .ribbon-icon-btn {
  color: #d1d5db;
}

body.theme-dark .ribbon-btn:hover,
body.theme-dark .ribbon-icon-btn:hover {
  background: #374151;
}

body.theme-dark .doc-list-item {
  border-color: #374151;
}

body.theme-dark .doc-list-item:hover {
  background: #374151;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

body.theme-dark .settings-modal-content,
body.theme-dark .insert-modal-content {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .dropdown-menu {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .dropdown-menu button:hover {
  background: #374151;
}

* {
  box-sizing: border-box;
}

/* Performance: Reduce motion for users who prefer it */
@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;
  }
}

/* Performance: Fallback for devices that prefer reduced transparency */
@media (prefers-reduced-transparency: reduce) {
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Performance: Low-power mode fallback (class added by JS) */
body.low-performance-mode * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: inherit;
}

body.low-performance-mode .app-header,
body.low-performance-mode .ribbon,
body.low-performance-mode .doc-sidebar,
body.low-performance-mode .status-bar,
body.low-performance-mode .modal-container,
body.low-performance-mode .theme-menu {
  background: #fff !important;
}

body.low-performance-mode .ribbon-btn,
body.low-performance-mode .ribbon-icon-btn,
body.low-performance-mode .ribbon-tab,
body.low-performance-mode .theme-btn {
  background: #f5f5f5 !important;
}

/* Dark mode overrides for low-performance mode */
body.theme-dark.low-performance-mode .app-header,
body.theme-dark.low-performance-mode .ribbon,
body.theme-dark.low-performance-mode .doc-sidebar,
body.theme-dark.low-performance-mode .status-bar,
body.theme-dark.low-performance-mode .modal-container,
body.theme-dark.low-performance-mode .theme-menu {
  background: #1f2937 !important;
}

body.theme-dark.low-performance-mode .ribbon-btn,
body.theme-dark.low-performance-mode .ribbon-icon-btn,
body.theme-dark.low-performance-mode .ribbon-tab,
body.theme-dark.low-performance-mode .theme-btn {
  background: #374151 !important;
  color: #f9fafb !important;
}

body.theme-dark.low-performance-mode .page-container {
  background: #111827 !important;
}

body.theme-dark.low-performance-mode .doc-sidebar {
  background: #1f2937 !important;
}

/* CSS-only fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(1px)) {
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  
  .app-header,
  .ribbon,
  .doc-sidebar,
  .status-bar,
  .modal-container,
  .theme-menu {
    background: #fff !important;
  }
  
  .ribbon-btn,
  .ribbon-icon-btn,
  .ribbon-tab,
  .theme-btn {
    background: #f5f5f5 !important;
  }
  
  /* Dark mode overrides when backdrop-filter not supported */
  body.theme-dark .app-header,
  body.theme-dark .ribbon,
  body.theme-dark .doc-sidebar,
  body.theme-dark .status-bar,
  body.theme-dark .modal-container,
  body.theme-dark .theme-menu {
    background: #1f2937 !important;
  }
  
  body.theme-dark .ribbon-btn,
  body.theme-dark .ribbon-icon-btn,
  body.theme-dark .ribbon-tab,
  body.theme-dark .theme-btn {
    background: #374151 !important;
    color: #f9fafb !important;
  }
  
  body.theme-dark .page-container {
    background: #111827 !important;
  }
  
  body.theme-dark .doc-sidebar {
    background: #1f2937 !important;
  }
}

/* ========== DARK MODE ========== */
body.theme-dark {
  color-scheme: dark;
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;
  --bg-hover: #4b5563;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-color: #374151;
  --border: #374151;
  --primary: #3b82f6;
  --surface-hover: #374151;
}

body.theme-dark {
  background: #111827;
  color: #f9fafb;
}

body.theme-dark .app-header {
  background: rgba(31, 41, 55, 0.95);
  border-color: #374151;
}

body.theme-dark .ribbon {
  background: rgba(31, 41, 55, 0.95);
  border-color: #374151;
}

body.theme-dark .ribbon-btn,
body.theme-dark .ribbon-icon-btn {
  background: #374151;
  color: #f9fafb;
  border-color: #4b5563;
}

body.theme-dark .ribbon-btn:hover,
body.theme-dark .ribbon-icon-btn:hover {
  background: #4b5563;
}

body.theme-dark .ribbon-tab {
  color: #d1d5db;
}

body.theme-dark .ribbon-tab.active {
  background: #374151;
  color: #f9fafb;
}

body.theme-dark .ribbon-group-title {
  color: #9ca3af;
}

body.theme-dark .doc-sidebar {
  background: rgba(31, 41, 55, 0.98);
  border-color: #374151;
}

body.theme-dark .doc-list-item {
  background: #374151;
  color: #f9fafb;
}

body.theme-dark .doc-list-item:hover {
  background: #4b5563;
}

body.theme-dark .doc-list-item.active {
  background: #3b82f6;
}

body.theme-dark .page {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.theme-dark .page::before {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 1117px,
    #4b5563 1117px,
    #4b5563 1119px,
    transparent 1119px,
    transparent 1121px,
    #4b5563 1121px,
    #4b5563 1123px
  );
}

body.theme-dark .main-content {
  background: #111827;
}

body.theme-dark .pages-container {
  background: #111827;
}

body.theme-dark .page-container {
  background: #111827;
}

body.theme-dark .pages {
  background: transparent;
}

body.theme-dark .doc-area {
  background: transparent;
}

body.theme-dark .doc-controls {
  color: #f9fafb;
}

body.theme-dark .ai-assistant-panel {
  background: linear-gradient(180deg, rgba(15,23,42,0.96), rgba(30,41,59,0.94));
  border-color: rgba(71, 85, 105, 0.72);
  box-shadow: none;
}

body.theme-dark .ai-assistant-header h3,
body.theme-dark .ai-chat-body,
body.theme-dark .ai-assistant-input {
  color: #f8fafc;
}

body.theme-dark .ai-assistant-kicker,
body.theme-dark .ai-assistant-close {
  color: #cbd5e1;
}

body.theme-dark .ai-assistant-window-btn,
body.theme-dark .ai-suggestion-preview,
body.theme-dark .ai-inline-suggestion-btn.reject {
  background: rgba(15,23,42,0.92);
  color: #e2e8f0;
  border-color: rgba(71,85,105,0.75);
}

body.theme-dark .ai-assistant-chip {
  background: rgba(15,23,42,0.82);
  border-color: rgba(71,85,105,0.75);
  color: #e2e8f0;
}

body.theme-dark .ai-chat-message.assistant {
  background: rgba(30, 64, 175, 0.18);
  border-color: rgba(96, 165, 250, 0.22);
}

body.theme-dark .ai-chat-message.user {
  background: rgba(2, 6, 23, 0.95);
}

body.theme-dark .ai-assistant-input {
  background: rgba(2, 6, 23, 0.9);
  border-color: rgba(71,85,105,0.8);
}

body.theme-dark .ai-suggestion-item {
  background: rgba(2, 6, 23, 0.55);
  border-color: rgba(71,85,105,0.65);
}

body.theme-dark .ai-suggestion-meta,
body.theme-dark .ai-suggestion-reason {
  color: #cbd5e1;
}

body.theme-dark .ai-inline-suggestion {
  background: rgba(30, 41, 59, 0.94);
  border-color: rgba(96, 165, 250, 0.3);
}

body.theme-dark .ai-inline-suggestion-before {
  color: #fca5a5;
}

body.theme-dark .ai-inline-suggestion-after {
  color: #6ee7b7;
}

body.theme-dark #doc-title {
  color: #f9fafb;
}

body.theme-dark .doc-status {
  color: #9ca3af;
}

body.theme-dark .doc-sidebar {
  background: #1f2937 !important;
  border-color: #374151;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

body.theme-dark .doc-sidebar h2 {
  color: #9ca3af;
}

body.theme-dark .doc-sidebar p {
  color: #d1d5db;
}

body.theme-dark .doc-list li {
  color: #f9fafb;
}

body.theme-dark .doc-list li .doc-title {
  color: #f9fafb;
}

body.theme-dark .doc-list li .doc-title-input {
  background: rgba(31, 41, 55, 0.95);
  border-color: #60a5fa;
  color: #f9fafb;
}

body.theme-dark .doc-list li:hover {
  background: #374151;
}

body.theme-dark .doc-list li.active {
  background: #3b82f6;
  border-color: #60a5fa;
}

body.theme-dark .doc-list li.active .doc-title {
  color: #fff;
}

body.theme-dark .app-body {
  background: #111827;
}

body.theme-dark .app-title {
  color: #f9fafb;
}

body.theme-dark .structure-bar-label {
  color: #9ca3af;
}

body.theme-dark .structure-bar {
  background: rgba(75, 85, 99, 0.5);
}

body.theme-dark .structure-percentage {
  color: #d1d5db;
}

body.theme-dark .app-title {
  color: #f9fafb;
}

body.theme-dark .app-body {
  background: #111827;
}

body.theme-dark .grammar-rail-item > button.grammar-rail-bubble {
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
}

body.theme-dark #ai-status {
  color: #9ca3af;
}

body.theme-dark .status-save {
  color: #34d399;
}

body.theme-dark .status-bar {
  background: rgba(31, 41, 55, 0.95);
  color: #d1d5db;
}

body.theme-dark .dropdown-menu,
body.theme-dark .settings-modal-content,
body.theme-dark .insert-modal-content {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #374151;
  color: #f9fafb;
  border-color: #4b5563;
}

body.theme-dark .spreadsheet-cell {
  background: #1f2937;
  color: #f9fafb;
  border-color: #374151;
}

body.theme-dark .spreadsheet-toolbar {
  background: #374151;
  border-color: #4b5563;
}

body.theme-dark .equation-panel {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .comments-panel {
  background: #111827;
  border-color: #374151;
  box-shadow: -8px 0 30px rgba(0,0,0,0.35);
}

body.theme-dark .comments-panel-header {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .comment-item {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .comment-item:hover {
  border-color: #60a5fa;
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.1);
}

body.theme-dark .comment-item-actions {
  border-color: #374151;
}

body.theme-dark .comment-edit-btn,
body.theme-dark .comment-delete-btn {
  background: #111827;
  border-color: #374151;
  color: #9ca3af;
}

body.theme-dark .comment-modal {
  background: #1f2937;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

body.theme-dark .comment-modal-header {
  border-color: #374151;
}

body.theme-dark .comment-modal-quote {
  background: #111827;
  border-left-color: #60a5fa;
}

body.theme-dark .comment-modal-input {
  background: #111827;
  border-color: #374151;
  color: #f3f4f6;
}

body.theme-dark .comment-modal-footer {
  background: #111827;
  border-color: #374151;
}

body.theme-dark .comment-modal-cancel {
  background: #1f2937;
  border-color: #374151;
  color: #9ca3af;
}

body.theme-dark .comments-delete-all-btn {
  border-color: #f87171;
  color: #f87171;
}

body.theme-dark .comments-delete-all-btn:hover {
  background: #f87171;
  color: #111827;
}

body.theme-dark .comment-modal-cancel {
  background: #374151;
  border-color: #4b5563;
  color: #d1d5db;
}

body.theme-dark .comment-modal-quote {
  background: #111827;
  border-left-color: #3b82f6;
}

body.theme-dark .symbol-picker {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark ::selection {
  background: #3b82f6;
  color: #fff;
}

/* Light Mode (explicit) */
body.theme-light {
  color-scheme: light;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
  --border: #e5e7eb;
  --primary: #2563eb;
  --surface-hover: #f3f4f6;
}

/* ========== UI MODES ========== */

/* Basic Mode (default) - Clean, minimal, no effects */
body.ui-basic * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.ui-basic .app-header {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

body.ui-basic .ribbon {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
}

body.ui-basic .ribbon-btn,
body.ui-basic .ribbon-icon-btn {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  box-shadow: none;
}

body.ui-basic .ribbon-btn:hover,
body.ui-basic .ribbon-icon-btn:hover {
  background: #f3f4f6;
  box-shadow: none;
  transform: none;
}

body.ui-basic .ribbon-tab {
  background: transparent;
  box-shadow: none;
}

body.ui-basic .ribbon-tab.active {
  background: #f3f4f6;
  box-shadow: none;
}

body.ui-basic .doc-sidebar {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
}

body.ui-basic .primary {
  background: #2563eb;
  box-shadow: none;
}

body.ui-basic .primary:hover {
  background: #1d4ed8;
  box-shadow: none;
  transform: none;
}

body.ui-basic .theme-btn,
body.ui-basic .theme-menu {
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

body.ui-basic .status-bar {
  background: #fff;
  box-shadow: none;
}

body.ui-basic .settings-btn {
  background: #f9fafb;
  box-shadow: none;
}

body.ui-basic .structure-bar-fill {
  animation: none;
  background: #6366f1;
}

body.ui-basic .structure-bar-shine,
body.ui-basic .structure-bar-particles,
body.ui-basic .structure-bar-glow,
body.ui-basic .button-shine {
  display: none !important;
}

body.ui-basic .auto-structure-button,
body.ui-basic .auto-style-button {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: none;
  color: #fff;
}

body.ui-basic .auto-structure-button .button-text,
body.ui-basic .auto-style-button .button-text {
  color: #fff;
}

body.ui-basic .auto-structure-button .button-icon,
body.ui-basic .auto-style-button .button-icon {
  color: #fff;
}

body.ui-basic .auto-structure-button .button-icon svg,
body.ui-basic .auto-style-button .button-icon svg {
  stroke: #fff;
}

body.ui-basic .grammar-rail-header-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: none;
  color: #fff;
}

/* Dark mode + Basic UI - ensure dark styling wins */
body.theme-dark.ui-basic .app-header {
  background: #1f2937 !important;
  border-color: #374151;
}

body.theme-dark.ui-basic .ribbon {
  background: #1f2937 !important;
  border-color: #374151;
}

body.theme-dark.ui-basic .ribbon-btn,
body.theme-dark.ui-basic .ribbon-icon-btn {
  background: #374151 !important;
  border-color: #4b5563;
  color: #f9fafb !important;
}

body.theme-dark.ui-basic .ribbon-btn:hover,
body.theme-dark.ui-basic .ribbon-icon-btn:hover {
  background: #4b5563 !important;
}

body.theme-dark.ui-basic .ribbon-tab {
  color: #d1d5db;
}

body.theme-dark.ui-basic .ribbon-tab.active {
  background: #374151 !important;
  color: #f9fafb;
}

body.theme-dark.ui-basic .doc-sidebar {
  background: #1f2937 !important;
  border-color: #374151;
}

body.theme-dark.ui-basic .status-bar {
  background: #1f2937 !important;
  color: #d1d5db;
}

body.theme-dark.ui-basic .theme-menu {
  background: #1f2937 !important;
  border-color: #374151;
}

body.theme-dark.ui-basic .page-container {
  background: #111827 !important;
}

/* Normal Mode - Subtle glassmorphism */
body.ui-normal .app-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.ui-normal .ribbon {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.ui-normal .ribbon-btn,
body.ui-normal .ribbon-icon-btn {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.ui-normal .doc-sidebar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.ui-normal .structure-bar-shine,
body.ui-normal .structure-bar-particles,
body.ui-normal .structure-bar-glow {
  display: none !important;
}

/* Dark mode + Normal UI */
body.theme-dark.ui-normal .app-header {
  background: rgba(31, 41, 55, 0.95) !important;
}

body.theme-dark.ui-normal .ribbon {
  background: rgba(31, 41, 55, 0.95) !important;
}

body.theme-dark.ui-normal .ribbon-btn,
body.theme-dark.ui-normal .ribbon-icon-btn {
  background: rgba(55, 65, 81, 0.8) !important;
  color: #f9fafb !important;
}

body.theme-dark.ui-normal .doc-sidebar {
  background: rgba(31, 41, 55, 0.98) !important;
}

/* Fancy Mode - Full effects (default CSS behavior) */
/* No overrides needed - uses default styles with all effects */

/* Animations disabled */
body.no-animations *,
body.no-animations *::before,
body.no-animations *::after {
  animation: none !important;
  transition: none !important;
}

/* Liquid glass disabled on selection bubbles */
body.no-liquid-glass .selection-bubble-group .glass-button,
body.no-liquid-glass .auto-parent-bubble .glass-button,
body.no-liquid-glass .auto-child-bubble .glass-button,
body.no-liquid-glass #auto-parent-bubble > *,
body.no-liquid-glass #auto-structure-bubble > *,
body.no-liquid-glass #auto-style-bubble > * {
  all: unset !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 10px 18px !important;
  min-width: 80px !important;
  border-radius: 20px !important;
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  color: #374151 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
}

body.no-liquid-glass .selection-bubble-group .glass-button:hover,
body.no-liquid-glass .auto-parent-bubble .glass-button:hover,
body.no-liquid-glass .auto-child-bubble .glass-button:hover,
body.no-liquid-glass #auto-parent-bubble > *:hover,
body.no-liquid-glass #auto-structure-bubble > *:hover,
body.no-liquid-glass #auto-style-bubble > *:hover {
  background: #f9fafb !important;
  transform: scale(1.02) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12) !important;
}

body.no-liquid-glass .fallback-bubble-button {
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  color: #374151 !important;
}

/* Blur effects disabled */
body.no-blur * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Progress bar animation disabled */
body.no-progress-animation .structure-bar-fill {
  animation: none !important;
  background: #6366f1 !important;
}

body.no-progress-animation .structure-bar-shine,
body.no-progress-animation .structure-bar-particles,
body.no-progress-animation .structure-bar-glow {
  display: none !important;
}

/* Hover effects disabled */
body.no-hover-effects *:hover {
  transform: none !important;
}

body.no-hover-effects .ribbon-btn:hover,
body.no-hover-effects .ribbon-icon-btn:hover,
body.no-hover-effects .ribbon-tab:hover,
body.no-hover-effects .primary:hover,
body.no-hover-effects .theme-btn:hover,
body.no-hover-effects .settings-btn:hover {
  transform: none !important;
  box-shadow: inherit !important;
}

/* ========== SETTINGS UI ========== */

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.membership-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 5px 10px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(254, 240, 138, 0.88), rgba(251, 191, 36, 0.7));
  color: #713f12;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.18);
}

.membership-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 14px 28px rgba(245, 158, 11, 0.24);
}

.membership-usage-banner {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(260px, 1.3fr) auto;
  align-items: center;
  gap: 16px;
  margin: 0 0 18px;
  padding: 14px 18px;
  max-width: 980px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(239, 246, 255, 0.88));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.membership-usage-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.membership-usage-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.membership-usage-title-row h3 {
  margin: 0;
  font-size: 22px;
  color: #0f172a;
}

.membership-usage-summary,
.membership-usage-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: #475569;
}

.membership-usage-meta-secondary {
  opacity: 0.88;
}

.membership-usage-meter {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.2);
}

.membership-usage-meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0ea5e9, #2563eb, #0f766e);
  transition: width 0.25s ease;
}

.membership-upgrade-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.22);
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.account-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  color: #111827;
}

.account-btn svg {
  flex-shrink: 0;
}

.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: #374151;
  transition: all 0.2s ease;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  color: #111827;
  transform: rotate(30deg);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.membership-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.membership-summary-card,
.membership-settings-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.9));
  padding: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.membership-summary-top,
.membership-settings-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.membership-summary-label,
.membership-settings-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.membership-summary-card h4,
.membership-settings-card h4 {
  margin: 0;
  font-size: 22px;
  color: #0f172a;
}

.membership-summary-text {
  margin: 12px 0 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.6;
}

.membership-quota-text {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
}

.membership-payment-text {
  margin: 8px 0 0;
  font-size: 13px;
  color: #475569;
}

.membership-feature-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 10px;
}

.membership-feature-list li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.55;
  color: #334155;
}

.membership-feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.membership-feature-list.compact {
  gap: 8px;
}

.membership-summary-actions,
.membership-settings-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-start;
}

.membership-meter {
  margin-top: 14px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.18);
}

.membership-meter-fill {
  height: 100%;
  width: 22%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3b82f6, #14b8a6);
  transition: width 0.25s ease;
}

.membership-meter-label {
  margin: 10px 0 0;
  font-size: 12px;
  color: #64748b;
}

.settings-modal-content {
  position: relative;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.settings-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
}

.settings-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #f3f4f6;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-close:hover {
  background: #e5e7eb;
  color: #111827;
}

.settings-modal-body {
  padding: 24px;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-option {
  margin-bottom: 20px;
}

.settings-option:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 4px;
}

.settings-description {
  font-size: 13px;
  color: #6b7280;
  margin: 0 0 12px;
}

/* Radio Group */
.settings-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-radio {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-radio:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}

.settings-radio:has(input:checked) {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}

.settings-radio input {
  display: none;
}

.settings-radio-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  margin-top: 2px;
  transition: all 0.15s ease;
  position: relative;
}

.settings-radio:has(input:checked) .settings-radio-check {
  border-color: #6366f1;
}

.settings-radio:has(input:checked) .settings-radio-check::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: #6366f1;
  border-radius: 50%;
}

.settings-radio-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-radio-title {
  font-size: 15px;
  font-weight: 500;
  color: #111827;
}

.settings-radio-desc {
  font-size: 13px;
  color: #6b7280;
}

/* Toggle Switch */
.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-toggle:hover {
  background: #f9fafb;
}

.settings-toggle input {
  display: none;
}

.settings-toggle-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-toggle-title {
  font-size: 15px;
  font-weight: 500;
  color: #111827;
}

.settings-toggle-desc {
  font-size: 13px;
  color: #6b7280;
}

.settings-toggle-switch {
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s ease;
}

.settings-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.settings-toggle:has(input:checked) .settings-toggle-switch {
  background: #6366f1;
}

.settings-toggle:has(input:checked) .settings-toggle-switch::after {
  transform: translateX(20px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f3f4f6;
  text-rendering: optimizeSpeed;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.3);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-title-input {
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  width: min(420px, 100%);
  color: inherit;
  cursor: text;
}

.app-title-input::placeholder {
  color: #6b7280;
}

/* Structure Progress Bar */
.structure-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  width: 100%;
}

.structure-bar-label {
  display: none;
}

.structure-bar {
  position: relative;
  flex: 1;
  height: 4px;
  background: rgba(229, 231, 235, 0.5);
  border-radius: 100px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.structure-bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    #6366f1 0%,
    #8b5cf6 25%,
    #a855f7 50%,
    #8b5cf6 75%,
    #6366f1 100%
  );
  background-size: 200% 100%;
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  animation: gradientFlow 3s linear infinite;
  box-shadow:
    0 0 6px rgba(99, 102, 241, 0.30),
    0 0 12px rgba(139, 92, 246, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.structure-bar-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shineSweep 2s ease-in-out infinite;
}

@keyframes shineSweep {
  0% {
    left: -100%;
  }
  50%, 100% {
    left: 100%;
  }
}

.structure-bar-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(2px 2px at 60% 70%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(255, 255, 255, 0.4), transparent);
  background-size: 200% 200%;
  animation: particleFloat 4s ease-in-out infinite;
  opacity: 0.45;
}

@keyframes particleFloat {
  0%, 100% {
    background-position: 0% 0%, 100% 100%, 50% 50%, 80% 20%;
  }
  50% {
    background-position: 100% 100%, 0% 0%, 50% 50%, 20% 80%;
  }
}

.structure-bar-glow {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 200%;
  background: radial-gradient(
    ellipse at center,
    rgba(99, 102, 241, 0.15) 0%,
    transparent 70%
  );
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.structure-bar-container:hover .structure-bar-glow {
  opacity: 1;
}

.structure-percentage {
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: color 0.25s ease;
}

.structure-bar-container:hover .structure-percentage {
  color: #6366f1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Ribbon (Word-like navbar) */
.ribbon {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  padding: 4px 8px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset,
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  contain: layout style;
}

.ribbon.collapsed .ribbon-panels {
  display: none !important;
  max-height: 0;
  opacity: 0;
}

.ribbon.collapsed {
  padding-bottom: 4px;
}

/* Temporary expand - show panels when clicking tabs while collapsed */
.ribbon.collapsed.temp-expanded .ribbon-panels {
  display: flex !important;
  max-height: 500px;
  opacity: 1;
}

.ribbon.collapsed.temp-expanded {
  padding-bottom: 8px;
}

/* Collapsed header state - hide title and structure bar */
.app-header {
  transition: padding 0.2s ease, gap 0.2s ease;
}

.app-header .app-header-top,
.app-header .structure-bar-container {
  transition: max-height 0.2s ease, opacity 0.2s ease, margin 0.2s ease;
  max-height: 100px;
  opacity: 1;
  overflow: hidden;
}

.app-header.collapsed {
  padding: 0;
  gap: 0;
  border-bottom: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.app-header.collapsed .app-header-top,
.app-header.collapsed .structure-bar-container {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
}

.ribbon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px 3px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 3px;
}

.ribbon-collapse-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  color: #6b7280;
  font-size: 10px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ribbon-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-color: rgba(255, 255, 255, 0.5);
  color: #111827;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ribbon.collapsed .ribbon-collapse-btn .collapse-icon {
  transform: rotate(180deg);
}

.collapse-icon {
  transition: transform 0.3s ease;
  display: inline-block;
}

.ribbon-tabs {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: wrap;
}

.ribbon-tab {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ribbon-tab:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ribbon-tab.active {
  background: rgba(99, 102, 241, 0.25);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-color: rgba(99, 102, 241, 0.4);
  color: #4f46e5;
  box-shadow: 
    0 4px 16px rgba(99, 102, 241, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

.ribbon-panels {
  display: block;
  width: 100%;
  overflow: hidden;
}

.ribbon-panel {
  display: none;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
  width: 100%;
  transform-origin: left center;
}

.ribbon-panel.active {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  align-items: stretch;
  align-content: flex-start;
  flex-wrap: wrap;
  overflow: visible;
}

.ribbon-group {
  border-right: 1px solid rgba(229, 231, 235, 0.8);
  padding: 2px 12px 2px 0;
  margin-right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 170px;
  max-width: 300px;
  justify-content: flex-start;
}

.ribbon-group:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}

.ribbon-group-title {
  font-size: 8px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  display: block;
}

.ribbon-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  justify-content: flex-start;
  width: 100%;
}

.ribbon-btn,
.ribbon-icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  color: #111827;
  white-space: nowrap;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(0); /* GPU layer for smoother animations */
  backface-visibility: hidden;
  min-width: fit-content;
  flex: 0 0 auto;
  width: max-content;
  font-weight: 500;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.ribbon-icon-btn {
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  padding: 5px;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
}

.ribbon-btn:hover,
.ribbon-icon-btn:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px) translateZ(0);
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Active state for icon buttons (Bold, Italic, etc.) */
.ribbon-icon-btn.active {
  background: rgba(99, 102, 241, 0.2);
  backdrop-filter: blur(14px) saturate(200%);
  -webkit-backdrop-filter: blur(14px) saturate(200%);
  border-color: rgba(99, 102, 241, 0.5);
  color: #4f46e5;
  box-shadow: 
    0 4px 16px rgba(99, 102, 241, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ribbon-icon-btn.active:hover {
  background: rgba(99, 102, 241, 0.3);
  backdrop-filter: blur(18px) saturate(200%);
  -webkit-backdrop-filter: blur(18px) saturate(200%);
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 
    0 6px 24px rgba(99, 102, 241, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.7) inset,
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

.ribbon-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

/* Buttons with both icon and text */
.ribbon-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ribbon-btn-icon svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ribbon-btn-icon span {
  white-space: nowrap;
}

/* Beta badge for ribbon buttons */
.ribbon-btn-beta {
  position: relative;
}
.ribbon-beta-badge {
  display: inline-flex;
  align-items: center;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.2;
  margin-left: 2px;
  vertical-align: middle;
  white-space: nowrap;
}

.ribbon-file-label {
  position: relative;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.ribbon-file-label input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
}

label.ribbon-btn-icon.ribbon-file-label {
  cursor: pointer;
}


.ribbon-select {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  height: 32px;
  min-width: fit-content;
  max-width: 180px;
  flex: 0 0 auto;
  width: max-content;
  flex-shrink: 0;
}

/* Custom font picker (replaces native select) */
.font-picker-container {
  position: relative;
  display: inline-flex;
}

.font-picker-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  height: 32px;
  min-width: 120px;
  max-width: 200px;
  cursor: pointer;
  color: #111827;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.font-picker-btn:hover {
  border-color: #d1d5db;
}

.font-picker-btn:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.font-picker-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-picker-arrow {
  font-size: 10px;
  color: #6b7280;
  flex-shrink: 0;
}

.font-picker-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10001;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  min-width: 180px;
  display: none;
}

.font-picker-menu.open {
  display: block;
}

.font-picker-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: #111827;
  transition: background 0.15s;
}

.font-picker-option:hover {
  background: #f3f4f6;
}

body.theme-dark .font-picker-btn {
  border-color: #374151;
  background: #1f2937;
  color: #f9fafb;
}

body.theme-dark .font-picker-menu {
  background: #1f2937;
  border-color: #374151;
}

body.theme-dark .font-picker-option {
  color: #f9fafb;
}

body.theme-dark .font-picker-option:hover {
  background: #374151;
}

.ribbon-input {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  height: 32px;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.ribbon-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Theme Selector - Clean Implementation */
.theme-selector-container {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.theme-label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}

.theme-btn {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #111827;
  white-space: nowrap;
  min-width: fit-content;
  font-weight: 500;
  font-family: inherit;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  transition: all 0.2s ease;
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(200%);
  -webkit-backdrop-filter: blur(16px) saturate(200%);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.theme-preview {
  display: flex;
  gap: 3px;
  align-items: center;
}

.theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  display: block;
}

.theme-name {
  font-size: 13px;
  color: #111827;
}

.theme-menu {
  position: fixed !important;
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  min-width: 220px !important;
  z-index: 100000 !important;
  padding: 6px !important;
  max-height: 400px !important;
  overflow-y: auto !important;
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.theme-menu.open {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.theme-dark .theme-menu {
  background: #1f2937 !important;
  border-color: #374151 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

body.theme-dark .theme-item:hover {
  background: #374151 !important;
}

body.theme-dark .theme-item.selected {
  background: #3b82f6 !important;
  color: #fff !important;
}

body.theme-dark .theme-name {
  color: #f9fafb;
}

body.theme-dark .theme-item-name {
  color: #f9fafb !important;
}

body.theme-dark .settings-btn {
  color: #f9fafb;
}

body.theme-dark .settings-btn:hover {
  background: rgba(75, 85, 99, 0.6);
  color: #fff;
}

body.theme-dark .settings-modal-header h2,
body.theme-dark .insert-modal-header h2,
body.theme-dark .insert-modal-title {
  color: #f9fafb;
}

body.theme-dark .settings-label,
body.theme-dark .settings-toggle-title,
body.theme-dark .settings-description,
body.theme-dark .settings-toggle-desc {
  color: #d1d5db;
}

body.theme-dark .settings-radio-title,
body.theme-dark .settings-radio-desc {
  color: #e5e7eb;
}

body.theme-dark .ribbon-checkbox-label {
  color: #9ca3af;
}

body.theme-dark .doc-list li .doc-delete-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

body.theme-dark .insert-modal-content h3,
body.theme-dark .insert-modal-content .insert-modal-title,
body.theme-dark .auto-style-title,
body.theme-dark .auto-style-description {
  color: #f9fafb;
}

body.theme-dark .insert-modal-content p,
body.theme-dark .insert-modal-content label {
  color: #d1d5db;
}

.theme-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 10px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  transition: background 0.15s ease !important;
  pointer-events: auto !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.theme-item:hover {
  background: #f3f4f6 !important;
}

.theme-item.selected {
  background: #eff6ff !important;
}

.theme-item-name {
  font-size: 13px !important;
  color: #111827 !important;
  pointer-events: none !important;
}

.theme-item .theme-preview {
  pointer-events: none !important;
}

.ribbon-checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.ribbon-checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
}

.ribbon-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #ffffff;
}

.ribbon-range {
  width: 160px;
}

.ribbon-meta {
  font-size: 12px;
  color: #6b7280;
  min-width: 44px;
  text-align: right;
}

.ribbon-file {
  border: 1px dashed #d1d5db;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  color: #111827;
}
.ribbon-file input {
  display: none;
}

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  border-top: 1px solid rgba(229, 231, 235, 0.3);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  font-size: 12px;
  color: #6b7280;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.status-sep {
  margin: 0 8px;
  color: #d1d5db;
}

.proofing-status {
  font-size: 11px;
  color: #6b7280;
}

.status-save {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #10b981;
  transition: opacity 0.3s ease;
}

.status-save.saving {
  color: #f59e0b;
}

.status-save svg {
  width: 14px;
  height: 14px;
}

.status-credits {
  font-size: 11px;
  color: #9ca3af;
}

body.theme-dark .status-credits {
  color: #6b7280;
}

.settings-credits {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

body.theme-dark .settings-credits {
  border-top-color: #374151;
}

.settings-credits-text {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

body.theme-dark .settings-credits-text {
  color: #9ca3af;
}

@keyframes saving-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-save.saving svg {
  animation: saving-pulse 1s ease-in-out infinite;
}

.tool-button,
.tool-select,
.tool-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.tool-button {
  min-height: 34px;
}

.tool-button.active {
  border-color: #2563eb;
  color: #1d4ed8;
}

.tool-select select {
  border: none;
  background: transparent;
  font-size: 14px;
}

.tool-color input {
  border: none;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
}

.divider {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
}

.underline {
  text-decoration: underline;
}

.strike {
  text-decoration: line-through;
}

.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  padding: 24px;
  flex: 1;
}

body.ai-assistant-open .app-body {
  grid-template-columns: 240px minmax(0, 1fr) 460px;
}

body.ai-assistant-dock .app-body {
  grid-template-columns: 240px minmax(0, 1fr) 420px;
}

body.ai-assistant-split .app-body {
  grid-template-columns: 240px minmax(0, 0.95fr) minmax(520px, 0.9fr);
}

body.ai-assistant-full .app-body {
  grid-template-columns: 240px minmax(0, 1fr);
}

.doc-sidebar {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  height: fit-content;
  position: sticky;
  top: calc(var(--header-height, 100px) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-height, 100px) - 48px);
  overflow-y: auto;
  transition: top 0.3s ease;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  contain: layout style;
  content-visibility: auto;
}

.sidebar-section + .sidebar-section {
  margin-top: 24px;
}

.doc-sidebar h2 {
  font-size: 14px;
  margin: 0 0 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.primary {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 
    0 4px 16px rgba(37, 99, 235, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  transition: all 0.2s ease;
}

.primary:hover {
  background: rgba(37, 99, 235, 0.95);
  backdrop-filter: blur(16px) saturate(200%);
  -webkit-backdrop-filter: blur(16px) saturate(200%);
  transform: translateY(-1px);
  box-shadow: 
    0 6px 24px rgba(37, 99, 235, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

.primary svg {
  vertical-align: middle;
  margin-right: 4px;
}

.doc-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.doc-list li {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background-color 0.2s ease;
}

.doc-list li.editing {
  cursor: default;
}

.doc-list li:hover {
  background: #f3f4f6;
}

.doc-list li .doc-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.doc-list li .doc-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-list li .doc-title-input {
  display: none;
  width: 100%;
  min-width: 0;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.9);
  outline: none;
}

.doc-list li.editing .doc-title {
  display: none;
}

.doc-list li.editing .doc-title-input {
  display: block;
}

.doc-list li .doc-edit-btn,
.doc-list li .doc-delete-btn {
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.doc-list li .doc-edit-btn {
  color: #64748b;
}

.doc-list li .doc-delete-btn {
  color: #ef4444;
}

.doc-list li:hover .doc-edit-btn,
.doc-list li:hover .doc-delete-btn,
.doc-list li.editing .doc-edit-btn,
.doc-list li.editing .doc-delete-btn {
  opacity: 1;
}

.doc-list li .doc-edit-btn:hover {
  background: #e2e8f0;
}

.doc-list li .doc-delete-btn:hover {
  background: #fee2e2;
  transform: scale(1.1);
}

.doc-list li .doc-delete-btn:active {
  transform: scale(0.95);
}

.doc-list li.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.doc-area {
  display: flex;
  flex-direction: column;
  gap: -8px;
  min-width: 0;
}

.ai-assistant-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--header-height, 100px) + 24px);
  align-self: start;
  height: calc(100vh - var(--header-height, 100px) - 48px);
  max-height: calc(100vh - var(--header-height, 100px) - 48px);
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(248,250,252,0.92));
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.1);
  overflow: hidden;
  min-height: 0;
}

.ai-assistant-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ai-assistant-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-assistant-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.ai-assistant-header h3 {
  margin: 0;
  font-size: 24px;
  color: #0f172a;
}

.ai-assistant-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
}

.ai-assistant-window-btn {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.ai-assistant-window-btn.active {
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
  border-color: transparent;
}

.ai-assistant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-assistant-chip {
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ai-assistant-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding-right: 4px;
}

.ai-chat-message {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
}

.ai-chat-message.assistant {
  background: rgba(219, 234, 254, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.16);
}

.ai-chat-message.user {
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
}

.ai-chat-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
}

.ai-chat-body {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.ai-suggestion-list {
  display: grid;
  gap: 10px;
}

.ai-suggestion-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(148,163,184,0.2);
}

.ai-suggestion-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.ai-suggestion-meta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.ai-suggestion-change {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.ai-suggestion-change em {
  color: #475569;
  font-style: normal;
}

.ai-suggestion-change span {
  color: #b91c1c;
  text-decoration: line-through;
}

.ai-suggestion-change strong {
  color: #047857;
}

.ai-suggestion-reason {
  margin-top: 6px;
  font-size: 13px;
  color: #475569;
}

.ai-suggestion-apply,
.ai-suggestion-bulk,
.ai-suggestion-preview {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 12px;
}

.ai-suggestion-preview {
  background: rgba(255,255,255,0.92);
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.ai-suggestion-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ai-assistant-form {
  display: grid;
  gap: 10px;
}

.ai-assistant-input {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  font-size: 14px;
  color: #0f172a;
}

.ai-assistant-form-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.ai-inline-suggestion {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(239, 246, 255, 0.98);
  border: 1px solid rgba(59, 130, 246, 0.28);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

.ai-inline-suggestion-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2563eb;
}

.ai-inline-suggestion-before,
.ai-inline-suggestion-after {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

.ai-inline-suggestion-before {
  color: #b91c1c;
  text-decoration: line-through;
}

.ai-inline-suggestion-after {
  color: #047857;
  margin-top: 6px;
}

.ai-inline-suggestion-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ai-inline-suggestion-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ai-inline-suggestion-btn.accept {
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #fff;
}

.ai-inline-suggestion-btn.reject {
  background: rgba(255,255,255,0.92);
  color: #334155;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.ai-assistant-panel.is-fullscreen {
  position: fixed;
  inset: 24px;
  top: max(24px, calc(var(--header-height, 100px) + 8px));
  height: auto;
  max-height: none;
  width: auto;
  z-index: 10020;
}

.doc-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: calc(var(--header-height, 100px) + 24px);
  background: transparent;
  z-index: 5;
  padding: 0;
  margin-bottom: 2px;
  transition: top 0.3s ease;
}

#doc-title {
  font-size: 15px;
  font-weight: 600;
}

.doc-status {
  font-size: 12px;
  color: #6b7280;
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.ribbon-panel[data-panel="style"],
.ribbon-panel[data-panel="review"] {
  gap: 8px;
}

.ribbon-panel[data-panel="style"] .ribbon-group,
.ribbon-panel[data-panel="review"] .ribbon-group {
  min-width: 148px;
  max-width: 240px;
  padding: 1px 8px 1px 0;
  gap: 4px;
}

.ribbon-panel[data-panel="style"] .ribbon-row,
.ribbon-panel[data-panel="review"] .ribbon-row {
  gap: 4px;
}

.ribbon-panel[data-panel="style"] .ribbon-btn,
.ribbon-panel[data-panel="style"] .ribbon-icon-btn,
.ribbon-panel[data-panel="review"] .ribbon-btn,
.ribbon-panel[data-panel="review"] .ribbon-icon-btn {
  height: 28px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 7px;
}

.ribbon-panel[data-panel="style"] .ribbon-icon-btn,
.ribbon-panel[data-panel="review"] .ribbon-icon-btn {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  padding: 4px;
}

.ribbon-panel[data-panel="style"] .ribbon-group-title,
.ribbon-panel[data-panel="review"] .ribbon-group-title {
  font-size: 7px;
  margin-bottom: 1px;
}

.ribbon-panel[data-panel="style"] .font-picker-btn,
.ribbon-panel[data-panel="style"] .theme-btn,
.ribbon-panel[data-panel="review"] .ribbon-btn {
  min-height: 28px;
}

.live-status {
  color: #059669;
  font-weight: 500;
}

.live-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #059669;
  margin-right: 4px;
  animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Live presence overlay - remote selections and cursors */
.live-presence-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: visible;
}

.live-presence-overlay .presence-selection,
.live-presence-overlay .presence-cursor,
.live-presence-overlay .presence-label {
  position: fixed;
  z-index: 9999;
}

.live-presence-overlay .presence-selection {
  border-radius: 2px;
  opacity: 0.35;
  mix-blend-mode: multiply;
}

body.theme-dark .live-presence-overlay .presence-selection {
  opacity: 0.4;
  mix-blend-mode: screen;
}

.live-presence-overlay .presence-cursor {
  position: absolute;
  width: 2px;
  height: 1.2em;
  border-radius: 1px;
  opacity: 0.9;
}

.live-presence-overlay .presence-label {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  transform: translateY(-100%);
  margin-bottom: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost {
  border: 1px solid #d1d5db;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  color: #1f2937;
}

.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Minimalist Auto-structure Button with Liquid Animation */
.auto-structure-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 140px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 
    0 8px 32px rgba(99, 102, 241, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.1),
    0 1px 4px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  transform: translateY(0) translateZ(0);
  letter-spacing: 0.2px;
  isolation: isolate;
}

/* When in ribbon, adjust sizing */
.ribbon-group .auto-structure-button {
  min-width: 0;
  padding: 4px 10px;
  font-size: 11px;
  height: 24px;
  width: max-content;
}

/* Liquid wave animation layer */
.auto-structure-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300%;
  height: 300%;
  background: radial-gradient(
    circle,
    rgba(99, 102, 241, 0.15) 0%,
    rgba(139, 92, 246, 0.12) 25%,
    rgba(59, 130, 246, 0.1) 50%,
    transparent 70%
  );
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: liquidFlow 8s ease-in-out infinite;
  z-index: 0;
}

/* Secondary liquid layer for depth */
.auto-structure-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250%;
  height: 250%;
  background: radial-gradient(
    circle,
    rgba(168, 85, 247, 0.12) 0%,
    rgba(99, 102, 241, 0.08) 30%,
    transparent 65%
  );
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: liquidFlow 6s ease-in-out infinite reverse;
  z-index: 0;
  opacity: 0.7;
}

@keyframes liquidFlow {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(-45%, -55%) rotate(120deg) scale(1.1);
  }
  66% {
    transform: translate(-55%, -45%) rotate(240deg) scale(0.95);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg) scale(1);
  }
}

.auto-structure-button:hover {
  transform: translateY(-2px) translateZ(0);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 
    0 12px 40px rgba(99, 102, 241, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.ribbon-group .auto-structure-button:hover {
  transform: translateY(-1px) translateZ(0);
}

.auto-structure-button:active {
  transform: translateY(-1px) translateZ(0);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.1),
    0 1px 4px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.auto-structure-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: translateY(0) translateZ(0);
  animation: none;
}

.auto-structure-button:disabled::before,
.auto-structure-button:disabled::after {
  animation: none;
  opacity: 0.3;
}

.button-icon {
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.button-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.ribbon-group .button-icon {
  font-size: 12px;
}

.ribbon-group .button-icon svg {
  width: 14px;
  height: 14px;
}

.button-text {
  position: relative;
  z-index: 1;
  color: #1f2937;
  font-weight: 500;
}

.button-shine {
  display: none;
}


@keyframes processingGlow {
  0%, 100% {
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.12),
      0 2px 8px rgba(0, 0, 0, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -1px 0 rgba(0, 0, 0, 0.05),
      0 0 0 1px rgba(99, 102, 241, 0.15);
  }
  50% {
    box-shadow: 
      0 8px 32px rgba(99, 102, 241, 0.2),
      0 2px 8px rgba(139, 92, 246, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -1px 0 rgba(0, 0, 0, 0.05),
      0 0 0 1px rgba(99, 102, 241, 0.25);
  }
}

/* Auto-style button - same size and effects as auto-structure but with orange/gold colors */
.auto-style-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 140px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.1),
    0 1px 4px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  transform: translateY(0) translateZ(0);
  letter-spacing: 0.2px;
  isolation: isolate;
}

/* When in ribbon, adjust sizing */
.ribbon-group .auto-style-button {
  min-width: 0;
  padding: 4px 10px;
  font-size: 11px;
  height: 24px;
  width: max-content;
}

/* Liquid wave animation layer - orange/gold colors */
.auto-style-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300%;
  height: 300%;
  background: radial-gradient(
    circle,
    rgba(255, 152, 0, 0.15) 0%,
    rgba(255, 193, 7, 0.12) 25%,
    rgba(255, 87, 34, 0.1) 50%,
    transparent 70%
  );
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: liquidFlowOrange 8s ease-in-out infinite;
  z-index: 0;
}

/* Secondary liquid layer for depth - orange/gold */
.auto-style-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250%;
  height: 250%;
  background: radial-gradient(
    circle,
    rgba(255, 193, 7, 0.12) 0%,
    rgba(255, 152, 0, 0.08) 30%,
    rgba(255, 87, 34, 0.06) 60%,
    transparent 80%
  );
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: liquidFlowOrange 6s ease-in-out infinite reverse;
  z-index: 0;
  opacity: 0.7;
}

@keyframes liquidFlowOrange {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(-45%, -55%) rotate(120deg) scale(1.1);
  }
  66% {
    transform: translate(-55%, -45%) rotate(240deg) scale(0.95);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg) scale(1);
  }
}

.auto-style-button:hover {
  transform: translateY(-2px) translateZ(0);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 
    0 12px 40px rgba(251, 146, 60, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.ribbon-group .auto-style-button:hover {
  transform: translateY(-1px) translateZ(0);
}

.auto-style-button:active {
  transform: translateY(-1px) translateZ(0);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.1),
    0 1px 4px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.auto-style-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: translateY(0) translateZ(0);
  animation: none;
}

.auto-style-button:disabled::before,
.auto-style-button:disabled::after {
  animation: none;
  opacity: 0.3;
}

.auto-style-button.processing {
  animation: processingGlowOrange 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes processingGlowOrange {
  0%, 100% {
    box-shadow: 
      0 8px 32px rgba(255, 152, 0, 0.15),
      0 2px 8px rgba(255, 87, 34, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -1px 0 rgba(0, 0, 0, 0.05),
      0 0 0 1px rgba(255, 193, 7, 0.15);
  }
  50% {
    box-shadow: 
      0 8px 32px rgba(255, 193, 7, 0.2),
      0 2px 8px rgba(255, 152, 0, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -1px 0 rgba(0, 0, 0, 0.05),
      0 0 0 1px rgba(255, 87, 34, 0.25);
  }
}

#ai-status {
  min-width: 100px;
}

.page-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px 24px 24px 24px;
  overflow-y: auto;
  overflow-x: auto;
  flex: 1;
  background: #f3f4f6;
  min-height: 0;
  overflow: visible;
  position: relative; /* anchor grammar rail overlay to the scrolling container */
}

.pages {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 16px 0;
  position: relative;
  overflow: visible;
}

/* Single page: seamless selection & navigation, A4 boundary indicators */
.page {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 48px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  position: relative;
  margin: 0 auto 24px auto;
  width: 794px;
  min-height: 1123px;
  height: auto;
  max-height: none;
  transition: width 0.3s ease, min-height 0.3s ease, padding 0.3s ease;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

/* A4 boundary indicator: dashed line every 1123px */
.page::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 1117px,
    #cbd5e1 1117px,
    #cbd5e1 1119px,
    transparent 1119px,
    transparent 1121px,
    #cbd5e1 1121px,
    #cbd5e1 1123px
  );
  pointer-events: none;
  z-index: 0;
}

.page.adjustable-width {
  width: auto;
  max-width: 100%;
}

.page.adjustable-height {
  min-height: auto;
  height: auto;
  max-height: none;
}

.page.adjustable-height .page-editor {
  overflow-y: visible;
  max-height: none;
}

.page.adjustable-both {
  width: auto;
  min-height: auto;
  height: auto;
  max-width: 100%;
}

.editor {
  outline: none;
  min-height: 60vh;
  line-height: 1.6;
  font-size: 16px;
}

.page-editor {
  position: relative;
  min-height: 0;
  overflow: visible;
  flex: 1;
  contain: style;
  z-index: 1;
}

/* Structure transition animations - Optimized for performance */
.page-editor.structure-transitioning {
  position: relative;
  will-change: opacity;
}

/* Show "BEFORE" label - simplified */
.page-editor.structure-show-before::after {
  content: 'BEFORE';
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  z-index: 10;
  will-change: transform;
}

/* Old content morphs out - using opacity only (GPU accelerated) */
.page-editor.structure-old-content {
  animation: textMorphOut 1s ease-out forwards;
  will-change: opacity;
}

@keyframes textMorphOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* New structured content morphs in - using opacity only */
.page-editor.structure-new-content {
  animation: textMorphIn 1s ease-in forwards;
  will-change: opacity;
}

@keyframes textMorphIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Show "AFTER" label - simplified */
.page-editor.structure-new-content::after {
  content: 'AFTER';
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.95) 0%, rgba(22, 163, 74, 0.95) 100%);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
  z-index: 10;
  opacity: 0;
  animation: fadeInLabel 0.4s ease-out 0.5s forwards;
  will-change: opacity, transform;
}

@keyframes fadeInLabel {
  0% {
    opacity: 0;
    transform: translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Subtle page glow - single shadow for performance */
.page.structure-transitioning {
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.2);
  will-change: box-shadow;
}

.page.adjustable-height .editor,
.page.adjustable-both .editor {
  min-height: auto;
}

/* Color Theme Variables */
:root {
  /* Default Theme */
  --theme-title-color: #111827;
  --theme-subtitle-color: #1f2937;
  --theme-heading-color: #374151;
  --theme-text-color: #111827;
  
  /* Ocean Theme */
  --theme-ocean-title: #0c4a6e;
  --theme-ocean-subtitle: #075985;
  --theme-ocean-heading: #0369a1;
  --theme-ocean-text: #0f172a;
  
  /* Forest Theme */
  --theme-forest-title: #14532d;
  --theme-forest-subtitle: #166534;
  --theme-forest-heading: #15803d;
  --theme-forest-text: #1c1917;
  
  /* Sunset Theme */
  --theme-sunset-title: #7c2d12;
  --theme-sunset-subtitle: #9a3412;
  --theme-sunset-heading: #c2410c;
  --theme-sunset-text: #1c1917;
  
  /* Purple Theme */
  --theme-purple-title: #581c87;
  --theme-purple-subtitle: #6b21a8;
  --theme-purple-heading: #7c3aed;
  --theme-purple-text: #1e1b4b;
  
  /* Monochrome Theme */
  --theme-monochrome-title: #000000;
  --theme-monochrome-subtitle: #1a1a1a;
  --theme-monochrome-heading: #333333;
  --theme-monochrome-text: #111827;
  
  /* Warm Theme */
  --theme-warm-title: #92400e;
  --theme-warm-subtitle: #b45309;
  --theme-warm-heading: #d97706;
  --theme-warm-text: #451a03;
  
  /* Cool Theme */
  --theme-cool-title: #1e3a8a;
  --theme-cool-subtitle: #1e40af;
  --theme-cool-heading: #2563eb;
  --theme-cool-text: #1e293b;
}

.editor h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--theme-title-color, #111827);
  transition: color 0.3s ease;
}

.editor h2 {
  font-size: 22px;
  line-height: 1.25;
  margin: 18px 0 8px;
  color: var(--theme-subtitle-color, #1f2937);
  transition: color 0.3s ease;
}

.editor h3 {
  font-size: 18px;
  line-height: 1.3;
  margin: 14px 0 6px;
  color: var(--theme-heading-color, #374151);
  transition: color 0.3s ease;
}

.editor p {
  margin: 8px 0;
  color: var(--theme-text-color, #111827);
  transition: color 0.3s ease;
}

/* Color themes: only affect title/subtitle/heading (h1, h2, h3); body text follows dark/light mode */
body.theme-ocean .editor h1 {
  color: var(--theme-ocean-title);
}
body.theme-ocean .editor h2 {
  color: var(--theme-ocean-subtitle);
}
body.theme-ocean .editor h3 {
  color: var(--theme-ocean-heading);
}

body.theme-forest .editor h1 {
  color: var(--theme-forest-title);
}
body.theme-forest .editor h2 {
  color: var(--theme-forest-subtitle);
}
body.theme-forest .editor h3 {
  color: var(--theme-forest-heading);
}

body.theme-sunset .editor h1 {
  color: var(--theme-sunset-title);
}
body.theme-sunset .editor h2 {
  color: var(--theme-sunset-subtitle);
}
body.theme-sunset .editor h3 {
  color: var(--theme-sunset-heading);
}

body.theme-purple .editor h1 {
  color: var(--theme-purple-title);
}
body.theme-purple .editor h2 {
  color: var(--theme-purple-subtitle);
}
body.theme-purple .editor h3 {
  color: var(--theme-purple-heading);
}

body.theme-monochrome .editor h1 {
  color: var(--theme-monochrome-title);
}
body.theme-monochrome .editor h2 {
  color: var(--theme-monochrome-subtitle);
}
body.theme-monochrome .editor h3 {
  color: var(--theme-monochrome-heading);
}

body.theme-warm .editor h1 {
  color: var(--theme-warm-title);
}
body.theme-warm .editor h2 {
  color: var(--theme-warm-subtitle);
}
body.theme-warm .editor h3 {
  color: var(--theme-warm-heading);
}

body.theme-cool .editor h1 {
  color: var(--theme-cool-title);
}
body.theme-cool .editor h2 {
  color: var(--theme-cool-subtitle);
}
body.theme-cool .editor h3 {
  color: var(--theme-cool-heading);
}

/* Dark mode: lighter heading colors for each color theme (visible on dark background) */
body.theme-dark.theme-ocean .editor h1 { color: #7dd3fc; }
body.theme-dark.theme-ocean .editor h2 { color: #38bdf8; }
body.theme-dark.theme-ocean .editor h3 { color: #0ea5e9; }

body.theme-dark.theme-forest .editor h1 { color: #86efac; }
body.theme-dark.theme-forest .editor h2 { color: #4ade80; }
body.theme-dark.theme-forest .editor h3 { color: #22c55e; }

body.theme-dark.theme-sunset .editor h1 { color: #fdba74; }
body.theme-dark.theme-sunset .editor h2 { color: #fb923c; }
body.theme-dark.theme-sunset .editor h3 { color: #f97316; }

body.theme-dark.theme-purple .editor h1 { color: #c4b5fd; }
body.theme-dark.theme-purple .editor h2 { color: #a78bfa; }
body.theme-dark.theme-purple .editor h3 { color: #8b5cf6; }

body.theme-dark.theme-monochrome .editor h1 { color: #f9fafb; }
body.theme-dark.theme-monochrome .editor h2 { color: #e5e7eb; }
body.theme-dark.theme-monochrome .editor h3 { color: #d1d5db; }

body.theme-dark.theme-warm .editor h1 { color: #fde68a; }
body.theme-dark.theme-warm .editor h2 { color: #fcd34d; }
body.theme-dark.theme-warm .editor h3 { color: #fbbf24; }

body.theme-dark.theme-cool .editor h1 { color: #93c5fd; }
body.theme-dark.theme-cool .editor h2 { color: #60a5fa; }
body.theme-dark.theme-cool .editor h3 { color: #3b82f6; }

.editor ul,
.editor ol {
  margin: 8px 0 8px 22px;
}

.editor li {
  margin: 4px 0;
}

#suggestion-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5000;
}

/* ========== Grammar bubble rail (positioned next to text blocks) ========== */
.grammar-bubble-rail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Keep behind the sticky navbar/ribbon (header is z-index: 10) */
  z-index: 6;
  pointer-events: none; /* bubbles enable pointer events individually */
}

/* Collapsible header - fixed position in right side */
.grammar-rail-header {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%) translateX(20px);
  z-index: 100;
  pointer-events: auto;
  opacity: 0;
  animation: grammarHeaderAppear 400ms ease forwards;
}

.grammar-rail-header.expanded {
  transform: translateY(-50%) translateX(0);
}

@keyframes grammarHeaderAppear {
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

.grammar-rail-header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #4f46e5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 
    0 2px 12px rgba(99, 102, 241, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

.grammar-rail-header-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(168, 85, 247, 0.3) 100%);
  box-shadow: 
    0 4px 16px rgba(99, 102, 241, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.grammar-rail-header.expanded .grammar-rail-header-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(168, 85, 247, 0.35) 100%);
}

.grammar-rail-chevron {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

/* Action buttons row (Accept All / Reject All) */
.grammar-rail-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.grammar-action-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.grammar-accept-all {
  background: rgba(34, 197, 94, 0.2);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.grammar-accept-all:hover {
  background: rgba(34, 197, 94, 0.35);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.grammar-reject-all {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.grammar-reject-all:hover {
  background: rgba(239, 68, 68, 0.3);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Each rail item - positioned absolutely next to its text block */
.grammar-rail-item {
  position: absolute;
  display: flex;
  align-items: center;
  pointer-events: auto;
  z-index: 7;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 200ms ease, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.grammar-rail-item.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Accepted animation - green flash and slide out */
.grammar-rail-item.accepted {
  animation: grammarAccepted 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes grammarAccepted {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
    background: transparent;
  }
  30% {
    opacity: 1;
    transform: translateX(-5px) scale(1.1);
    background: rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
  }
  100% {
    opacity: 0;
    transform: translateX(50px) scale(0.8);
    background: rgba(34, 197, 94, 0.1);
  }
}

/* Rejected animation - red flash and fade out */
.grammar-rail-item.rejected {
  animation: grammarRejected 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes grammarRejected {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  20% {
    opacity: 1;
    transform: translateX(3px) scale(0.95);
    background: rgba(239, 68, 68, 0.15);
  }
  100% {
    opacity: 0;
    transform: translateX(-30px) scale(0.7);
  }
}

/* Dismissed animation - subtle fade for stale/outdated suggestions */
.grammar-rail-item.dismissed {
  animation: grammarDismissed 300ms ease-out forwards;
  pointer-events: none;
}

@keyframes grammarDismissed {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(20px) scale(0.9);
  }
}

/* New suggestion appearing animation */
.grammar-rail-item.appearing {
  animation: grammarAppear 300ms ease-out forwards;
}

@keyframes grammarAppear {
  0% {
    opacity: 0;
    transform: translateX(15px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}


/* Grammar suggestion bubble - styled as a nice pill */
.grammar-rail-item > button.grammar-rail-bubble {
  appearance: none;
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.10) 50%, rgba(99, 102, 241, 0.12) 100%);
  background-size: 200% 200%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: #4f46e5;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.2, 0.9, 0.2, 1), border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: 
    0 2px 8px rgba(99, 102, 241, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  animation: grammarGradientShift 3s ease-in-out infinite;
}

@keyframes grammarGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.grammar-rail-item:hover > button.grammar-rail-bubble {
  transform: translateY(-2px) scale(1.05);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 
    0 4px 12px rgba(99, 102, 241, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  animation-duration: 1.5s;
}

.grammar-rail-item > button.grammar-rail-bubble:active {
  transform: translateY(0) scale(1);
}

/* Green preview text that appears below the target text when suggestion is clicked */
.grammar-preview-text {
  color: #16a34a;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  /* Position and appearance handled by JS */
  -webkit-user-select: none !important;
  user-select: none !important;
  pointer-events: none !important;
  /* Simple fade in without transform to prevent glitching */
  animation: grammarPreviewSimpleFade 200ms ease-out forwards;
}

@keyframes grammarPreviewSimpleFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes grammarPreviewFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  60% {
    opacity: 1;
    transform: translateY(2px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Accept/Reject action buttons container */
.grammar-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  animation: grammarPreviewFadeIn 200ms ease-out 100ms forwards;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
}

/* Accept/Reject buttons - background-less, just symbols */
.grammar-accept-btn,
.grammar-reject-btn {
  appearance: none;
  border: none !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 160ms ease;
  user-select: none !important;
  -webkit-user-select: none !important;
  pointer-events: auto !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.grammar-accept-btn:hover,
.grammar-reject-btn:hover {
  transform: scale(1.15);
  opacity: 0.8;
}

.grammar-accept-btn {
  color: #16a34a;
}

.grammar-reject-btn {
  color: #dc2626;
}

/* Remove all liquid glass styling from accept/reject buttons */
.grammar-accept-btn *,
.grammar-reject-btn * {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.grammar-accept-btn .glass-button-text,
.grammar-reject-btn .glass-button-text {
  color: inherit !important;
  font-weight: 700 !important;
}

/* Popover is completely removed - suggestions are handled one at a time via click */
.grammar-rail-popover,
.grammar-rail-popover * {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
}

.grammar-rail-popover-inner {
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(22px) saturate(190%) contrast(120%);
  -webkit-backdrop-filter: blur(22px) saturate(190%) contrast(120%);
  transform-origin: left center;
  animation: grammarPopoverIn 180ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
  overflow: hidden;
}

@keyframes grammarPopoverIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.grammar-rail-popover-inner::before {
  content: "";
  position: absolute;
  inset: -50% -40%;
  background:
    radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.20), transparent 55%),
    radial-gradient(circle at 80% 60%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(circle at 60% 10%, rgba(255, 255, 255, 0.22), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='240' viewBox='0 0 520 240'%3E%3Cpath d='M-20 160 C 30 70, 80 240, 130 150 S 230 55, 280 150 S 380 240, 430 150 S 530 70, 580 150' fill='none' stroke='rgba(255,255,255,0.38)' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='M-30 110 C 20 30, 70 180, 120 100 S 220 25, 270 100 S 370 180, 420 100 S 520 30, 570 100' fill='none' stroke='rgba(99,102,241,0.18)' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: auto, auto, auto, 170% 150%;
  background-position: 0 0, 0 0, 0 0, 55% 55%;
  filter: blur(10px);
  opacity: 0.75;
  transform: translateZ(0);
  pointer-events: none;
  animation: grammarLiquidDrift2 7s ease-in-out infinite;
}

/* Stronger reflection layer inside popover */
.grammar-rail-popover-inner::after {
  content: "";
  position: absolute;
  inset: -60% -80%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.48) 18%,
    rgba(255, 255, 255, 0.08) 34%,
    transparent 56%
  );
  opacity: 0.50;
  transform: translateX(-30%) rotate(8deg);
  pointer-events: none;
  mix-blend-mode: screen;
  animation: grammarGlassSweep 7.2s ease-in-out infinite;
}

@keyframes grammarLiquidDrift2 {
  0% { transform: translate(-2%, -1%) rotate(0deg); }
  50% { transform: translate(2%, 1%) rotate(6deg); }
  100% { transform: translate(-2%, -1%) rotate(0deg); }
}

.grammar-rail-popover-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(17, 24, 39, 0.86);
  margin-bottom: 8px;
}

.grammar-rail-popover-line {
  font-size: 13px;
  line-height: 1.45;
  color: rgba(17, 24, 39, 0.92);
}

.grammar-rail-popover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.grammar-rail-popover-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.22);
  color: rgba(17, 24, 39, 0.92);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.grammar-rail-popover-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.30);
  border-color: rgba(255, 255, 255, 0.52);
}

.grammar-rail-popover-btn.dismiss {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.10);
}

@media (max-width: 1040px) {
  .grammar-bubble-rail {
    display: none;
  }
}

.suggestion-target {
  position: relative;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.08);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.22);
  transition: box-shadow 180ms ease, background 180ms ease;
  animation: targetPulse 1.4s ease-in-out infinite;
}

@keyframes targetPulse {
  0% {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.10);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
  }
}

.suggestion-bubble {
  position: absolute;
  pointer-events: auto;
  width: min(420px, calc(100% - 24px));
  background: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  padding: 12px 12px 10px;
  transform-origin: top left;
  animation: bubbleIn 180ms ease-out;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.suggestion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.suggestion-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #047857;
}

.suggestion-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer;
}

.icon-button.accept {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.10);
}

.icon-button.reject {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.suggestion-body {
  display: grid;
  gap: 8px;
}

.suggestion-line {
  font-size: 13px;
  line-height: 1.45;
  color: #111827;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  width: fit-content;
}

.suggestion-preview {
  margin: 8px 0 0 0;
  padding-left: 20px;
  font-size: 13px;
  color: #6b7280;
  list-style-type: disc;
}

.suggestion-preview li {
  margin: 4px 0;
}

.suggestion-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.suggestion-bulk-button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.suggestion-bulk-button.apply-all {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
  color: #16a34a;
}

.suggestion-bulk-button.apply-all:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.6);
}

.suggestion-bulk-button.reject-all {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
}

.suggestion-bulk-button.reject-all:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.6);
}

/* Green highlight for text being changed */
.suggestion-highlight {
  color: #16a34a !important;
  text-decoration: underline;
  text-decoration-color: rgba(34, 197, 94, 0.4);
  text-underline-offset: 2px;
}

/* Text preview section */
.suggestion-text-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.suggestion-preview-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 6px;
}

.suggestion-preview-text,
.suggestion-preview-full {
  font-size: 13px;
  line-height: 1.5;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.06);
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid rgba(34, 197, 94, 0.3);
  word-break: break-word;
  white-space: pre-wrap;
}

.suggestion-preview-collapsed {
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-show-more {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: #16a34a;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.suggestion-show-more:hover {
  background: rgba(34, 197, 94, 0.08);
}

.suggestion-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
  display: inline-block;
}

/* Structure Alternatives Overlay */
/* Auto-style overlay */
.auto-style-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.auto-style-overlay.active {
  display: flex;
  opacity: 1;
  animation: fadeInOverlay 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auto-style-container {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  max-width: 500px;
  width: 90vw;
  padding: 32px;
  position: relative;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
}

.auto-style-overlay.active .auto-style-container {
  transform: scale(1) translateY(0);
  opacity: 1;
  animation: slideUpContainer 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auto-style-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.auto-style-title {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.auto-style-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.auto-style-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.auto-style-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auto-style-description {
  color: #6b7280;
  font-size: 14px;
  margin: 0;
  text-align: center;
}

.auto-style-slider-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-intensity-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #e5e7eb 0%, #3b82f6 50%, #8b5cf6 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.style-intensity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.style-intensity-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.style-intensity-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.style-intensity-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.auto-style-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
}

.auto-style-label {
  font-weight: 500;
}

#style-intensity-value {
  font-size: 16px;
  font-weight: 700;
  color: #3b82f6;
}

.auto-style-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.auto-style-apply-btn,
.auto-style-cancel-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.auto-style-apply-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.auto-style-apply-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.auto-style-cancel-btn {
  background: #f3f4f6;
  color: #6b7280;
}

.auto-style-cancel-btn:hover {
  background: #e5e7eb;
  color: #111827;
}

.auto-style-cancel-btn:active {
  transform: scale(0.98);
}

/* Table Insert Overlay */
.table-insert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-insert-overlay.active {
  display: flex;
  opacity: 1;
  animation: fadeInOverlay 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.table-insert-container {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  max-width: 700px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
}

.table-insert-overlay.active .table-insert-container {
  transform: scale(1) translateY(0);
  opacity: 1;
  animation: slideUpContainer 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.table-insert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.table-insert-title {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.table-insert-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.table-insert-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.table-insert-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.table-insert-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.table-insert-visual-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 20px;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.table-grid-selector {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 3px;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  padding: 8px;
  background: #ffffff;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.table-grid-cell {
  aspect-ratio: 1;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.table-grid-cell:hover {
  background: #e0e7ff;
  border-color: #3b82f6;
  transform: scale(1.05);
  z-index: 1;
}

.table-grid-cell.hover {
  background: #dbeafe;
  border-color: #3b82f6;
}

.table-grid-cell.selected {
  background: #3b82f6;
  border-color: #2563eb;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.table-grid-cell.selected.hover {
  background: #2563eb;
}

.table-grid-info {
  font-size: 16px;
  font-weight: 600;
  color: #3b82f6;
  text-align: center;
  padding: 8px 16px;
  background: #eff6ff;
  border-radius: 8px;
  min-width: 80px;
}

.table-insert-label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin: 0;
}

.table-insert-size-controls,
.table-insert-style-controls,
.table-insert-color-controls,
.table-insert-width-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.table-insert-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-insert-input-group label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.table-insert-input {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  width: 100px;
  transition: all 0.2s;
}

.table-insert-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.table-insert-color {
  width: 60px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
}

.table-insert-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #3b82f6;
}

.table-insert-select {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  min-width: 200px;
  cursor: pointer;
  transition: all 0.2s;
}

.table-insert-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.table-insert-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.table-preview-container {
  overflow-x: auto;
  max-width: 100%;
}

.table-insert-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

.table-insert-apply-btn,
.table-insert-cancel-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.table-insert-apply-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.table-insert-apply-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.table-insert-apply-btn:active {
  transform: translateY(0);
}

.table-insert-cancel-btn {
  background: #f3f4f6;
  color: #374151;
}

.table-insert-cancel-btn:hover {
  background: #e5e7eb;
}

.table-insert-cancel-btn:active {
  transform: scale(0.98);
}

/* Table Styling */
.webdoc-table {
  margin: 16px 0;
  border-collapse: collapse;
  width: 100%;
}

.webdoc-table td,
.webdoc-table th {
  min-width: 50px;
  vertical-align: top;
  text-align: left;
}

.webdoc-table th {
  font-weight: 600;
  background-color: #f3f4f6;
}

.webdoc-table td:focus,
.webdoc-table th:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background-color: #eff6ff;
}

/* Excel-like table features */
.excel-table {
  position: relative;
  transition: all 0.3s ease;
}

.excel-table.excel-mode-active {
  border: 3px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.02) 0%, rgba(147, 197, 253, 0.05) 100%);
}

.excel-mode-indicator {
  display: inline-block;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  animation: excelModeIndicatorPulse 2s ease-in-out infinite;
}

@keyframes excelModeActivate {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(59, 130, 246, 0);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.6), 0 0 60px rgba(59, 130, 246, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2);
  }
}

@keyframes excelModeIndicatorPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

.excel-cell {
  position: relative;
}

.excel-table.excel-mode-active .excel-cell:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background-color: #eff6ff;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3), 0 0 8px rgba(59, 130, 246, 0.2);
}

.excel-table.excel-mode-active .excel-cell:hover {
  background-color: #f8fafc;
  cursor: cell;
}

.excel-formula-cell {
  background-color: #fef3c7 !important;
  border-left: 3px solid #f59e0b !important;
  position: relative;
}

.excel-formula-cell::before {
  content: "=";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: #f59e0b;
  font-weight: bold;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.excel-formula-cell:focus {
  background-color: #fef3c7 !important;
  border-left: 3px solid #f59e0b !important;
  outline: 2px solid #f59e0b !important;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.3), 0 0 8px rgba(245, 158, 11, 0.2) !important;
}

/* Excel Formula Bar */
.excel-formula-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  padding: 12px 20px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 10000;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  border-top: 2px solid #2563eb;
}

.excel-formula-bar.active {
  display: flex;
  animation: excelFormulaBarSlideUp 0.3s ease-out;
}

@keyframes excelFormulaBarSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.excel-formula-bar-label {
  color: white;
  font-weight: 600;
  font-size: 14px;
  min-width: 70px;
}

.excel-formula-input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  color: #1e293b;
  outline: none;
  transition: all 0.2s;
}

.excel-formula-input:focus {
  border-color: white;
  background: white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.excel-formula-input::placeholder {
  color: #94a3b8;
}

.excel-formula-cell-ref {
  color: white;
  font-weight: 600;
  font-size: 14px;
  min-width: 60px;
  text-align: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.excel-dropdown-cell {
  padding: 0 !important;
}

.excel-dropdown {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  font: inherit;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.excel-dropdown:focus {
  background-color: #eff6ff;
}

.excel-conditional-format {
  font-weight: 500;
}

/* Excel cell hover button */
.excel-cell-menu-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  background: #3b82f6;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0.8;
  transition: opacity 0.2s, transform 0.2s;
  padding: 0;
  line-height: 1;
}

.excel-cell-menu-btn:hover {
  opacity: 1;
  transform: scale(1.1);
  background: #2563eb;
}

/* Excel cell menu */
.excel-cell-menu {
  position: fixed;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  z-index: 10000;
  min-width: 200px;
  display: none;
}

.excel-cell-menu.active {
  display: block;
}

.excel-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background-color 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.excel-menu-item:hover {
  background-color: #f3f4f6;
}

.excel-menu-item.disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.excel-menu-separator {
  border-top: 1px solid #e5e7eb;
  margin: 4px 0;
}

/* Spreadsheet Styles */
.spreadsheet-container {
  margin: 16px 0;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  overflow: auto;
  max-width: 100%;
  background: white;
}

.spreadsheet-table {
  border-collapse: collapse;
  min-width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

.spreadsheet-table th,
.spreadsheet-table td {
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  text-align: left;
  min-width: 80px;
  height: 28px;
}

.spreadsheet-corner {
  width: 40px;
  min-width: 40px;
  background: #f3f4f6;
}

.spreadsheet-col-header {
  background: #f3f4f6;
  font-weight: 600;
  text-align: center !important;
  color: #374151;
}

.spreadsheet-row-header {
  background: #f3f4f6;
  font-weight: 600;
  text-align: center !important;
  color: #374151;
  width: 40px;
  min-width: 40px;
}

.spreadsheet-cell {
  background: white;
  outline: none;
}

.spreadsheet-cell:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background-color: #eff6ff;
}

.spreadsheet-cell.selected {
  background-color: #dbeafe;
  outline: 1px solid #93c5fd;
}

.spreadsheet-cell.selected:focus {
  background-color: #eff6ff;
}

.spreadsheet-cell.referenced {
  background-color: #fef3c7;
  outline: 2px dashed #f59e0b;
  outline-offset: -2px;
}

/* Spreadsheet Toolbar */
.spreadsheet-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.spreadsheet-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: white;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
}

.spreadsheet-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.spreadsheet-btn:active {
  background: #e5e7eb;
}

.spreadsheet-btn-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.spreadsheet-btn-danger:hover {
  background: #fef2f2;
  border-color: #f87171;
}

.spreadsheet-separator {
  width: 1px;
  height: 20px;
  background: #d1d5db;
  margin: 0 4px;
}

.spreadsheet-color-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: white;
  transition: all 0.15s ease;
}

.spreadsheet-color-picker:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.spreadsheet-color-picker input[type="color"] {
  width: 20px;
  height: 20px;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 3px;
}

.spreadsheet-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.spreadsheet-color-picker input[type="color"]::-webkit-color-swatch {
  border: 1px solid #d1d5db;
  border-radius: 3px;
}

.color-icon {
  font-size: 12px;
  font-weight: 600;
}

.color-icon.bg-icon {
  font-size: 10px;
}

.color-icon.text-icon {
  color: #374151;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 3px;
  text-underline-offset: 2px;
}

/* Equation Panel Styles */
.equation-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  width: 90%;
  max-width: 700px;
  animation: equationSlideUp 0.2s ease;
}

@keyframes equationSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.equation-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}

.equation-panel-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.equation-panel-close:hover {
  color: #111827;
  background: #f3f4f6;
}

.equation-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.equation-panel-tabs::-webkit-scrollbar {
  display: none;
}

.equation-tab {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.equation-tab:hover {
  background: #f3f4f6;
  color: #374151;
}

.equation-tab.active {
  background: #3b82f6;
  color: white;
}

.equation-symbols-container {
  padding: 12px;
  max-height: 250px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.equation-symbols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
}

.eq-sym {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  font-size: 18px;
  font-family: "Cambria Math", "Times New Roman", serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.eq-sym:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: scale(1.1);
}

.eq-sym:active {
  transform: scale(0.95);
  background: #dbeafe;
}

/* Mobile styles for equation panel */
@media (max-width: 768px) {
  body.ai-assistant-open .app-body {
    grid-template-columns: 1fr;
  }

  body.ai-assistant-dock .app-body,
  body.ai-assistant-split .app-body,
  body.ai-assistant-full .app-body {
    grid-template-columns: 1fr;
  }

  .ai-assistant-panel {
    position: fixed;
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 12px;
    height: auto;
    max-height: 70vh;
    z-index: 10001;
    min-height: 0;
  }

  .equation-panel {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    transform: none;
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
  }
  
  @keyframes equationSlideUp {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .equation-panel-header {
    padding: 16px 20px;
    font-size: 16px;
  }
  
  .equation-panel-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
  }
  
  .equation-panel-close {
    font-size: 28px;
    padding: 10px;
  }
  
  .equation-panel-tabs {
    padding: 10px 16px;
    gap: 6px;
  }
  
  .equation-tab {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .equation-symbols-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: none;
  }
  
  .equation-symbols {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
  }
  
  .eq-sym {
    width: 44px;
    height: 44px;
    font-size: 20px;
    border-radius: 10px;
  }
  
  .eq-sym:hover {
    transform: none;
  }
  
  .eq-sym:active {
    transform: scale(0.92);
  }
}

/* Equation Box in Document */
.equation-box {
  display: inline-block;
  min-width: 80px;
  padding: 10px 16px;
  margin: 4px 2px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: linear-gradient(to bottom, #fafbfc, #f5f6f8);
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  font-size: 18px;
  font-style: italic;
  letter-spacing: 0.02em;
  cursor: text;
  outline: none;
  min-height: 24px;
  vertical-align: middle;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.equation-box:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.equation-box:empty::before {
  content: "Type equation...";
  color: #9ca3af;
  font-style: italic;
  font-size: 0.9em;
}

/* Numbers and operators in equations should be upright */
.equation-box .eq-number,
.equation-box .eq-operator {
  font-style: normal;
}

/* Mobile styles for equation box */
@media (max-width: 768px) {
  .equation-box {
    min-width: 60px;
    padding: 12px 14px;
    font-size: 17px;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
  }
  
  .equation-box:focus {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
  }
  
  .equation-box:empty::before {
    content: "Tap to type...";
    font-size: 0.85em;
  }
}

/* Insert Modal Styles */
.insert-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insert-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.insert-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 440px;
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.insert-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.insert-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.insert-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.insert-modal-close:hover {
  color: #111827;
}

.insert-modal-body {
  padding: 20px;
}

.insert-modal-field {
  margin-bottom: 16px;
}

.insert-modal-field:last-child {
  margin-bottom: 0;
}

.insert-modal-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.insert-modal-field input[type="url"],
.insert-modal-field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.15s;
  box-sizing: border-box;
}

.insert-modal-field input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.insert-modal-field input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  cursor: pointer;
}

/* Share modal */
.share-modal-content {
  max-width: 480px;
}

.share-modal-description {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.share-modal-mode-row {
  margin-bottom: 16px;
}

.share-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.share-mode-toggle input[type="checkbox"] {
  margin: 3px 0 0 0;
  flex-shrink: 0;
}

.share-mode-label {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.share-mode-hint {
  font-size: 12px;
  color: #6b7280;
  width: 100%;
  margin-left: 24px;
}

.share-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.share-link-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.share-actions .insert-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.share-modal-note {
  font-size: 13px;
  margin: 0;
  min-height: 20px;
}

/* Auth modal */
.auth-modal-content {
  max-width: 400px;
}

.auth-config-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.auth-config-hint {
  font-size: 13px;
  color: #6b7280;
  margin: 0 0 16px;
  line-height: 1.5;
}

.auth-config-hint a {
  color: #2563eb;
  text-decoration: underline;
}

.auth-config-optional {
  font-weight: normal;
  color: #9ca3af;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s;
}

.auth-tab:hover {
  background: #f3f4f6;
  color: #111827;
}

.auth-tab.active {
  background: #111827;
  color: white;
  border-color: #111827;
}

.auth-form .insert-modal-field {
  margin-bottom: 16px;
}

.auth-form .insert-modal-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

.auth-form .insert-modal-btn {
  margin-top: 8px;
  width: 100%;
}

.auth-modal-note {
  font-size: 13px;
  margin: 16px 0 0;
  min-height: 20px;
}

.auth-signed-in {
  margin-top: 16px;
}

.auth-user-info {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 12px;
}

body.theme-dark .account-btn {
  color: #9ca3af;
}

body.theme-dark .account-btn:hover {
  color: #f9fafb;
}

body.theme-dark .membership-btn {
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.95), rgba(180, 83, 9, 0.92));
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

body.theme-dark .membership-usage-banner {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.94));
  border-color: rgba(71, 85, 105, 0.75);
  box-shadow: none;
}

body.theme-dark .membership-usage-title-row h3,
body.theme-dark .membership-upgrade-btn {
  color: #f8fafc;
}

body.theme-dark .membership-usage-summary,
body.theme-dark .membership-usage-meta,
body.theme-dark .membership-quota-text {
  color: #cbd5e1;
}

body.theme-dark .membership-badge {
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

body.theme-dark .membership-summary-card,
body.theme-dark .membership-settings-card,
body.theme-dark .plan,
body.theme-dark .pricing-compare-row {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(71, 85, 105, 0.7);
  box-shadow: none;
}

body.theme-dark .pricing-compare-head {
  background: rgba(30, 64, 175, 0.22);
  color: #bfdbfe;
}

body.theme-dark .membership-summary-card h4,
body.theme-dark .membership-settings-card h4,
body.theme-dark .plan h3,
body.theme-dark .plan-price {
  color: #f8fafc;
}

body.theme-dark .membership-summary-text,
body.theme-dark .membership-feature-list li,
body.theme-dark .plan-description,
body.theme-dark .pricing-subtitle,
body.theme-dark .pricing-compare-row,
body.theme-dark .membership-meter-label {
  color: #cbd5e1;
}

body.theme-dark .membership-payment-text,
body.theme-dark .billing-note,
body.theme-dark .payment-method-main p,
body.theme-dark .payment-method-empty p,
body.theme-dark .payment-default-toggle,
body.theme-dark .payment-field {
  color: #cbd5e1;
}

body.theme-dark .billing-panel,
body.theme-dark .payment-method-item,
body.theme-dark .payment-form-card,
body.theme-dark .payment-method-empty {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(71, 85, 105, 0.7);
}

body.theme-dark #pricing-modal .settings-modal-header {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.94));
  border-bottom-color: rgba(71, 85, 105, 0.7);
}

body.theme-dark .billing-panel-header h3,
body.theme-dark .payment-form-top h4,
body.theme-dark .payment-method-empty h4,
body.theme-dark .payment-method-main h4 {
  color: #f8fafc;
}

body.theme-dark .payment-type-switch {
  background: #334155;
}

body.theme-dark .payment-type-btn.active {
  background: #eff6ff;
  color: #0f172a;
}

body.theme-dark .payment-field input,
body.theme-dark .payment-method-btn {
  background: #0f172a;
  color: #e2e8f0;
  border-color: rgba(71, 85, 105, 0.8);
}

body.theme-dark .auth-tab {
  background: #374151;
  border-color: #4b5563;
  color: #9ca3af;
}

body.theme-dark .auth-tab:hover {
  background: #4b5563;
  color: #f9fafb;
}

body.theme-dark .auth-tab.active {
  background: #60a5fa;
  color: #111827;
  border-color: #60a5fa;
}

.insert-modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.insert-modal-tab {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}

.insert-modal-tab:hover {
  background: #f3f4f6;
}

.insert-modal-tab.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.image-preview {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  max-height: 200px;
}

.image-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.insert-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 0 0 12px 12px;
}

.insert-modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.insert-modal-btn.cancel {
  background: white;
  border: 1px solid #d1d5db;
  color: #374151;
}

.insert-modal-btn.cancel:hover {
  background: #f3f4f6;
}

.insert-modal-btn.primary {
  background: #3b82f6;
  border: 1px solid #3b82f6;
  color: white;
}

.insert-modal-btn.primary:hover {
  background: #2563eb;
}

/* Clickable links in editor */
.page-editor a {
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
}

.page-editor a:hover {
  color: #2563eb;
}

/* Formula autocomplete */
#formula-autocomplete {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#formula-autocomplete .autocomplete-item:hover,
#formula-autocomplete .autocomplete-item.selected {
  background-color: #eff6ff !important;
}

/* Grammar suggestion bubble buttons */
.grammar-suggestion-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.grammar-suggestion-btn {
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #111827;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.grammar-suggestion-btn:hover {
  background: rgba(239, 246, 255, 0.75);
  border-color: rgba(59, 130, 246, 0.45);
}

.grammar-suggestion-highlight {
  box-shadow: inset 0 -2px 0 rgba(34, 197, 94, 0.35);
}

/* Grammar context menu (right-click) */
.grammar-context-menu {
  position: fixed;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  z-index: 10001;
  min-width: 180px;
  max-width: 280px;
}

.grammar-context-menu-header {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.grammar-context-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  border: none;
  background: none;
  font-size: 14px;
  color: #111827;
  cursor: pointer;
  transition: background-color 0.15s;
}

.grammar-context-menu-item:hover {
  background-color: #f3f4f6;
}

.grammar-context-menu-sep {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

body.theme-dark .grammar-context-menu {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.theme-dark .grammar-context-menu-header {
  color: #9ca3af;
  border-bottom-color: #374151;
}

body.theme-dark .grammar-context-menu-item {
  color: #f9fafb;
}

body.theme-dark .grammar-context-menu-item:hover {
  background-color: #374151;
}

body.theme-dark .grammar-context-menu-sep {
  background: #374151;
}

.excel-menu-separator {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

.structure-alternatives-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.structure-alternatives-overlay.active {
  display: flex;
  opacity: 1;
  animation: fadeInOverlay 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

.structure-alternatives-container {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  max-width: 90vw;
  max-height: 90vh;
  width: 1200px;
  padding: 32px;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  position: relative;
}

.structure-alternatives-overlay.active .structure-alternatives-container {
  transform: scale(1) translateY(0);
  animation: slideUpContainer 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpContainer {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.structure-alternatives-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}

.structure-alternatives-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  letter-spacing: -0.02em;
}

.structure-alternatives-close {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.structure-alternatives-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  transform: rotate(90deg) scale(1.1);
}

.structure-alternatives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  max-height: calc(90vh - 140px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.structure-alternatives-grid::-webkit-scrollbar {
  width: 8px;
}

.structure-alternatives-grid::-webkit-scrollbar-track {
  background: transparent;
}

.structure-alternatives-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.structure-alternatives-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.structure-alternative-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  border: 2px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  animation: cardSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.structure-alternative-card:nth-child(1) {
  animation-delay: 0.1s;
}

.structure-alternative-card:nth-child(2) {
  animation-delay: 0.2s;
}

.structure-alternative-card:nth-child(3) {
  animation-delay: 0.3s;
}

.structure-alternative-card:nth-child(4) {
  animation-delay: 0.4s;
}

.structure-alternative-card:nth-child(5) {
  animation-delay: 0.5s;
}

.structure-alternative-card:nth-child(6) {
  animation-delay: 0.6s;
}

@keyframes cardSlideIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.structure-alternative-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.structure-alternative-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    0 12px 40px rgba(102, 126, 234, 0.25),
    0 0 0 1px rgba(102, 126, 234, 0.1);
  border-color: rgba(102, 126, 234, 0.3);
}

.structure-alternative-card:hover::before {
  transform: scaleX(1);
}

.structure-alternative-card.selected {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.3),
    inset 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.structure-alternative-card.selected::before {
  transform: scaleX(1);
  height: 6px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.structure-alternative-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.structure-alternative-name {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0;
  letter-spacing: -0.01em;
}

.structure-alternative-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #667eea;
}

.structure-alternative-preview {
  background: #f9fafb;
  border-radius: 12px;
  padding: 16px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
}

.structure-alternative-preview h1 {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.structure-alternative-preview h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 12px 0 8px 0;
}

.structure-alternative-preview h3 {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin: 10px 0 6px 0;
}

.structure-alternative-preview p {
  margin: 8px 0;
  color: #4b5563;
}

.structure-alternative-preview ul,
.structure-alternative-preview ol {
  margin: 8px 0;
  padding-left: 20px;
}

.structure-alternative-preview li {
  margin: 4px 0;
  color: #4b5563;
}

.structure-alternative-stats {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 12px;
  color: #6b7280;
}

.structure-alternative-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.structure-alternative-stat-icon {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.structure-alternative-apply {
  margin-top: 16px;
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.structure-alternative-apply::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.structure-alternative-apply:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.structure-alternative-apply:hover::before {
  left: 100%;
}

.structure-alternative-apply:active {
  transform: translateY(0);
}

/* Selection Bubble Container - Liquid Glass */
/* Selection Bubble Group Container */
.selection-bubble-group {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: none; /* No initial transform to prevent teleporting */
  transition: opacity 0.15s ease-out; /* Faster, simpler transition */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.selection-bubble-group.show {
  opacity: 1;
  transform: none; /* No transform animation - appears in fixed position */
  pointer-events: auto;
}

/* Parent "Auto" bubble - fixed size to prevent expansion */
#auto-parent-bubble {
  position: relative;
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  height: fit-content;
  flex-shrink: 0;
}

/* Child bubbles container - hidden by default, shown on hover */
#auto-child-bubbles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out,
              transform 0.15s ease-out;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  margin-top: 8px;
  z-index: 1001;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-width: 100%;
  will-change: opacity, transform; /* Optimize for performance */
}

/* Bridge element removed - using single hitbox in JavaScript instead */

/* Show child bubbles on hover - JavaScript handles this, CSS is fallback only */
.selection-bubble-group:hover #auto-child-bubbles {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

/* Also show when directly hovering the child container or its bridge */
#auto-child-bubbles:hover {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
  pointer-events: auto !important;
}

/* Individual child bubble */
.auto-child-bubble {
  position: relative;
  pointer-events: auto;
  white-space: nowrap;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Custom styling for liquid glass buttons */
.selection-bubble-group .glass-button {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  /* Prevent expansion on hover - fixed size */
  width: fit-content;
  height: fit-content;
  flex-shrink: 0;
  max-width: 100%;
  overflow: hidden;
}

.selection-bubble-group .glass-button-text {
  color: #111827;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Child bubbles slightly smaller */
.auto-child-bubble .glass-button {
  font-size: 13px;
}

/* Custom styling for liquid glass button */
#selection-bubble-container .glass-button {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

#selection-bubble-container .glass-button-text {
  color: #111827;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Enhanced glass effect visual improvements */
#selection-bubble-container .glass-container {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

/* Selection-only structuring transition (lightweight, does not affect rest of doc) */
.selection-structuring-wrapper {
  display: inline;
  border-radius: 10px;
  padding: 0 2px;
  background: rgba(99, 102, 241, 0.10);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.20);
  transition: opacity 220ms ease, transform 220ms ease, box-shadow 220ms ease;
  will-change: opacity, transform;
}

.selection-structuring-wrapper.is-morphing-out {
  opacity: 0;
  transform: translateY(-2px) scale(0.985);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.20);
}

.selection-structured-in {
  animation: selectionStructuredIn 520ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes selectionStructuredIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Selection highlight */
::selection {
  background: rgba(102, 126, 234, 0.2);
  color: inherit;
}

::-moz-selection {
  background: rgba(102, 126, 234, 0.2);
  color: inherit;
}

@media (max-width: 960px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .doc-sidebar {
    order: 2;
  }

  .page {
    padding: 32px;
  }

  .structure-alternatives-container {
    width: 95vw;
    padding: 24px;
  }

  .structure-alternatives-grid {
    grid-template-columns: 1fr;
  }
  
  .liquid-glass-bubble {
    padding: 10px 16px;
  }
  
  .bubble-button {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* ========================================
   NEW WORD-LIKE FEATURES
   ======================================== */

/* Highlight Dropdown */
.highlight-dropdown-container {
  display: inline-flex;
  position: relative;
}

.highlight-btn {
  border-radius: 4px 0 0 4px !important;
  padding-right: 4px !important;
}

.highlight-btn .highlight-indicator {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  height: 3px;
  border-radius: 1px;
}

.highlight-dropdown-toggle {
  width: 16px;
  height: 28px;
  padding: 0;
  border: none;
  background: var(--surface);
  border-radius: 0 4px 4px 0;
  font-size: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
}

.highlight-dropdown-toggle:hover {
  background: var(--surface-hover);
}

.highlight-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 1000;
}

.highlight-option {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.highlight-option:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.highlight-option[data-color="transparent"] {
  background: linear-gradient(135deg, #fff 45%, #ccc 45%, #ccc 55%, #fff 55%);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

/* Format Painter active state */
#format-painter-btn.active {
  background: var(--primary);
  color: white;
}

/* Symbol Modal */
.symbol-modal-content {
  max-width: 600px;
  width: 95vw;
}

.symbol-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.symbol-category {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.symbol-category:hover {
  background: var(--surface-hover);
}

.symbol-category.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.symbol-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.symbol-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.1);
}

.symbol-search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

/* Word Count Modal */
.wordcount-modal-content {
  max-width: 400px;
}

.wordcount-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wordcount-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
}

.wordcount-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.wordcount-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Find/Replace Modal */
.findreplace-modal-content {
  max-width: 480px;
}

.findreplace-options {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.findreplace-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.findreplace-option input {
  accent-color: var(--primary);
}

.findreplace-count {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.findreplace-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.findreplace-nav,
.findreplace-actions {
  display: flex;
  gap: 8px;
}

/* Highlight for find results */
.find-highlight {
  background: #fff59d !important;
  border-radius: 2px;
}

.find-highlight-current {
  background: #ff9800 !important;
  color: white !important;
}

/* Columns Modal */
.columns-options {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.columns-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.columns-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.columns-preview {
  width: 80px;
  height: 60px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 4px;
}

.columns-preview div {
  flex: 1;
  background: var(--primary);
  opacity: 0.3;
  border-radius: 2px;
}

.columns-option span {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Dropdown Menu */
.dropdown-menu {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 4px;
  z-index: 1001;
  min-width: 180px;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* (Comments Panel - see consolidated styles below) */

/* ========== HISTORY PANEL ========== */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-primary, #ffffff);
  border-left: 1px solid var(--border-color, #e5e7eb);
  box-shadow: -8px 0 30px rgba(0,0,0,0.1);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  animation: historySlideIn 0.25s ease-out;
}

@keyframes historySlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.history-panel-closing {
  animation: historySlideOut 0.2s ease-in forwards;
}

@keyframes historySlideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  flex-shrink: 0;
}

.history-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

.history-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-count {
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
  background: var(--bg-tertiary, #f3f4f6);
  padding: 3px 8px;
  border-radius: 10px;
}

.history-reload-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s, transform 0.3s;
}

.history-reload-btn:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
  transform: rotate(45deg);
}

.history-panel-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.history-panel-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.history-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.history-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-tertiary, #9ca3af);
  font-size: 13px;
}

.history-date-group {
  padding: 0 12px;
}

.history-date-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary, #9ca3af);
  padding: 14px 8px 6px;
  position: sticky;
  top: 0;
  background: var(--bg-primary, #ffffff);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-date-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-tertiary, #e5e7eb);
  color: var(--text-secondary, #6b7280);
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0;
  text-transform: none;
}

/* Collapsible hour / 10-min groups */
.history-hour-group {
  margin: 0 0 2px;
}

.history-tenmin-group {
  margin-left: 8px;
}

.history-collapse-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text-secondary, #6b7280);
  transition: background 0.12s;
}

.history-collapse-btn:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.history-collapse-btn-sm {
  padding: 5px 8px;
}

.history-chevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.history-collapse-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #4b5563);
}

.history-collapse-btn-sm .history-collapse-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary, #6b7280);
}

.history-collapse-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-tertiary, #9ca3af);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}

.history-collapse-body {
  padding-left: 6px;
}

/* Session grouping (Google Docs style) */
.history-session {
  margin: 2px 0;
  border-radius: 8px;
  overflow: hidden;
}

.history-session-current {
  background: rgba(59, 130, 246, 0.04);
}

.history-session-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
}

.history-session-header:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.history-session-current .history-session-header {
  border-left: 3px solid var(--accent-primary, #3b82f6);
  padding-left: 9px;
}

.history-session-expand {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-top: 4px;
  color: var(--text-tertiary, #9ca3af);
}

.history-session-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-tertiary, #9ca3af);
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

.history-session-body {
  padding-left: 20px;
  border-left: 2px solid var(--border-color, #e5e7eb);
  margin-left: 24px;
  margin-bottom: 4px;
}

.history-session-body .history-entry {
  padding: 6px 10px;
}

.history-session-body .history-entry-icon {
  width: 22px;
  height: 22px;
}

.history-session-body .history-entry-icon svg {
  width: 11px;
  height: 11px;
}

.history-session-body .history-entry-desc {
  font-size: 12px;
}

.history-session-body .history-entry-meta {
  font-size: 10px;
}

.history-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
  position: relative;
}

.history-entry:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.history-entry-current {
  background: rgba(59, 130, 246, 0.06);
  border-left: 3px solid var(--accent-primary, #3b82f6);
  padding-left: 9px;
}

.history-entry-current:hover {
  background: rgba(59, 130, 246, 0.1);
}

.history-entry-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-secondary, #6b7280);
  margin-top: 1px;
}

.history-entry-current .history-entry-icon {
  background: var(--accent-primary, #3b82f6);
  color: #ffffff;
}

.history-entry-content {
  flex: 1;
  min-width: 0;
}

.history-entry-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1f2937);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.history-current-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
  background: var(--accent-primary, #3b82f6);
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.5;
}

.history-entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
}

.history-entry-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.history-entry-words::before {
  content: "\00b7";
  margin-right: 2px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 500px) {
  .history-panel {
    width: 100vw;
  }
}

/* Drop Cap */
.drop-cap {
  float: left;
  font-size: 4em;
  line-height: 0.8;
  padding-right: 8px;
  padding-top: 4px;
  font-weight: bold;
  color: var(--primary);
}

/* Block Quote */
.block-quote {
  margin: 16px 0;
  padding: 16px 24px;
  border-left: 4px solid var(--primary);
  background: var(--surface);
  font-style: italic;
  color: var(--text-secondary);
}

/* Page Break */
.page-break {
  page-break-after: always;
  break-after: page;
  display: block;
  height: 0;
  margin: 32px 0;
  border: none;
  border-top: 2px dashed var(--border);
  position: relative;
}

/* Invisible spacing when text passes A4 indicator */
.page-break-spacer {
  display: block;
  height: 0;
  margin: 32px 0;
  border: none;
  pointer-events: none;
  user-select: none;
}

li.page-break-spacer {
  list-style: none;
  margin: 32px 0;
}

.page-break::after {
  content: "Page Break";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 2px 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Horizontal Rule */
.hr-styled {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 24px 0;
}

/* Multi-column layout */
.columns-wrapper {
  display: flex;
  gap: 24px;
  margin: 16px 0;
}

.column-section {
  flex: 1;
  min-width: 0;
}

/* Page Header/Footer */
.page-header,
.page-footer {
  padding: 16px 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  margin-bottom: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.page-header {
  border-bottom-style: dashed;
}

.page-footer {
  margin-top: 16px;
  margin-bottom: 0;
}

/* Paragraph with borders */
.bordered-paragraph {
  border: 1px solid var(--text-primary);
  padding: 12px;
  margin: 12px 0;
}

.bordered-paragraph.border-top {
  border-width: 1px 0 0 0;
  padding-top: 12px;
}

.bordered-paragraph.border-bottom {
  border-width: 0 0 1px 0;
  padding-bottom: 12px;
}

.bordered-paragraph.border-left {
  border-width: 0 0 0 4px;
  padding-left: 12px;
  border-color: var(--primary);
}

.bordered-paragraph.border-right {
  border-width: 0 4px 0 0;
  padding-right: 12px;
  border-color: var(--primary);
}

.bordered-paragraph.border-box {
  border-width: 2px;
  border-radius: 8px;
}

.bordered-paragraph.border-shadow {
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 16px;
}

/* Watermark */
.watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 72px;
  color: rgba(0, 0, 0, 0.05);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}

/* --- New Word-like Feature Styles --- */

/* Page Break */
.page-break {
  display: block;
  width: 100%;
  height: 24px;
  margin: 24px 0;
  border-top: 2px dashed var(--border);
  position: relative;
  page-break-after: always;
}

.page-break-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  padding: 2px 12px;
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 4px;
}

/* Drop Cap */
.drop-cap {
  float: left;
  font-size: 3.5em;
  line-height: 0.85;
  margin-right: 8px;
  margin-top: 4px;
  font-weight: 700;
  color: var(--primary);
}

/* Block Quote */
.block-quote {
  margin: 20px 0;
  padding: 16px 24px;
  border-left: 4px solid var(--primary);
  background: var(--bg-tertiary);
  font-style: italic;
  color: var(--text-secondary);
  border-radius: 0 8px 8px 0;
}

.block-quote p {
  margin: 0;
}

/* Column Layout */
.column-layout {
  column-gap: 24px;
  column-rule: 1px solid var(--border);
  padding: 12px 0;
}

/* Symbol Picker */
.symbol-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  width: 320px;
  max-height: 400px;
  overflow: hidden;
}

.symbol-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.symbol-picker-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
}

.symbol-picker-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.symbol-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.symbol-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.symbol-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Page Header/Footer */
.page-header,
.page-footer {
  padding: 8px 16px;
  min-height: 32px;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

.page-footer {
  border-bottom: none;
  border-top: 1px dashed var(--border);
  margin-top: auto;
}

.page-header p,
.page-footer p {
  margin: 0;
}

/* (Comment Highlight - see consolidated styles below) */

/* Change Case Menu */
.change-case-menu {
  min-width: 160px;
}

.change-case-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
}

.change-case-menu button:hover {
  background: var(--bg-tertiary);
}

/* Highlight Color Menu */
.highlight-color-menu {
  min-width: 140px;
}

.highlight-color-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
}

.highlight-color-menu button:hover {
  background: var(--bg-tertiary);
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Highlight button with indicator */
.highlight-btn-wrapper {
  position: relative;
}

.highlight-indicator {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 3px;
  background: #ffff00;
  border-radius: 2px;
}

/* Generic dropdown menu styling */
.dropdown-menu {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 10000;
  overflow: hidden;
}

/* Format painter active state */
.ribbon-btn.active {
  background: var(--primary);
  color: white;
}

/* Line Spacing Dropdown */
.line-spacing-dropdown {
  min-width: 80px;
}

.line-spacing-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  text-align: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
}

.line-spacing-dropdown button:hover {
  background: var(--bg-tertiary);
}

/* Paragraph Borders Menu */
.paragraph-borders-menu {
  min-width: 140px;
}

.paragraph-borders-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
}

.paragraph-borders-menu button:hover {
  background: var(--bg-tertiary);
}

/* ========== COMMENTS PANEL ========== */
.comments-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-primary, #ffffff);
  border-left: 1px solid var(--border-color, #e5e7eb);
  box-shadow: -8px 0 30px rgba(0,0,0,0.1);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  animation: commentsPanelIn 0.25s ease-out;
}

@keyframes commentsPanelIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.comments-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  flex-shrink: 0;
}

.comments-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
}

.comments-panel-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comments-delete-all-btn {
  background: none;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.comments-delete-all-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

.comments-panel-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.comments-panel-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.comments-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.comment-item {
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.comment-item:hover {
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.comment-quoted-text {
  font-size: 12px;
  font-style: italic;
  color: var(--text-tertiary, #9ca3af);
  margin-bottom: 6px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-note-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1f2937);
  margin-bottom: 6px;
  line-height: 1.4;
}

.comment-time {
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
  margin-bottom: 8px;
}

.comment-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  padding-top: 8px;
}

.comment-edit-btn,
.comment-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  background: var(--bg-primary, #ffffff);
  color: var(--text-secondary, #6b7280);
}

.comment-edit-btn:hover {
  border-color: var(--accent-primary, #3b82f6);
  color: var(--accent-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.05);
}

.comment-delete-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.no-comments {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-tertiary, #9ca3af);
  text-align: center;
}

.no-comments p {
  margin: 0 0 4px;
  font-size: 13px;
}

/* ========== COMMENT MODAL ========== */
.comment-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: commentOverlayIn 0.15s ease-out;
}

@keyframes commentOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.comment-modal-closing {
  animation: commentOverlayOut 0.2s ease-in forwards;
}

@keyframes commentOverlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.comment-modal {
  background: var(--bg-primary, #ffffff);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.1);
  width: 440px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: commentModalIn 0.2s ease-out;
}

@keyframes commentModalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);       opacity: 1; }
}

.comment-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.comment-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
}

.comment-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.comment-modal-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.comment-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.comment-modal-selection {
  margin-bottom: 14px;
}

.comment-modal-selection label,
.comment-modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.comment-modal-quote {
  background: var(--bg-secondary, #f9fafb);
  border-left: 3px solid var(--accent-primary, #3b82f6);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary, #6b7280);
  line-height: 1.5;
}

.comment-modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary, #1f2937);
  background: var(--bg-primary, #ffffff);
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.comment-modal-input:focus {
  outline: none;
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.comment-modal-input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.comment-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.comment-modal-cancel {
  padding: 8px 16px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background: var(--bg-primary, #ffffff);
  color: var(--text-secondary, #6b7280);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.comment-modal-cancel:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.comment-modal-submit {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent-primary, #3b82f6);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.comment-modal-submit:hover {
  background: var(--primary-hover, #2563eb);
}

.comment-modal-danger {
  background: #ef4444 !important;
}

.comment-modal-danger:hover {
  background: #dc2626 !important;
}

/* Responsive */
@media (max-width: 500px) {
  .comments-panel { width: 100vw; }
  .comment-modal { width: 95vw; }
}

/* Page Break */
.page-break {
  display: block;
  width: 100%;
  height: 1px;
  margin: 24px 0;
  border: none;
  border-top: 2px dashed var(--border-color);
  position: relative;
  page-break-after: always;
}

.page-break-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  padding: 2px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Drop Cap */
.drop-cap {
  float: left;
  font-size: 3.5em;
  line-height: 0.8;
  padding-right: 8px;
  padding-top: 4px;
  font-weight: bold;
  color: var(--primary);
}

/* Block Quote */
.block-quote {
  margin: 16px 0;
  padding: 16px 24px;
  border-left: 4px solid var(--primary);
  background: var(--bg-secondary);
  font-style: italic;
  color: var(--text-secondary);
}

.block-quote p {
  margin: 0;
}

/* Column Layout */
.column-layout {
  column-gap: 24px;
  column-rule: 1px solid var(--border-color);
  padding: 16px 0;
}

/* Symbol Picker */
.symbol-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  width: 360px;
  max-width: 90vw;
}

.symbol-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.symbol-picker-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}

.symbol-picker-close:hover {
  color: var(--text-primary);
}

.symbol-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.symbol-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
}

.symbol-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Page Header/Footer */
.page-header,
.page-footer {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 32px;
}

.page-footer {
  border-bottom: none;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.page-header p,
.page-footer p {
  margin: 0;
}

/* ========== SPELLING & GRAMMAR UNDERLINES ========== */
/* Red wavy underline for spelling errors (browser spellcheck) */
.page-editor::spelling-error,
::spelling-error {
  text-decoration: wavy underline;
  text-decoration-color: #dc2626;
  text-underline-offset: 2px;
}

/* Blue wavy underline for grammar errors (custom grammar highlights) */
::highlight(grammar-underline) {
  text-decoration: wavy underline;
  text-decoration-color: #2563eb;
  text-underline-offset: 2px;
}

body.theme-dark .page-editor::spelling-error {
  text-decoration-color: #f87171;
}

body.theme-dark ::highlight(grammar-underline) {
  text-decoration-color: #60a5fa;
}

/* ========== PERSISTENT SELECTION HIGHLIGHT ========== */
/* CSS Highlight API (modern browsers) */
::highlight(editor-selection) {
  background-color: rgba(59, 130, 246, 0.3);
  color: inherit;
}

/* Fallback: absolutely-positioned overlay divs */
.fake-sel-highlight {
  background-color: rgba(59, 130, 246, 0.28);
  border-radius: 2px;
  z-index: 1;
  pointer-events: none;
  animation: fakeSelFadeIn 0.1s ease-out;
}

@keyframes fakeSelFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Dark theme overrides */
body.theme-dark ::highlight(editor-selection) {
  background-color: rgba(96, 165, 250, 0.35);
}

body.theme-dark .fake-sel-highlight {
  background-color: rgba(96, 165, 250, 0.3);
}

/* Comment Highlight */
.comment-highlight {
  background-color: rgba(255, 220, 100, 0.35);
  border-bottom: 2px solid #f59e0b;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s;
}

.comment-highlight:hover {
  background-color: rgba(255, 220, 100, 0.55);
}

.comment-highlight:hover::after {
  content: attr(data-comment);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary, #1f2937);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
}

.comment-highlight:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 0px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary, #1f2937);
  z-index: 1000;
  pointer-events: none;
}

body.theme-dark .comment-highlight {
  background-color: rgba(245, 158, 11, 0.2);
  border-bottom-color: #d97706;
}

body.theme-dark .comment-highlight:hover {
  background-color: rgba(245, 158, 11, 0.35);
}

/* Change Case Menu */
.change-case-menu {
  min-width: 160px;
}

.change-case-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.change-case-menu button:hover {
  background: var(--bg-hover);
}

/* Highlight Color Menu */
.highlight-color-menu {
  min-width: 140px;
}

.highlight-color-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.highlight-color-menu button:hover {
  background: var(--bg-hover);
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Highlight button with indicator */
.highlight-btn-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.highlight-indicator {
  width: 100%;
  height: 3px;
  background-color: #ffff00;
  border-radius: 0 0 2px 2px;
  margin-top: -2px;
}

body.theme-dark .highlight-indicator {
  background-color: #b45309 !important;
}

/* Dropdown menus general */
.dropdown-menu {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  overflow: hidden;
}

/* Format painter active state */
.ribbon-btn.active {
  background: var(--primary) !important;
  color: white !important;
}

/* Subscript and Superscript buttons */
.ribbon-btn[data-command="subscript"] svg,
.ribbon-btn[data-command="superscript"] svg {
  font-size: 12px;
}

/* (duplicate comments panel removed - see unified section above) */

/* Line Spacing Dropdown */
.line-spacing-dropdown {
  min-width: 80px;
}

.line-spacing-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
}

.line-spacing-dropdown button:hover {
  background: var(--bg-hover);
}

/* Paragraph Borders Menu */
.paragraph-borders-menu {
  min-width: 140px;
}

.paragraph-borders-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.paragraph-borders-menu button:hover {
  background: var(--bg-hover);
}

/* Mobile Responsive for New Features */
@media (max-width: 768px) {
  .symbol-picker {
    width: 95vw;
    max-height: 70vh;
  }
  
  .symbol-picker-grid {
    grid-template-columns: repeat(8, 1fr);
  }
  
  .symbol-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  
  .comments-panel {
    width: 100%;
    max-width: 100%;
  }
  
  .page-break-label {
    font-size: 10px;
    padding: 2px 8px;
  }
  
  .drop-cap {
    font-size: 2.5em;
  }
  
  .block-quote {
    padding: 12px 16px;
    margin: 12px 0;
  }
  
  .dropdown-menu {
    max-width: 90vw;
  }
  
  .change-case-menu,
  .highlight-color-menu,
  .line-spacing-dropdown,
  .paragraph-borders-menu {
    min-width: 120px;
  }
}

/* Page Color Picker */
.page-color-picker {
  padding: 12px;
  min-width: 160px;
}

.page-color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.page-color-swatch {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.page-color-swatch:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.page-color-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.page-color-custom input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.page-color-custom label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Page with border */
.page.with-border {
  border: 3px double var(--text-primary);
}

.page.with-border .page-editor {
  padding: 32px;
}

/* Page landscape orientation */
.page.landscape {
  width: 1123px !important;
  min-height: 794px !important;
}

/* Find & Replace Modal */
.find-replace-content {
  max-width: 450px;
}

.find-options {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.find-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.find-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.find-results {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.find-replace-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.find-nav-buttons,
.replace-buttons {
  display: flex;
  gap: 8px;
}

/* Text Box */
.text-box {
  display: inline-block;
  min-width: 150px;
  min-height: 80px;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  background: var(--bg-secondary);
  margin: 8px;
  cursor: text;
}

.text-box:focus {
  outline: none;
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.text-box p {
  margin: 0;
}

/* Word Art */
.word-art {
  display: inline-block;
  font-size: 36px;
  font-weight: 900;
  font-family: "Impact", "Arial Black", sans-serif;
  letter-spacing: 2px;
  padding: 16px;
  margin: 8px;
  cursor: text;
  text-transform: uppercase;
}

.word-art:focus {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
}

/* Word Art Modal */
.wordart-modal-content {
  max-width: 500px;
}

.wordart-styles-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.wordart-style-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.15s ease;
}

.wordart-style-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.wordart-style-btn.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.wordart-preview {
  margin-top: 16px;
}

.wordart-preview label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.wordart-preview-box {
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  font-family: "Impact", "Arial Black", sans-serif;
  text-transform: uppercase;
  letter-spacing: 2px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Font size input container */
.font-size-input-container {
  display: flex;
  align-items: center;
  gap: 2px;
}

.font-size-input {
  width: 60px !important;
  text-align: center;
  padding: 4px 6px !important;
}

.font-size-unit {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Font Size Input */
.font-size-input-container {
  display: flex;
  align-items: center;
  gap: 2px;
}

.font-size-input {
  width: 50px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.font-size-input:focus {
  outline: none;
  border-color: var(--primary);
}

.font-size-unit {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Word Art Modal */
.wordart-modal-content {
  width: 480px;
  max-width: 95vw;
}

.wordart-styles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 0;
}

.wordart-style-btn {
  width: 100%;
  aspect-ratio: 1.2;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 8px;
}

.wordart-style-btn:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
  transform: scale(1.05);
}

.wordart-style-btn.selected {
  border-color: var(--primary);
  border-width: 3px;
  background: rgba(59, 130, 246, 0.1);
}

.wordart-style-btn span {
  pointer-events: none;
}

/* Resizable / draggable media (images and shapes) */
.resizable-media {
  display: inline-block;
  position: relative;
  cursor: move;
  margin: 8px 4px;
  vertical-align: middle;
}

.resizable-media.media-image {
  line-height: 0;
}

.resizable-media.media-image img {
  display: block;
  max-width: 100%;
  height: auto;
}

.resizable-media:hover {
  outline: 2px dashed rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
}

.resizable-media.media-selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.resizable-media .resize-handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.resizable-media .resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary);
  border: 1px solid #fff;
  pointer-events: auto;
  cursor: nwse-resize;
}

.resizable-media .resize-handle-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resizable-media .resize-handle-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resizable-media .resize-handle-e { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.resizable-media .resize-handle-w { left: -5px; top: 50%; transform: translateY(-50%); cursor: w-resize; }
.resizable-media .resize-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resizable-media .resize-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resizable-media .resize-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resizable-media .resize-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

/* Shape Container */
.shape-container {
  display: inline-block;
  margin: 8px;
  cursor: move;
  position: relative;
}

.shape-container:hover {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

.shape-container.media-selected:hover {
  outline: 2px solid var(--primary);
}

.shape-container svg {
  display: block;
}

/* Page Ruler */
.page-ruler {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 8px 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.ruler-mark {
  width: 36px;
  height: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-color);
}

.ruler-mark.major {
  border-left: 2px solid var(--text-secondary);
  font-weight: 600;
}

/* Gridlines */
.show-gridlines .page-editor {
  background-image: 
    linear-gradient(var(--border-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Show formatting marks */
.show-formatting .page-editor p::after {
  content: "¶";
  color: var(--text-tertiary);
  font-size: 12px;
  margin-left: 2px;
}

.show-formatting .page-editor br::after {
  content: "↵";
  color: var(--text-tertiary);
}

/* Focus Mode */
.focus-mode .doc-sidebar,
.focus-mode .ribbon,
.focus-mode .app-header,
.focus-mode .structure-bar-container {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.focus-mode:hover .doc-sidebar,
.focus-mode:hover .ribbon,
.focus-mode:hover .app-header,
.focus-mode:hover .structure-bar-container {
  opacity: 1;
  pointer-events: auto;
}

.focus-mode .pages-container {
  padding-top: 40px;
}

.focus-mode .page {
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Print styles */
@media print {
  .ribbon,
  .doc-sidebar,
  .app-header,
  .comments-panel,
  .dropdown-menu,
  .insert-modal,
  .settings-modal,
  .equation-panel,
  .grammar-suggestion-pill,
  .mobile-sidebar-toggle,
  .sidebar-backdrop,
  .symbol-picker,
  .change-case-menu,
  .highlight-color-menu,
  .page-ruler {
    display: none !important;
  }
  
  .page {
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: none;
  }
  
  .page-editor {
    min-height: auto;
  }
  
  .page-break {
    page-break-after: always;
    border: none;
  }
  
  .page-break-label {
    display: none;
  }
  
  .app-body {
    display: block;
  }
  
  .main-content {
    padding: 0;
  }
  
  .page-header,
  .page-footer {
    position: running(header);
  }
  
  @page {
    margin: 1in;
  }
}

/* Font Size Input */
.font-size-input-container {
  display: flex;
  align-items: center;
  gap: 2px;
}

.font-size-input {
  width: 50px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.font-size-input:focus {
  outline: none;
  border-color: var(--primary);
}

.font-size-unit {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Word Art Modal */
.wordart-modal-content {
  max-width: 500px;
}

.wordart-styles-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.wordart-style-btn {
  width: 50px;
  height: 50px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.wordart-style-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.wordart-style-btn.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.wordart-preview-container {
  margin-top: 16px;
}

.wordart-preview-container label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.wordart-preview {
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  font-family: "Impact", "Arial Black", sans-serif;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== SYNONYM FINDER PANEL ========== */
.synonym-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: synonymPanelIn 0.22s ease-out;
}

@keyframes synonymPanelIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.synonym-panel-closing {
  animation: synonymPanelOut 0.2s ease-in forwards;
}

@keyframes synonymPanelOut {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

.synonym-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.synonym-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

.synonym-panel-title strong {
  color: var(--accent-primary, #3b82f6);
}

.synonym-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.synonym-panel-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.synonym-panel-body {
  padding: 16px 18px;
  overflow-y: auto;
  max-height: 50vh;
}

.synonym-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
  color: var(--text-secondary, #6b7280);
  font-size: 13px;
  gap: 8px;
}

.synonym-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color, #e5e7eb);
  border-top-color: var(--accent-primary, #3b82f6);
  border-radius: 50%;
  animation: synonymSpin 0.6s linear infinite;
}

@keyframes synonymSpin {
  to { transform: rotate(360deg); }
}

.synonym-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.synonym-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--bg-secondary, #f3f4f6);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #374151);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.synonym-pill:hover {
  background: var(--accent-primary, #3b82f6);
  color: #ffffff;
  border-color: var(--accent-primary, #3b82f6);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.synonym-pill:active {
  transform: translateY(0);
}

.synonym-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #9ca3af);
  margin-bottom: 8px;
}

.synonym-more-wrap {
  display: contents;
}

.synonym-show-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 12px;
  background: none;
  border: 1px dashed var(--border-color, #d1d5db);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-primary, #3b82f6);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.synonym-show-more-btn:hover {
  background: var(--bg-secondary, #f3f4f6);
  border-color: var(--accent-primary, #3b82f6);
}

.synonym-show-more-btn.synonym-show-more-expanded {
  color: var(--text-secondary, #6b7280);
}

.synonym-tip {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
  text-align: center;
}

.synonym-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  gap: 8px;
  text-align: center;
}

.synonym-empty p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
}

.synonym-empty-hint {
  font-size: 12px !important;
  color: var(--text-tertiary, #9ca3af) !important;
}

/* Responsive synonym panel */
@media (max-width: 500px) {
  .synonym-panel {
    width: 95vw;
  }
  .synonym-pill {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ========== DICTIONARY LOOKUP PANEL ========== */
.dictionary-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 460px;
  max-width: 90vw;
  max-height: 75vh;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dictPanelIn 0.22s ease-out;
}

@keyframes dictPanelIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.dictionary-panel-closing {
  animation: dictPanelOut 0.2s ease-in forwards;
}

@keyframes dictPanelOut {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

.dictionary-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.dictionary-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

.dictionary-panel-title strong {
  color: var(--accent-primary, #3b82f6);
}

.dictionary-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.dictionary-panel-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.dictionary-panel-body {
  padding: 16px 18px;
  overflow-y: auto;
  max-height: 60vh;
}

.dictionary-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary, #6b7280);
  font-size: 13px;
  padding: 10px 0;
}

.dictionary-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color, #e5e7eb);
  border-top-color: var(--accent-primary, #3b82f6);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.dictionary-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  gap: 8px;
  color: var(--text-secondary, #6b7280);
}

.dictionary-empty p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.dictionary-empty-hint {
  font-size: 12px !important;
  opacity: 0.7;
}

/* Word heading */
.dict-word-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.dict-headword {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
}

.dict-phonetic {
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
  font-style: italic;
}

.dict-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f3f4f6);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--accent-primary, #3b82f6);
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.dict-audio-btn:hover {
  background: var(--accent-primary, #3b82f6);
  color: #fff;
  transform: scale(1.08);
}

.dict-audio-btn:active {
  transform: scale(0.96);
}

/* Part of speech sections */
.dict-pos-section {
  margin-bottom: 16px;
}

.dict-pos-section:last-of-type {
  margin-bottom: 8px;
}

.dict-pos-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary, #3b82f6);
  text-transform: capitalize;
  margin-bottom: 6px;
  font-style: italic;
}

/* Definitions list */
.dict-definitions {
  margin: 0;
  padding-left: 22px;
  list-style: decimal;
}

.dict-def-item {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary, #1f2937);
}

.dict-def-item:last-child {
  margin-bottom: 0;
}

.dict-def-text {
  display: inline;
}

.dict-example {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  font-style: italic;
  padding-left: 4px;
  border-left: 2px solid var(--border-color, #e5e7eb);
  margin-left: 2px;
}

/* Related words (synonyms / antonyms) */
.dict-related {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  margin-top: 6px;
}

.dict-related-label {
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

/* Source link */
.dict-source {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  font-size: 11px;
  color: var(--text-secondary, #9ca3af);
}

.dict-source a {
  color: var(--accent-primary, #3b82f6);
  text-decoration: none;
}

.dict-source a:hover {
  text-decoration: underline;
}

/* Responsive dictionary panel */
@media (max-width: 500px) {
  .dictionary-panel {
    width: 95vw;
  }
  .dict-headword {
    font-size: 18px;
  }
}

/* ========== TEMPLATE GALLERY ========== */
.template-gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tplOverlayIn 0.2s ease-out;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@keyframes tplOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.template-gallery-overlay.template-gallery-closing {
  animation: tplOverlayOut 0.2s ease-in forwards;
}

@keyframes tplOverlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.template-gallery {
  width: 880px;
  max-width: 94vw;
  max-height: 85vh;
  background: var(--bg-primary, #ffffff);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tplGalleryIn 0.25s ease-out;
}

@keyframes tplGalleryIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.template-gallery-header {
  position: relative;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.template-gallery-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
}

.template-gallery-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
}

.template-gallery-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.template-gallery-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.template-gallery-body {
  padding: 20px 28px 28px;
  overflow-y: auto;
  flex: 1;
}

/* --- Template Customize Bar (mode toggle + color swatches) --- */
.tpl-customize-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-primary, #ffffff);
  flex-wrap: wrap;
}
.tpl-customize-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tpl-customize-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
}
.tpl-mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary, #f3f4f6);
  padding: 3px;
  border-radius: 10px;
}
.tpl-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #6b7280);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tpl-mode-btn:hover {
  color: var(--text-primary, #1f2937);
}
.tpl-mode-btn.tpl-mode-active {
  background: var(--bg-primary, #ffffff);
  color: var(--text-primary, #1f2937);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.04);
}
.tpl-theme-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tpl-swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid transparent;
  padding: 2px;
  cursor: pointer;
  background: var(--bg-primary, #ffffff);
  transition: all 0.15s;
  flex-shrink: 0;
}
.tpl-swatch:hover {
  border-color: var(--text-tertiary, #9ca3af);
  transform: scale(1.1);
}
.tpl-swatch.tpl-swatch-active {
  border-color: var(--text-primary, #1f2937);
  box-shadow: 0 0 0 1px var(--text-primary, #1f2937);
  transform: scale(1.1);
}
.tpl-swatch-circle {
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
.tpl-swatch-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  overflow: hidden;
}
.tpl-swatch-palette > div {
  width: 100%;
  height: 100%;
}
/* Preview filter transition */
.tpl-card-preview {
  transition: filter 0.3s ease;
}
/* Dark mode badge on preview cards */
.tpl-mode-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1f2937;
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 2;
}

.tpl-category-section {
  margin-bottom: 24px;
}

.tpl-category-section:last-child {
  margin-bottom: 0;
}

.tpl-category-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 12px;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.tpl-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--bg-primary, #ffffff);
  border: 1.5px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.22s, transform 0.18s;
  padding: 0;
  text-align: left;
}

.tpl-card:hover {
  border-color: var(--tpl-color, #3b82f6);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.10), 0 0 0 1.5px var(--tpl-color, #3b82f6);
  transform: translateY(-3px);
}

.tpl-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tpl-card-preview {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  pointer-events: none;
  user-select: none;
}

.tpl-card-preview > div {
  pointer-events: none;
}

.tpl-card-title {
  padding: 10px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive template gallery */
@media (max-width: 640px) {
  .template-gallery {
    max-width: 98vw;
    max-height: 92vh;
    border-radius: 12px;
  }
  .template-gallery-header {
    padding: 18px 18px 12px;
  }
  .tpl-customize-bar {
    padding: 10px 18px;
    gap: 14px;
  }
  .template-gallery-body {
    padding: 14px 18px 20px;
  }
  .tpl-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
  }
}

@media (max-width: 400px) {
  .tpl-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* ========== TEMPLATE IMAGE PLACEHOLDERS ========== */
.tpl-img-placeholder {
  transition: outline 0.15s, box-shadow 0.15s, background 0.15s;
  outline: 2px dashed transparent;
  user-select: none;
}

.tpl-img-placeholder:hover {
  outline: 2px dashed rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.tpl-img-placeholder:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.tpl-img-placeholder.tpl-img-dragover {
  outline: 2px solid #3b82f6 !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2) !important;
  filter: brightness(1.05);
}

/* ========== IMAGE UPLOAD MODAL ========== */
.img-upload-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10003;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: imgModalOverlayIn 0.18s ease-out;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@keyframes imgModalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.img-upload-modal-overlay.img-upload-modal-closing {
  animation: imgModalOverlayOut 0.18s ease-in forwards;
}

@keyframes imgModalOverlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.img-upload-modal {
  width: 460px;
  max-width: 92vw;
  background: var(--bg-primary, #ffffff);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: imgModalIn 0.22s ease-out;
}

@keyframes imgModalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.img-upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.img-upload-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
}

.img-upload-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.img-upload-modal-close:hover {
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.img-upload-modal-body {
  padding: 20px;
}

/* Dropzone */
.img-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  border: 2px dashed var(--border-color, #d1d5db);
  border-radius: 12px;
  background: var(--bg-secondary, #f9fafb);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  color: var(--text-secondary, #9ca3af);
  text-align: center;
  gap: 4px;
}

.img-upload-dropzone:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #3b82f6;
}

.img-upload-dropzone.img-upload-dropzone-active {
  border-color: #3b82f6;
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.img-upload-dropzone svg {
  margin-bottom: 6px;
  opacity: 0.5;
}

.img-upload-dropzone:hover svg,
.img-upload-dropzone.img-upload-dropzone-active svg {
  opacity: 0.8;
}

.img-upload-dropzone-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #374151);
}

.img-upload-dropzone-hint {
  font-size: 12px;
  margin: 2px 0 0;
  color: var(--text-secondary, #9ca3af);
}

/* Preview area */
.img-upload-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  background: var(--bg-secondary, #f9fafb);
}

.img-upload-preview-area img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.img-upload-remove-btn {
  font-size: 12px;
  padding: 4px 14px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
  background: var(--bg-primary, #fff);
  color: #dc2626;
  cursor: pointer;
  transition: background 0.15s;
}

.img-upload-remove-btn:hover {
  background: #fef2f2;
}

/* Divider */
.img-upload-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-secondary, #9ca3af);
  font-size: 12px;
}

.img-upload-divider::before,
.img-upload-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color, #e5e7eb);
}

/* URL row */
.img-upload-url-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary, #1f2937);
  background: var(--bg-primary, #fff);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.img-upload-url-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.img-upload-url-input::placeholder {
  color: var(--text-secondary, #9ca3af);
}

/* Footer */
.img-upload-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}

.img-upload-btn-cancel {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #374151);
  cursor: pointer;
  transition: background 0.15s;
}

.img-upload-btn-cancel:hover {
  background: var(--bg-tertiary, #f3f4f6);
}

.img-upload-btn-insert {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.img-upload-btn-insert:hover {
  background: #2563eb;
}

@media (max-width: 500px) {
  .img-upload-modal {
    max-width: 96vw;
  }
  .img-upload-dropzone {
    padding: 24px 16px;
  }
}

.pricing-modal-content {
  width: min(96vw, 1800px);
  max-width: none;
  height: min(94vh, 1400px);
  max-height: 94vh;
  overflow: auto;
  padding: 28px 30px 36px;
}

#pricing-modal {
  align-items: stretch;
  justify-content: stretch;
  padding: 3vh 2vw;
}

#pricing-modal .settings-modal-backdrop {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#pricing-modal .settings-modal-content {
  margin: auto;
}

#pricing-modal .settings-modal-header {
  position: sticky;
  top: -28px;
  z-index: 2;
  margin: -28px -30px 0;
  padding: 26px 30px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.92));
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.pricing-subtitle {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 15px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px;
  margin-top: 30px;
}

.plan {
  position: relative;
  min-height: 560px;
  padding: 34px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
  box-shadow: 0 22px 44px rgba(15, 23, 42, 0.08);
  text-align: left;
}

.plan.active {
  border-color: #2563eb;
  box-shadow: 0 24px 56px rgba(37, 99, 235, 0.18);
}

.plan.premium {
  border-width: 2px;
  border-color: rgba(59, 130, 246, 0.45);
  transform: translateY(-10px) scale(1.02);
}

.plan.platinum {
  border-width: 2px;
  border-color: rgba(245, 158, 11, 0.45);
}

.plan.business {
  border-width: 2px;
  border-color: rgba(16, 185, 129, 0.42);
}

.plan-kicker {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.plan-spotlight {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.plan h3 {
  margin: 0;
  font-size: 34px;
  color: #0f172a;
}

.plan-price {
  margin: 14px 0 0;
  font-size: 42px;
  font-weight: 800;
  color: #0f172a;
}

.plan-price span {
  margin-left: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
}

.plan-description {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.7;
  color: #475569;
}

.plan-quota {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.plan-action {
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2);
}

.plan-action:hover {
  transform: translateY(-1px);
}

.plan-action.current {
  background: linear-gradient(135deg, #0f172a, #334155);
}

.pricing-compare {
  margin-top: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  overflow: hidden;
}

.billing-panel {
  margin-top: 32px;
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.92));
}

.billing-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.billing-panel-header h3,
.payment-form-top h4,
.payment-method-empty h4 {
  margin: 0;
  font-size: 24px;
  color: #0f172a;
}

.billing-note,
.payment-method-empty p {
  margin: 8px 0 0;
  font-size: 14px;
  color: #64748b;
}

.payment-method-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.payment-method-empty {
  padding: 22px;
  border: 1px dashed rgba(148,163,184,0.5);
  border-radius: 18px;
  text-align: center;
}

.payment-method-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(148,163,184,0.24);
  border-radius: 18px;
  background: rgba(255,255,255,0.85);
}

.payment-method-item.default {
  border-color: rgba(37,99,235,0.4);
  box-shadow: 0 10px 24px rgba(37,99,235,0.08);
}

.payment-method-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.payment-method-icon,
.payment-method-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.payment-method-main h4 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.payment-method-main p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
}

.payment-method-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.payment-method-btn {
  padding: 9px 12px;
  border: 1px solid rgba(148,163,184,0.35);
  border-radius: 12px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.payment-method-btn.danger {
  color: #b91c1c;
}

.payment-form-card {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid rgba(148,163,184,0.24);
  border-radius: 20px;
  background: rgba(255,255,255,0.88);
}

.payment-form-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.payment-type-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #e2e8f0;
}

.payment-type-btn {
  padding: 9px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.payment-type-btn.active {
  background: #0f172a;
  color: #fff;
}

.payment-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.payment-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.payment-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(148,163,184,0.35);
  border-radius: 14px;
  background: #fff;
}

.payment-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

.payment-default-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
}

.theme-item-locked,
.membership-locked-action {
  opacity: 0.5;
  filter: grayscale(0.15);
}

.theme-item-locked::after {
  content: "Locked";
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: #b91c1c;
}

.pricing-compare-row {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  color: #334155;
  font-size: 13px;
}

.pricing-compare-row:first-child {
  border-top: none;
}

.pricing-compare-head {
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}

@media (max-width: 900px) {
  #pricing-modal {
    padding: 2vh 2vw;
  }

  .pricing-modal-content {
    width: 100%;
    height: 96vh;
    max-height: 96vh;
    padding: 22px 18px 28px;
  }

  #pricing-modal .settings-modal-header {
    top: -22px;
    margin: -22px -18px 0;
    padding: 20px 18px 18px;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .plan.premium {
    transform: none;
  }

  .pricing-compare-row {
    grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
    font-size: 12px;
  }

  .payment-form-grid {
    grid-template-columns: 1fr;
  }

  .payment-form-top,
  .billing-panel-header,
  .payment-form-actions,
  .payment-method-item {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .membership-btn {
    min-width: 74px;
    padding: 6px 10px;
  }

  .membership-usage-banner {
    grid-template-columns: 1fr;
  }

  #pricing-modal {
    padding: 0;
  }

  .pricing-modal-content {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 18px 14px 24px;
  }

  #pricing-modal .settings-modal-header {
    top: -18px;
    margin: -18px -14px 0;
    padding: 18px 14px 16px;
  }

  .pricing-compare {
    overflow-x: auto;
  }

  .pricing-compare-row {
    min-width: 700px;
  }
}
