/*
 * Markdown编辑器主样式
 * 支持浅色/深色主题，响应式布局，现代简洁风格
 */
:root {
    /* 现代化配色方案 */
    --color-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --color-bg-solid: #f8fafc;
    --color-fg: #1e293b;
    --color-fg-secondary: #64748b;
    --color-toolbar: rgba(255, 255, 255, 0.95);
    --color-toolbar-border: rgba(148, 163, 184, 0.2);
    --color-statusbar: rgba(248, 250, 252, 0.95);
    --color-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --color-primary-solid: #667eea;
    --color-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --color-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --color-success: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --color-warning: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

    /* 阴影系统 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);

    /* 动画 */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* 边框半径 */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

[data-theme="dark"] {
    /* 深色主题现代化配色 */
    --color-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --color-bg-solid: #0f172a;
    --color-fg: #f1f5f9;
    --color-fg-secondary: #94a3b8;
    --color-toolbar: rgba(15, 23, 42, 0.95);
    --color-toolbar-border: rgba(71, 85, 105, 0.3);
    --color-statusbar: rgba(15, 23, 42, 0.95);
    --color-primary: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --color-primary-solid: #818cf8;
    --color-secondary: linear-gradient(135deg, #f472b6 0%, #fb7185 100%);
    --color-accent: linear-gradient(135deg, #06b6d4 0%, #67e8f9 100%);
    --color-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --color-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);

    --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.4);
}
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-fg);
    transition: all var(--transition-normal);
    font-feature-settings: 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 背景装饰元素 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 80%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(245, 87, 108, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    z-index: -1;
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(circle at 20% 80%, rgba(129, 140, 248, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(244, 114, 182, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(6, 182, 212, 0.15) 0%, transparent 50%);
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(120deg); }
    66% { transform: translate(-20px, 20px) rotate(240deg); }
}
.toolbar {
    display: flex;
    align-items: center;
    background: var(--color-toolbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--color-toolbar-border);
    padding: 0 1.5rem;
    height: 64px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: all var(--transition-normal);
    gap: 1.5rem;
    overflow-x: auto;
    position: relative;
}

.toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(102, 126, 234, 0.05) 50%,
        transparent 100%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.toolbar:hover::before {
    opacity: 1;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.toolbar-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent);
    transition: left var(--transition-fast);
}

.toolbar-group:hover::before {
    left: 100%;
}

[data-theme="dark"] .toolbar-group {
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid rgba(71, 85, 105, 0.3);
}

.toolbar-group:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-2px);
}

[data-theme="dark"] .toolbar-group:hover {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(129, 140, 248, 0.4);
}

.toolbar button {
    background: transparent;
    border: none;
    color: var(--color-fg);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: auto;
    position: relative;
    overflow: hidden;
}

.toolbar button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: -1;
}

.toolbar button:hover::before,
.toolbar button:focus::before {
    opacity: 1;
}

.toolbar button:hover,
.toolbar button:focus {
    color: white;
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.toolbar button:active {
    transform: translateY(-1px) scale(1);
    transition: transform 0.1s ease;
}

.toolbar i {
    font-size: 1rem;
    transition: transform var(--transition-fast);
}

.toolbar button:hover i {
    transform: scale(1.1);
}

/* 工具栏按钮特殊样式 */
.toolbar-group:first-child button {
    font-weight: 600;
    padding: 0.75rem 1.25rem;
}

.toolbar-group:first-child button::before {
    background: var(--color-success);
}

.toolbar-group:nth-child(2) button::before {
    background: var(--color-primary);
}

.toolbar-group:nth-child(3) button::before {
    background: var(--color-secondary);
}

.toolbar-group:last-child button::before {
    background: var(--color-accent);
}

.toolbar-group:not(:first-child):not(:last-child) button {
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
}

.toolbar-group:not(:first-child):not(:last-child) button i {
    margin: 0;
    font-size: 1.1rem;
}

/* 特殊按钮样式 */
#theme-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--radius-lg);
}

