
:root {
    --primary-color: #3b82f6;
    --bg-color: #ffffff;
    --text-color: #1f2937;
    --sidebar-bg: #f9fafb;
    --border-color: #e5e7eb;
    --sidebar-width: 280px;
    --toc-width: 240px;
    --content-max-width: 720px;
    --base-font-size: 16px;
    --heading-font-family: system-ui, sans-serif;
    --app-max-width: 1380px;

    --code-bg: #f3f4f6;
    --code-lang-bg: #e5e7eb;
}


.dark {
    --primary-color: #60a5fa;
    --bg-color: #111827;
    --text-color: #f3f4f6;
    --sidebar-bg: #1f2937;
    --border-color: #374151;

    --code-bg: #000000;
    --code-lang-bg: #374151;
}

body {
    background: linear-gradient(135deg, #f0f2f5 0%, #e2e8f0 100%);
    color: var(--text-color);
    font-size: var(--base-font-size);
    transition: background-color 0.3s, color 0.3s;
    overflow: hidden;
    display: flex;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    position: relative;
}

.dark body {
    background: linear-gradient(135deg, #0f172a 0%, #000000 100%);
}


#background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

/* 应用主容器 */
#app-container {
    width: 100%;
    height: 100%;
    max-width: var(--app-max-width);
    display: flex;
    background-color: var(--bg-color);
    box-shadow: 0 0 50px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* 侧边栏样式 */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease;
}

/* 右侧大纲栏样式 */
#toc-sidebar {
    width: var(--toc-width);
    background-color: var(--bg-color);
    border-left: 1px solid var(--border-color);
}

/* Markdown 内容样式自定义 */
.markdown-body {
    max-width: var(--content-max-width);
    margin: 0 auto;
    line-height: 1.75;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    font-family: var(--heading-font-family);
    margin-top: 1.5em;
    margin-bottom: 0.6em;
    font-weight: 700;
    color: var(--text-color);
    scroll-margin-top: 80px;
}

.markdown-body h1 { font-size: 2.2em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.7em; }
.markdown-body h3 { font-size: 1.4em; }
.markdown-body p { margin-bottom: 1.2em; }
.markdown-body ul { list-style-type: disc; padding-left: 1.5em; margin-bottom: 1.2em; }
.markdown-body ol { list-style-type: decimal; padding-left: 1.5em; margin-bottom: 1.2em; }

/* 代码块样式优化 */
.markdown-body pre {
    background-color: var(--code-bg) !important;
    padding: 1.2rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1.5em;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    position: relative;
}

.markdown-body pre code.hljs {
    background: transparent !important;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
}

.markdown-body p code,
.markdown-body li code,
.markdown-body h1 code,
.markdown-body h2 code,
.markdown-body h3 code {
    background: rgba(125,125,125,0.15);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--primary-color);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* 代码块右上角语言显示 */
.markdown-body pre[data-lang]::after {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--code-lang-bg);
    color: var(--text-color);
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    padding: 0.2rem 0.6rem;
    border-bottom-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    font-weight: 600;
}

.markdown-body pre:hover[data-lang]::after {
    opacity: 1;
}

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

.markdown-body a:hover {
    opacity: 0.8;
    border-bottom-color: var(--primary-color);
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    background: rgba(125,125,125,0.05);
    padding: 1em;
    margin-bottom: 1.5em;
    color: #6b7280;
    border-radius: 0 0.5rem 0.5rem 0;
}
.dark .markdown-body blockquote { color: #9ca3af; }

.markdown-body img {
    max-width: 100%;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

.markdown-body details {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin-bottom: 1.5em;
    background-color: var(--bg-color);
    overflow: hidden;
    transition: all 0.2s;
}

.markdown-body summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    background-color: rgba(0,0,0,0.03);
    font-weight: 600;
    color: var(--text-color);
    outline: none;
    transition: background-color 0.2s;
    user-select: none;
}

.dark .markdown-body summary {
    background-color: rgba(255,255,255,0.05);
}

.markdown-body summary:hover {
    background-color: rgba(0,0,0,0.06);
}
.dark .markdown-body summary:hover {
    background-color: rgba(255,255,255,0.08);
}

.markdown-body details[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.markdown-body details > *:not(summary) {
    margin: 1rem;
}

.markdown-body details pre {
    margin: 0;
    border-radius: 0;
    border: none;
}

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: #4b5563; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 文件夹列表 */
.folder-content { display: none; }
.folder-content.open { display: block; }

.tree-item {
    cursor: pointer;
    padding: 0.35rem 0.8rem;
    margin: 0.05rem 0;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-color);
    transition: all 0.15s;
    font-size: 0.9rem;
}
.tree-item:hover {
    background-color: rgba(0,0,0,0.04);
    color: var(--primary-color);
}
.dark .tree-item:hover {
    background-color: rgba(255,255,255,0.04);
}
.folder-header { font-weight: 600; opacity: 0.9; justify-content: space-between;}
.tree-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}
.dark .tree-item.active {
    background-color: rgba(96, 165, 250, 0.15);
}

.folder-arrow {
    transition: transform 0.2s;
    font-size: 0.7em;
    opacity: 0.5;
}
.folder-arrow.rotated {
    transform: rotate(90deg);
}

/* 目录 (TOC) */
.toc-link {
    display: block;
    padding: 0.3rem 0.6rem;
    color: var(--text-color);
    opacity: 0.7;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc-link:hover {
    background-color: rgba(0,0,0,0.05);
    opacity: 1;
    color: var(--primary-color);
}
.dark .toc-link:hover {
    background-color: rgba(255,255,255,0.05);
}
.toc-h1 { font-weight: bold; margin-top: 0.5rem; }
.toc-h2 { padding-left: 1rem; }
.toc-h3 { padding-left: 2rem; font-size: 0.85rem; }

@media (max-width: 1024px) {
    #toc-sidebar {
        display: none;
    }
}

#user-custom-style-container { display: block; }

/* 基础样式补丁 */
.markdown-body {
    font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;
    line-height: 1.6;
}
.markdown-body img { max-width: 100%; }
.folder-arrow { transition: transform 0.2s; }
.folder-arrow.rotated { transform: rotate(90deg); }
.folder-content { display: none; padding-left: 0.5rem; }
.folder-content.open { display: block; }
.tree-item {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    color: #4b5563;
}
.dark .tree-item { color: #d1d5db; }
.tree-item:hover { background-color: #f3f4f6; }
.dark .tree-item:hover { background-color: #374151; }
.tree-item.active { background-color: #eff6ff; color: #2563eb; }
.dark .tree-item.active { background-color: #1e3a8a; color: #60a5fa; }

.tab-btn {
    position: relative;
    padding-bottom: 2px;
    color: #9ca3af;
    transition: all 0.2s;
}
.tab-btn:hover { color: #4b5563; }
.dark .tab-btn:hover { color: #d1d5db; }

.tab-btn.active-tab {
    color: #1f2937;
    font-weight: bold;
}
.dark .tab-btn.active-tab {
    color: #f3f4f6;
}

.tab-btn::after {

    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: transparent;
    transition: background-color 0.2s;
}

.tab-btn.active-tab::after {
    background-color: #3b82f6;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.shake { animation: shake 0.5s; }

.role-ttr{
    color: #ffc000;
}

.role-ch{
    color: #ff027f;
}

.role-sl{
    color: #00b0f0;
}
.role-gk{
    color: #30c0b4;
}
.role-wv{
    color: #767171;
}
.role-ls{
    color: #ef939e;
}
.role-fe{
    color: #0b0dbd;
}

.dialogue-line{
    text-align: center;
}