/* ==================== 全局变量与重置 ==================== */

:root {
    /* 亮色主题颜色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #f0f2f5;
    --bg-hover: #e8eaed;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-tertiary: #8b949e;
    --border-color: #d0d7de;
    --border-hover: #a8b1ba;
    --accent-color: #0969da;
    --accent-hover: #0550ae;
    --accent-color-alpha: rgba(9, 105, 218, 0.2);
    --selection-bg: rgba(9, 105, 218, 0.25);
    --success-color: #1a7f37;
    --danger-color: #cf222e;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    
    /* 编辑器颜色 */
    --editor-bg: #ffffff;
    --editor-text: #24292f;
    --editor-line-number: #8b949e;
    
    /* 滚动条 */
    --scrollbar-track: #f6f8fa;
    --scrollbar-thumb: #d0d7de;
    --scrollbar-thumb-hover: #a8b1ba;
    
    /* 间距 */
    --toolbar-height: 56px;
    --statusbar-height: 32px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    
    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* 动画 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* 暗色主题 */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #262c36;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --border-color: #30363d;
    --border-hover: #484f58;
    --accent-color: #2f81f7;
    --accent-hover: #539bf5;
    --accent-color-alpha: rgba(47, 129, 247, 0.3);
    --selection-bg: rgba(47, 129, 247, 0.35);
    --success-color: #3fb950;
    --danger-color: #f85149;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    
    --editor-bg: #0d1117;
    --editor-text: #e6edf3;
    --editor-line-number: #6e7681;
    
    --scrollbar-track: #161b22;
    --scrollbar-thumb: #30363d;
    --scrollbar-thumb-hover: #484f58;
}

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* SVG 图标全局样式 */
svg {
    display: inline-block;
    vertical-align: middle;
}

svg.icon {
    color: currentColor;
    fill: currentColor;
    transition: all var(--transition-fast);
}

/* Logo 动画 - 酷炫悬浮 + 光效 */
.logo-icon {
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        filter: drop-shadow(0 2px 8px rgba(91, 134, 229, 0.3));
    }
    50% {
        transform: translateY(-3px) rotate(1deg);
        filter: drop-shadow(0 4px 16px rgba(91, 134, 229, 0.5));
    }
}

[data-theme="dark"] .logo-icon {
    animation: logoFloatDark 4s ease-in-out infinite;
}

@keyframes logoFloatDark {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        filter: drop-shadow(0 2px 12px rgba(102, 126, 234, 0.5));
    }
    50% {
        transform: translateY(-3px) rotate(1deg);
        filter: drop-shadow(0 4px 20px rgba(102, 126, 234, 0.8));
    }
}

/* Logo 悬停效果 */
.logo:hover .logo-icon {
    animation: logoSpin 0.6s ease;
}

@keyframes logoSpin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* 工具栏按钮图标悬停效果 */
.toolbar-btn:hover svg.icon {
    transform: scale(1.1);
}

.toolbar-btn:active svg.icon {
    transform: scale(0.95);
}

/* 主题切换按钮 - 超酷动画 */
#themeBtn {
    position: relative;
    overflow: visible;
}

#themeBtn svg.icon {
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#themeBtn:hover svg.icon {
    transform: rotate(180deg) scale(1.2);
}

#themeBtn:active svg.icon {
    transform: rotate(360deg) scale(1);
}

[data-theme="dark"] #themeBtn svg.icon {
    filter: drop-shadow(0 0 10px rgba(255, 193, 7, 0.6));
    color: #FDD835;
}

[data-theme="light"] #themeBtn svg.icon {
    filter: drop-shadow(0 0 8px rgba(63, 81, 181, 0.4));
    color: #5C6BC0;
}

/* 主题切换按钮光环效果 */
#themeBtn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    transition: all 0.5s ease;
}

#themeBtn:hover::after {
    opacity: 0.1;
    transform: translate(-50%, -50%) scale(1.5);
}

/* 布局切换按钮 - 3D 翻转效果 */
#layoutBtn svg.icon {
    transition: all 0.4s ease;
}

