/**
 * Theme Variables Configuration
 * Uses CSS variables for dynamic theme switching.
 * Default is Light Mode.
 */
:root {
    /* Light Mode (Default) */
    /* Primary Colors */
    --primary-50: #f5f3ff;
    --primary-100: #ede9fe;
    --primary-200: #ddd6fe;
    --primary-300: #c4b5fd;
    --primary-400: #a78bfa;
    --primary-500: #8b5cf6;
    --primary-600: #7c3aed;      /* Main Primary */
    --primary-700: #6d28d9;      /* Primary Dark */
    --primary-800: #5b21b6;
    --primary-900: #4c1d95;
    --primary-950: #2e1065;
    
    /* Legacy aliases for backward compatibility */
    --primary-color: var(--primary-600);
    --primary-light: var(--primary-400);
    --primary-dark: var(--primary-700);
    --primary-rgb: 124 58 237;
    
    /* Functional Colors */
    --success-color: #10b981;
    --success-rgb: 16 185 129;
    --warning-color: #f59e0b;
    --warning-rgb: 245 158 11;
    --danger-color: #dc2626;
    --danger-rgb: 220 38 38;
    
    /* Secondary Colors */
    --secondary-50: #f0f9ff;
    --secondary-100: #e0f2fe;
    --secondary-200: #bae6fd;
    --secondary-300: #7dd3fc;
    --secondary-400: #38bdf8;
    --secondary-500: #0ea5e9;
    --secondary-600: #0284c7;
    --secondary-700: #0369a1;
    --secondary-800: #075985;
    --secondary-900: #0c4a6e;
    
    /* Background Colors */
    --bg-50: #f8fafc;
    --bg-100: #f1f5f9;
    --bg-200: #e2e8f0;
    --bg-300: #cbd5e1;
    --bg-400: #94a3b8;
    --bg-500: #64748b;
    --bg-600: #475569;
    --bg-700: #334155;
    --bg-800: #1e293b;
    --bg-900: #0f172a;
    
    --bg-dark: #f8fafc;            /* Slate 50 - Base background */
    --bg-sidebar: #ffffff;         /* White - Sidebar background */
    --bg-card: #ffffff;            /* White - Card/Modal background */
    --bg-editor: #ffffff;          /* White - Editor area background */
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    
    /* Text Colors */
    --text-50: #f8fafc;
    --text-100: #f1f5f9;
    --text-200: #e2e8f0;
    --text-300: #cbd5e1;
    --text-400: #94a3b8;
    --text-500: #64748b;
    --text-600: #475569;
    --text-700: #334155;
    --text-800: #1e293b;
    --text-900: #0f172a;
    
    --text-primary: #0f172a;       /* Slate 900 - Primary text */
    --text-secondary: #475569;     /* Slate 600 - Secondary text */
    --text-muted: #64748b;         /* Slate 500 - Muted text */
    --text-disabled: #94a3b8;
    
    /* Border Colors */
    --border-50: #f8fafc;
    --border-100: #f1f5f9;
    --border-200: #e2e8f0;
    --border-300: #cbd5e1;
    --border-400: #94a3b8;
    --border-500: #64748b;
    --border-600: #475569;
    
    --border-color: #e2e8f0;       /* Slate 200 - Borders */
    --border-hover: #cbd5e1;
    
    /* Functional Colors */
    --success-50: #f0fdf4;
    --success-100: #dcfce7;
    --success-500: #10b981;      /* Main Success */
    --success-600: #059669;
    --success-color: #10b981;
    
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;      /* Main Warning */
    --warning-600: #d97706;
    --warning-color: #f59e0b;
    
    --danger-50: #fef2f2;
    --danger-100: #fee2e2;
    --danger-500: #ef4444;       /* Main Danger */
    --danger-600: #dc2626;
    --danger-color: #dc2626;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.9); /* Glassmorphism background opacity */
    --glass-border: rgba(255, 255, 255, 0.2);
    
    /* Typography */
    --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-serif: 'Noto Serif SC', 'Georgia', serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    
    --text-xs: 0.75rem;   /* 12px */
    --text-sm: 0.875rem;  /* 14px */
    --text-base: 1rem;    /* 16px */
    --text-lg: 1.125rem;  /* 18px */
    --text-xl: 1.25rem;   /* 20px */
    --text-2xl: 1.5rem;   /* 24px */
    --text-3xl: 1.875rem; /* 30px */
    
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;
    
    /* Spacing */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    
    /* Border Radius */
    --radius-sm: 0.125rem; /* 2px */
    --radius: 0.25rem;     /* 4px */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-2xl: 1rem;     /* 16px */
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Layout Dimensions */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --right-panel-width: 320px;
    --header-height: 60px;
}

