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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, "Microsoft YaHei", "PingFang SC";
    background-color: #f7fdf7;
    padding: 20px;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.15);
}

.header {
    padding: 20px;
    border-bottom: 1px solid #c8e6c9;
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    flex: 1;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.file-info {
    font-size: 14px;
    opacity: 0.9;
}

.language-selector {
    display: flex;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 6px;
    border-radius: 6px;
}

.language-selector button {
    background-color: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
}

.language-selector button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-selector button.active {
    background-color: rgba(255, 255, 255, 0.9);
    color: #43a047;
    border-color: white;
}

.nav {
    padding: 15px 20px;
    background-color: #f1f8e9;
    border-bottom: 1px solid #c5e1a5;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a {
    color: #388e3c;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav a:hover {
    background-color: #dcedc8;
}

.nav a.active {
    background-color: #66bb6a;
    color: white;
}

.content {
    padding: 40px;
}

#markdownContent {
    line-height: 1.6;
    color: #1f2937;
}

#markdownContent h1,
#markdownContent h2,
#markdownContent h3,
#markdownContent h4,
#markdownContent h5,
#markdownContent h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: #2e7d32;
}

#markdownContent h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 2px solid #c5e1a5;
}

#markdownContent h2 {
    font-size: 1.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #dcedc8;
}

#markdownContent h3 { font-size: 1.25em; }
#markdownContent h4 { font-size: 1em; }
#markdownContent h5 { font-size: 0.875em; }
#markdownContent h6 { font-size: 0.85em; color: #388e3c; }

#markdownContent p {
    margin-bottom: 16px;
}

#markdownContent code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(175, 184, 193, 0.2);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

#markdownContent pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

#markdownContent pre code {
    background-color: transparent;
    padding: 0;
}

#markdownContent blockquote {
    padding: 0 1em;
    color: #388e3c;
    border-left: 0.25em solid #66bb6a;
    margin-bottom: 16px;
    background-color: #f1f8e9;
    padding: 12px 16px;
    border-radius: 0 6px 6px 0;
}

#markdownContent ul,
#markdownContent ol {
    padding-left: 2em;
    margin-bottom: 16px;
}

#markdownContent li {
    margin-bottom: 0.25em;
}

#markdownContent a {
    color: #43a047;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

#markdownContent a:hover {
    border-bottom: 1px solid #43a047;
}

#markdownContent img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 16px 0;
    border: 1px solid #dcedc8;
}

.table-wrapper {
    display: inline-block;
    width: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border: 1px solid #c5e1a5;
    border-radius: 3px;
    position: relative;
}

.table-wrapper::after {
    content: '← 左右滑动查看更多 →';
    display: none;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: white;
    text-align: center;
    padding: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 5;
}

#markdownContent table {
    border-collapse: collapse;
    width: unset;
    margin-bottom: 0;
    display: table;
}

#markdownContent table th,
#markdownContent table td {
    padding: 8px 13px;
    border: 1px solid #c5e1a5;
    white-space: nowrap;
    vertical-align: top;
}

#markdownContent table th:last-child,
#markdownContent table td:last-child {
    white-space: normal;
    min-width: unset;
}

#markdownContent table th {
    font-weight: 600;
    background-color: #e8f5e9;
    color: #2e7d32;
    position: sticky;
    top: 0;
    z-index: 10;
}

#markdownContent table tr:nth-child(2n) {
    background-color: #f1f8e9;
}

#markdownContent table tr:hover {
    background-color: #dcedc8;
}

#markdownContent hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #c5e1a5;
    border: 0;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: #388e3c;
}

.spinner {
    border: 3px solid #dcedc8;
    border-top: 3px solid #66bb6a;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.error {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 20px;
    margin: 20px;
    color: #dc2626;
}

.error h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.error p {
    margin-bottom: 10px;
}

.error pre {
    background-color: #fff;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    color: #1f2937;
}

.error ol {
    padding-left: 20px;
    margin-top: 10px;
}

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

.reload-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid #fff;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-left: 14px;
    transition: all 0.15s;
}

.reload-btn:hover {
    background: #fff;
    color: #43a047;
}

.reload-btn:active {
    transform: scale(0.95);
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .content {
        padding: 20px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header h1 {
        font-size: 20px;
    }

    .language-selector {
        align-self: flex-end;
    }

    .nav {
        padding: 10px;
    }

    .nav a {
        font-size: 13px;
        padding: 6px 12px;
    }

    .table-wrapper {
        box-shadow: inset -15px 0 15px -15px rgba(102, 187, 106, 0.2);
    }

    .table-wrapper::after {
        display: block;
    }

    #markdownContent table th,
    #markdownContent table td {
        padding: 6px 10px;
        font-size: 13px;
    }

    #markdownContent table th:last-child,
    #markdownContent table td:last-child {
        min-width: 0px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .table-wrapper::after {
        display: block;
    }
}

@media print {
    .nav, .header {
        display: none;
    }

    .container {
        box-shadow: none;
    }

    body {
        background-color: white;
    }

    .table-wrapper::after {
        display: none;
    }

    #markdownContent table th,
    #markdownContent table td {
        white-space: normal;
    }
}

/* ========== 二级菜单样式 ========== */
.nav {
    padding: 0;
    position: relative;
}

.nav-item {
    position: relative;
}

.nav-item > a,
.nav-item > .nav-title {
    display: block;
    color: #388e3c;
    text-decoration: none;
    padding:  12px 18px;
    font-size: 14px;
    font-weight:  500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item > a:hover,
.nav-item > .nav-title:hover {
    background-color: #dcedc8;
}

.nav-item > a.active {
    background-color: #66bb6a;
    color:  white;
}

.nav-title:: after {
    content: ' ▾';
    font-size: 10px;
    opacity: 0.7;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border: 1px solid #c5e1a5;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 160px;
    z-index:  100;
}

.nav-item:hover .nav-dropdown {
    display: block;
}

.nav-dropdown a {
    display: block;
    color: #388e3c;
    text-decoration: none;
    padding:  10px 16px;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-dropdown a:hover {
    background-color: #f1f8e9;
    border-left-color: #66bb6a;
}

.nav-dropdown a.active {
    background-color: #e8f5e9;
    color: #2e7d32;
    border-left-color: #43a047;
    font-weight: 600;
}

/* 移动端二级菜单 */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
    }
    .nav-dropdown {
        position: static;
        box-shadow: none;
        border: none;
        background-color: #e8f5e9;
        display: none;
    }
    .nav-item.open .nav-dropdown {
        display: block;
    }
    .nav-dropdown a {
        padding-left: 36px;
    }
}

/* ========== KaTeX 公式样式 ========== */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
}

.katex {
    font-size: 1.1em;
}

/* 行内公式不换行 */
.katex-inline {
    white-space: nowrap;
}

/* 块级公式居中 */
.katex-display > .katex {
    display: inline-block;
    text-align: center;
}

/* 公式在移动端的响应式处理 */
@media (max-width: 768px) {
    .katex-display {
        font-size: 0.9em;
    }
}
