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

/* 基础样式与颜色变量 */
:root {
    --primary-dark: #1e293b;
    --primary-sidebar-bg: #0f172a;
    --primary-sidebar-hover: #334155;
    --primary-sidebar-active: #3b82f6;
    --primary-text-light: #f1f5f9;
    --primary-text-muted: #cbd5e1;
    --content-bg: #f8fafc;
    --content-card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --transition-speed: 0.3s;
    --sidebar-width: 300px;
    --header-height: 64px;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--content-bg);
    color: #0f172a;
    overflow-x: hidden;
}

/* 布局容器 */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* 侧边栏导航 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary-sidebar-bg);
    color: var(--primary-text-light);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--transition-speed) cubic-bezier(0.2, 0.9, 0.4, 1.1);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #c084fc, #60a5fa);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--primary-text-muted);
    margin-top: 0.25rem;
}

/* 导航菜单 */
.nav-menu {
    flex: 1;
    padding: 0 0.5rem 1rem 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 0.75rem;
    color: var(--primary-text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--primary-sidebar-hover);
    color: white;
}

.nav-item.active {
    background-color: var(--primary-sidebar-active);
    color: white;
    box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}

.nav-icon {
    font-size: 1.35rem;
    width: 1.75rem;
    text-align: center;
}

.nav-text {
    font-size: 0.95rem;
}

/* 树形结构样式 */
.tree-node {
    margin-left: 0;
    list-style: none;
}

.tree-node-children {
    margin-left: 1.75rem;
    padding-left: 0;
    list-style: none;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.tree-node-children.collapsed {
    display: none;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    margin: 0.15rem 0;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-text-muted);
    transition: all 0.15s;
}

.tree-item:hover {
    background-color: var(--primary-sidebar-hover);
    color: white;
}

.tree-item.active-file {
    background-color: #2563eb;
    color: white;
}

.folder-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.folder-toggle span:first-child {
    font-size: 1rem;
    width: 1.25rem;
    display: inline-block;
}

.file-item {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
}

.file-item:hover {
    background-color: var(--primary-sidebar-hover);
}

.folder-icon, .file-icon {
    font-size: 1rem;
    width: 1.5rem;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--primary-text-muted);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(145deg, #64748b, #334155);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* 右侧主要内容区域 */
.main-content {
    flex: 1;
    width: 100%;
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
    background-color: var(--content-bg);
}

.top-bar {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    z-index: 999;
    gap: 1rem;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #1e293b;
}

.menu-toggle:hover {
    background-color: #eef2ff;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0f172a;
}

.content-pane {
    padding: 2rem 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeInUp 0.25s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.note-card {
    background: var(--content-card-bg);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.note-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #1e293b, #3b82f6);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.note-content {
    line-height: 1.7;
    color: #334155;
    font-size: 1rem;
    white-space: pre-wrap;
}

.note-meta {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: #64748b;
}

/* 按钮容器：上一篇/下一篇 */
.note-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
}

.nav-btn {
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover:not(:disabled) {
    background-color: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

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

.nav-btn.prev::before {
    content: "←";
    font-size: 1.1rem;
}

.nav-btn.next::after {
    content: "→";
    font-size: 1.1rem;
}

.empty-folder-message {
    color: #94a3b8;
    font-style: italic;
    padding: 0.5rem 0.75rem;
}

/* 桌面设备：侧边栏常驻 */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0) !important;
        position: sticky;
        top: 0;
        height: 100vh;
    }
    .menu-toggle {
        display: none;
    }
}

/* 移动/平板：滑动模式 + 遮罩 */
@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        z-index: 1100;
    }
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s;
    }
    .overlay.active {
        opacity: 1;
        visibility: visible;
    }
    .menu-toggle {
        display: flex;
    }
}

@media (max-width: 640px) {
    .content-pane {
        padding: 1.25rem;
    }
    .note-card {
        padding: 1.25rem;
    }
    .note-title {
        font-size: 1.4rem;
    }
}

::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: #e2e8f0;
}
::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}