#layoutBtn:hover svg.icon {
    transform: rotateY(180deg) scale(1.15);
}

/* 图表按钮 - 脉冲效果 */
#mermaidBtn {
    position: relative;
}

#mermaidBtn svg.icon {
    transition: all 0.3s ease;
}

#mermaidBtn:hover svg.icon {
    animation: chartPulse 1s ease infinite;
    color: #36D1DC;
}

@keyframes chartPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

/* Markdown 格式化按钮 - 统一色彩提示 */
#boldBtn:hover svg.icon { color: #E91E63; }
#italicBtn:hover svg.icon { color: #9C27B0; }
#headingBtn:hover svg.icon { color: #3F51B5; }
#linkBtn:hover svg.icon { color: #2196F3; }
#imageBtn:hover svg.icon { color: #00BCD4; }
#codeBtn:hover svg.icon { color: #009688; }
#tableBtn:hover svg.icon { color: #4CAF50; }

/* Mermaid 导出按钮图标 */
.mermaid-export-btn:hover svg.icon {
    transform: translateY(-2px);
}

/* 图标渐变效果（高级设计）*/
.toolbar-btn:hover svg.icon use {
    animation: iconPulse 0.6s ease;
}

@keyframes iconPulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* 保存按钮特殊效果 - 更酷炫 */
#saveBtn {
    position: relative;
    overflow: hidden;
}

#saveBtn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.3;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#saveBtn:hover::before {
    width: 200%;
    height: 200%;
}

#saveBtn:hover svg.icon {
    animation: saveBounce 0.5s ease;
}

@keyframes saveBounce {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.15) rotate(-5deg);
    }
    75% {
        transform: scale(1.15) rotate(5deg);
    }
}

/* 文件操作按钮组 - 高级渐变效果 */
#newBtn,
#openBtn,
#saveBtn {
    position: relative;
    overflow: hidden;
}

#newBtn:hover,
#openBtn:hover,
#saveBtn:hover {
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-tertiary) 100%);
    box-shadow: 0 2px 8px rgba(91, 134, 229, 0.15);
}

#newBtn:hover svg.icon {
    color: #36D1DC;
}

#openBtn:hover svg.icon {
    color: #5B86E5;
}

#saveBtn:hover svg.icon {
    color: #4CAF50;
}

/* Mermaid 导出按钮渐变效果 */
.mermaid-export-btn:hover {
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-tertiary) 100%);
    border-color: var(--accent-color);
}

.mermaid-export-btn[data-format="svg"]:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.mermaid-export-btn[data-format="png"]:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
}

/* ==================== KaTeX 数学公式样式 ==================== */

/* 行内公式 */
.katex {
    font-size: 1.05em;
    color: var(--text-primary);
}

/* 块级公式容器 */
.katex-block {
    margin: 1.5em 0;
    padding: 0;
    text-align: center;
}

/* 块级公式 */
.katex-display {
    margin: 0 !important;
    padding: 1.2em;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
    overflow-x: auto;
    text-align: center;
}

/* 暗色主题优化 */
[data-theme="dark"] .katex {
    color: var(--text-primary);
}