/**
 * Dark Mode Overrides
 * Activated when 'dark' class is present on <html> tag.
 * These variables override the :root variables when in dark mode.
 */
html.dark {
    /* Dark Mode Colors - Adjusted for better contrast */
    /* Primary Colors */
    --primary-50: #f5f3ff;
    --primary-100: #ede9fe;
    --primary-200: #ddd6fe;
    --primary-300: #c4b5fd;
    --primary-400: #a78bfa;
    --primary-500: #8b5cf6;
    --primary-600: #7c3aed;      /* Main Primary */
    --primary-700: #6d28d9;      /* Primary Dark */
    --primary-800: #5b21b6;
    --primary-900: #4c1d95;
    --primary-950: #2e1065;
    
    /* Legacy aliases for backward compatibility */
    --primary-color: var(--primary-600);
    --primary-light: var(--primary-400);
    --primary-dark: var(--primary-700);
    --primary-rgb: 124 58 237;
    
    /* Secondary Colors */
    --secondary-50: #f0f9ff;
    --secondary-100: #e0f2fe;
    --secondary-200: #bae6fd;
    --secondary-300: #7dd3fc;
    --secondary-400: #38bdf8;
    --secondary-500: #0ea5e9;
    --secondary-600: #0284c7;
    --secondary-700: #0369a1;
    --secondary-800: #075985;
    --secondary-900: #0c4a6e;
    
    /* Background Colors */
    --bg-50: #f8fafc;
    --bg-100: #f1f5f9;
    --bg-200: #e2e8f0;
    --bg-300: #cbd5e1;
    --bg-400: #94a3b8;
    --bg-500: #64748b;
    --bg-600: #475569;
    --bg-700: #334155;
    --bg-800: #1e293b;
    --bg-900: #0f172a;
    
    --bg-dark: #0f172a;            /* Slate 900 - Base background */
    --bg-sidebar: #1e293b;         /* Slate 800 - Sidebar background */
    --bg-card: #334155;            /* Slate 700 - Card/Modal background */
    --bg-editor: #0f172a;          /* Slate 900 - Editor area background */
    --bg-hover: #334155;
    --bg-active: #475569;
    
    /* Text Colors */
    --text-50: #f8fafc;
    --text-100: #f1f5f9;
    --text-200: #e2e8f0;
    --text-300: #cbd5e1;
    --text-400: #94a3b8;
    --text-500: #64748b;
    --text-600: #475569;
    --text-700: #334155;
    --text-800: #1e293b;
    --text-900: #0f172a;
    
    --text-primary: #f8fafc;       /* Slate 50 - Primary text */
    --text-secondary: #cbd5e1;     /* Slate 300 - Secondary text */
    --text-muted: #94a3b8;         /* Slate 400 - Muted text */
    --text-disabled: #64748b;
    
    /* Border Colors */
    --border-50: #f8fafc;
    --border-100: #f1f5f9;
    --border-200: #e2e8f0;
    --border-300: #cbd5e1;
    --border-400: #94a3b8;
    --border-500: #64748b;
    --border-600: #475569;
    
    --border-color: #475569;       /* Slate 600 - Borders */
    --border-hover: #64748b;
    
    /* Glassmorphism */
    --glass-bg: rgba(15, 23, 42, 0.9); /* Darker glass background */
    --glass-border: rgba(255, 255, 255, 0.1);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

html[data-theme="eye-care"] {
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --primary-200: #bbf7d0;
    --primary-300: #86efac;
    --primary-400: #4ade80;
    --primary-500: #22c55e;
    --primary-600: #16a34a;
    --primary-700: #15803d;
    --primary-800: #166534;
    --primary-900: #14532d;
    --primary-950: #052e16;
    --primary-color: var(--primary-600);
    --primary-light: var(--primary-400);
    --primary-dark: var(--primary-700);
    --primary-rgb: 22 163 74;
    --bg-dark: #f2f6e8;
    --bg-sidebar: #edf4dc;
    --bg-card: #ffffff;
    --bg-editor: #f9fdea;
    --bg-hover: #e6efd4;
    --bg-active: #d3e3b3;
    --text-primary: #1f2d1d;
    --text-secondary: #344a32;
    --text-muted: #556b53;
    --text-disabled: #8ba286;
    --border-color: #c8d8ad;
    --border-hover: #afc58d;
    --success-color: #16a34a;
    --success-rgb: 22 163 74;
    --warning-color: #d97706;
    --warning-rgb: 217 119 6;
    --danger-color: #dc2626;
    --danger-rgb: 220 38 38;
    --success-500: #16a34a;
    --success-600: #15803d;
    --warning-500: #d97706;
    --warning-600: #b45309;
    --danger-500: #dc2626;
    --danger-600: #b91c1c;
    --glass-bg: rgba(245, 250, 233, 0.92);
    --glass-border: rgba(105, 129, 88, 0.28);
    --shadow-sm: 0 1px 2px 0 rgb(35 51 33 / 0.06);
    --shadow: 0 1px 3px 0 rgb(35 51 33 / 0.1), 0 1px 2px -1px rgb(35 51 33 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(35 51 33 / 0.12), 0 2px 4px -2px rgb(35 51 33 / 0.12);
    --shadow-lg: 0 10px 15px -3px rgb(35 51 33 / 0.14), 0 4px 6px -4px rgb(35 51 33 / 0.14);
    --shadow-xl: 0 20px 25px -5px rgb(35 51 33 / 0.16), 0 8px 10px -6px rgb(35 51 33 / 0.16);
}

html.dark .bg-primary:hover,
.bg-primary:hover {
    color: white;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Global Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 {
    font-size: var(--text-3xl);
}

h2 {
    font-size: var(--text-2xl);
}

h3 {
    font-size: var(--text-xl);
}

h4 {
    font-size: var(--text-lg);
}

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

/* Links */
a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-700);
    text-decoration: none;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

/* Selection */
::selection {
    background-color: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

/* CodeMirror 编辑器样式重置 */
.text-editor-host .cm-editor {
    font-family: 'Noto Serif SC', serif;
    line-height: 1.8;
}

.text-editor-host .cm-content {
    padding: 25px 30px;
    background: transparent;
    color: var(--text-primary);
    caret-color: var(--text-primary);
}

.text-editor-host .cm-cursor,
.text-editor-host .cm-dropCursor {
    border-left-color: var(--text-primary) !important;
}

html.dark .text-editor-host .cm-content {
    caret-color: #e2e8f0;
}

html.dark .text-editor-host .cm-cursor,
html.dark .text-editor-host .cm-dropCursor {
    border-left-color: #e2e8f0 !important;
}

/* 重置选择样式 */
.text-editor-host .cm-selectionBackground {
    background-color: rgba(59, 130, 246, 0.3) !important;
}

/* 禁用行高亮 */
.text-editor-host .cm-activeLine {
    background-color: transparent !important;
}

/* 禁用匹配高亮 */
.text-editor-host .cm-selectionMatch {
    background-color: transparent !important;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
    background: var(--border-400);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-500);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-400) transparent;
}

.glass-effect {
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
}

.logo-text-gradient {
    background: linear-gradient(135deg, var(--primary-color), #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout & Components */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow-y: auto;
    flex-shrink: 0;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-toggle {
    display: flex;
    justify-content: flex-end;
    padding: 15px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.sidebar-toggle i {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0 15px 80px;
}

.sidebar-usage {
    position: absolute;
    left: 15px;
    right: 15px;
    bottom: 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    max-height: 200px;
    overflow-y: auto;
}

.sidebar-usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.sidebar-usage-title {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-usage-percent {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-usage-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.sidebar-usage-bar {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background-color: var(--bg-card);
    overflow: hidden;
}

.sidebar-usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.nav-section {
    margin-bottom: 15px;
}

.nav-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 1px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 3px;
    color: var(--text-secondary);
    text-decoration: none;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(124, 58, 237, 0.15);
    color: var(--primary-light);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item span {
    font-size: 14px;
    font-weight: 500;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section h3,
.sidebar.collapsed .sidebar-usage {
    display: none;
}

/* Buttons */
.btn {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    border: none;
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    box-shadow: var(--shadow-sm);
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

/* Outline Button */
.btn-outline {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-500);
    color: var(--primary-600);
}

/* Text Button */
.btn-text {
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-text:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Size Variations */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

/* Disabled State */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    box-shadow: none;
}

/* Loading State */
.btn-loading {
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Editor Area */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-editor);
    overflow: hidden;
}

.editor-toolbar {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.toolbar-btn.active {
    background-color: rgba(124, 58, 237, 0.2);
    color: var(--primary-light);
    border-color: var(--primary-light);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.document-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Noto Serif SC', serif;
}

.document-stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--text-muted);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.editor-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chapter-list {
    width: 220px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 15px;
    background-color: var(--bg-sidebar);
    flex-shrink: 0;
}

.chapter-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chapter-list-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chapter-item {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.chapter-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.chapter-item.active {
    background-color: rgba(124, 58, 237, 0.15);
    border-left-color: var(--primary-color);
}

.chapter-title {
    font-weight: 500;
    margin-bottom: 5px;
}

.chapter-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.add-chapter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    background-color: rgba(124, 58, 237, 0.1);
    color: var(--primary-light);
    cursor: pointer;
    margin-top: 10px;
    border: 1px dashed var(--primary-light);
    justify-content: center;
    transition: background 0.2s;
}

.add-chapter:hover {
    background-color: rgba(124, 58, 237, 0.2);
}

.text-editor {
    flex: 1;
    padding: 25px 30px;
    overflow-y: auto;
    font-family: 'Noto Serif SC', serif;
    line-height: 1.8;
    background: transparent;
    border: none;
    color: var(--text-primary);
    resize: none;
}

.text-editor:focus {
    outline: none;
}

/* Right Panel */
.right-panel {
    width: var(--right-panel-width);
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition-normal);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.right-panel.collapsed {
    width: 0;
    border-left: none;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-tab {
    flex: 1;
    padding: var(--space-4);
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    position: relative;
}

.panel-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.panel-tab.active {
    color: var(--primary-600);
}

.panel-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-700));
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.panel-section {
    margin-bottom: var(--space-6);
}

.panel-section h3 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
}

/* Components */
.outline-item {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-2);
    cursor: pointer;
    transition: all var(--transition-normal);
    border-left: 3px solid transparent;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.outline-item:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-300);
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.outline-item.active {
    background-color: rgba(124, 58, 237, 0.15);
    border-left-color: var(--primary-600);
    border-color: var(--primary-300);
    box-shadow: var(--shadow);
}

/* Card Components */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.card-body {
    margin-bottom: var(--space-4);
}

.card-footer {
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* Character Card */
.character-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.character-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-300);
    transform: translateY(-2px);
}

.character-name {
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
    color: var(--primary-600);
    font-size: var(--text-lg);
}

.character-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.version-item {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.version-item:hover {
    border-color: var(--primary-400);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.version-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
    font-weight: var(--font-medium);
}

.version-preview {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: var(--leading-relaxed);
}

/* AI Chat Styles */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 90;
}

.ai-chat-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.ai-chat-drawer {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 380px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-card);
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform 0.2s;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.ai-chat-drawer.open {
    transform: translateX(0);
}

@media (max-width: 1024px) {
    .ai-chat-drawer {
        width: 100%;
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: 0 var(--space-4);
}

.message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    max-width: 85%;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.ai-message {
    background-color: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
    align-self: flex-start;
    color: var(--text-secondary);
    border-bottom-left-radius: var(--radius-sm);
}

.user-message {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border: 1px solid var(--primary-500);
    align-self: flex-end;
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: 0 var(--space-4) var(--space-4);
}

.chat-input-area textarea {
    width: 100%;
    padding: var(--space-3);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    resize: none;
    height: 100px;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    transition: all var(--transition-normal);
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.chat-input-area button {
    align-self: flex-end;
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.chat-input-area button:hover {
    background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.chat-input-area button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

html:not(.dark) ::-webkit-scrollbar-thumb {
    background: var(--border-400);
}

html:not(.dark) ::-webkit-scrollbar-thumb:hover {
    background: var(--border-500);
}

html:not(.dark) .sidebar-usage {
    box-shadow: var(--shadow-md);
}

html:not(.dark) .nav-item:hover,
html:not(.dark) .nav-item.active {
    color: var(--primary-700);
    background-color: rgba(124, 58, 237, 0.1);
}

html:not(.dark) .btn-outline:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-400);
    color: var(--primary-600);
}

html:not(.dark) .toolbar-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-400);
    color: var(--text-primary);
}

html:not(.dark) .toolbar-btn.active {
    color: var(--primary-700);
    border-color: var(--primary-400);
    background-color: rgba(124, 58, 237, 0.12);
}

html:not(.dark) .chapter-item:hover {
    background-color: var(--bg-hover);
}

html:not(.dark) .chapter-item.active {
    background-color: rgba(124, 58, 237, 0.1);
}

html:not(.dark) .add-chapter {
    color: var(--primary-700);
    border-color: var(--primary-300);
    background-color: rgba(124, 58, 237, 0.08);
}

html:not(.dark) .add-chapter:hover {
    background-color: rgba(124, 58, 237, 0.14);
}

html:not(.dark) .panel-tab:hover {
    background-color: var(--bg-hover);
}

html:not(.dark) .panel-tab.active {
    color: var(--primary-700);
}

html:not(.dark) .ai-chat-backdrop {
    background: rgba(15, 23, 42, 0.3);
}

html:not(.dark) .ai-message {
    background-color: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.28);
    color: var(--text-700);
}

html:not(.dark) .user-message {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-color: var(--primary-500);
    color: white;
}

html[data-theme="eye-care"] .nav-item:hover,
html[data-theme="eye-care"] .nav-item.active {
    background-color: rgba(22, 163, 74, 0.14);
    color: var(--primary-700);
}

html[data-theme="eye-care"] .sidebar {
    background-color: var(--bg-sidebar);
}

html[data-theme="eye-care"] .glass-effect {
    border-bottom: 1px solid var(--border-color);
}

html[data-theme="eye-care"] .card {
    border-color: var(--border-color);
}

html[data-theme="eye-care"] .card:hover {
    border-color: var(--border-hover);
}

html[data-theme="eye-care"] .logo-text-gradient {
    background: linear-gradient(135deg, #15803d, #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

html[data-theme="eye-care"] .toolbar-btn.active {
    color: var(--primary-700);
    border-color: var(--primary-400);
    background-color: rgba(22, 163, 74, 0.14);
}

html[data-theme="eye-care"] .chapter-item.active {
    background-color: rgba(22, 163, 74, 0.12);
}

html[data-theme="eye-care"] .add-chapter {
    color: var(--primary-700);
    border-color: var(--primary-300);
    background-color: rgba(22, 163, 74, 0.08);
}

html[data-theme="eye-care"] .add-chapter:hover {
    background-color: rgba(22, 163, 74, 0.14);
}

html[data-theme="eye-care"] .ai-message {
    background-color: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.28);
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.fade-in-up {
    animation: fadeInUp 0.4s ease-out forwards;
}

.fade-in-down {
    animation: fadeInDown 0.4s ease-out forwards;
}

.fade-in-left {
    animation: fadeInLeft 0.4s ease-out forwards;
}

.fade-in-right {
    animation: fadeInRight 0.4s ease-out forwards;
}

.slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

.slide-out {
    animation: slideOut 0.3s ease-in forwards;
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

.scale-out {
    animation: scaleOut 0.3s ease-in forwards;
}

/* Button Styles */
.bg-danger {
    background-color: var(--danger-500) !important;
}

.bg-danger:hover {
    background-color: var(--danger-600) !important;
}

.bg-danger-dark {
    background-color: var(--danger-600) !important;
}
.bg-success {
    background-color: var(--success-color) !important;
}
.bg-success:hover {
    background-color: var(--success-600) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}
.text-success {
    color: var(--success-color) !important;
}


/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 400px;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    animation: slideInRight 0.3s ease-out forwards;
    position: relative;
    overflow: hidden;
}

.toast.toast-success {
    border-left: 4px solid var(--success-500);
}

.toast.toast-info {
    border-left: 4px solid var(--primary-500);
}

.toast.toast-warning {
    border-left: 4px solid var(--warning-500);
}

.toast.toast-error {
    border-left: 4px solid var(--danger-500);
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success .toast-icon { color: var(--success-500); }
.toast-info .toast-icon { color: var(--primary-500); }
.toast-warning .toast-icon { color: var(--warning-500); }
.toast-error .toast-icon { color: var(--danger-500); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    font-size: var(--text-sm);
}

.toast-message {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    background: transparent;
    border: none;
    padding: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background-color: var(--primary-500);
    animation: toastProgress linear forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-200);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* AI Loading Indicator */
.ai-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    animation: fadeIn 0.2s ease-out forwards;
}

.ai-loading-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: scaleIn 0.3s ease-out forwards;
}

.ai-loading-text {
    color: var(--text-primary);
    font-weight: var(--font-medium);
    font-size: var(--text-base);
}

.ai-loading-subtext {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--primary-500);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Keyboard Navigation Focus States */
.nav-item:focus,
.btn:focus,
.toolbar-btn:focus,
.card:focus,
select:focus,
button:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Input, Textarea and Select Focus States */
input:focus,
textarea:focus,
select:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgb(var(--primary-rgb) / 0.15);
}

/* Prevent autofill background color change */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-background-clip: text;
    -webkit-text-fill-color: var(--text-primary);
    background-color: var(--bg-dark) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Skip to content link for accessibility */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary-600);
    color: white;
    padding: var(--space-2) var(--space-4);
    z-index: 10000;
    transition: top var(--transition-fast);
}

