:root {
    /* Apple-inspired Color Palette */
    --primary-color: #007AFF;
    --primary-hover: #0062CC;
    --bg-color: #F5F5F7;
    --panel-bg: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --border-color: #D2D2D7;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    
    /* 橙色主题（左栏 Input Source） */
    --orange-primary: #fb923c;
    --orange-light: #fff7ed;
    --orange-medium: #ffedd5;
    --orange-dark: #f97316;
    --orange-accent: #fdba74;
    
    /* 蓝色主题（右栏 Live Preview） */
    --blue-primary: #3b82f6;
    --blue-light: #eff6ff;
    --blue-medium: #dbeafe;
    --blue-dark: #2563eb;
    --blue-accent: #60a5fa;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-main: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 1rem;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12px;
    }
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    background: white;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--orange-primary) 0%, var(--blue-primary) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--transition);
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.brand-icon:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.brand-icon svg {
    width: 100%;
    height: 100%;
}

.brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--orange-primary) 0%, var(--blue-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-start;
    margin-left: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.stats-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-color);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stats-badge.warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--warning-color);
}

.stats-badge strong {
    color: var(--text-primary);
    font-weight: 600;
}

.stats-badge.warning strong {
    color: var(--warning-color);
}

/* Toolbar */
.toolbar {
    padding: 0;
    background: transparent;
    border-bottom: none;
    display: none;
}

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

.stats-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-color);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stats-badge.warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--warning-color);
}

/* Navigation Controls */
.navigation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(255, 149, 0, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 149, 0, 0.3);
    border-radius: 6px;
    color: var(--warning-color);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover:not(:disabled) {
    background: rgba(255, 149, 0, 0.2);
    border-color: var(--warning-color);
    transform: scale(1.05);
}

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

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.navigation-progress {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--warning-color);
    min-width: 45px;
    text-align: center;
}

/* Workspace */
.editor-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #F8F9FA;
    position: relative;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    min-width: 0;
    position: relative;
}

/* 分隔线 */
.editor-workspace::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    transform: translateX(-50%);
    z-index: 1;
}

/* 左栏 - Input Source */
.panel:first-child {
    border-right: 1px solid var(--border-color);
}

.panel:first-child .panel-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
}

.panel:first-child .scroll-area {
    background: #FFFFFF;
}

/* 右栏 - Preview */
.panel:last-child {
    border-left: 1px solid var(--border-color);
    border-right: none;
}

.panel:last-child .panel-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
}

.panel:last-child .scroll-area {
    background: #F5F7FA;
}

.panel-header {
    height: 48px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
}

.panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.orange-dot {
    background: var(--orange-primary);
}

.blue-dot {
    background: var(--blue-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Scrollable Content Areas */
.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
    /* Smooth scrolling for user interactions */
    /* Optimize scrolling performance */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

/* Preview panel - Word document style */
#preview.scroll-area {
    background: #F5F7FA;
    padding: 40px 20px;
    position: relative;
}

/* Word document page simulation - A4 size */
.word-page {
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 11pt;
    line-height: 1.5;
    color: #000000;
    width: 21cm;
    min-height: 29.7cm;
    margin: 0 auto 40px;
    padding: 2.54cm;
    background: white;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 100%;
    transform-origin: top center;
}

/* Page break simulation */
.word-page+.word-page {
    margin-top: 20px;
}

/* Paragraph styling - Word default */
.word-page p {
    margin: 0;
    text-align: justify;
    text-justify: inter-ideograph;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    line-height: 1.3;
    /* Tighter line spacing */
}

/* Text content in word-page */
.word-page {
    white-space: pre-wrap;
}

.word-page>* {
    white-space: normal;
}

/* Headings */
.word-page h1 {
    font-family: "微软雅黑", "Microsoft YaHei", "SimHei", sans-serif;
    font-size: 16pt;
    font-weight: bold;
    margin: 12pt 0 6pt 0;
    color: #000000;
}

.word-page h2 {
    font-family: "微软雅黑", "Microsoft YaHei", "SimHei", sans-serif;
    font-size: 14pt;
    font-weight: bold;
    margin: 10pt 0 5pt 0;
    color: #000000;
}

.word-page h3 {
    font-family: "微软雅黑", "Microsoft YaHei", "SimHei", sans-serif;
    font-size: 12pt;
    font-weight: bold;
    margin: 8pt 0 4pt 0;
    color: #000000;
}

/* Lists */
.word-page ul,
.word-page ol {
    margin: 6pt 0;
    padding-left: 36pt;
}

.word-page li {
    margin: 3pt 0;
    line-height: 1.5;
}

/* Code blocks */
.word-page code {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 10pt;
    background-color: #F5F5F5;
    padding: 1pt 3pt;
    border-radius: 2pt;
}

.word-page pre {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 10pt;
    background-color: #F5F5F5;
    padding: 8pt;
    border-radius: 4pt;
    overflow-x: auto;
    margin: 6pt 0;
    white-space: pre-wrap;
    /* Preserve whitespace and wrap lines */
}

/* Links */
.word-page a {
    color: #0563C1;
    text-decoration: underline;
}

/* Horizontal rule */
.word-page hr {
    border: none;
    border-top: 0.5pt solid #CCCCCC;
    margin: 12pt 0;
}

/* Custom Scrollbar */
.scroll-area::-webkit-scrollbar {
    width: 10px;
}

.scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-area::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

.scroll-area::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* 滚动条保持统一风格 */

/* Input Textarea */
#inputText {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    outline: none;
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    background: transparent;
}

