/* 经典风格：使用衬线字体、简洁的配色和清晰的间距 */
:root {
    --primary-color: #0056b3; /* 标题栏蓝色背景 */
    --secondary-color: #cc0000; /* 红色 */
    --background-color: #ffffff;
    --text-color: #333333;
    --border-color: #cccccc;
    --highlight-bg: #fffbe6;
    --theorem-color: #008000;
    /* 域名定制颜色 */
    --domain-c-color: #FFD700;
}

body {
    font-family: 'Times New Roman', Georgia, serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
}

nav .latex-box {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0 0 0 4px; /* 可选：在 a_n 左侧保留一点间距 */
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 移除 h1，只保留定制的 header-title */
header h1 {
    display: none;
}

/* 域名定制样式 - 显著增强 */
.header-title {
    font-size: 2.5em; /* 增大字号 */
    font-weight: 900;
    margin-top: 10px;
    font-family: 'Georgia', 'Times New Roman', serif; /* 经典衬线字体 */
    color: white;
}

.domain-l {
    color: var(--secondary-color); /* L 的颜色保持红色 */
    font-weight: 900;
}

.domain-c {
    color: var(--domain-c-color); /* C 的颜色改为白色 */
    font-weight: 900;
}

/* 导航标签页样式 */
nav {
    margin-top: 15px; /* 标题与导航分隔 */
}

nav a {
    color: white;
    text-decoration: none;
    margin: 0 10px; /* 减小间距以容纳新标签 */
    font-weight: bold;
    padding: 5px 10px;
    border-bottom: 3px solid transparent;
    transition: border-bottom 0.3s;
    cursor: pointer;
}

nav a.active-tab {
    border-bottom: 3px solid #ffcc00;
}

main {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    min-height: 80vh;
}

/* .concept-module 现在是 section 的直接样式 */
.concept-module {
    padding: 30px 0;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-top: 10px;
}

/* 模块内小标题样式 */
.concept-module h3 {
    color: #333;
    font-style: italic;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 5px;
    margin-top: 30px;
}

.concept-module h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.8em;
}

/* 定理强调框 */
.theorem-box {
    background-color: #e6ffe6;
    border: 2px solid var(--theorem-color);
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}

.theorem-box h4 {
    color: var(--theorem-color);
    margin-top: 0;
    font-size: 1.3em;
}

