/* Digital Math Notebook - Main Styles */

/* CSS Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    overflow: hidden;
}

/* CSS Variables for Themes */
.theme-notebook-light {
    --bg-primary: #fdfdf8;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent-primary: #3498db;
    --accent-secondary: #2980b9;
    --accent-success: #27ae60;
    --accent-warning: #f39c12;
    --accent-danger: #e74c3c;
    --border-light: #e9ecef;
    --border-medium: #dee2e6;
    --shadow-light: rgba(0,0,0,0.05);
    --shadow-medium: rgba(0,0,0,0.1);
    --shadow-strong: rgba(0,0,0,0.15);
    --notebook-lines: rgba(173,216,230,0.3);
}

.theme-notebook-dark {
    --bg-primary: #1a1d23;
    --bg-secondary: #2c3e50;
    --bg-tertiary: #34495e;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --text-muted: #7f8c8d;
    --accent-primary: #3498db;
    --accent-secondary: #2980b9;
    --accent-success: #27ae60;
    --accent-warning: #f39c12;
    --accent-danger: #e74c3c;
    --border-light: #4a5568;
    --border-medium: #5a6c7d;
    --shadow-light: rgba(0,0,0,0.2);
    --shadow-medium: rgba(0,0,0,0.3);
    --shadow-strong: rgba(0,0,0,0.4);
    --notebook-lines: rgba(52,152,219,0.2);
}

.theme-academic-blue {
    --bg-primary: #f8fafc;
    --bg-secondary: #edf2f7;
    --bg-tertiary: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent-primary: #2b6cb0;
    --accent-secondary: #2c5282;
    --accent-success: #38a169;
    --accent-warning: #d69e2e;
    --accent-danger: #e53e3e;
    --border-light: #e2e8f0;
    --border-medium: #cbd5e0;
    --shadow-light: rgba(0,0,0,0.04);
    --shadow-medium: rgba(0,0,0,0.08);
    --shadow-strong: rgba(0,0,0,0.12);
    --notebook-lines: rgba(43,108,176,0.15);
}

.theme-warm-paper {
    --bg-primary: #fef9f3;
    --bg-secondary: #fef4e6;
    --bg-tertiary: #ffffff;
    --text-primary: #744210;
    --text-secondary: #a16207;
    --text-muted: #d97706;
    --accent-primary: #ea580c;
    --accent-secondary: #c2410c;
    --accent-success: #16a34a;
    --accent-warning: #ca8a04;
    --accent-danger: #dc2626;
    --border-light: #fed7aa;
    --border-medium: #fdba74;
    --shadow-light: rgba(251,146,60,0.05);
    --shadow-medium: rgba(251,146,60,0.1);
    --shadow-strong: rgba(251,146,60,0.15);
    --notebook-lines: rgba(234,88,12,0.2);
}

.theme-minimal-clean {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #ffffff;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --accent-primary: #059669;
    --accent-secondary: #047857;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-light: #f3f4f6;
    --border-medium: #e5e7eb;
    --shadow-light: rgba(0,0,0,0.03);
    --shadow-medium: rgba(0,0,0,0.06);
    --shadow-strong: rgba(0,0,0,0.09);
    --notebook-lines: rgba(5,150,105,0.1);
}

/* Base Elements */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

/* Header */
.app-header {
    height: 60px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow-light);
    z-index: 1000;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 250px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title i {
    color: var(--accent-primary);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--border-medium);
    border-radius: 25px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: var(--shadow-medium);
    display: none;
}

.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.search-result-snippet {
    font-size: 12px;
    color: var(--text-secondary);
}

.search-result-type {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
    margin-left: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
    justify-content: flex-end;
}

/* Buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.btn-primary, .btn-secondary, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

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

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
}

/* Layout */
.app-layout {
    display: flex;
    height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-light);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-content {
    padding: 20px;
    height: 100%;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.topic-tabs {
    margin-bottom: 30px;
}

.topic-tabs h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.topic-item:hover {
    background: var(--bg-secondary);
}

.topic-item.active {
    background: var(--accent-primary);
    color: white;
}

.topic-item i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}

.topic-item span:first-of-type {
    flex: 1;
    font-weight: 500;
}

.page-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    min-width: 20px;
    text-align: center;
}

.topic-item.active .page-count {
    background: rgba(255,255,255,0.2);
    color: white;
}

.table-of-contents h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toc-list {
    display: flex;
    flex-direction: column;
}

.toc-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 13px;
    border-left: 3px solid transparent;
}

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