#inputText::placeholder {
    color: #C7C7CC;
}

/* Preview Content */
.preview-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Math Formula Styling - Word-like */
.word-page .katex-display {
    margin: 12pt 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border: none;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: center;
    display: block;
    width: 100%;
}

.word-page .katex-display .katex {
    display: inline-block;
    text-align: center;
    max-width: 100%;
}

/* Inline math - Word style */
.word-page .katex {
    font-size: 1em;
    font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", serif;
    line-height: 1.2;
    vertical-align: baseline;
}

/* Ensure formulas don't break lines inappropriately */
.word-page .katex:not(.katex-display) {
    white-space: nowrap;
}

/* Display math should allow proper spacing */
.word-page .katex-display .katex {
    white-space: normal;
}

.word-page .formula-maybe .katex,
.word-page .formula-auto .katex,
.word-page .formula-completed .katex {
    white-space: nowrap;
}

/* Ensure KaTeX elements inside formula-completed don't override the border */
.formula-completed .katex,
.formula-completed .katex-display {
    background-color: transparent !important;
}

/* Buttons - Premium Feel */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--blue-primary);
    color: white;
    border: none;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--bg-color);
    border-color: #B0B0B5;
}

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

.btn-ghost:hover:not(:disabled) {
    color: var(--primary-color);
    background: rgba(0, 122, 255, 0.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Modal - Modern Backdrop */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* backdrop-filter: blur(5px); REMOVED for performance */
    /* -webkit-backdrop-filter: blur(5px); REMOVED for performance */
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: white;
    margin: 10vh auto;
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.modal h3 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1400px) {
    .word-page {
        width: 90%;
        padding: 2cm;
        font-size: 10pt;
    }
}

@media (max-width: 1200px) {
    .app-container {
        max-width: 100%;
    }

    .word-page {
        width: 95%;
        padding: 1.5cm;
        font-size: 9pt;
    }

    .editor-workspace {
        flex-direction: column;
    }

    .editor-workspace::after {
        display: none;
    }

    .panel:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .panel:last-child {
        border-left: none;
        border-top: 1px solid var(--border-color);
        border-bottom: none;
    }

    .panel {
        min-height: 50vh;
    }
}

@media (max-width: 768px) {
    header {
        height: auto;
        min-height: 56px;
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .brand h1 {
        font-size: 1rem;
    }

    .header-toolbar {
        order: 2;
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions {
        order: 3;
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        gap: 8px;
    }

    .stats-badge {
        font-size: 0.85rem;
        padding: 4px 10px;
    }

    .word-page {
        width: 100%;
        padding: 1cm;
        font-size: 8pt;
        margin: 0 auto 20px;
    }

    #preview.scroll-area {
        padding: 20px 10px;
    }

    .panel-header {
        height: 40px;
        padding: 0 12px;
    }

    .panel-title {
        font-size: 0.8rem;
    }

    .scroll-area {
        padding: 16px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .modal-content {
        width: 95%;
        padding: 24px;
        margin: 5vh auto;
    }
}

@media (max-width: 480px) {
    header {
        padding: 8px 12px;
    }

    .brand-icon {
        width: 28px;
        height: 28px;
    }

    .brand h1 {
        font-size: 0.9rem;
    }

    .toolbar {
        padding: 8px 12px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

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

    .word-page {
        padding: 0.8cm;
        font-size: 7pt;
    }

    .modal-content {
        padding: 16px;
    }

    .modal h3 {
        font-size: 1.2rem;
    }
}

/* Scale word page for very small screens */
@media (max-width: 600px) {
    .word-page {
        transform: scale(0.85);
        transform-origin: top center;
        margin-bottom: 20px;
    }
}

@media (max-width: 400px) {
    .word-page {
        transform: scale(0.75);
    }
}

/* Ensure panels stack vertically on small screens */
@media (max-width: 1200px) {
    .editor-workspace {
        flex-direction: column;
    }

    .editor-workspace::after {
        display: none;
    }

    .panel:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .panel:last-child {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .panel {
        width: 100%;
        min-height: 400px;
    }
}

/* Interactive Formula States */
.formula-maybe {
    background-color: rgba(255, 149, 0, 0.15) !important;
    border-bottom: 3px solid #FF9500 !important;
    cursor: pointer;
    transition: all 0.2s;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    position: relative;
    margin: 0 2px;
}

.formula-maybe:hover {
    background-color: rgba(255, 149, 0, 0.25) !important;
    border-bottom-color: #FF6B00 !important;
}

/* Ensure KaTeX elements inside formula-maybe don't override the border */
.formula-maybe .katex,
.formula-maybe .katex-display {
    background-color: transparent !important;
}

/* Ensure KaTeX elements inside formula-plain don't override the background */
.formula-plain .katex,
.formula-plain .katex-display {
    background-color: transparent !important;
}

.formula-auto {
    background-color: rgba(52, 199, 89, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.formula-auto:hover {
    background-color: rgba(52, 199, 89, 0.2) !important;
    border-bottom-color: #34C759 !important;
}

.formula-completed {
    background-color: rgba(0, 122, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.formula-completed:hover {
    background-color: rgba(0, 122, 255, 0.2) !important;
    border-bottom-color: #007AFF !important;
}

.formula-plain {
    background-color: rgba(128, 128, 128, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.formula-plain:hover {
    background-color: rgba(128, 128, 128, 0.2) !important;
    border-bottom-color: #808080 !important;
}

/* 基础公式元素样式 */
.formula-element {
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    position: relative;
}

/* 确保 KaTeX 元素可以应用公式样式 */
.katex.formula-element,
.katex-display.formula-element {
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

/* Current focused formula (for navigation) */
.formula-maybe.formula-focused {
    background-color: rgba(255, 149, 0, 0.3) !important;
    border-bottom: 4px solid #FF6B00 !important;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

.formula-auto.formula-focused {
    background-color: rgba(52, 199, 89, 0.3) !important;
    border-bottom: 4px solid #34C759 !important;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
    animation: pulseGreen 1.5s ease-in-out infinite;
}

.formula-completed.formula-focused {
    background-color: rgba(0, 122, 255, 0.3) !important;
    border-bottom: 4px solid #007AFF !important;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    animation: pulseBlue 1.5s ease-in-out infinite;
}

.formula-plain.formula-focused {
    background-color: rgba(128, 128, 128, 0.3) !important;
    border-bottom: 4px solid #808080 !important;
    box-shadow: 0 2px 8px rgba(128, 128, 128, 0.3);
    animation: pulseGray 1.5s ease-in-out infinite;
}

@keyframes pulseGray {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(128, 128, 128, 0.3);
    }

    50% {
        box-shadow: 0 4px 12px rgba(128, 128, 128, 0.5);
    }
}

@keyframes pulseGreen {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
    }

    50% {
        box-shadow: 0 4px 12px rgba(52, 199, 89, 0.5);
    }
}

@keyframes pulseBlue {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    }

    50% {
        box-shadow: 0 4px 12px rgba(0, 122, 255, 0.5);
    }
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(255, 149, 0, 0.3);
    }

    50% {
        box-shadow: 0 4px 12px rgba(255, 149, 0, 0.5);
    }
}

/* Fix for block formula layout */
.formula-block {
    display: block !important;
    width: 100%;
    margin: 10px 0;
    text-align: center;
}

.formula-block .katex-display {
    margin: 0 !important;
    width: 100%;
}

.formula-block.formula-maybe,
.formula-block.formula-auto {
    display: block !important;
}

/* Tagged Formula Layout */
.tagged-formula {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 12pt 0;
}

.formula-main {
    flex: 1;
    text-align: center;
    padding-right: 10px;
    min-width: 0;
    /* Prevent flex item overflow */
}

.formula-tag {
    white-space: nowrap;
    font-family: 'Cambria Math', 'Latin Modern Math', serif;
    font-size: 1em;
    color: var(--text-primary);
    margin-left: auto;
    /* Push to right if flex doesn't */
}

/* Ensure KaTeX inside formula-main behaves */
.formula-main .katex-display {
    margin: 0 !important;
    width: 100%;
}


/* User Suggested Fixes for Formula Display */

/* 1. Reset line-height to prevent misalignment */
.katex {
    line-height: normal !important;
}

/* 2. Enforce KaTeX fonts to prevent external font bleeding */
.katex .katex-html {
    font-family: 'KaTeX_Main', 'Times New Roman', serif !important;
}

/* 3. Handle overflow for block formulas */
.katex-display {
    overflow-x: auto !important;
    overflow-y: hidden;
    max-width: 100%;
    padding-bottom: 4px;
    /* Space for scrollbar */
}

/* Ensure scrollbar is styled nicely */
.katex-display::-webkit-scrollbar {
    height: 4px;
}

.katex-display::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}