[data-theme="dark"] .katex-display {
    background: var(--bg-tertiary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 错误显示 */
.katex-error {
    color: #ef5350 !important;
    background: rgba(239, 83, 80, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

/* 公式滚动条美化 */
.katex-display::-webkit-scrollbar {
    height: 8px;
}

.katex-display::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.katex-display::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

.katex-display::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 数学公式按钮特殊效果 */
#mathBtn:hover svg.icon {
    color: #FF6B6B;
    animation: formulaShake 0.5s ease;
}

@keyframes formulaShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ==================== 工具栏样式 ==================== */

.toolbar {
    height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    gap: var(--spacing-sm);
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: 200;
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .toolbar {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: nowrap;
    min-width: 0;
}

/* 确保工具栏右侧有足够空间，不被GitHub角标遮挡 */
.toolbar-right {
    padding-right: 50px; /* 为GitHub角标留出空间 */
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    margin-right: var(--spacing-sm);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all var(--transition-normal);
}

.logo:hover {
    background: var(--bg-hover);
}

.logo span {
    background: linear-gradient(135deg, #5B86E5 0%, #36D1DC 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.5px;
}

[data-theme="dark"] .logo span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    --logo-from: #5B86E5;
    --logo-to: #36D1DC;
    filter: drop-shadow(0 2px 8px rgba(91, 134, 229, 0.3));
}

[data-theme="dark"] .logo-icon {
    --logo-from: #667eea;
    --logo-to: #764ba2;
    filter: drop-shadow(0 2px 12px rgba(102, 126, 234, 0.5));
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.toolbar-btn:active {
    transform: scale(0.98);
}

.toolbar-btn .icon,
.toolbar-btn svg.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toolbar-btn svg.icon {
    --icon-bg: var(--bg-primary);
}

.toolbar-btn .text {
    font-size: 13px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs);
}

/* 下拉菜单 */
.dropdown {
    position: relative;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xs);
    display: none;
    z-index: 9999;
    animation: dropdownFadeIn var(--transition-fast);
}

/* 增加下拉菜单的悬停区域，防止鼠标移动时意外关闭 */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.dropdown-right {
    left: auto;
    right: 0;
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
    display: block;
}

.dropdown-item {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-family);
    transition: background var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
}

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

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

/* ==================== 主内容区 ==================== */

.main-content {
    height: calc(100vh - var(--toolbar-height) - var(--statusbar-height));
    display: flex;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* 编辑器容器 */
.editor-container {
    flex: 1;
    min-width: 0;
    background: var(--editor-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: flex var(--transition-normal);
    position: relative;
}

/* 编辑器容器右侧拖拽区域 */
.editor-container::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 10;
    background: transparent;
    transition: background var(--transition-fast);
}

.editor-container:hover::after {
    background: rgba(9, 105, 218, 0.1);
}

[data-theme="dark"] .editor-container:hover::after {
    background: rgba(47, 129, 247, 0.2);
}

.editor-container.dragging::after {
    background: var(--accent-color);
    cursor: col-resize;
}

.editor {
    flex: 1;
    width: 100%;
    padding: var(--spacing-lg);
    background: var(--editor-bg);
    color: var(--editor-text);
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    overflow-y: auto;
    tab-size: 2;
}

.editor::placeholder {
    color: var(--text-tertiary);
}

/* 预览容器 */
.preview-container {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    overflow-y: auto;
    transition: flex var(--transition-normal);
}

.preview {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    min-height: 100%;
}

/* 布局模式 */
body.layout-editor-only .preview-container {
    display: none;
}

body.layout-editor-only .editor-container {
    border-right: none;
}

body.layout-preview-only .editor-container {
    display: none;
}

body.layout-vertical .main-content {
    flex-direction: column;
}

body.layout-vertical .editor-container {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
}

/* ==================== Markdown 预览样式 ==================== */

.markdown-body {
    color: var(--text-primary);
    line-height: 1.6;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    scroll-margin-top: var(--spacing-lg);
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body h5 { font-size: 0.875em; }
.markdown-body h6 { font-size: 0.85em; color: var(--text-secondary); }

.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-body a {
    color: var(--accent-color);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body strong {
    font-weight: 600;
}

.markdown-body em {
    font-style: italic;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-family: var(--font-mono);
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 100%;
    border-radius: 0;
}

.markdown-body blockquote {
    margin: 0 0 16px 0;
    padding: 0 1em;
    color: var(--text-secondary);
    border-left: 4px solid var(--border-color);
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 2em;
    margin-bottom: 16px;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body li > p {
    margin-bottom: 0.5em;
}

.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
    overflow: auto;
}

.markdown-body table th,
.markdown-body table td {
    padding: 6px 13px;
    border: 1px solid var(--border-color);
}

.markdown-body table th {
    font-weight: 600;
    background: var(--bg-secondary);
}

.markdown-body table tr {
    background: var(--bg-primary);
}

.markdown-body table tr:nth-child(2n) {
    background: var(--bg-secondary);
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.markdown-body hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: var(--border-color);
    border: 0;
}

/* 任务列表 */
.markdown-body input[type="checkbox"] {
    margin-right: 0.5em;
}

/* Mermaid 图表容器 */
.mermaid {
    text-align: center;
    margin: 24px 0;
    padding: 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    position: relative;
}

/* Mermaid 包装器 */
.mermaid-wrapper {
    position: relative;
}

/* Mermaid 内容区 */
.mermaid-content {
    padding: 16px;
}

/* Mermaid 导出工具栏 */
.mermaid-export-toolbar {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    padding: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 0 0 8px 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.mermaid:hover .mermaid-export-toolbar,
.mermaid-export-toolbar:hover {
    opacity: 1;
}

/* Mermaid 导出按钮 */
.mermaid-export-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mermaid-export-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.mermaid-export-btn .icon,
.mermaid-export-btn svg.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mermaid-export-btn .text {
    font-weight: 500;
}

/* Mermaid 错误提示 */
.mermaid-error {
    padding: 16px;
    background: rgba(207, 34, 46, 0.1);
    border: 1px solid var(--danger-color);
    border-radius: 6px;
    color: var(--danger-color);
    margin: 16px 0;
}

.mermaid-error-title {
    font-weight: 600;
    margin-bottom: 8px;
}

/* ==================== 状态栏 ==================== */

.statusbar {
    height: var(--statusbar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.statusbar-left,
.statusbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.statusbar-divider {
    color: var(--border-color);
}

/* ==================== 滚动条美化 ==================== */

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Firefox 滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ==================== 响应式设计 ==================== */

@media (max-width: 768px) {
    .toolbar {
        padding: 0 var(--spacing-sm);
    }
    
    .toolbar-btn .text {
        display: none;
    }
    
    .toolbar-divider {
        display: none;
    }
    
    .logo {
        font-size: 16px;
    }
    
    /* 移动端默认单栏布局 */
    .main-content {
        flex-direction: column;
    }
    
    .editor-container,
    .preview-container {
        height: 50vh;
        border-right: none;
    }
    
    .editor-container {
        border-bottom: 1px solid var(--border-color);
    }
    
    body.layout-editor-only .editor-container,
    body.layout-preview-only .preview-container {
        height: 100%;
    }
    
    .editor,
    .preview {
        padding: var(--spacing-md);
    }
    
    /* 移动端 Mermaid 导出工具栏始终显示 */
    .mermaid-export-toolbar {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .statusbar-right span:not(#charCount):not(#readTime) {
        display: none;
    }
    
    .statusbar-divider {
        display: none;
    }
}

/* ==================== 打印样式 ==================== */

@media print {
    .toolbar,
    .editor-container,
    .statusbar {
        display: none !important;
    }
    
    .main-content {
        display: block;
        height: auto;
    }
    
    .preview-container {
        border: none;
        overflow: visible;
    }
    
    .preview {
        max-width: 100%;
        padding: 0;
    }
}

/* ==================== 加载动画 ==================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==================== 辅助类 ==================== */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==================== 草稿恢复对话框 ==================== */

.draft-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.draft-dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.draft-dialog-content {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-lg);
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

.draft-dialog-content h3 {
    margin: 0 0 var(--spacing-md) 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.draft-dialog-content p {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.draft-dialog-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.draft-dialog-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.draft-dialog-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.draft-dialog-buttons {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

.draft-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

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

.draft-btn-secondary:hover {
    background: var(--bg-hover);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==================== 选择文本样式 ==================== */

::selection {
    background: var(--accent-color);
    color: white;
}

::-moz-selection {
    background: var(--accent-color);
    color: white;
}

/* ==================== Ace Editor 编辑器样式 ==================== */

/* 编辑器容器 */
.editor {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-size: 15px;
}

/* Ace Editor 自定义样式 */
.ace_editor {
    font-family: var(--font-mono) !important;
    line-height: 1.8 !important;
}

.ace_gutter {
    background: var(--bg-secondary) !important;
    color: var(--text-tertiary) !important;
    border-right: 1px solid var(--border-color) !important;
}

.ace_gutter-active-line {
    background: var(--bg-hover) !important;
}

.ace_cursor {
    color: var(--accent-color) !important;
}

/* 选中文本高亮 - 确保明显可见 */
.ace_marker-layer .ace_selection {
    background: var(--selection-bg) !important;
    border-radius: 2px;
}

/* 聚焦时的选中文本 */
.ace_editor.ace_focus .ace_marker-layer .ace_selection {
    background: var(--selection-bg) !important;
}

.ace_marker-layer .ace_active-line {
    background: var(--bg-hover) !important;
}

/* 暗色主题覆盖 */
[data-theme="dark"] .ace_gutter {
    background: rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .ace_gutter-active-line {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* ==================== Mermaid 全屏查看器 ==================== */

.mermaid-fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mermaid-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.mermaid-viewer-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.mermaid-viewer-controls {
    display: flex;
    gap: var(--spacing-xs);
}

.mermaid-viewer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mermaid-viewer-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
}

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

.mermaid-viewer-btn .icon {
    width: 18px;
    height: 18px;
}

.mermaid-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.mermaid-viewer-svg-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    cursor: grab;
}

.mermaid-viewer-svg-container:active {
    cursor: grabbing;
}

.mermaid-viewer-svg-wrapper {
    display: inline-block;
    position: absolute;
    will-change: transform;
    transition: transform 0.1s ease-out;
}

.mermaid-viewer-svg-wrapper svg {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

.mermaid-viewer-footer {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    flex-shrink: 0;
}

.mermaid-viewer-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 当查看器激活时，隐藏其他内容 */
body.mermaid-viewer-active > *:not(.mermaid-fullscreen-viewer) {
    visibility: hidden;
}

body.mermaid-viewer-active .mermaid-fullscreen-viewer {
    visibility: visible;
}

/* ==================== GitHub 角标 ==================== */

.github-corner {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 201;
    width: 80px;
    height: 80px;
    overflow: hidden;
    pointer-events: auto;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.github-corner:hover {
    transform: scale(1.05);
}

.github-corner svg {
    display: block;
    pointer-events: none;
    position: absolute;
    top: 10px;
    right: 10px;
    border: 0;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

/* 亮色主题：使用渐变蓝色 */
.github-corner-bg {
    fill: url(#githubGradient);
}

/* 暗色主题：使用更亮的颜色 */
[data-theme="dark"] .github-corner-bg {
    fill: url(#githubGradient);
    opacity: 0.95;
}

[data-theme="dark"] .github-corner svg {
    filter: drop-shadow(0 2px 12px rgba(91, 134, 229, 0.4));
}

.github-corner:hover svg {
    filter: drop-shadow(0 4px 16px rgba(91, 134, 229, 0.5));
}

[data-theme="dark"] .github-corner:hover svg {
    filter: drop-shadow(0 4px 20px rgba(91, 134, 229, 0.6));
}

.github-corner .octo-arm {
    transform-origin: 130px 106px;
}

.github-corner:hover .octo-arm {
    animation: octocat-wave 560ms ease-in-out;
}

@keyframes octocat-wave {
    0%, 100% {
        transform: rotate(0);
    }
    20%, 60% {
        transform: rotate(-25deg);
    }
    40%, 80% {
        transform: rotate(10deg);
    }
}

/* 响应式：移动端缩小角标 */
@media (max-width: 768px) {
    .github-corner {
        width: 60px;
        height: 60px;
    }
    
    .github-corner svg {
        width: 60px;
        height: 60px;
    }
    
    /* 移动端工具栏右侧padding调整 */
    .toolbar-right {
        padding-right: 30px;
    }
}

/* 打印时隐藏 */
@media print {
    .github-corner {
        display: none !important;
    }
}