#theme-btn::before {
    display: none;
}

#theme-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] #theme-btn {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
}

[data-theme="dark"] #theme-btn:hover {
    background: linear-gradient(135deg, #c084fc 0%, #818cf8 100%);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(129, 140, 248, 0.5);
}
.editor-container {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    transition: all var(--transition-normal);
    gap: 1px;
    padding: 1rem;
    background: var(--color-bg-solid);
}

.editor-panel, .preview-panel {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.editor-panel {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-right: 0.5rem;
}

[data-theme="dark"] .editor-panel {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.3);
}

/* 编辑器包装容器 */
.editor-wrapper {
    display: flex;
    height: 100%;
    position: relative;
}

/* 行号容器样式 */
.line-numbers {
    background: rgba(248, 250, 252, 0.9);
    border-right: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--color-fg-secondary);
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Roboto Mono', 'Consolas', 'Menlo', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.8;
    padding: 2rem 0.75rem 2rem 1rem;
    text-align: right;
    user-select: none;
    white-space: pre;
    min-width: 3rem;
    max-width: 4rem;
    overflow: hidden;
    position: relative;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .line-numbers {
    background: rgba(15, 23, 42, 0.9);
    border-right-color: rgba(71, 85, 105, 0.4);
    color: var(--color-fg-secondary);
}

/* 行号悬停效果 */
.line-numbers:hover {
    background: rgba(248, 250, 252, 1);
    border-right-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .line-numbers:hover {
    background: rgba(15, 23, 42, 1);
    border-right-color: rgba(129, 140, 248, 0.4);
}

/* 行号滚动条隐藏 */
.line-numbers::-webkit-scrollbar {
    display: none;
}

.line-numbers {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 行号装饰效果 */
.line-numbers::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(102, 126, 234, 0.3) 50%,
        transparent 100%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.line-numbers:hover::before {
    opacity: 1;
}

[data-theme="dark"] .line-numbers::before {
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(129, 140, 248, 0.4) 50%,
        transparent 100%);
}

.preview-panel {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-left: 0.5rem;
}

[data-theme="dark"] .preview-panel {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.3);
}
#editor {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    padding: 2rem 2rem 2rem 1rem;
    font-size: 1rem;
    line-height: 1.8;
    background: transparent;
    color: var(--color-fg);
    outline: none;
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Roboto Mono', 'Consolas', 'Menlo', 'Monaco', monospace;
    transition: all var(--transition-normal);
    font-feature-settings: 'liga' 1, 'calt' 1;
    letter-spacing: 0.025em;
    overflow-y: auto;
    overflow-x: hidden;
}

#editor:focus {
    box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#editor::placeholder {
    color: var(--color-fg-secondary);
    opacity: 0.6;
}

.preview-panel {
    overflow: auto;
    padding: 2rem;
    position: relative;
}

.preview-panel::-webkit-scrollbar {
    width: 6px;
}

.preview-panel::-webkit-scrollbar-track {
    background: transparent;
}

.preview-panel::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.preview-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

.markdown-body {
    font-size: 1rem;
    line-height: 1.8;
    word-break: break-word;
    max-width: none;
    color: var(--color-fg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.statusbar {
    height: 48px;
    background: var(--color-statusbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--color-fg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-top: 1px solid var(--color-toolbar-border);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    gap: 2rem;
    position: relative;
}

.statusbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(102, 126, 234, 0.5) 50%,
        transparent 100%);
}

.statusbar span {
    white-space: nowrap;
    opacity: 0.7;
    transition: all var(--transition-fast);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    position: relative;
}

.statusbar span:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

#status-filename {
    font-weight: 600;
    opacity: 1;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(245, 87, 108, 0.1));
    border: 1px solid rgba(102, 126, 234, 0.2);
    color: var(--color-primary-solid);
}

