:root {
    --primary-color: #7C4DFF;
    --primary-light: #B388FF;
    --primary-dark: #5E35B1;
    --success-color: #4CAF50;
    --danger-color: #FF5252;
    --background-color: #F5F7FA;
    --surface-color: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #606F7B;
    --border-color: #E2E8F0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background-color);
}

.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

.toolbar {
    background: var(--surface-color);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-color);
    color: white;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.2);
}

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

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 140px);
}

.editor-section, .preview-section {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* CodeMirror 自定义样式 */
.CodeMirror {
    height: 100% !important;
    font-family: "JetBrains Mono", monospace;
    font-size: 15px;
    line-height: 1.6;
    padding: 20px;
}

.cm-header {
    color: var(--primary-color) !important;
    font-weight: 600;
}

/* 预览区域样式 */
.preview-content {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
    font-size: 15px;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

.preview-content p {
    margin-bottom: 1em;
    line-height: 1.8;
}

/* LaTeX公式样式 */
.preview-content .katex-display {
    margin: 1.5em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5em 0;
}

.preview-content .katex {
    font-size: 1.1em;
}

.preview-content .katex-display > .katex {
    font-size: 1.21em;
}

.preview-content p .katex {
    margin: 0 0.2em;
}

/* 支持LaTeX公式换行和对齐 */
.preview-content .katex-display .katex-html {
    overflow-x: auto;
    overflow-y: hidden;
}

.preview-content .katex-display .align {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.preview-content .katex-display .align .align-row:not(:last-child) {
    margin-bottom: 0.5em;
}

.preview-content .katex-display .tag {
    position: relative;
}

/* 待办事项面板 */
.todo-panel {
    position: fixed;
    right: 24px;
    top: 24px;
    width: 360px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 20px;
    z-index: 1000;
    display: none;
    transform-origin: top right;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.95);
}

.todo-panel.show {
    opacity: 1;
    transform: scale(1);
    display: block;
}

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

.todo-header h3 {
    color: var(--primary-color);
    font-size: 18px;
}

.todo-input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.todo-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.todo-input:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.1);
}

.todo-list {
    max-height: 400px;
    overflow-y: auto;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #F8FAFC;
    transition: all 0.3s ease;
    cursor: move;
    user-select: none;
}

.todo-item:hover {
    background: #F1F5F9;
}

.todo-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    accent-color: var(--primary-color);
}

.todo-item.completed span {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.todo-item .delete-btn {
    margin-left: auto;
    color: var(--danger-color);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 4px 8px;
    border-radius: 4px;
}

.todo-item:hover .delete-btn {
    opacity: 1;
    background: rgba(255, 82, 82, 0.1);
}

.todo-item .delete-btn:hover {
    background: rgba(255, 82, 82, 0.2);
}

.todo-item.dragging {
    opacity: 0.5;
    background: #E2E8F0;
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.todo-item.drag-over {
    border-top: 2px solid var(--primary-color);
    margin-top: 10px;
}

/* 上传按钮样式 */
.upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-light);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-label:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.2);
}

.file-upload {
    display: none;
}

/* 自动保存提示样式 */
#autoSaveIndicator {
    background: rgba(44, 62, 80, 0.9) !important;
    backdrop-filter: blur(8px);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* 消息提示样式 */
.message {
    background: var(--primary-color) !important;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.2);
    border-radius: 8px;
    font-weight: 500;
}

.message-error {
    background: var(--danger-color) !important;
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.2);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* 代码折叠样式 */
.CodeMirror-foldgutter {
    width: 1.5em;
}

.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
    color: var(--text-secondary);
    cursor: pointer;
}

.CodeMirror-foldgutter-open:hover,
.CodeMirror-foldgutter-folded:hover {
    color: var(--primary-color);
}

.CodeMirror-foldgutter-open::after {
    content: "▾";
}

.CodeMirror-foldgutter-folded::after {
    content: "▸";
}

.CodeMirror-gutters {
    border-right: 1px solid var(--border-color);
    background: transparent;
}

.CodeMirror-foldmarker {
    color: var(--primary-color);
    text-shadow: none;
    font-family: inherit;
    line-height: .3;
    cursor: pointer;
    padding: 0 4px;
    background: rgba(124, 77, 255, 0.1);
    border-radius: 4px;
    margin: 0 4px;
}

.CodeMirror-foldmarker:hover {
    background: rgba(124, 77, 255, 0.2);
}

/* 工具提示样式 */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    margin-bottom: 8px;
    z-index: 1000;
}

[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    margin-bottom: -4px;
}

/* 帮助按钮样式 */
.help-btn, .settings-button {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.help-btn:hover, .settings-button:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.2);
}

.help-btn:active, .settings-button:active {
    transform: translateY(0);
}

