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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

a {
    text-decoration: none;
    color: #c45a2a;
    transition: color 0.3s ease;
}

a:hover {
    color: #a84820;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation Bar */
.navbar {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: #F1641E;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-logo {
    height: 40px;
    width: auto;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: #333;
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-menu a:hover {
    color: #F1641E;
    border-bottom-color: #F1641E;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #F1641E 0%, #d55418 100%);
    color: #fff;
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero .subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.hero .cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #fff;
    color: #F1641E;
}

.btn-primary:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: #fff;
    border: 2px solid #fff;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Features Section */
.features {
    padding: 4rem 0;
    background-color: #fff;
}

.features h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #F1641E;
}

.feature-card p {
    color: #666;
    line-height: 1.8;
}

/* Open Source Section */
.opensource {
    padding: 4rem 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    text-align: center;
}

.opensource h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: #fff;
}

.opensource-desc {
    max-width: 700px;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ddd;
}

.opensource .cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Changelog Section */
.changelog {
    padding: 4rem 0;
    background-color: #f8f9fa;
}

.changelog h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.changelog-list {
    max-width: 800px;
    margin: 0 auto;
}

.changelog-item {
    background: #fff;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    border-left: 4px solid #F1641E;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.changelog-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(4px);
}

.changelog-item .version {
    font-weight: bold;
    font-size: 1.25rem;
    color: #333;
}

.changelog-item .date {
    color: #999;
    font-size: 0.9rem;
}

.changelog-item a {
    color: #F1641E;
    font-weight: 500;
}

/* Footer */
.footer {
    background-color: #333;
    color: #fff;
    padding: 2rem 0;
    text-align: center;
}

.footer p {
    margin: 0.5rem 0;
}

.footer a {
    color: #F1641E;
}