[data-theme="dark"] #status-filename {
    color: var(--color-primary-solid);
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.15), rgba(244, 114, 182, 0.15));
    border-color: rgba(129, 140, 248, 0.3);
}
/* 响应式布局：移动端上下布局 */
@media (max-width: 1024px) {
    .editor-container {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .editor-panel {
        margin-right: 0;
        margin-bottom: 0.5rem;
        border-radius: var(--radius-lg);
    }

    .preview-panel {
        margin-left: 0;
        margin-top: 0.5rem;
        border-radius: var(--radius-lg);
    }

    #editor, .preview-panel {
        padding: 1.5rem;
    }

    /* 移动端行号优化 */
    .line-numbers {
        min-width: 2.5rem;
        max-width: 3rem;
        padding: 1.5rem 0.5rem 1.5rem 0.75rem;
        font-size: 0.8rem;
    }

    #editor {
        padding: 1.5rem 1.5rem 1.5rem 0.75rem;
    }
}

@media (max-width: 768px) {
    /* 移动端工具栏优化 */
    .toolbar {
        height: auto;
        min-height: 64px;
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.75rem;
    }

    .toolbar-group {
        flex-shrink: 0;
        padding: 0.375rem;
    }

    .toolbar-group:first-child,
    .toolbar-group:nth-child(2) {
        order: -1;
        width: 100%;
        justify-content: space-around;
        margin-bottom: 0.5rem;
    }

    .toolbar button {
        font-size: 0.8rem;
        padding: 0.625rem 0.875rem;
    }

    .toolbar-group:not(:first-child):not(:last-child) button {
        padding: 0.625rem;
        min-width: 40px;
        min-height: 40px;
    }

    .statusbar {
        padding: 0 1rem;
        gap: 1rem;
        flex-wrap: wrap;
        height: auto;
        min-height: 48px;
    }

    .statusbar span {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    #editor, .preview-panel {
        padding: 1rem;
        font-size: 0.9rem;
    }

    /* 小屏幕行号进一步优化 */
    .line-numbers {
        min-width: 2rem;
        max-width: 2.5rem;
        padding: 1rem 0.375rem 1rem 0.5rem;
        font-size: 0.75rem;
    }

    #editor {
        padding: 1rem 1rem 1rem 0.5rem;
        font-size: 0.9rem;
    }
}
/* 过渡动画 */
.editor-panel, .preview-panel, .toolbar, .statusbar {
    transition: background var(--transition), color var(--transition);
}
/* 代码块样式优化 */
.markdown-body pre code {
    font-size: 1em;
    border-radius: 4px;
    padding: 0.8em 1em;
    background: #222;
    color: #f5f5f5;
    overflow-x: auto;
}
[data-theme="dark"] .markdown-body pre code {
    background: #181c22;
    color: #e0e0e0;
}
/* 表格样式 */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}
.markdown-body th, .markdown-body td {
    border: 1px solid #ccc;
    padding: 0.5em 1em;
    text-align: left;
}
[data-theme="dark"] .markdown-body th, [data-theme="dark"] .markdown-body td {
    border-color: #444;
}
/* 引用块样式 */
.markdown-body blockquote {
    border-left: 4px solid var(--color-primary);
    background: rgba(0,0,0,0.03);
    margin: 1em 0;
    padding: 0.5em 1em;
    color: #555;
}
[data-theme="dark"] .markdown-body blockquote {
    background: rgba(255,255,255,0.03);
    color: #aaa;
}
/* 分割线样式 */
.markdown-body hr {
    border: none;
    border-top: 2px solid #eee;
    margin: 2em 0;
}
[data-theme="dark"] .markdown-body hr {
    border-top: 2px solid #444;
}

/* 全屏模式样式 */
.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: var(--color-bg) !important;
}

.fullscreen .toolbar {
    position: sticky;
    top: 0;
    z-index: 10000;
}

.fullscreen .editor-container {
    height: calc(100vh - 56px - 32px);
}

/* 任务列表样式 */
.markdown-body input[type="checkbox"] {
    margin-right: 0.5em;
    transform: scale(1.1);
}