/* 帮助面板样式 */
.help-panel {
    position: fixed;
    right: 24px;
    bottom: 70px;
    width: 400px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 20px;
    z-index: 1000;
    display: none;
    transform-origin: bottom right;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.95);
}

.help-panel.show {
    opacity: 1;
    transform: scale(1);
}

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

.help-header h3 {
    color: var(--primary-color);
    font-size: 18px;
}

.help-content {
    max-height: 70vh;
    overflow-y: auto;
}

.help-content section {
    margin-bottom: 24px;
}

.help-content h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 16px;
}

/* 快捷键表格样式 */
.shortcut-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.shortcut-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.shortcut-table td:first-child {
    font-family: "JetBrains Mono", monospace;
    color: var(--primary-color);
    width: 40%;
}

/* Markdown 帮助样式 */
.markdown-help {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
}

.markdown-help p {
    margin: 8px 0;
    color: var(--text-secondary);
}

/* 功能列表样式 */
.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 8px 0;
    position: relative;
    padding-left: 24px;
}

.feature-list li::before {
    content: "•";
    color: var(--primary-color);
    position: absolute;
    left: 8px;
    font-weight: bold;
}

/* 设置面板样式 */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 500px;
    opacity: 0;
    transition: all 0.3s ease;
}

.settings-panel.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.settings-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.settings-content th,
.settings-content td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.settings-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.shortcut-input {
    width: 150px;
    padding: 5px;
}

/* 图标容器样式 */
.icon-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1000;
}

/* 引用样式 */
.preview-content blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 4px solid var(--primary-color);
    background: rgba(124, 77, 255, 0.05);
    color: var(--text-secondary);
    border-radius: 0 4px 4px 0;
}

.preview-content blockquote p {
    margin: 0;
}

.preview-content blockquote blockquote {
    margin-left: 1em;
    border-left-color: var(--primary-light);
}

/* 全屏样式 */
.fullscreen, .fullscreen .editor-container {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 2000 !important;
    background: var(--background-color) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.fullscreen .editor-section, .fullscreen .preview-section {
    height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

body.fullscreen-mode {
    overflow: hidden;
}

/* 全屏下悬浮按钮区样式 */
.fullscreen-toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1100;
    background: var(--surface-color);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.fullscreen-toolbar button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.fullscreen-toolbar button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.2);
}

/* 全屏下隐藏/只显示预览的样式 */
.fullscreen.hide-preview .preview-section {
    display: none !important;
}

.fullscreen.hide-preview .editor-section {
    width: 100% !important;
    grid-column: 1 / span 2 !important;
}

.fullscreen.only-preview .editor-section {
    display: none !important;
}

.fullscreen.only-preview .preview-section {
    width: 100% !important;
    grid-column: 1 / span 2 !important;
}

/* 导出图片按钮样式 */
.fullscreen-toolbar button#exportImgBtn {
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(124,77,255,0.12);
}

.fullscreen-toolbar button#exportImgBtn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* vim 模式开关样式 */
.vim-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(124,77,255,0.2);
    transition: all 0.3s ease;
    display: block;
}

.vim-toggle.active {
    background: var(--success-color);
}

.vim-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124,77,255,0.3);
}

.fullscreen.hide-preview .vim-toggle {
    display: block;
}

.fullscreen.only-preview .vim-toggle {
    display: none;
}

/* 预览区域中待办项的样式 */
.preview-content .task-item {
    margin: 4px 0;
    padding: 4px 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    border-radius: 4px;
    list-style-type: none !important;
    position: relative;
    cursor: pointer;
}

.preview-content .task-item:hover {
    background-color: #f5f5f5;
}

/* 自定义复选框样式 */
.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    margin-right: 12px;
    position: relative;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.custom-checkbox:hover {
    background-color: rgba(124, 77, 255, 0.1);
}

.custom-checkbox.checked {
    background-color: var(--primary-color);
}

.custom-checkbox.checked .checkbox-inner {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
}

.task-text {
    flex: 1;
    margin-left: 8px;
    cursor: pointer;
}

.custom-checkbox.checked + .task-text {
    text-decoration: line-through;
    color: #888;
}

/* 修复预览区域中列表和待办项的样式 */
.preview-content ul {
    list-style-type: disc;
    padding-left: 20px;
    margin: 1em 0;
}

.preview-content ul li {
    margin: 0.5em 0;
}

.preview-content ul li.task-item {
    margin-left: -24px;
    padding-left: 24px;
}

/* 历史记录点容器 */
.history-dots {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin: 12px 0;
    min-height: 36px;
}

/* 历史记录点 */
.history-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--surface-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.history-dot:hover {
    transform: scale(1.2);
    border-color: var(--primary-light);
    background-color: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(124,77,255,0.1);
}

.history-dot:active {
    transform: scale(0.9);
}

.history-dot.active {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(124,77,255,0.2);
}

.history-dot::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.history-dot:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
} 