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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 左侧目录 */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
}

.sidebar-header h2 {
    font-size: 18px;
    color: #333;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.file-item {
    padding: 10px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-item:hover {
    background: #e9ecef;
}

.file-item.active {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.file-item .file-info {
    display: flex;
    align-items: center;
    pointer-events: none;
}

.file-item .file-icon {
    margin-right: 8px;
    color: #666;
}

.file-item .file-name {
    color: #333;
    font-size: 14px;
}

.file-item .file-status {
    pointer-events: none;
}

.file-item .file-status {
    font-size: 10px;
    color: #999;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.file-item .file-status.modified {
    color: #e53935;
    background: #ffebee;
}

/* 右侧内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.content-header {
    padding: 15px 30px;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.content-header h1 {
    font-size: 20px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-primary:disabled {
    background: #bbdefb;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #388e3c;
}

/* 搜索框样式 */
.search-container {
    position: relative;
    flex-shrink: 0;
}

.search-input {
    width: 240px;
    padding: 8px 36px 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.search-input::placeholder {
    color: #999;
}

.search-nav {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: #666;
    font-size: 12px;
    border-radius: 3px;
    transition: background 0.2s;
}

.search-nav-btn:hover {
    background: #e9ecef;
}

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

.search-count {
    font-size: 12px;
    color: #666;
    margin-right: 4px;
    min-width: 50px;
    text-align: center;
}

/* 搜索高亮样式 */
.search-highlight {
    background: #fff59d;
    border-radius: 2px;
    padding: 0 2px;
}

.search-highlight.current {
    background: #ffeb3b;
    box-shadow: 0 0 0 2px #ffc107;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #fff;
}

/* 编辑器容器 - 左右分栏 */
.editor-container {
    display: none;
    height: 100%;
}

.editor-container.active {
    display: flex;
    flex-direction: column;
}

.editor-split {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-pane-left {
    border-right: 1px solid #dee2e6;
}

.pane-header {
    padding: 8px 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #dee2e6;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.editor-textarea {
    flex: 1;
    width: 100%;
    padding: 20px;
    border: none;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: #fafafa;
    overflow-y: auto;
    overflow-x: hidden;
}

.preview-pane {
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-pane .pane-header {
    flex-shrink: 0;
}

.preview-content {
    padding: 20px 30px;
    max-width: 100%;
    margin: 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

.editor-toolbar {
    padding: 10px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
    align-items: center;
}

.editor-toolbar .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Markdown 样式 */
.markdown-body {
    /*max-width: 900px;*/
    margin: 0 auto;
    line-height: 1.8;
    color: #333;
}

.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;
}

.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child {
    margin-top: 0;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: .3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: .3em;
}

.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }

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

.markdown-body code {
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27,31,35,.05);
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
}

.markdown-body blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: .25em solid #dfe2e5;
    margin-bottom: 16px;
}

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

.markdown-body li {
    margin-bottom: 4px;
}

.markdown-body a {
    color: #0366d6;
    text-decoration: none;
}

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

/* 图片延迟加载样式 */
.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #f5f5f5;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

/* 预览区默认隐藏图片 */
.preview-content.hide-images img {
    display: none;
}

.markdown-body img.lazy-image {
    min-height: 100px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.markdown-body img.lazy-image.loaded {
    background: transparent;
    animation: none;
}

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

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

.markdown-body table th,
.markdown-body table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.markdown-body table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.markdown-body hr {
    height: .25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

/* 加载状态 */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #e53935;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* 文件列表标题 */
.file-list-title {
    padding: 10px 20px;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 目录 TOC */
.toc-list {
    list-style: none;
    padding-left: 0;
}

.toc-list .toc-item {
    padding: 6px 20px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: color 0.2s;
}

.toc-list .toc-item:hover {
    color: #0366d6;
}

.toc-list .toc-item.h2 { padding-left: 30px; }
.toc-list .toc-item.h3 { padding-left: 40px; }
.toc-list .toc-item.h4 { padding-left: 50px; }

.toc-title {
    padding: 10px 20px;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 视图切换 */
.view-container {
    height: 100%;
}

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