:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #06b6d4;
  --bg: #f4f6fb;
  --card: #ffffff;
  --nav-bg: #111827;
  --text: #1f2430;
  --text-light: #4b5563;
  --muted: #8b93a7;
  --border: #e5e8f0;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --purple: #9333ea;
  --purple-soft: #faf5ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --max-width: 1200px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; width: 100%; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--nav-bg);
  color: #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 80;
}
.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .2px;
}
.topbar .brand .logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 900;
  color: #fff;
}
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: .93rem;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.topbar nav a.active { color: #fff; background: var(--primary); }
.topbar .user-area { display: flex; gap: 8px; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  transition: all .2s;
  background: var(--card);
  color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { border-color: var(--border); color: var(--text-light); background: transparent; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: #cbd5e1; }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,.08); }
.btn-sm { padding: 6px 13px; font-size: .84rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #0e7490 120%);
  color: #fff;
  padding: 64px 0;
  margin-bottom: -34px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -100px;
  top: -120px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.hero h1 { font-size: 2.2rem; margin: 0 0 10px; color: #fff; }
.hero p { color: rgba(255,255,255,.85); font-size: 1.05rem; max-width: 620px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 2; }
.hero .btn-primary { background: #fff; color: var(--primary); }
.hero .btn-primary:hover { background: #e0e7ff; }
.hero .btn-outline { border-color: rgba(255,255,255,.45); color: #fff; }
.hero .btn-outline:hover { border-color: #fff; background: rgba(255,255,255,.1); }

.stats-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 38px 0 10px;
  overflow: hidden;
}
.stat-cell { padding: 20px 24px; text-align: center; border-right: 1px solid var(--border); }
.stat-cell:last-child { border-right: 0; }
.stat-cell b { display: block; font-size: 1.55rem; color: var(--primary); }
.stat-cell span { font-size: .82rem; color: var(--muted); }

/* ---------- 通用区块 ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.35rem; margin: 0; }
.section-head .more { font-size: .88rem; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm, none);
}

.panel { padding: 22px 24px; }

/* ---------- 推荐卡片 ---------- */
.recommend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.problem-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .22s, box-shadow .22s, border-color .22s;
  color: var(--text);
}
.problem-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); color: var(--text); }
.problem-card .p-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.problem-card .p-id { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.problem-card h3 { font-size: 1.02rem; margin: 0; }
.problem-card h3 a { color: var(--text); }
.problem-card h3 a:hover { color: var(--primary); }
.problem-card .p-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.problem-card .p-meta { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: auto; }

.featured-problem {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0;
  overflow: hidden;
  margin-bottom: 22px;
}
.featured-problem .fp-main { padding: 28px 30px; }
.featured-problem .fp-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 14px;
}
.featured-problem h3 { font-size: 1.5rem; margin: 0 0 8px; }
.featured-problem .fp-desc { color: var(--text-light); font-size: .95rem; margin: 0 0 16px; }
.featured-problem .fp-side {
  background: linear-gradient(160deg, var(--primary-soft), var(--accent-soft, #ecfeff));
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}
.featured-problem .fp-stat { display: flex; justify-content: space-between; font-size: .88rem; }
.featured-problem .fp-stat b { color: var(--primary); }

/* ---------- 难度徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.diff-入门 { background: var(--green-soft); color: var(--green); }
.diff-普及 { background: var(--blue-soft); color: var(--blue); }
.diff-普及\+ { background: #e0f2fe; color: #0284c7; }
.diff-提高 { background: var(--amber-soft); color: var(--amber); }
.diff-提高\+ { background: #fdf2f8; color: #db2777; }
.diff-省选 { background: #fdf2f8; color: #db2777; }
.diff-NOI { background: var(--red-soft); color: var(--red); }

.status-badge { font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.status-upcoming { background: var(--blue-soft); color: var(--blue); }
.status-running { background: var(--green-soft); color: var(--green); animation: pulse 2s infinite; }
.status-ended { background: #f3f4f6; color: var(--muted); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  font-size: .76rem;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-light);
}
.tag:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 工具条（筛选） ---------- */
.toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.search-input {
  flex: 1;
  min-width: 220px;
  padding: 10px 15px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .94rem;
  outline: none;
  background: var(--bg);
  transition: border-color .2s, background .2s;
}
.search-input:focus { border-color: var(--primary); background: #fff; }
.select-input {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: .92rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.select-input:focus { border-color: var(--primary); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.data-table th { background: #f8fafc; color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.data-table tr:hover td { background: #fafbff; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { font-family: var(--mono); font-size: .88rem; }
.data-table .problem-title { font-weight: 700; }
.data-table .problem-title a { color: var(--text); }
.data-table .problem-title a:hover { color: var(--primary); }
.data-table .subtitle { font-size: .78rem; color: var(--muted); font-weight: 400; }

.rate-bar { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.rate-bar .bar { flex: 1; height: 6px; background: #eef0f5; border-radius: 99px; overflow: hidden; }
.rate-bar .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; }
.rate-bar .rate { font-size: .78rem; color: var(--muted); min-width: 36px; text-align: right; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.ac { background: var(--green); }
.status-dot.tried { background: var(--amber); }
.status-dot.none { background: #d1d5db; }

/* ---------- 用户名颜色 / 头衔 ---------- */
.nc-green { color: #16a34a; font-weight: 700; }
.nc-blue { color: #2563eb; font-weight: 700; }
.nc-gold { color: #b8860b; font-weight: 800; }
.nc-rainbow {
  font-weight: 800;
  background: linear-gradient(90deg, #f43f5e, #f59e0b, #22c55e, #06b6d4, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: nc-rainbow 6s linear infinite;
}
@keyframes nc-rainbow { to { filter: hue-rotate(360deg); } }
.nc-s { color: #dc2626; font-weight: 800; }
.nc-a { color: #9333ea; font-weight: 700; }
.nc-b { color: #0891b2; font-weight: 700; }
.title-badge {
  display: inline-block; font-size: .72rem; padding: 1px 8px;
  border-radius: 99px; border: 1px solid currentColor; margin-left: 6px; vertical-align: middle;
}
.round-vip {
  display: inline-flex; width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; font-size: .62rem; font-weight: 900;
  align-items: center; justify-content: center; margin-left: 5px; vertical-align: middle;
  box-shadow: 0 2px 6px rgba(245,158,11,.35);
}

/* ---------- 表格对齐 ---------- */
.data-table th, .data-table td { text-align: center; }
.data-table .problem-title { text-align: left; }
.data-table td.num { font-family: var(--mono); }
.data-table .rate-bar { margin: 0 auto; }

/* ---------- 题目头部信息对齐 ---------- */
.problem-meta { align-items: center; }
.problem-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.problem-meta .badge, .problem-meta .verdict { vertical-align: middle; }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin: 24px 0; flex-wrap: wrap; }
.pagination button {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
}
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:hover:not(.active):not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 题目详情 ---------- */
.problem-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}
.problem-header .crumb { font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.problem-header h1 { font-size: 1.6rem; margin: 0 0 6px; }
.problem-header .sub { color: var(--muted); font-size: .92rem; margin: 0 0 16px; }
.problem-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: .86rem; color: var(--text-light); }
.problem-meta b { color: var(--text); }

.problem-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 0; background: var(--card); border-radius: var(--radius) var(--radius) 0 0; padding: 10px 12px 0; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 18px;
  border: 0;
  background: transparent;
  color: var(--text-light);
  font-weight: 700;
  font-size: .93rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.statement {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 26px 30px;
  font-size: .98rem;
  line-height: 1.85;
}
.statement h2 { font-size: 1.12rem; margin: 1.6em 0 .6em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.statement h2:first-child { margin-top: 0; }
.statement p { margin: 0 0 1em; }
.statement ul, .statement ol { padding-left: 1.4em; }
.statement code {
  font-family: var(--mono);
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: .88em;
}
.statement pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.6;
}
.statement pre code { background: transparent; color: inherit; padding: 0; }
.statement .math {
  font-family: var(--mono);
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .92em;
}
.statement .math-display { overflow-x: auto; overflow-y: hidden; margin: 1em 0; }
.statement .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.sample-block { margin: 14px 0; }
.sample-block .sample-label { font-weight: 800; font-size: .84rem; color: var(--muted); margin-bottom: 6px; }
.sample-block pre {
  margin: 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
}

/* ---------- 提交面板 ---------- */
.submit-panel { position: sticky; top: 76px; }
.submit-panel .panel { display: flex; flex-direction: column; gap: 14px; }
.submit-panel h3 { font-size: 1rem; margin: 0; }
.lang-select { padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: .92rem; width: 100%; background: var(--bg); outline: none; }
.code-editor {
  width: 100%;
  min-height: 260px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: .86rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.code-editor:focus { border-color: var(--primary); }
.submit-note { font-size: .78rem; color: var(--muted); text-align: center; }

.judge-result { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; display: none; }
.judge-result.visible { display: block; }
.judge-result .jr-line { display: flex; justify-content: space-between; font-size: .88rem; padding: 4px 0; }
.judge-result .jr-line .status-text { font-weight: 800; }
.judge-result .verdict { font-size: 1.05rem; font-weight: 900; text-align: center; padding: 8px 0 4px; }
.judge-result.verdict-ac { border-color: #bbf7d0; background: var(--green-soft); }
.judge-result.verdict-ac .verdict { color: var(--green); }
.judge-result.verdict-wa { border-color: #fecaca; background: var(--red-soft); }
.judge-result.verdict-wa .verdict { color: var(--red); }
.progress-steps { display: flex; gap: 6px; margin-top: 8px; }
.progress-steps .step { flex: 1; height: 5px; border-radius: 99px; background: #e5e7eb; }
.progress-steps .step.done { background: var(--green); }
.progress-steps .step.run { background: var(--primary); animation: pulse 1s infinite; }

.side-box { margin-bottom: 18px; }
.side-box h3 { font-size: .95rem; margin: 0 0 12px; }
.side-box .tags { display: flex; flex-wrap: wrap; gap: 8px; }
.related-list { list-style: none; margin: 0; padding: 0; }
.related-list li { border-bottom: 1px solid var(--border); padding: 9px 2px; }
.related-list li:last-child { border-bottom: 0; }
.related-list a { color: var(--text); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.related-list a:hover { color: var(--primary); }
.related-list .id { font-family: var(--mono); color: var(--muted); font-size: .8rem; }

/* ---------- 随机跳题 ---------- */
.random-hero { text-align: center; padding: 60px 0 40px; }
.random-hero h1 { font-size: 2rem; margin: 0 0 10px; }
.random-hero p { color: var(--text-light); max-width: 560px; margin: 0 auto 30px; }
.random-stage {
  max-width: 520px;
  margin: 0 auto 34px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 30px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.random-stage .dice {
  width: 86px;
  height: 86px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 2.3rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  box-shadow: 0 12px 30px rgba(79,70,229,.35);
}
.random-stage.spinning .dice { animation: shake .18s infinite alternate; }
@keyframes shake { from { transform: translateX(-4px) rotate(-3deg); } to { transform: translateX(4px) rotate(3deg); } }
.random-stage .hint { color: var(--muted); font-size: .9rem; }
.random-stage .picked { font-size: 1.3rem; font-weight: 800; }
.random-stage .picked a { color: var(--primary); }
.random-controls {
  max-width: 680px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.random-controls .row-label { font-size: .86rem; font-weight: 700; color: var(--text-light); margin: 14px 0 8px; }
.random-controls .row-label:first-child { margin-top: 0; }
.random-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.random-history { max-width: 680px; margin: 26px auto 0; }
.random-history ul { list-style: none; padding: 0; margin: 0; }
.random-history li { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px dashed var(--border); font-size: .9rem; }

/* ---------- 比赛 ---------- */
.contest-tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.contest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.contest-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .22s, box-shadow .22s, border-color .22s;
}
.contest-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); }
.contest-card .c-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.contest-card h3 { margin: 0; font-size: 1.12rem; }
.contest-card h3 a { color: var(--text); }
.contest-card h3 a:hover { color: var(--primary); }
.contest-card .c-type { font-size: .76rem; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 3px 10px; border-radius: 99px; }
.contest-card .c-desc { color: var(--text-light); font-size: .9rem; margin: 0; flex: 1; }
.contest-card .c-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--muted); }
.contest-card .c-countdown { font-weight: 800; color: var(--primary); font-size: .88rem; }

.contest-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 20px;
}
.contest-header h1 { font-size: 1.6rem; margin: 0 0 6px; }
.contest-header .c-desc { color: var(--text-light); margin: 0 0 14px; }
.contest-header .c-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: .88rem; color: var(--text-light); margin-bottom: 16px; }
.contest-header .c-meta b { color: var(--text); }
.countdown-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: .95rem;
}
.countdown-box.cd-running { background: var(--green-soft); color: var(--green); }
.countdown-box.cd-upcoming { background: var(--blue-soft); color: var(--blue); }
.countdown-box.cd-ended { background: #f3f4f6; color: var(--muted); }
.countdown-box .num { font-family: var(--mono); font-size: 1.05rem; }
.announcement {
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .88rem;
  color: #92400e;
  margin-bottom: 20px;
}
.announcement b { display: block; margin-bottom: 2px; }

.score-cell { font-family: var(--mono); font-size: .8rem; }
.score-cell .ac { color: var(--green); font-weight: 700; }
.score-cell .wa { color: var(--red); }
.score-cell .fa { color: var(--muted); }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: auto;
  background: var(--nav-bg);
  color: #94a3b8;
  padding: 30px 0;
  font-size: .86rem;
  margin-top: 60px;
}
.site-footer .footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: #cbd5e1; }
.site-footer a:hover { color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: all .25s;
  z-index: 200;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ---------- 登录/注册弹窗 ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.55); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.auth-overlay.open { display: flex; }
.auth-modal { width: min(400px, 100%); padding: 26px 28px; position: relative; }
.auth-close {
  position: absolute; top: 12px; right: 16px; border: 0; background: none;
  font-size: 1.4rem; color: var(--muted); cursor: pointer; line-height: 1;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-weight: 700; cursor: pointer; color: var(--text-light);
}
.auth-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.auth-body label { display: block; font-size: .84rem; font-weight: 700; color: var(--text-light); margin: 12px 0 6px; }
.auth-body .search-input { width: 100%; }
.auth-error {
  display: none; margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: var(--red-soft); color: var(--red); font-size: .84rem;
}
.user-name { color: #fff; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.user-name:hover { color: #fff; }

/* ---------- 个人中心 ---------- */
.profile-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-side { text-align: center; position: sticky; top: 84px; }
.profile-avatar {
  width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 2rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.profile-side h2 { margin: 0 0 14px; font-size: 1.25rem; }
.profile-meta { text-align: left; margin-bottom: 16px; }
.profile-meta div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .88rem;
}
.profile-meta span { color: var(--muted); }
.checkin-info { margin-top: 14px; }
.checkin-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: .9rem; }
.checkin-row b { color: var(--primary); }

.heatmap-wrap {
  display: flex; gap: 3px; overflow-x: auto; padding: 8px 0 12px;
}
.hm-col { display: flex; flex-direction: column; gap: 3px; }
.hm-cell {
  width: 12px; height: 12px; border-radius: 3px; background: #ebedf0; display: inline-block;
}
.hm-cell.lvl1 { background: #c6e48b; }
.hm-cell.lvl2 { background: #7bc96f; }
.hm-cell.lvl3 { background: #239a3b; }
.hm-cell.lvl4 { background: #196127; }
.hm-cell.empty { background: transparent; }
.heatmap-legend { display: flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--muted); }
.heatmap-legend .hm-cell { width: 11px; height: 11px; }

.solved-list { display: flex; flex-wrap: wrap; gap: 8px; }
.solved-chip {
  font-size: .82rem; padding: 6px 12px; border-radius: 99px;
  background: var(--green-soft); color: var(--green); font-weight: 700; border: 1px solid #bbf7d0;
}
.solved-chip:hover { background: var(--green); color: #fff; }
.empty-tip { color: var(--muted); margin: 8px 0; }

/* ---------- 提交详情弹窗 ---------- */
.detail-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.55); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.detail-overlay.open { display: flex; }
.detail-modal { width: min(720px, 100%); max-height: 86vh; overflow: auto; padding: 24px 26px; position: relative; }
.detail-modal h3 { margin: 0 0 12px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; margin-bottom: 12px; }
.detail-code {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px;
  font-size: .78rem; line-height: 1.55; overflow-x: auto; max-height: 260px; overflow-y: auto;
  font-family: var(--mono);
}

/* ---------- 排行榜 ---------- */
.leaderboard-top3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.lb-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.lb-card.first { border-color: #f59e0b; box-shadow: 0 8px 24px rgba(245,158,11,.18); }
.lb-card.second { border-color: #94a3b8; }
.lb-card.third { border-color: #b45309; }
.lb-rank { font-size: 1.4rem; font-weight: 900; color: var(--primary); }
.lb-card .lb-name { font-size: 1.05rem; font-weight: 800; margin: 6px 0; }
.lb-card .lb-points { color: var(--primary); font-weight: 800; }
@media (max-width: 760px) { .leaderboard-top3 { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-side { position: static; }
}

/* ---------- 判题结果徽章 ---------- */
.verdict {
  display: inline-flex; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 800;
}
.v-ac { background: var(--green-soft); color: var(--green); }
.v-wa { background: var(--red-soft); color: var(--red); }
.v-ce { background: #fef3c7; color: #b45309; }
.v-tle { background: var(--purple-soft); color: var(--purple); }
.v-mle { background: #fff7ed; color: #ea580c; }
.v-re { background: #fef2f2; color: #b91c1c; }
.v-pending { background: #f3f4f6; color: var(--muted); }

/* ---------- 管理后台 ---------- */
.admin-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; padding-top: 28px; align-items: start; }
.admin-side {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 80px;
}
.admin-nav {
  text-align: left; padding: 10px 14px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 700; font-size: .92rem; color: var(--text-light); cursor: pointer;
}
.admin-nav:hover { background: var(--bg); color: var(--primary); }
.admin-nav.active { background: var(--primary-soft); color: var(--primary); }
.admin-main { min-width: 0; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel h2 { font-size: 1.35rem; margin: 0 0 16px; }
.admin-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.admin-stats .stat-cell { border: 0; }
.admin-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; }
.admin-form label { display: block; font-size: .86rem; font-weight: 700; color: var(--text-light); margin: 12px 0 6px; }
.admin-form .search-input, .admin-form .select-input { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.admin-textarea { min-height: 110px; resize: vertical; font-size: .88rem; }
.admin-form .checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.admin-form .checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side { position: static; flex-direction: row; overflow-x: auto; }
  .admin-nav { white-space: nowrap; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 比赛专属题目页 ---------- */
.cp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 540px; gap: 20px; align-items: start; }
.cp-ide { position: sticky; top: 76px; }
.cp-editor {
  width: 100%; min-height: 380px; padding: 14px; resize: vertical;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: #0f172a; color: #e2e8f0; font-family: var(--mono);
  font-size: .9rem; line-height: 1.6; outline: none;
}
.cp-editor:focus { border-color: var(--primary); }
.cp-input {
  width: 100%; min-height: 130px; padding: 12px; resize: vertical;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-family: var(--mono); font-size: .84rem; outline: none;
}
.cp-input:focus { border-color: var(--primary); background: #fff; }
.testrun-result { display: none; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.testrun-result.visible { display: block; }

/* ---------- 比赛题目列表（管理表单） ---------- */
.cf-problem-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--bg);
}
.cf-problem-row .cf-pname { flex: 1; font-weight: 700; font-size: .9rem; min-width: 0; }
.cf-problem-row .cf-score { width: 90px; padding: 7px 10px; border: 2px solid var(--border); border-radius: 8px; font-size: .88rem; }
.cf-problem-row button { padding: 6px 10px; }

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

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 6px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .problem-layout { grid-template-columns: 1fr; }
  .submit-panel { position: static; }
  .featured-problem { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat-cell:nth-child(2) { border-right: 0; }
  .stat-cell:nth-child(1), .stat-cell:nth-child(2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 720px) {
  .topbar-inner { gap: 8px; flex-wrap: wrap; height: auto; padding: 10px 0; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; gap: 0; }
  .topbar nav a { white-space: nowrap; }
  .hero { padding: 42px 0; }
  .hero h1 { font-size: 1.6rem; }
  .section-head h2 { font-size: 1.15rem; }
  .statement { padding: 20px 18px; }
  .problem-header { padding: 18px 20px; }
  .random-stage { padding: 30px 20px; }
}
