:root {
    /* 莫兰迪色系 - 默认亮色 */
    --primary: #7a9e9f;       /* 灰绿 */
    --secondary: #b8c4c2;     /* 浅灰绿 */
    --bg-color: #f7f9f9;      /* 极浅灰蓝背景 */
    --surface: #ffffff;       /* 纯白表面 */
    --text-main: #4a5568;     /* 深灰文本 */
    --text-light: #a0aec0;    /* 浅灰文本 */
    --border: #e2e8f0;
    --radius: 8px;
}

/* 深色模式变量 */
[data-theme="dark"] {
    --bg-color: #1a202c;
    --surface: #2d3748;
    --text-main: #e2e8f0;
    --text-light: #a0aec0;
    --border: #4a5568;
}

[data-theme="dark"] .markdown-body pre {
    background: #2d3748;
    border-color: #4a5568;
}

[data-theme="dark"] .markdown-body pre code {
    color: #e2e8f0;
}

[data-theme="dark"] .markdown-body table {
    background: #2d3748;
}

[data-theme="dark"] .markdown-body th {
    background: rgba(122, 158, 159, 0.2);
}

[data-theme="dark"] .markdown-body tr:hover {
    background: rgba(122, 158, 159, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a202c;
        --surface: #2d3748;
        --text-main: #e2e8f0;
        --text-light: #a0aec0;
        --border: #4a5568;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: var(--bg-color); color: var(--text-main); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }

/* 布局 */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 300px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.main-content { flex: 1; overflow-y: auto; padding: 2rem; position: relative; }

/* 侧边栏组件样式 */
.sidebar-header {
    padding: 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
}

.controls {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.controls label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.controls select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    font-size: 0.9rem;
}

/* 导航容器 */
#nav-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* 树状视图样式 */
.tree-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.tree-item:hover {
    background-color: var(--border);
}

.tree-item.file-icon {
    color: var(--text-light);
}

.tree-item.folder-icon {
    font-weight: 500;
}

.tree-item.folder-open {
    background-color: var(--border);
}

/* 文件管理器样式 */
.explorer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.explorer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
}

.explorer-item:hover {
    background-color: var(--border);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.explorer-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* 面包屑导航 */
.breadcrumb {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-light);
}

.breadcrumb span {
    cursor: pointer;
    color: var(--primary);
}

.breadcrumb span:hover {
    text-decoration: underline;
}

/* 内容区域样式 */
.markdown-body {
    max-width: none;
    padding: 2rem;
    line-height: 1.7;
    font-size: 16px;
    color: var(--text-main);
}

/* Markdown 标题样式 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.4;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.markdown-body h1 {
    font-size: 2.5rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

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

.markdown-body h3 {
    font-size: 1.5rem;
}

.markdown-body h4 {
    font-size: 1.25rem;
}

.markdown-body h5 {
    font-size: 1.125rem;
}

.markdown-body h6 {
    font-size: 1rem;
    color: var(--text-light);
}

/* 段落和文本 */
.markdown-body p {
    margin: 1rem 0;
    line-height: 1.7;
}

.markdown-body strong {
    font-weight: 600;
    color: var(--text-main);
}

.markdown-body em {
    font-style: italic;
    color: var(--text-main);
}

/* 链接样式 */
.markdown-body a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.markdown-body a:hover {
    border-bottom-color: var(--primary);
    background: rgba(122, 158, 159, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* 列表样式 */
.markdown-body ul,
.markdown-body ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.markdown-body li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.markdown-body ul li {
    list-style-type: disc;
}

.markdown-body ol li {
    list-style-type: decimal;
}

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

/* 引用块样式 */
.markdown-body blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--primary);
    background: rgba(122, 158, 159, 0.05);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-light);
    font-style: italic;
}

.markdown-body blockquote p {
    margin: 0.5rem 0;
}

/* 代码样式 */
.markdown-body code {
    background: rgba(122, 158, 159, 0.1);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
    font-weight: 500;
}

.markdown-body pre {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    line-height: 1.5;
}

.markdown-body pre code {
    background: none;
    color: #333;
    padding: 0;
    font-size: 0.9rem;
}

/* 表格样式 */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.markdown-body th,
.markdown-body td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.markdown-body th {
    background: rgba(122, 158, 159, 0.1);
    font-weight: 600;
    color: var(--text-main);
}

.markdown-body tr:hover {
    background: rgba(122, 158, 159, 0.05);
}

.markdown-body tr:last-child td {
    border-bottom: none;
}

/* 分隔线样式 */
.markdown-body hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 2rem 0;
}

/* 图片样式 */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 1rem 0;
    transition: transform 0.3s ease;
}

.markdown-body img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.placeholder {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    padding: 4rem 2rem;
}

.loading {
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
    padding: 2rem;
}

.error {
    text-align: center;
    color: #e74c3c;
    font-size: 1rem;
    padding: 2rem;
    background: #fdf2f2;
    border: 1px solid #f5c6cb;
    border-radius: var(--radius);
}

@media (max-width: 768px) {
    #app { flex-direction: column; }
    .sidebar { 
        width: 100%; 
        height: auto; 
        max-height: 40vh; 
        border-bottom: 1px solid var(--border); 
        border-right: none; 
    }
    .main-content { 
        height: 60vh; 
        padding: 1rem;
    }
    .sidebar-header {
        padding: 1rem;
        font-size: 1.1rem;
    }
    .controls {
        padding: 0.75rem;
    }
    .explorer-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    .markdown-body {
        padding: 1rem;
    }
}