.markdown-body .task-list-item {
    list-style: none;
    margin-left: -1.5em;
}

.markdown-body .task-list-item input[type="checkbox"] {
    margin-right: 0.5em;
}

/* 改进的表格样式 */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.markdown-body th {
    background: var(--color-primary);
    color: white;
    font-weight: 600;
    text-align: left;
}

.markdown-body th, .markdown-body td {
    border: 1px solid #ddd;
    padding: 0.75em 1em;
    text-align: left;
}

.markdown-body tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

.markdown-body tbody tr:hover {
    background: rgba(0,0,0,0.04);
}

[data-theme="dark"] .markdown-body th,
[data-theme="dark"] .markdown-body td {
    border-color: #444;
}

[data-theme="dark"] .markdown-body tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .markdown-body tbody tr:hover {
    background: rgba(255,255,255,0.04);
}

/* 高级动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.markdown-body {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.editor-panel {
    animation: slideInRight 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-panel {
    animation: slideInLeft 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation-delay: 0.1s;
    animation-fill-mode: both;
}

.toolbar-group {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

.toolbar-group:nth-child(1) { animation-delay: 0.1s; }
.toolbar-group:nth-child(2) { animation-delay: 0.2s; }
.toolbar-group:nth-child(3) { animation-delay: 0.3s; }
.toolbar-group:nth-child(4) { animation-delay: 0.4s; }

.statusbar span {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation-delay: 0.8s;
    animation-fill-mode: both;
}

/* 加载状态 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* 拖拽样式 */
.dragover {
    border: 2px dashed var(--color-primary) !important;
    background: rgba(0,120,215,0.05) !important;
}

/* 选中文本样式 - 增强可见性 */
::selection {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.4), rgba(245, 87, 108, 0.4));
    color: var(--color-fg);
    text-shadow: none;
    border-radius: 2px;
}

::-moz-selection {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.4), rgba(245, 87, 108, 0.4));
    color: var(--color-fg);
    text-shadow: none;
}

/* 编辑器中的选中文本样式 */
#editor::selection {
    background: rgba(102, 126, 234, 0.5);
    color: white;
}

#editor::-moz-selection {
    background: rgba(102, 126, 234, 0.5);
    color: white;
}

/* 全局滚动条样式 */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg,
        rgba(102, 126, 234, 0.6),
        rgba(245, 87, 108, 0.6));
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: all var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg,
        rgba(102, 126, 234, 0.8),
        rgba(245, 87, 108, 0.8));
    transform: scale(1.1);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg,
        rgba(129, 140, 248, 0.6),
        rgba(244, 114, 182, 0.6));
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg,
        rgba(129, 140, 248, 0.8),
        rgba(244, 114, 182, 0.8));
}

/* 代码块复制按钮 - 增强可见性 */
.markdown-body pre {
    position: relative;
}

.markdown-body pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(102, 126, 234, 0.8);
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    opacity: 0.7; /* 提高默认可见性 */
    transition: all var(--transition-fast);
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.copy-btn:hover {
    background: rgba(102, 126, 234, 1);
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* 右键上下文菜单 */
.context-menu {
    position: fixed;
    background: var(--color-toolbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--color-toolbar-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    min-width: 180px;
    padding: 0.5rem 0;
    animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: var(--color-fg);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.context-menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: -1;
}

.context-menu-item:hover::before {
    left: 0;
    opacity: 0.1;
}

.context-menu-item:hover {
    color: var(--color-primary-solid);
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(3px);
}

.context-menu-item i {
    width: 16px;
    text-align: center;
    opacity: 0.7;
}

.context-menu-item:hover i {
    opacity: 1;
    transform: scale(1.1);
}

.context-menu-separator {
    height: 1px;
    background: var(--color-toolbar-border);
    margin: 0.5rem 0;
    opacity: 0.5;
}

[data-theme="dark"] .context-menu {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(71, 85, 105, 0.3);
}

[data-theme="dark"] .context-menu-item:hover {
    background: rgba(129, 140, 248, 0.1);
    color: var(--color-primary-solid);
}

/* 现代化装饰元素 */
.editor-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-primary);
    z-index: 1;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.preview-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-secondary);
    z-index: 1;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* 焦点指示器 */
