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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
}

/* 左侧树形导航 */
.sidebar {
    width: 260px;
    background: #2c3e50;
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    padding: 20px 0;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.sidebar-header h2 {
    color: #3498db;
    font-size: 1.5em;
    margin-bottom: 5px;
}

.sidebar-header p {
    color: rgba(255,255,255,0.6);
    font-size: 0.85em;
}

.nav-tree {
    list-style: none;
    padding: 0 10px;
}

.nav-tree > li {
    margin-bottom: 5px;
}

.nav-tree a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    display: block;
    padding: 10px 15px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.95em;
    border-left: 3px solid transparent;
}

.nav-tree a:hover {
    background: rgba(52, 152, 219, 0.15);
    border-left-color: #3498db;
    color: white;
    padding-left: 18px;
}

.nav-tree a.active {
    background: rgba(52, 152, 219, 0.2);
    border-left-color: #3498db;
    color: white;
    font-weight: 600;
}

.nav-tree .nav-icon {
    margin-right: 10px;
    font-size: 1.1em;
}

/* 主内容区域 */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 40px;
    width: calc(100% - 260px);
    min-height: 100vh;
}

.section {
    background: #ffffff;
    border-radius: 8px;
    padding: 35px;
    margin: 25px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e8ecef;
}

.section h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 12px;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600;
}

.section h3 {
    color: #34495e;
    margin: 25px 0 15px;
    font-size: 1.4em;
    font-weight: 600;
}

.section p {
    margin-bottom: 15px;
    text-align: justify;
    color: #555;
}

.content-block {
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 6px 6px 0;
}

.content-block h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-weight: 600;
}

.code-block {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 6px;
    margin: 15px 0;
    overflow-x: auto;
    border: 1px solid #e1e4e8;
}

.code-block pre {
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.code-block .keyword {
    color: #c678dd;
}

.code-block .string {
    color: #98c379;
}

.code-block .comment {
    color: #5c6370;
}

.code-block .function {
    color: #61afef;
}

.code-block .number {
    color: #d19a66;
}

.example-section {
    background: #fff9f9;
    border: 1px solid #ffdfe0;
    border-radius: 8px;
    padding: 25px;
    margin: 25px 0;
}

.example-section h3 {
    color: #e74c3c;
}

.language-tabs {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.language-tab {
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: white;
}

.language-tab.python {
    color: #3776ab;
}

.language-tab.golang {
    color: #00add8;
}

.language-tab:hover {
    background: #f5f5f5;
}

.language-tab.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.diagram {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.diagram svg {
    max-width: 100%;
    height: auto;
}

.info-box {
    background: #e8f4f8;
    border: 1px solid #b8daff;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
}

.info-box.warning {
    background: #fff3cd;
    border-color: #ffc107;
}

.info-box.success {
    background: #d4edda;
    border-color: #28a745;
}

ul, ol {
    margin: 15px 0 15px 30px;
}

li {
    margin: 10px 0;
    color: #555;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th, td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: left;
}

th {
    background: #34495e;
    color: white;
    font-weight: 600;
}

tr:nth-child(even) {
    background: #f8f9fa;
}

footer {
    background: #2c3e50;
    color: rgba(255,255,255,0.8);
    text-align: center;
    padding: 20px;
    margin-top: 40px;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #3498db;
    color: white;
    padding: 12px 18px;
    border-radius: 6px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.back-to-top:hover {
    background: #2980b9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.audio-visualizer {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
}

.audio-visualizer canvas {
    width: 100%;
    border-radius: 6px;
}

.math-formula {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    font-family: 'Times New Roman', serif;
    font-size: 1.1em;
}

.algorithm-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    transition: all 0.2s ease;
}

.algorithm-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.algorithm-card h4 {
    color: #3498db;
    margin-bottom: 15px;
    font-weight: 600;
}

.flowchart {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 30px;
    margin: 25px 0;
}

.comparison-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.interactive-demo {
    background: #3498db;
    border-radius: 8px;
    padding: 30px;
    margin: 25px 0;
    color: white;
}

.interactive-demo h4 {
    margin-bottom: 20px;
}

.interactive-demo button {
    background: white;
    color: #3498db;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    margin: 5px;
}

.interactive-demo button:hover {
    background: #f5f5f5;
}

/* 侧边栏滚动条美化 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* 导航菜单缩进效果 */
.nav-tree .nav-submenu {
    list-style: none;
    padding-left: 20px;
    margin-top: 5px;
}

.nav-tree .nav-submenu a {
    font-size: 0.9em;
    padding: 8px 15px;
}

/* 主内容区域平滑滚动 */
.main-content {
    scroll-behavior: smooth;
}

/* 回到顶部按钮位置调整 */
.back-to-top {
    right: 50px;
    z-index: 999;
}

@media (max-width: 768px) {
    .back-to-top {
        right: 20px;
        bottom: 20px;
    }
}
