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

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --bg-color: #f5f5f5;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --editor-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 工具栏 */
.toolbar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 100;
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 保存状态 */
.save-status-container {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.save-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s;
}

.save-status.idle {
    opacity: 0;
}

.save-status.saving {
    color: #4a90e2;
    background: #e8f4fd;
}

.save-status.saved {
    color: #50c878;
    background: #e8f8f0;
}

.save-status.error {
    color: #e74c3c;
    background: #fde8e8;
}

.save-status i {
    font-size: 12px;
}

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: #f0f0f0;
    border-color: var(--primary-color);
}

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

.btn-primary:hover {
    background: #357abd;
}

.btn-icon {
    padding: 8px 12px;
    min-width: 36px;
    justify-content: center;
}

.btn-icon.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.view-toggle {
    display: flex;
    gap: 5px;
}

/* 主内容区 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-actions {
    display: flex;
    gap: 5px;
}

.sidebar-actions .btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 8px;
}

.sidebar-actions .btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.outline-container, .mindmap-container {
    flex: 1;
    overflow: auto;
    padding: 10px;
}

.mindmap-container {
    background: white;
}

.mindmap-container.hidden {
    display: none;
}

.book-browser {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.book-browser-header h3 {
    font-size: 15px;
}

.book-browser-search input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
}

.book-browser-search input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.book-browser-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.book-file-list {
    max-height: 200px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.book-file-item {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.book-file-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.book-file-icon {
    width: 26px;
    text-align: center;
    font-size: 16px;
}

.book-file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.book-file-name {
    font-size: 13px;
    color: #fff;
}

.book-file-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.book-empty {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 20px 0;
}

.outline-tree {
    list-style: none;
}

.outline-node {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s;
}

.outline-node:hover {
    background: var(--sidebar-hover);
}

.outline-node.active {
    background: var(--primary-color);
}

.outline-node-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.outline-node-icon {
    width: 16px;
    text-align: center;
    cursor: pointer;
}

.outline-node-icon.has-children {
    cursor: pointer;
}

.outline-node-title {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.outline-node-title.editing {
    background: rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.4);
    white-space: normal;
    outline: none;
}

.outline-node-actions {
    display: none;
    gap: 4px;
}

.outline-node:hover .outline-node-actions {
    display: flex;
}

.outline-node-actions .btn {
    padding: 2px 6px;
    font-size: 12px;
    background: transparent;
    border: none;
    color: white;
}

.outline-node-children {
    margin-left: 24px;
    display: none;
}

.outline-node.expanded .outline-node-children {
    display: block;
}

.outline-node.dragging {
    opacity: 0.5;
}

.outline-node.drag-over {
    border-top: 2px solid var(--primary-color);
}

/* 编辑区 */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--editor-bg);
    overflow: hidden;
}

.editor-toolbar {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    flex-wrap: wrap;
    gap: 10px;
}

.editor-toolbar-left, .editor-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.font-size-select, .font-family-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.editor-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.markdown-editor {
    width: 100%;
    height: 100%;
    padding: 20px;
    border: none;
    outline: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    background: var(--editor-bg);
    color: var(--text-color);
}

.markdown-editor.hidden {
    display: none;
}

.markdown-preview {
    padding: 30px 40px;
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 16px;
}

.markdown-preview.hidden {
    display: none;
}

.snapshot-panel {
    border-top: 1px solid var(--border-color);
    background: #fff;
    padding: 12px 16px;
    max-height: 200px;
    overflow: auto;
}

.snapshot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
}

.snapshot-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.snapshot-toggle {
    border: none;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.snapshot-actions {
    display: flex;
    gap: 6px;
}

.snapshot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.snapshot-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.snapshot-item:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.08);
}

.snapshot-title {
    font-size: 14px;
    font-weight: 500;
}

.snapshot-meta {
    font-size: 12px;
    color: var(--text-light);
}

.snapshot-empty {
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
}

.snapshot-panel.collapsed {
    max-height: 52px;
    overflow: hidden;
}

.snapshot-panel.collapsed .snapshot-actions,
.snapshot-panel.collapsed .snapshot-list {
    display: none;
}

.snapshot-panel.collapsed .snapshot-toggle i {
    transform: rotate(-90deg);
}
/* Markdown 预览样式 */
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

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

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

.markdown-preview h3 {
    font-size: 1.25em;
}

.markdown-preview p {
    margin-bottom: 16px;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 16px;
    padding-left: 30px;
}

.markdown-preview li {
    margin-bottom: 8px;
}

.markdown-preview code {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.markdown-preview pre {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-light);
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 16px 0;
}

.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}

.markdown-preview table th,
.markdown-preview table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.markdown-preview table th {
    background: #f4f4f4;
    font-weight: 600;
}

.markdown-preview a {
    color: var(--primary-color);
    text-decoration: none;
}

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

/* 脑图样式 */
#mindmapSvg {
    width: 100%;
    height: 100%;
}

.mindmap-node {
    cursor: pointer;
}

.mindmap-node circle {
    fill: var(--primary-color);
    stroke: white;
    stroke-width: 2px;
}

.mindmap-node text {
    font-size: 14px;
    fill: white;
    text-anchor: middle;
    pointer-events: none;
}

.mindmap-link {
    fill: none;
    stroke: #999;
    stroke-width: 2px;
}

.mindmap-node.active circle {
    fill: var(--secondary-color);
}

/* 拖拽相关 */
.drag-ghost {
    opacity: 0.5;
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .editor-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 全屏模式 */
.editor-area.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}