/* 历史/挑战内容区块样式 */
.content-box {
    background-color: var(--highlight-bg);
    border: 1px solid #ffcc00;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}

p {
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* 内联 LaTeX 框样式 - 关键样式 */
.latex-box {
    display: inline-block;
    border: 1px solid #cce5ff;
    background-color: #e6f3ff;
    padding: 0 2px;
    margin: 0 2px;
    line-height: 1.5;
    border-radius: 3px;
    font-weight: normal;
    vertical-align: middle;
}

/* 交互区域布局 */
.interactive-area {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: #f9f9f9;
}

/* 修复图表诡异拉伸问题：给容器固定高度 */
.plot-container {
    background-color: white;
    border: 1px solid #ddd;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
    min-height: 400px; /* 保留这个 */
    width: 100%; /* 明确添加宽度 */
    height: 400px; /* ★ 关键补充：给一个固定的初始高度 */
    flex: 1 1 400px; /* ★ 关键修改：改进flex属性 */
}

@media (min-width: 768px) {
    .interactive-area {
        flex-direction: row;
    }
    .plot-container {
        flex: 3;
    }
    .controls {
        flex: 1;
        min-width: 200px;
    }
}

/* --- 多项式拟合模块特定样式 --- */
.polyfit-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

.polyfit-controls label {
    font-weight: bold;
}

.polyfit-controls select {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.polyfit-inputs {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.polyfit-inputs .polyfit-input-wrapper input {
    width: 70px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.polyfit-result-box {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid var(--primary-color);
    background-color: #f0f8ff;
    border-radius: 5px;
}

.polyfit-formula-output {
    font-size: 1.2em; /* 稍微缩小以适应更长的公式 */
    text-align: center;
    padding: 10px 0;
    min-height: 50px;
    overflow-x: auto; /* 公式过长时可以滚动 */
}

.polyfit-predictions {
    padding: 10px 0;
    font-size: 1.1em;
    color: var(--secondary-color);
    font-weight: bold;
}

/* --- 科学计算器模块特定样式 --- */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 20px auto;
    background-color: #eee;
    padding: 15px;
    border-radius: 8px;
}

#calc-display {
    grid-column: 1 / -1;
    background-color: #fff;
    padding: 15px;
    font-size: 2em;
    text-align: right;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 50px;
    overflow-x: auto;
}

.calc-button {
    padding: 15px 5px;
    font-size: 1.1em;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.1s;
    font-family: 'Times New Roman', Georgia, serif;
    font-weight: bold;
}

.calc-button:hover {
    background-color: #f0f0f0;
}

.calc-operator {
    background-color: var(--primary-color);
    color: white;
}

.calc-operator:hover {
    background-color: #004499;
}

.calc-equal {
    background-color: var(--secondary-color);
    color: white;
}

.calc-equal:hover {
    background-color: #aa0000;
}

/* --- 无理数精度计算模块特定样式 --- */
.precision-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.precision-controls .control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.precision-controls label {
    font-weight: bold;
    font-size: 1.1em;
}

.precision-controls input[type="number"] {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Times New Roman', Georgia, serif;
}

.precision-controls .button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.precision-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'Times New Roman', Georgia, serif;
    font-weight: bold;
    transition: background-color 0.3s;
    flex-grow: 1;
}

.precision-button:hover {
    background-color: #004499;
}

.precision-button.download-btn {
    background-color: var(--theorem-color);
}

.precision-button.download-btn:hover {
    background-color: #006400;
}

.precision-output-container {
    margin-top: 20px;
}

#precision-output {
    width: 100%;
    height: 200px;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

#precision-status {
    color: var(--secondary-color);
    font-weight: bold;
    min-height: 20px;
}

/* 其他样式保持不变 */
.exercise-section { padding: 15px 0; }
.solution-toggle { background-color: var(--primary-color); color: white; border: none; padding: 8px 15px; margin-top: 10px; cursor: pointer; border-radius: 3px; }
.solution { border-left: 3px solid var(--secondary-color); padding-left: 10px; margin-top: 10px; display: none; }
p[data-katex] { display: block; text-align: center; font-size: 1.5em; padding: 10px 0; background-color: #f0f8ff; border: 1px dashed var(--primary-color); }
footer { text-align: center; padding: 20px; margin-top: 40px; border-top: 1px solid var(--border-color); color: #666; font-size: 0.9em; }


/* style.css (追加在文件末尾) */

/* --- 响应式侧边栏样式 --- */

/* 1. 汉堡按钮默认样式 (桌面端隐藏) */
#hamburger-btn {
    display: none; /* 默认隐藏 */
    position: absolute;
    top: 35px;
    left: 20px;
    z-index: 1001; /* 确保在最上层 */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    justify-content: space-around;
    width: 32px;
    height: 32px;
}

#hamburger-btn span {
    width: 100%;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* 2. 遮罩层默认样式 (隐藏) */
#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none; /* 看不见的时候不能被点击 */
}

/* 3. 当侧边栏打开时 (通过JS给body添加.sidebar-open类) */
body.sidebar-open #sidebar-overlay {
    opacity: 1;
    pointer-events: auto; /* 看得见时可以被点击 */
}

body.sidebar-open #hamburger-btn span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
body.sidebar-open #hamburger-btn span:nth-child(2) {
    opacity: 0;
}
body.sidebar-open #hamburger-btn span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}


/* 4. 媒体查询：当屏幕宽度小于等于 768px 时 (手机或平板) */
@media (max-width: 768px) {
    /* 让标题居中，为按钮留出空间 */
    header .header-title {
        padding: 0 40px;
    }

    /* 显示汉堡按钮 */
    #hamburger-btn {
        display: flex;
    }

    /* 将原来的导航栏变成侧边栏 */
    #sidebar-nav {
        position: fixed; /* 固定在屏幕上 */
        top: 0;
        left: 0;
        width: 280px; /* 侧边栏宽度 */
        height: 100vh; /* 占满整个屏幕高度 */
        background-color: var(--primary-color);
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        padding-top: 80px;
