* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: #333;
}

/* 布局容器 */
.layout {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 360px;
    background: #ffffff;
    border-right: 1px solid #f3f4f6;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    padding: 24px 0;
    scroll-behavior: smooth;
}

.sidebar-header {
    padding: 0 24px 16px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 16px;
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 13px;
    color: #6b7280;
}

.sidebar-nav {
    padding: 0 16px;
}

.nav-item {
    display: block;
    padding: 10px 15px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.nav-item.active {
    background: #f3f4f6;
    color: #111827;
    border-left-color: #111827;
}

/* 树状导航结构 */
.nav-tree-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-tree-item {
    margin-bottom: 2px;
}

.nav-tree-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.nav-tree-toggle {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 10px;
    border-radius: 3px;
    transition: background-color 0.2s, transform 0.2s;
    padding: 0;
}

.nav-tree-toggle:hover {
    background: #f3f4f6;
}

.nav-tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.nav-tree-icon {
    width: 20px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.nav-tree-link {
    flex: 1;
    padding: 8px 10px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.nav-tree-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.nav-tree-link.active {
    background: #f3f4f6;
    color: #111827;
    font-weight: 500;
}

/* 父文档标题样式 */
.nav-tree-title {
    flex: 1;
    padding: 8px 10px;
    color: #111827;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    cursor: pointer;
    user-select: none;
}

.nav-tree-title:hover {
    background: #f3f4f6;
}

.nav-tree-children {
    padding-left: 26px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    max-height: 5000px;
    opacity: 1;
}

.nav-tree-children:not(.expanded) {
    max-height: 0;
    opacity: 0;
}

.nav-tree-children.collapsed {
    max-height: 0;
    opacity: 0;
}

/* 不同层级的样式 */
.nav-tree-item.level-0 > .nav-tree-header .nav-tree-link {
    font-size: 14px;
}

.nav-tree-item.level-1 > .nav-tree-header .nav-tree-link {
    font-size: 13px;
}

.nav-tree-item.level-2 > .nav-tree-header .nav-tree-link {
    font-size: 13px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 360px;
    padding: 40px 60px;
    max-width: 100%;
    display: flex;
    gap: 0;
}

.content-wrapper {
    display: flex;
    gap: 40px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.doc-article {
    flex: 1;
    min-width: 0;
    max-width: 900px;
    padding-right: 0;
}

.container {
    max-width: 100%;
}

header {
    background: transparent;
    color: #111827;
    padding: 0 0 30px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 40px;
}

header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #111827;
}

.doc-header {
    margin-bottom: 30px;
}

.doc-title-row {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.doc-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

main {
    padding: 0;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
}

.btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-primary {
    background: #111827;
    color: white;
    border-color: #111827;
}

.btn-primary:hover {
    background: #1f2937;
    border-color: #1f2937;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: white;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

/* 文档列表 */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.doc-item {
    border-bottom: 1px solid #f3f4f6;
    padding: 24px 20px;
    margin: 0 -20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: background-color 0.2s;
}

.doc-item:hover {
    background: #fafafa;
}

.doc-item:first-child {
    padding-top: 0;
}

.doc-info {
    flex: 1;
}

.doc-info h3 {
    margin-bottom: 8px;
}

.doc-info h3 a {
    color: #111827;
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
}

.doc-info h3 a:hover {
    color: #4b5563;
}

.doc-preview {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 10px;
    line-height: 1.6;
}

.doc-date {
    color: #9ca3af;
    font-size: 13px;
}

.doc-actions {
    display: flex;
    gap: 10px;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 16px;
}

/* 文档查看 */
.doc-view {
    background: #ffffff;
    padding: 0;
}

.doc-content {
    line-height: 1.8;
    color: #374151;
    font-size: 16px;
}

/* Markdown 内容样式 */
.markdown-body {
    background: transparent !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.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;
    scroll-margin-top: 80px;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25em;
}

/* 行内代码 - 浅色背景 */
.markdown-body code {
    background: #f3f4f6;
    color: #e11d48;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 85%;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    border: 1px solid #f3f4f6;
}

/* 代码块 - 暗色背景（由 atom-one-dark 主题控制） */
.markdown-body pre {
    background: #282c34 !important;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    position: relative;
    border: 1px solid #3a3f4b !important;
    margin: 16px 0;
}

.markdown-body pre code {
    background: transparent !important;
    padding: 0;
    border: none !important;
    color: #abb2bf;
}

/* 支持自定义颜色样式 */
.markdown-body span[style*="color"],
.markdown-body span[style*="background-color"] {
    padding: 0 2px;
}

/* 下划线样式 */
.markdown-body u {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
}

/* 代码复制按钮 */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 12px;
    background: #4b5563;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

pre:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: #374151;
}

.copy-code-btn:active {
    background: #1f2937;
}

/* 右侧目录 */
.toc-sidebar {
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 40px;
    height: fit-content;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-left: 0;
    z-index: 10;
}

/* 默认隐藏滚动条 */
.toc-sidebar::-webkit-scrollbar {
    width: 6px;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

/* 鼠标悬停时显示浅色滚动条 */
.toc-sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

.toc-sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Firefox 滚动条样式 */
.toc-sidebar {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.toc-sidebar:hover {
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

/* 文档导航按钮 */
.doc-navigation {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #f3f4f6;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid #f3f4f6;
}

.nav-link:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-link svg {
    flex-shrink: 0;
    color: #6b7280;
}

.nav-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.nav-label {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
}

.nav-title {
    font-size: 15px;
    color: #111827;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.nav-prev:hover {
    transform: translateX(-4px);
}

.nav-next {
    justify-content: flex-end;
}

.nav-next:hover {
    transform: translateX(4px);
}

.nav-next .nav-text {
    align-items: flex-end;
    text-align: right;
}

.nav-placeholder {
    /* 占位符，保持布局 */
}

.doc-toc {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 40px;
    height: fit-content;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.toc-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 12px;
}

.toc-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 4px;
}

.toc-link {
    display: block;
    padding: 6px 12px;
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1.5;
}

.toc-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.toc-link.active {
    background: #f3f4f6;
    color: #111827;
    font-weight: 500;
}

.toc-h1 {
    font-weight: 500;
}

.toc-h2 {
    padding-left: 12px;
}

.toc-h3 {
    padding-left: 24px;
}

.toc-h4 {
    padding-left: 36px;
}

.toc-h5,
.toc-h6 {
    padding-left: 48px;
}

/* 表单样式 */
.doc-form {
    max-width: 800px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 300px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
        padding: 30px 40px;
    }
}

@media (max-width: 1200px) {
    .doc-toc,
    .toc-sidebar {
        display: none;
    }
    
    .doc-article {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .content-wrapper {
        flex-direction: column;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .doc-item {
        flex-direction: column;
        gap: 15px;
    }
    
    .doc-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* 侧边栏描述和底部 */
.sidebar-desc {
    font-size: 13px;
    color: #6b7280;
    margin-top: 8px;
    line-height: 1.5;
}

.sidebar-footer {
    padding: 20px 30px;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}

.sidebar-footer .back-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    transition: color 0.2s;
}

.sidebar-footer .back-link:hover {
    color: #111827;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 100px 40px;
    color: #9ca3af;
}

.empty-state h2 {
    font-size: 24px;
    color: #6b7280;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 16px;
    color: #9ca3af;
}

/* 文档元信息 */
.doc-meta {
    display: flex;
    gap: 20px;
    color: #9ca3af;
    font-size: 13px;
    margin: 0;
    padding: 0;
}

.doc-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 主题切换按钮 */
.theme-toggle {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.theme-icon {
    display: block;
    color: #6b7280;
    transition: color 0.2s;
}

.theme-toggle:hover .theme-icon {
    color: #111827;
}

/* 搜索框 */
.search-box {
    position: relative;
    padding: 0 24px 16px;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff;
}

.search-input:focus {
    outline: none;
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1);
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-icon {
    position: absolute;
    left: 36px;
    top: 11px;
    color: #9ca3af;
    pointer-events: none;
}

/* 暗夜模式 */
body.dark {
    background: #1a1a1a;
    color: #e5e7eb;
}

body.dark .sidebar {
    background: #1f1f1f;
    border-right-color: #333333;
}

body.dark .sidebar-header {
    border-bottom-color: #333333;
}

body.dark .sidebar-header h1,
body.dark .sidebar-header h2 {
    color: #f9fafb;
}

body.dark .sidebar-header p,
body.dark .sidebar-desc {
    color: #9ca3af;
}

body.dark .nav-item {
    color: #d1d5db;
}

body.dark .nav-item:hover {
    background: #2a2a2a;
    color: #f9fafb;
}

body.dark .nav-item.active {
    background: #2a2a2a;
    color: #f9fafb;
    border-left-color: #f9fafb;
}

body.dark .nav-tree-link {
    color: #d1d5db;
}

body.dark .nav-tree-link:hover {
    background: #2a2a2a;
    color: #f9fafb;
}

body.dark .nav-tree-link.active {
    background: #2a2a2a;
    color: #f9fafb;
}

body.dark .nav-tree-title {
    color: #f9fafb;
}

body.dark .nav-tree-title:hover {
    background: #2a2a2a;
}

body.dark .nav-tree-toggle {
    color: #9ca3af;
}

body.dark .nav-tree-toggle:hover {
    background: #2a2a2a;
}

body.dark .main-content {
    background: #1a1a1a;
}

body.dark header {
    border-bottom-color: #333333;
}

body.dark header h1,
body.dark .doc-header h1 {
    color: #f9fafb;
}

body.dark .doc-meta {
    color: #9ca3af;
}

body.dark .markdown-body {
    color: #e5e7eb;
}

body.dark .markdown-body h1,
body.dark .markdown-body h2,
body.dark .markdown-body h3,
body.dark .markdown-body h4,
body.dark .markdown-body h5,
body.dark .markdown-body h6 {
    color: #f9fafb;
    border-bottom-color: #333333;
}

body.dark .markdown-body code {
    background: #2a2a2a;
    color: #f472b6;
    border-color: #333333;
}

body.dark .markdown-body pre {
    background: #282c34 !important;
    border: 1px solid #3a3f4b !important;
}

body.dark .markdown-body pre code {
    background: transparent !important;
    border: none !important;
}

body.dark .markdown-body a {
    color: #60a5fa;
}

body.dark .markdown-body blockquote {
    color: #9ca3af;
    border-left-color: #4b5563;
}

body.dark .markdown-body table tr {
    background: #1f1f1f;
    border-top-color: #333333;
}

body.dark .markdown-body table tr:nth-child(2n) {
    background: #2a2a2a;
}

body.dark .markdown-body table th,
body.dark .markdown-body table td {
    border-color: #333333;
}

body.dark .toc-sidebar {
    background: transparent;
}

/* 暗黑模式下的滚动条 */
body.dark .toc-sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

body.dark .toc-sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

body.dark .toc-sidebar:hover {
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body.dark .doc-navigation {
    border-top-color: #333333;
}

body.dark .doc-article footer {
    border-top-color: #333333;
}

body.dark .nav-link {
    background: #2a2a2a;
    border-color: #333333;
}

body.dark .nav-link:hover {
    background: #333333;
    border-color: #4b5563;
}

body.dark .nav-title {
    color: #f9fafb;
}

body.dark .nav-label {
    color: #9ca3af;
}

body.dark .toc-header {
    border-bottom-color: #2a2a2a;
    color: #f9fafb;
}

body.dark .toc-link {
    color: #9ca3af;
}

body.dark .toc-link:hover {
    background: #2a2a2a;
    color: #f9fafb;
}

body.dark .toc-link.active {
    background: #2a2a2a;
    color: #f9fafb;
}

body.dark .theme-toggle:hover .theme-icon {
    color: #f9fafb;
}

body.dark .search-input {
    background: #2a2a2a;
    border-color: #333333;
    color: #e5e7eb;
}

body.dark .search-input:focus {
    border-color: #f9fafb;
    box-shadow: 0 0 0 3px rgba(249, 250, 251, 0.1);
}

body.dark .search-input::placeholder {
    color: #6b7280;
}

body.dark .search-icon {
    color: #6b7280;
}

body.dark .empty-state h2 {
    color: #9ca3af;
}

body.dark .empty-state p {
    color: #6b7280;
}

body.dark .btn {
    background: #2a2a2a;
    color: #e5e7eb;
    border-color: #333333;
}

body.dark .btn:hover {
    background: #333333;
    border-color: #4b5563;
}

body.dark .btn-primary {
    background: #f9fafb;
    color: #111827;
    border-color: #f9fafb;
}

body.dark .btn-primary:hover {
    background: #e5e7eb;
    border-color: #e5e7eb;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 48px;
    height: 48px;
    background: #111827;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #1f2937;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:active {
    transform: translateY(0);
}

.back-to-top svg {
    flex-shrink: 0;
}

/* 暗夜模式 */
body.dark .back-to-top {
    background: #f9fafb;
    color: #111827;
}

body.dark .back-to-top:hover {
    background: #e5e7eb;
}

/* 响应式 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
}