.editor-panel:focus-within {
    box-shadow: var(--shadow-xl), 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.preview-panel:hover {
    box-shadow: var(--shadow-xl), 0 0 0 3px rgba(245, 87, 108, 0.1);
    transform: translateY(-2px);
}

/* 加载动画 */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(102, 126, 234, 0.1);
    border-top: 3px solid var(--color-primary-solid);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 工具提示样式 */
[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out forwards;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(5px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 成功状态指示 */
.success-indicator {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--color-success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    animation: slideInFromRight 0.3s ease-out;
}

@keyframes slideInFromRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 错误状态指示 */
.error-indicator {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--color-warning);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes slideOutToRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* 主题切换过渡效果 */
* {
    transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* 性能优化 */
.toolbar-group,
.toolbar button,
.editor-panel,
.preview-panel {
    will-change: transform, opacity;
}

/* 数学公式样式 */
.math-inline {
    display: inline;
    margin: 0 2px;
}

.math-block {
    display: block;
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
    padding: 1rem;
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

[data-theme="dark"] .math-block {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(71, 85, 105, 0.3);
}

.math-block:hover {
    background: rgba(248, 250, 252, 1);
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .math-block:hover {
    background: rgba(15, 23, 42, 1);
    border-color: rgba(129, 140, 248, 0.4);
}

.math-error {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
}

/* 数学公式对话框样式 */
.math-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.math-dialog-content {
    background: var(--color-bg-solid);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: slideUp 0.3s ease-out;
}

[data-theme="dark"] .math-dialog-content {
    border-color: rgba(71, 85, 105, 0.3);
}

.math-dialog h3 {
    margin: 0 0 1.5rem 0;
    color: var(--color-fg);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.math-type-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(248, 250, 252, 0.5);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .math-type-selector {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(71, 85, 105, 0.3);
}

.math-type-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--color-fg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.math-type-btn.active {
    background: var(--color-primary-solid);
    color: white;
    box-shadow: var(--shadow-md);
}

.math-type-btn:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
    color: var(--color-primary-solid);
}

.math-examples h4 {
    margin: 0 0 1rem 0;
    color: var(--color-fg);
    font-size: 1rem;
    font-weight: 600;
}

.math-example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.math-example {
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(248, 250, 252, 0.5);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    color: var(--color-fg);
    text-align: center;
}

[data-theme="dark"] .math-example {
    border-color: rgba(71, 85, 105, 0.4);
    background: rgba(15, 23, 42, 0.5);
}

.math-example:hover {
    background: var(--color-primary-solid);
    color: white;
    border-color: var(--color-primary-solid);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.math-input-area {
    margin-bottom: 1.5rem;
}

.math-input-area label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-fg);
    font-weight: 500;
}

#math-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-md);
    background: rgba(248, 250, 252, 0.8);
    color: var(--color-fg);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
    transition: all var(--transition-normal);
}

[data-theme="dark"] #math-input {
    border-color: rgba(71, 85, 105, 0.4);
    background: rgba(15, 23, 42, 0.8);
}

#math-input:focus {
    outline: none;
    border-color: var(--color-primary-solid);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.math-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-md);
    text-align: center;
    min-height: 60px;
    display: none;
    transition: all var(--transition-normal);
}

[data-theme="dark"] .math-preview {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(71, 85, 105, 0.3);
}

.math-dialog-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.math-dialog-buttons button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-cancel {
    background: rgba(148, 163, 184, 0.2);
    color: var(--color-fg);
}

.btn-cancel:hover {
    background: rgba(148, 163, 184, 0.3);
    transform: translateY(-2px);
}

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

.btn-insert:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 减少动画在低性能设备上的影响 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}