:root {
  --bg: #f5f7fb;
  --fg: #1f2937;
  --muted: #6b7280;
  --primary: #22c55e; /* green CTA */
  --accent: #6366f1;  /* purple pills */
  --card: #ffffff;
  --border: rgba(17,24,39,0.08);
  --danger: #ef4444;
  --warning: #f59e0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  /* Light dreamy gradient */
  background: linear-gradient(135deg, #eef2ff 0%, #e9d5ff 35%, #fde7f3 65%, #ffffff 100%);
  background-attachment: fixed;
  color: var(--fg);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
}
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.header {
  border-bottom: 1px solid rgba(17,24,39,0.06);
  background: rgba(255,255,255,0.85);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(140%) blur(10px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  color: #111827;
  text-decoration: none;
  font-weight: 700;
}
.auth-area { display:flex; align-items:center; gap:6px; }
.btn-mini { display:inline-flex; align-items:center; height:28px; padding:0 10px; border-radius:8px; border:1px solid var(--border); background:#fff; color:#111827; text-decoration:none; cursor:pointer; }
.btn-mini-primary { border-color:#16a34a; background: linear-gradient(135deg,#22c55e,#16a34a); color:#fff; }
.nav .nav-link {
  color: #6b7280;
  text-decoration: none;
  margin-left: 16px;
}
.nav .nav-link.active, .nav .nav-link:hover {
  color: #111827;
}

.hero {
  padding: 32px 0 8px;
}
.hero h1 {
  margin: 16px 0 8px;
}
.content-panel { background:#fff; border:1px solid var(--border); border-radius:14px; box-shadow:0 12px 28px rgba(17,24,39,0.08); padding:12px 16px; }
.filter-bar {
  margin: 8px 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pills { display:flex; gap:8px; flex-wrap:wrap; }
.chip {
  display:inline-flex;
  align-items:center;
  height:28px;
  padding:0 10px;
  font-size:13px;
  color:#374151;
  border:1px solid var(--border);
  background: #ffffff;
  border-radius: 999px;
  cursor:pointer;
  user-select:none;
  text-decoration:none;
}
.chip.active { border-color: #16a34a; background: linear-gradient(135deg,#22c55e,#16a34a); color:#fff; }
.chip.secondary.active { border-color:#6366f1; background: linear-gradient(135deg,#a78bfa,#6366f1); color:#fff; }
.chip.warn.active { border-color:#f59e0b; background: linear-gradient(135deg,#fbbf24,#f59e0b); color:#111; }
.search-input {
  margin-left:auto;
  height:32px;
  padding:0 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background: #ffffff;
  color:#111827;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  display: block;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(17,24,39,0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  color: var(--fg);
  text-decoration: none;
}
.card:hover { border-color: rgba(17,24,39,0.18); box-shadow:0 12px 28px rgba(17,24,39,0.12); }

.list h1, .taxonomy h1, .recent h2 { margin-top: 24px; }
.post-list { list-style: none; padding: 0; margin: 12px 0 0; }
.post-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.post-title { color: #111827; text-decoration: none; font-weight: 600; }
.post-title:hover { color: #0f172a; }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.excerpt { color: var(--muted); margin: 6px 0 0; }
.tax { color: var(--muted); font-size: 13px; margin-top: 6px; }
.pagination { display: flex; gap: 12px; align-items: center; margin: 16px 0; }
.pagination a { color: #374151; text-decoration: none; }
.pagination .num { display:inline-flex; align-items:center; justify-content:center; width:34px; height:32px; border:1px solid var(--border); border-radius:8px; background:#fff; }
.pagination .num.active { border-color:#22c55e; color:#16a34a; }
.page-size { margin-left:auto; display:flex; align-items:center; gap:8px; }
.page-size select { height:32px; border:1px solid var(--border); border-radius:8px; background:#fff; color:#111827; }

.sort-select { height:32px; border:1px solid var(--border); border-radius:8px; background:#fff; color:#111827; margin-left:8px; }
.btn-outline { background:#fff; color:#111827; border:1px solid var(--border); }
.btn-outline:hover { border-color:#22c55e; color:#16a34a; }
/* 由于 .btn 在后方声明，增加更高优先级以避免文字变白 */
.btn.btn-outline { background:#fff; color:#111827; border:1px solid var(--border); }

/* Inputs */
.input { width:100%; height:36px; padding:0 10px; border:1px solid var(--border); border-radius:8px; background:#fff; color:#111827; }
.form-row { margin:8px 0; }
.btn-full { width:100%; }
.auth-tabs { display:flex; gap:8px; margin-bottom:10px; }
.auth-tab { height:32px; padding:0 12px; border-radius:999px; border:1px solid var(--border); background:#fff; color:#111827; cursor:pointer; }
.auth-tab.active { border-color:#22c55e; color:#16a34a; }

/* Modal */
.modal { position:fixed; inset:0; background:rgba(0,0,0,0.45); display:flex; align-items:center; justify-content:center; padding:16px; z-index:50; }
.modal[hidden] { display:none; }
.modal-dialog { width: min(720px, 96vw); background:#fff; color:#111827; border-radius:12px; border:1px solid var(--border); box-shadow:0 20px 50px rgba(0,0,0,0.25); }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid var(--border); }
.modal-body { padding:14px 16px; color:#374151; }
.modal-actions { display:flex; gap:12px; justify-content:flex-end; padding:14px 16px; border-top:1px solid var(--border); }
.modal-close { background:transparent; border:0; font-size:22px; line-height:1; cursor:pointer; color:#6b7280; }

/* Back to top */
.back-top { position:fixed; right:18px; bottom:18px; width:40px; height:40px; border-radius:10px; border:1px solid var(--border); background:#fff; color:#111827; cursor:pointer; box-shadow:0 10px 20px rgba(17,24,39,0.12); }
.back-top:hover { border-color:#22c55e; color:#16a34a; }

/* Empty state */
.empty { color:#6b7280; padding:24px 0; text-align:center; }

/* Sidebar merged panel */
.side-panel { background:#fff; border:1px solid var(--border); border-radius:14px; box-shadow:0 10px 24px rgba(17,24,39,0.08); overflow:hidden; }
.side-panel .section { padding:14px 16px; }
.side-panel .section + .section { border-top:1px solid var(--border); }
.section-title { font-weight:600; margin-bottom:8px; color:#111827; }

.post h1 { margin-top: 24px; }
.post .content img { max-width: 100%; height: auto; }
.post .content pre { background: #f8fafc; padding: 12px; border-radius: 6px; overflow: auto; border: 1px solid var(--border); }
.post .content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.badge { display:inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.badge.easy { background: rgba(34,197,94,0.12); color: #16a34a; border-color: rgba(34,197,94,0.28); }
.badge.medium { background: rgba(250,204,21,0.15); color: #facc15; border-color: rgba(250,204,21,0.3); }
.badge.hard { background: rgba(248,113,113,0.15); color: #f87171; border-color: rgba(248,113,113,0.3); }
.badge.info { background: rgba(99,102,241,0.12); color: var(--accent); border-color: rgba(99,102,241,0.28); }

/* Challenge grid and card */
.challenge-grid {
  display:grid;
  grid-template-columns: repeat(auto-fill,minmax(340px,1fr));
  gap:18px;
}
.challenge-card {
  display:flex;
  flex-direction:column;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 10px 24px rgba(17,24,39,0.1);
}
.challenge-card .title-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}
.challenge-card .meta {
  margin-bottom: 12px;
}
.num-badge{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:999px;background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;font-weight:700;font-size:13px;margin-right:8px;border:1px solid rgba(34,197,94,0.35)}
.challenge-card .desc { color: var(--muted); font-size:14px; margin: 10px 0 12px; }
.tags { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.tag { display:inline-flex; align-items:center; height:24px; padding:0 8px; background:#f3f4f6; color:#374151; border:1px solid var(--border); border-radius:999px; font-size:12px; }
.challenge-card .btn-primary {
  margin-top:auto;
  align-self:flex-start;
}
.btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 0;
  color:#fff;
  cursor:pointer;
  text-decoration:none;
}
.btn-primary { background: linear-gradient(135deg,#16a34a,#22c55e); }
.btn-primary:hover { filter: brightness(1.05); }

/* Sidebar cards */
.home-layout { display:grid; grid-template-columns: 300px 1fr; gap:24px; align-items:start; }
.sidebar { display:flex; flex-direction:column; gap:16px; position:sticky; top:80px; align-self:start; }
.stat-card, .board-card { background:#ffffff; border:1px solid var(--border); border-radius:12px; padding:12px 14px; box-shadow:0 8px 20px rgba(17,24,39,0.06); }
.board-list { list-style:none; padding:0; margin:8px 0 0; }
.board-item { display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); }
.board-item:last-child { border-bottom:0; }

.panel-title { font-weight:700; color:#0f172a; margin-bottom:10px; }
.kpis { display:grid; grid-template-columns: repeat(3,1fr); gap:8px; margin-top:6px; }
.kpi { display:flex; flex-direction:column; align-items:center; justify-content:center; background:#fafafa; border:1px solid var(--border); border-radius:10px; padding:8px 6px; }
.kpi .num { font-size:22px; font-weight:700; color:#111827; line-height:1; }
.kpi .label { font-size:12px; color:#6b7280; margin-top:4px; }
.rank { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:999px; font-size:12px; color:#fff; margin-right:8px; }
.rank.r1 { background: linear-gradient(135deg,#f59e0b,#fbbf24); }
.rank.r2 { background: linear-gradient(135deg,#9ca3af,#e5e7eb); color:#111827; }
.rank.r3 { background: linear-gradient(135deg,#f97316,#fdba74); }
.board-item .name { flex:1; color:#111827; }
.board-item .score { color:#6b7280; }

@media (max-width: 1024px) {
  .home-layout { grid-template-columns: 1fr; }
}

details.hint, details.answer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 12px 0;
}
details summary { cursor: pointer; color: var(--primary); }
details .hint-body, details .answer-body { color: var(--fg); margin-top: 8px; }

.footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding: 16px 0 24px;
  color: var(--muted);
}

/* Tables */
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid var(--border); padding: 10px; }
th { background: #f3f4f6; color:#111827; text-align: left; }

/* Table card wrapper for admin pages */
.table-card { background:#fff; border:1px solid var(--border); border-radius:12px; box-shadow:0 8px 20px rgba(17,24,39,0.06); padding:8px; margin:12px 0; }

/* Responsive images and iframes */
iframe, img { max-width: 100%; }

/* Article detail white card + code block styling */
.post .content.article-body { color:#111827; }
.post .content.article-body p { margin: 10px 0; }
.post .content.article-body img { max-width:100%; height:auto; border-radius:6px; }
/* let theme handle background, but ensure text color is readable */
.post .content.article-body pre { position:relative; padding:14px; border-radius:8px; overflow:auto; border:1px solid var(--border); }
.post .content.article-body pre code { color: #f3f4f6; } /* force light text base */
.post .content.article-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
/* inline code only */
.post .content.article-body p code, .post .content.article-body li code { background:#f3f4f6; color:#111827; padding:2px 5px; border-radius:4px; border:1px solid var(--border); }

/* preview pages without .post wrapper */
.article-body pre { position:relative; padding:14px; border-radius:8px; overflow:auto; border:1px solid var(--border); }
.article-body pre code { color: #f3f4f6; } /* force light text base */
.article-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.article-body p code, .article-body li code { background:#f3f4f6; color:#111827; padding:2px 5px; border-radius:4px; border:1px solid var(--border); }
.code-copy-btn { position:absolute; top:8px; right:8px; height:28px; padding:0 8px; border-radius:6px; border:1px solid rgba(255,255,255,0.25); background:rgba(255,255,255,0.08); color:#fff; cursor:pointer; }
.code-copy-btn:hover { background:rgba(255,255,255,0.18); }

/* Fallback color for non-highlighted code (no .hljs class) */
.post .content.article-body pre code:not(.hljs),
.article-body pre code:not(.hljs) {
  color: #e5e7eb; /* light foreground on dark bg */
}

/* Article detail layout with right TOC */
.post-layout {
  display:grid;
  grid-template-columns: minmax(0,1fr) 260px;
  gap:24px;
  align-items:flex-start;
}
.post-main {
  min-width: 0;
}
.post-toc {
  position:sticky;
  top:96px;
  align-self:flex-start;
}
.post-toc .table-card {
  margin-top:0;
}
.toc-list {
  list-style:none;
  padding-left:0;
  margin:0;
  font-size:14px;
}
.toc-list li {
  margin:4px 0;
}
.toc-l1 > a { font-weight:600; color:#111827; }
.toc-l2 { padding-left:12px; }
.toc-l3 { padding-left:24px; }
.toc-list a {
  color:#6b7280;
  text-decoration:none;
  display:block;
  padding:2px 0;
  border-radius:4px;
}
.toc-list a:hover {
  color:#111827;
}
.toc-list a.active {
  color:#111827;
  background:rgba(99,102,241,0.06);
}
@media (max-width: 1024px) {
  .post-layout {
    grid-template-columns: 1fr;
  }
  .post-toc {
    position:static;
  }
}

/* Enhanced Markdown Styles */
.article-body blockquote,
.post .content.article-body blockquote {
  margin: 1.5em 0;
  padding: 0.8em 1.2em;
  border-left: 4px solid #d1d5db; /* Gray line */
  background: #f9fafb; /* Very light gray bg */
  color: #4b5563;
  border-radius: 0 4px 4px 0;
}
.article-body blockquote p,
.post .content.article-body blockquote p {
  margin: 0;
}

.article-body ul, .article-body ol,
.post .content.article-body ul, .post .content.article-body ol {
  padding-left: 1.5em;
  margin: 1em 0;
}
.article-body li,
.post .content.article-body li {
  margin: 0.4em 0;
}

.article-body h1, .article-body h2, .article-body h3,
.post .content.article-body h1, .post .content.article-body h2, .post .content.article-body h3 {
  margin-top: 1.5em;
  margin-bottom: 0.8em;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}
.article-body h1, .post .content.article-body h1 { font-size: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.article-body h2, .post .content.article-body h2 { font-size: 1.5em; }
.article-body h3, .post .content.article-body h3 { font-size: 1.25em; }

.article-body hr,
.post .content.article-body hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}

.article-body a,
.post .content.article-body a {
  color: #2563eb;
  text-decoration: none;
}
.article-body a:hover,
.post .content.article-body a:hover {
  text-decoration: underline;
}

.article-body strong,
.post .content.article-body strong {
  font-weight: 600;
  color: #111827;
}

/* Learn 文章详情页：更接近博客风格的窄列排版 */
.article-page .hero {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}
.article-page .post-layout {
  max-width: 1060px;
  margin-left: auto;
  margin-right: auto;
}
.article-page .post-main .table-card {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}