.footer a:hover {
    color: #f28c55;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero .subtitle {
        font-size: 1rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .changelog-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Download Section */
.download {
    background: linear-gradient(135deg, #F1641E 0%, #d55418 100%);
    color: #fff;
    padding: 4rem 0;
    text-align: center;
}

.download h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.download .subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.download-button {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
}

.download-info {
    font-size: 1rem;
    opacity: 0.9;
}

/* Active Navigation Link */
.nav-menu a.active {
    color: #F1641E;
    border-bottom-color: #F1641E;
}

/* ===================== OJ ===================== */

/* Hero */
.oj-hero {
    background: linear-gradient(135deg, #F1641E 0%, #d55418 100%);
    color: #fff;
    padding: 3rem 0;
    text-align: center;
}

.oj-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.oj-hero .subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.oj-section {
    padding: 2.5rem 0 4rem;
    background-color: #f8f9fa;
    min-height: 50vh;
}

/* 题目列表 */
.oj-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

/* 洛谷式过滤栏 */
.oj-filter {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.25rem;
}

.oj-filter input[type="text"] {
    flex: 1;
    min-width: 240px;
    padding: 0.55rem 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #333;
}

.oj-filter input[type="text"]:focus {
    outline: none;
    border-color: #F1641E;
    box-shadow: 0 0 0 3px rgba(241, 100, 30, 0.12);
}

.oj-filter select {
    padding: 0.55rem 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 0.9rem;
    cursor: pointer;
}

.oj-filter .btn-filter {
    background: #F1641E;
    color: #fff;
    border: none;
    padding: 0.55rem 1.4rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.25s ease;
}

.oj-filter .btn-filter:hover {
    background: #d55418;
}

.oj-filter .btn-filter-reset {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #777;
    font-size: 0.9rem;
    background: #fff;
    transition: all 0.25s ease;
}

.oj-filter .btn-filter-reset:hover {
    color: #F1641E;
    border-color: #F1641E;
}

.oj-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    transition: background 0.2s ease;
}

.oj-row:last-child {
    border-bottom: none;
}

.oj-row:hover {
    background: #f8f9fa;
    color: #333;
}

.oj-code {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    color: #aaa;
    font-size: 0.9rem;
    min-width: 64px;
}

.oj-title {
    flex: 1;
    font-weight: 500;
    font-size: 1.05rem;
}

.oj-meta {
    color: #999;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* 算法 tag 徽章 */
.oj-tags {
    display: inline-flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    max-width: 260px;
}

.oj-tag {
    font-size: 0.72rem;
    color: #555;
    background: #f1f3f5;
    border: 1px solid #e5e7eb;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}

.oj-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #999;
}

/* 分页栏 */
.oj-pagination {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.pagination-info {
    color: #999;
    font-size: 0.85rem;
    margin-right: 0.6rem;
}

.page-num,
.page-btn {
    display: inline-block;
    min-width: 2.1rem;
    text-align: center;
    padding: 0.35rem 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.page-num:hover,
.page-btn:hover {
    border-color: #F1641E;
    color: #F1641E;
}

.page-num.active {
    background: #F1641E;
    border-color: #F1641E;
    color: #fff;
    font-weight: 600;
}

.page-btn.disabled {
    color: #ccc;
    pointer-events: none;
    border-color: #eee;
}

.page-ellipsis {
    color: #aaa;
    padding: 0 0.2rem;
}

/* 难度徽章（洛谷式配色） */
.oj-diff {
    font-size: 0.78rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}

.diff-basic { background: #16a34a; }
.diff-easy  { background: #0ea5e9; }
.diff-mid   { background: #f59e0b; }
.diff-hard  { background: #ef4444; }
.diff-master { background: #8b5cf6; }

/* 题目详情 */
.problem-page {
    max-width: 1200px;
}

/* 双栏布局：左题面 / 右代码 IDE */
.problem-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 1.5rem;
    align-items: start;
}

.problem-main {
    min-width: 0;
}

.submit-side {
    position: sticky;
    top: 90px;
    min-width: 0;
}

@media (max-width: 1100px) {
    .problem-layout {
        grid-template-columns: 1fr;
    }

    .submit-side {
        position: static;
    }
}

.problem-header {
    margin-bottom: 1.25rem;
}

.problem-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.problem-title-row h1 {
    font-size: 1.75rem;
    color: #333;
    font-weight: 700;
}

.problem-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-ghost {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border: 1px solid #F1641E;
    color: #F1641E;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s ease;
}

.btn-ghost:hover {
    background: #F1641E;
    color: #fff;
}

.problem-meta {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.meta-chip {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #666;
    font-size: 0.85rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* 题面排版（Markdown 渲染结果） */
.statement {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    line-height: 1.9;
    color: #333;
    overflow-wrap: break-word;
}

.statement h2 {
    font-size: 1.2rem;
    color: #F1641E;
    margin: 1.75rem 0 0.75rem;
    padding-left: 0.7rem;
    border-left: 4px solid #F1641E;
}

.statement p {
    margin: 0.6rem 0;
}

.statement pre {
    background: #f6f8fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 0.9rem 1.1rem;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0.75rem 0;
}

.statement code {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    background: #f1f3f5;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.88em;
}

.statement pre code {
    background: none;
    padding: 0;
}

.statement table {
    border-collapse: collapse;
    margin: 0.75rem 0;
    width: 100%;
}

.statement th, .statement td {
    border: 1px solid #e5e7eb;
    padding: 0.45rem 0.8rem;
}

.statement th {
    background: #f8f9fa;
}

.statement ul, .statement ol {
    margin: 0.6rem 0 0.6rem 1.5rem;
}

.statement blockquote {
    border-left: 4px solid #e5e7eb;
    color: #666;
    margin: 0.75rem 0;
    padding-left: 1rem;
}

/* 公式（KaTeX 浏览器端渲染） */
.statement .math-inline {
    white-space: nowrap;
}

.statement .math-display {
    text-align: center;
    margin: 1rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
}

.statement .math-display .katex-display {
    margin: 0;
}

/* 样例卡片 */
.example-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 1.25rem 1.5rem;
    margin-top: 1.25rem;
}

.example-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.92rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.copy-btn {
    border: 1px solid #e5e7eb;
    background: #f8f9fa;
    color: #666;
    border-radius: 4px;
    font-size: 0.8rem;
    padding: 0.2rem 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #F1641E;
    border-color: #F1641E;
    color: #fff;
}

.example-card pre {
    background: #f6f8fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 0.8rem 1rem;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0 0 1rem;
}

.example-card pre:last-child {
    margin-bottom: 0;
}

.example-note {
    margin-top: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: #fff8f0;
    border: 1px solid #fde8cf;
    border-radius: 6px;
    color: #9a6700;
    font-size: 0.88rem;
}

/* ===== 提交评测面板 ===== */
.submit-panel {
    margin-top: 1.5rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 1.25rem 1.5rem 1.5rem;
}

.submit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.submit-header h2 {
    font-size: 1.15rem;
    color: #333;
    border-left: 4px solid #F1641E;
    padding-left: 0.7rem;
}

.submit-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.submit-hint {
    color: #999;
    font-size: 0.8rem;
}

.btn-submit {
    background: #F1641E;
    color: #fff;
    border: none;
    padding: 0.5rem 1.4rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-submit:hover {
    background: #d55418;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(241, 100, 30, 0.3);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#codeEditor {
    min-height: 52vh;   /* 兜底：JS 未加载时容器也有高度 */
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    background: #fbfbfd;
}

#codeEditor .cm-editor {
    height: 52vh;
    max-height: 70vh;
    font-size: 0.9rem;
}

#codeEditor .cm-scroller {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    line-height: 1.6;
}

#codeEditor .cm-editor.cm-focused {
    outline: none;
}

#codeEditor:focus-within {
    border-color: #F1641E;
    box-shadow: 0 0 0 3px rgba(241, 100, 30, 0.12);
}

.hidden {
    display: none;
}

/* 结果区 */
.result-area {
    margin-top: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem 1.25rem;
}

.result-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.result-badge {
    font-weight: 700;
    font-size: 1rem;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    color: #fff;
    letter-spacing: 0.02em;
}

.st-ac      { background: #16a34a; }
.st-wa      { background: #f59e0b; }
.st-ce      { background: #ca8a04; }
.st-re      { background: #ef4444; }
.st-tle     { background: #8b5cf6; }
.st-mle     { background: #db2777; }
.st-judging { background: #0ea5e9; animation: oj-pulse 1.2s ease-in-out infinite; }

@keyframes oj-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.result-meta {
    color: #777;
    font-size: 0.85rem;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.6rem;
    font-size: 0.88rem;
}

.result-table th,
.result-table td {
    border: 1px solid #eee;
    padding: 0.4rem 0.7rem;
    text-align: left;
}

.result-table th {
    background: #f8f9fa;
    color: #666;
}

.case-ac   { color: #16a34a; font-weight: 600; }
.case-fail { color: #ef4444; font-weight: 600; }

.result-error {
    margin-top: 0.6rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 移动端 */
@media (max-width: 768px) {
    .oj-row {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.9rem 1rem;
    }

    .oj-title {
        flex-basis: 100%;
        order: -1;
    }

    .oj-meta {
        margin-left: auto;
    }

    .statement {
        padding: 1.25rem 1.25rem;
    }

    .problem-title-row h1 {
        font-size: 1.4rem;
    }
}

/* ===== FAQ section ===== */
.faq-section { padding: 3rem 0; background: #fff; }
.faq-section h2 { text-align: center; font-size: 2rem; color: #2c3e50; margin-bottom: 1.8rem; }
.faq-list { max-width: 800px; margin: 0 auto; display: grid; gap: 0.8rem; }
.faq-item { border: 1px solid #e4e8ec; border-radius: 10px; background: #fafbfc; }
.faq-item[open] { background: #fff; border-color: #c45a2a; }
.faq-item summary { padding: 0.9rem 1.2rem; cursor: pointer; font-weight: 600; color: #2c3e50; list-style: none; position: relative; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%); color: #c45a2a; font-size: 1.2rem; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin: 0; padding: 0 1.2rem 1rem; color: #555; line-height: 1.7; font-size: 0.95rem; }
.faq-item p a { color: #c45a2a; }
/* 隐私政策等法律文本页面 */
.legal-page {
    max-width: 860px;
    padding: 2.5rem 1.25rem 4rem;
}
.legal-page h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.legal-meta {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.legal-page h2 {
    font-size: 1.15rem;
    margin: 1.75rem 0 0.75rem;
    color: #c45a2a;
}
.legal-page p {
    margin: 0.5rem 0;
    line-height: 1.85;
}
.legal-page ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
    line-height: 1.85;
}
.legal-page li {
    margin: 0.35rem 0;
}
.legal-page a {
    color: #F1641E;
}