.skip-to-content:focus {
    top: 0;
}

/* Fullscreen Mode */
.fullscreen-mode .sidebar,
.fullscreen-mode .right-panel,
.fullscreen-mode .editor-toolbar {
    display: none !important;
}

.fullscreen-mode .editor-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9997;
}

.fullscreen-mode .editor-area {
    display: flex;
}

/* Focus Mode */
.focus-mode .sidebar,
.focus-mode .right-panel {
    opacity: 0.1;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.focus-mode .sidebar:hover,
.focus-mode .right-panel:hover {
    opacity: 1;
    pointer-events: auto;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-6);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--text-sm);
    max-width: 400px;
    line-height: var(--leading-relaxed);
}

.empty-state-action {
    margin-top: var(--space-6);
}

/* Font Size Controls */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.font-size-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: var(--font-bold);
}

.font-size-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary-400);
}

.font-size-display {
    min-width: 40px;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

/* Improved Word Count Bar */
.sidebar-usage-bar-fill {
    transition: width 0.5s ease-out;
    background: linear-gradient(90deg,
        var(--success-500) 0%,
        var(--success-500) 60%,
        var(--warning-500) 60%,
        var(--warning-500) 85%,
        var(--danger-500) 85%,
        var(--danger-500) 100%);
}

/* Transition Classes */
.transition-all {
    transition: all var(--transition-normal);
}

.transition-fast {
    transition: all var(--transition-fast);
}

.transition-slow {
    transition: all var(--transition-slow);
}

.transition-colors {
    transition: color var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
}

.transition-transform {
    transition: transform var(--transition-normal);
}

.transition-opacity {
    transition: opacity var(--transition-normal);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Layout Adjustments */
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 999;
        width: 280px;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        border-right: none;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar.collapsed {
        width: 280px;
    }
    
    .editor-container {
        height: calc(100vh - var(--header-height) - 60px);
    }
    
    .chapter-list {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        z-index: 90;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
        width: 100%;
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }
    
    .chapter-list.open {
        transform: translateX(0);
    }
    
    .right-panel {
        position: fixed;
        right: 0;
        top: var(--header-height);
        bottom: 0;
        z-index: 90;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
        width: 100%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform var(--transition-normal);
    }
    
    .right-panel.open {
        transform: translateX(0);
    }
    
    .text-editor,
    .text-editor-host .cm-content {
        padding: var(--space-6) var(--space-4);
        font-size: 16px;
    }
    
    .editor-toolbar {
        padding: var(--space-2) var(--space-3);
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
    }
    
    .toolbar-center {
        order: 3;
        flex: 1 1 100%;
        justify-content: flex-start;
        padding-top: var(--space-2);
    }
    
    .status-quick {
        width: 100%;
        justify-content: center;
    }
    
    .toolbar-left,
    .toolbar-right {
        flex: 1;
    }
    
    .toolbar-left {
        justify-content: flex-start;
    }
    
    .toolbar-right {
        justify-content: flex-end;
    }
    
    /* Components */
    .card {
        padding: var(--space-3);
    }
    
    .btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }
    
    .nav-item {
        padding: var(--space-2) var(--space-3);
    }
    
    .chapter-item {
        padding: var(--space-2);
    }
    
    .panel-content {
        padding: var(--space-3);
    }

    .toast-container {
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
    }

    /* Better touch targets */
    .btn {
        min-height: 44px;
        padding: var(--space-3) var(--space-4);
    }

    /* Prevent keyboard from breaking layout */
    @media (max-height: 500px) {
        .editor-container {
            height: 100vh;
        }

        .sidebar,
        .right-panel {
            position: static;
            transform: none;
        }
    }
}

/* Tablet Responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .sidebar.collapsed {
        width: 70px;
    }

    .right-panel {
        width: 300px;
    }

    .text-editor,
    .text-editor-host .cm-content {
        padding: var(--space-8) var(--space-6);
    }

    /* Compact toast on tablet */
    .toast {
        min-width: 280px;
    }
}

/* Small Mobile Responsive */
@media (max-width: 480px) {
    .text-editor,
    .text-editor-host .cm-content {
        padding: var(--space-4) var(--space-3);
        font-size: 15px;
    }
    
    .chapter-list,
    .right-panel {
        max-width: 100%;
    }
    
    .editor-toolbar {
        padding: var(--space-2);
    }
    
    .toolbar-group {
        gap: var(--space-1);
    }
    
    .toolbar-btn {
        width: 32px;
        height: 32px;
    }
}