.toc-item.active {
    background: var(--bg-secondary);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

.content-area {
    height: 100%;
    position: relative;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 800px;
}

.welcome-icon {
    font-size: 64px;
    color: var(--accent-primary);
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.welcome-content > p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.feature-card {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.feature-card i {
    font-size: 32px;
    color: var(--accent-primary);
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 14px;
}

.getting-started {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Page Editor */
.page-editor {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
}

.editor-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

.title-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    font-size: 24px;
    font-weight: 600;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.title-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topic-select, .category-select {
    padding: 10px 15px;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.toolbar-group {
    display: flex;
    gap: 5px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.toolbar-btn.active {
    background: var(--accent-primary);
    color: white;
}

.editor-content {
    flex: 1;
    display: flex;
    min-height: 0;
}

#page-content {
    flex: 1;
    padding: 20px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.8;
    resize: none;
    background-image: 
        repeating-linear-gradient(
            transparent,
            transparent 28px,
            var(--notebook-lines) 28px,
            var(--notebook-lines) 30px
        );
}

#page-content:focus {
    outline: none;
}

.content-preview {
    flex: 1;
    padding: 20px;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-light);
    overflow-y: auto;
    font-family: 'Inter', sans-serif;
    line-height: 1.8;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-secondary);
}

.editor-info {
    display: flex;
    gap: 20px;
}

.save-status.saved {
    color: var(--accent-success);
}

.save-status.unsaved {
    color: var(--accent-warning);
}

.editor-tags {
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-tags input {
    padding: 6px 10px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
}

/* Page Viewer */
.page-viewer {
    height: 100%;
    overflow-y: auto;
    padding: 40px;
    background: var(--bg-primary);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}

.page-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
}

.page-actions {
    display: flex;
    gap: 10px;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.page-topic-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--accent-primary);
    color: white;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.page-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.page-dates {
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    gap: 15px;
}

.page-content {
    font-size: 16px;
    line-height: 1.8;
    max-width: none;
    margin-bottom: 40px;
}

.page-content h1, .page-content h2, .page-content h3,
.page-content h4, .page-content h5, .page-content h6 {
    margin: 30px 0 15px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.page-content h1 { font-size: 28px; }
.page-content h2 { font-size: 24px; }
.page-content h3 { font-size: 20px; }
.page-content h4 { font-size: 18px; }

.page-content p {
    margin-bottom: 15px;
}

.page-content ul, .page-content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.page-content li {
    margin-bottom: 8px;
}

.page-content code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
}

.page-content pre {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
}

.page-content blockquote {
    border-left: 4px solid var(--accent-primary);
    margin: 20px 0;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
}

.page-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.cross-references h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.related-link {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.related-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Formula Library */
.formula-library {
    height: 100%;
    overflow-y: auto;
    padding: 40px;
    background: var(--bg-primary);
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.library-header h2 {
    font-size: 28px;
    font-weight: 700;
}

.library-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.formula-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.formula-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-primary);
}

.formula-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.formula-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.formula-category {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.formula-latex {
    margin: 15px 0;
    text-align: center;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.formula-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-tertiary);
    border-radius: 12px;
    box-shadow: var(--shadow-strong);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 800px;
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.theme-option {
    text-align: center;
    cursor: pointer;
    padding: 15px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.theme-option:hover {
    background: var(--bg-secondary);
}

.theme-option.active {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    margin: 0 auto 10px;
    border: 1px solid var(--border-medium);
}

.theme-preview-light { background: linear-gradient(135deg, #fdfdf8 50%, #3498db 50%); }
.theme-preview-dark { background: linear-gradient(135deg, #1a1d23 50%, #3498db 50%); }
.theme-preview-blue { background: linear-gradient(135deg, #f8fafc 50%, #2b6cb0 50%); }
.theme-preview-warm { background: linear-gradient(135deg, #fef9f3 50%, #ea580c 50%); }
.theme-preview-minimal { background: linear-gradient(135deg, #ffffff 50%, #059669 50%); }

.theme-option span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Formula Calculator */
.formula-display {
    margin-bottom: 30px;
    text-align: center;
}

.formula-calculator {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
}

.formula-calculator h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.formula-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.formula-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.formula-input-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.formula-input-group input {
    padding: 10px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.formula-result {
    text-align: center;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 2px solid var(--accent-primary);
}

.formula-result-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 5px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Loading Spinner */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 15px;
    z-index: 3000;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Math Rendering */
.MathJax {
    font-size: 1.1em !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0 15px;
    }
    
    .header-left {
        min-width: auto;
    }
    
    .app-title {
        font-size: 16px;
    }
    
    .app-title span {
        display: none;
    }
    
    .header-center {
        margin: 0 15px;
    }
    
    .header-right {
        min-width: auto;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .getting-started {
        flex-direction: column;
        align-items: center;
    }
    
    .page-viewer {
        padding: 20px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .editor-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .editor-actions {
        justify-content: flex-end;
    }
    
    .editor-content {
        flex-direction: column;
    }
    
    .content-preview {
        border-left: none;
        border-top: 1px solid var(--border-light);
        max-height: 300px;
    }
    
    .formula-grid {
        grid-template-columns: 1fr;
    }
    
    .library-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .theme-options {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .modal-content {
        margin: 10px;
        max-width: none;
        width: auto;
    }
    
    .formula-inputs {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 1500;
        height: 100%;
    }
    
    .main-content {
        width: 100%;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .page-viewer {
        padding: 15px;
    }
    
    .welcome-screen {
        padding: 20px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .editor-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}