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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 0;
}

.main-nav li {
    padding: 0 25px;
    height: 60px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    position: relative;
}

.main-nav li:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.main-nav li.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.main-nav li.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #fff;
}

.main-container {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 250px;
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    padding: 20px 0;
    position: fixed;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.sidebar ul {
    list-style: none;
}

/* 一级菜单项容器 */
.menu-item {
    margin-bottom: 5px;
}

/* 一级菜单标题（可展开/收缩） */
.menu-header {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.menu-header:hover {
    background-color: #f0f0f0;
    color: #667eea;
}

.menu-header.expanded {
    background-color: #f8f8f8;
    color: #667eea;
    border-left-color: #667eea;
}

/* 展开/收缩图标 */
.toggle-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    font-size: 10px;
    color: #999;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 16px;
}

.menu-header:hover .toggle-icon,
.menu-header.expanded .toggle-icon {
    color: #667eea;
}

.menu-title {
    flex: 1;
}

/* 子菜单列表 */
.sub-items {
    list-style: none;
    background-color: #fafafa;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sub-items li {
    padding: 10px 20px 10px 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    color: #666;
    font-size: 13px;
}

.sub-items li:hover {
    background-color: #f0f0f0;
    color: #667eea;
}

.sub-items li.active {
    background-color: #f0f4ff;
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 500;
}

/* 兼容旧样式 */
.sidebar li {
    padding: 12px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    color: #555;
    font-size: 14px;
}

.sidebar li:hover {
    background-color: #f0f0f0;
    color: #667eea;
}

.sidebar li.active {
    background-color: #f0f4ff;
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 500;
}

.content {
    flex: 1;
    margin-left: 250px;
    padding: 30px 40px;
    background-color: #fff;
    min-height: calc(100vh - 60px);
}

.content h1 {
    font-size: 32px;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.content h2 {
    font-size: 24px;
    color: #444;
    margin: 30px 0 15px 0;
}

.content h3 {
    font-size: 20px;
    color: #555;
    margin: 25px 0 12px 0;
}

.content p {
    margin-bottom: 15px;
    text-align: justify;
}

.content ul, .content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.content li {
    margin-bottom: 8px;
}

.content code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #e83e8c;
}

.content pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
}

.content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

.content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 20px;
    margin: 20px 0;
    color: #666;
    font-style: italic;
}

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

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.table-container table {
    margin: 0;
    min-width: 100%;
}

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

.content th {
    background-color: #f5f5f5;
    font-weight: 600;
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
}

.content a {
    color: #667eea;
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    .main-container {
        display: block;
    }
    
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 300px;
        height: 100vh;
        background-color: #667eea;
        transition: right 0.3s ease;
        z-index: 999;
        padding-top: 80px;
    }
    
    .main-nav.active {
        right: 0;
    }
    
    .main-nav ul {
        flex-direction: column;
        width: 100%;
    }
    
    .main-nav li {
        padding: 20px;
        height: auto;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 16px;
    }
    
    .main-nav li.active::after {
        display: none;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        width: 70%;
        max-width: 300px;
        z-index: 998;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .content {
        margin-left: 0;
        padding: 20px 15px;
    }
    
    .content h1 {
        font-size: 24px;
    }
    
    .content h2 {
        font-size: 20px;
    }
    
    .content h3 {
        font-size: 18px;
    }
    
    .content pre {
        padding: 15px;
        font-size: 13px;
        overflow-x: auto;
    }
    
    .content table {
        font-size: 13px;
    }
    
    .content th, .content td {
        padding: 8px;
    }
    
    .content ul, .content ol {
        padding-left: 20px;
    }
    
    .header {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 18px;
    }
    
    .content {
        padding: 15px 10px;
    }
    
    .content h1 {
        font-size: 22px;
    }
    
    .content h2 {
        font-size: 18px;
    }
    
    .content h3 {
        font-size: 16px;
    }
    
    .content p {
        font-size: 14px;
    }
    
    .sidebar li {
        padding: 15px 20px;
        font-size: 13px;
    }
}

.submenu-float-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 997;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.submenu-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.submenu-float-btn span {
    font-size: 24px;
    line-height: 1;
}

@media (max-width: 768px) {
    .submenu-float-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 997;
}

.overlay.active {
    display: block;
}

.loading {
    text-align: center;
    padding: 50px;
    color: #999;
    font-size: 16px;
}

.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 0;
    margin: 20px 0;
}

.katex {
    font-size: 1.1em;
}

.mermaid {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    overflow-x: auto;
}

.loading-progress {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
}

.loading-progress-bar {
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.loading-text {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* 初始加载提示样式 */
.initial-loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    background-color: rgba(255, 255, 255, 0.95);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .loading-progress {
        padding: 10px 15px;
    }
    
    .loading-text {
        font-size: 12px;
    }
    
    .initial-loading {
        padding: 20px;
    }
    
    .loading-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
}
