/* 全站样式改造说明：基于 Bootstrap 的轻量主题层与通用布局类 */
:root {
  --app-bg: #f5f8ff;
  --app-surface: #ffffff;
  --app-primary: #2f6df6;
  --app-primary-soft: #eef4ff;
  --app-text: #1e3a5f;
  --app-text-muted: #64748b;
  --app-border: #dbe7ff;
  --app-shadow: 0 1px 6px rgba(47, 109, 246, 0.06);
  --app-radius-lg: 14px;
  --app-radius-md: 10px;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-text);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  flex-shrink: 0;
  border-bottom: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.app-navbar {
  min-height: 64px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
}

.app-brand-mark {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

.app-nav-link {
  color: var(--app-text-muted);
  font-weight: 500;
}

.app-nav-link:hover,
.app-navbar .nav-link.app-nav-link:hover {
  color: var(--app-primary);
}

.app-navbar .nav-link.app-nav-link {
  color: var(--app-text-muted);
  font-weight: 500;
  padding: 0.45rem 0.7rem;
}

.app-navbar .nav-link.app-nav-link.active {
  color: var(--app-primary);
  font-weight: 700;
}

.app-main {
  flex: 1;
  width: min(1200px, 95vw);
  margin: 22px auto 24px;
}

/* 编程做题页：主内容区更宽（不影响其他页）、仅当页内存在包装时生效 */
.app-main:has(.program-problem-page) {
  width: min(1800px, 90vw);
}

/* 知识图谱页：内容区加宽，画布按视口高度拉大 */
.app-main:has(.knowledge-graph-page) {
  width: min(1760px, 98vw);
}

.app-main:has(.knowledge-graph-page) .app-content {
  padding: 0.65rem 0.85rem 1rem;
}

/* 高度由 knowledge_graph.html 内脚本按视口动态设置，避免与 calc/min-height 争抢导致图挤在上方 */
.knowledge-graph-viewport {
  width: 100%;
  min-height: 480px;
}

/* vis-network 内部层默认高度不足时会导致画布只占顶端一条 */
.knowledge-graph-viewport.knowledge-graph-canvas {
  background: radial-gradient(
    120% 85% at 50% 42%,
    var(--app-surface) 0%,
    var(--app-primary-soft) 48%,
    var(--app-bg) 100%
  );
}

.knowledge-graph-viewport .vis-network {
  min-height: 100%;
}

.knowledge-graph-viewport.knowledge-graph-canvas canvas {
  background: transparent !important;
}

.knowledge-graph-canvas.is-layouting {
  opacity: 0;
  pointer-events: none;
}

.knowledge-graph-stage {
  position: relative;
}

.knowledge-graph-pending {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--app-text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.learn-graph-page .knowledge-graph-pending {
  inset: 0;
}

.knowledge-graph-pending.d-none {
  display: none !important;
}

/* vis-network 导航钮（上下左右、缩放）；选项关闭仍偶现时强制隐藏 */
.knowledge-graph-viewport .vis-network div.vis-navigation {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 991.98px) {
  .knowledge-graph-viewport {
    min-height: 360px;
  }
}

.app-content {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow);
  padding: 1rem 1.25rem 1.25rem;
}

.app-card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: var(--app-surface);
  box-shadow: none;
}

.app-section-title {
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.app-list-card {
  margin-bottom: 1rem;
}

.app-question-index {
  position: sticky;
  top: 88px;
}

.app-question-index .btn {
  width: 45px;
  margin-top: 5px;
}

.app-table-wrap {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  overflow: hidden;
}

.app-table-wrap .table {
  margin-bottom: 0;
}

.app-tag-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-footer {
  border-top: 1px solid var(--app-border);
  background: #ffffff;
  color: var(--app-text-muted);
}

.app-shell:has(.is-subject-open) {
  height: 100vh;
  overflow: hidden;
}

.app-shell:has(.is-subject-open) .app-footer {
  display: none;
}

.app-shell:has(.is-subject-open) .app-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-footer-inner {
  width: min(1200px, 95vw);
  margin: 0 auto;
  padding: 1.15rem 0;
  font-size: 0.9rem;
  line-height: 1.7;
  text-align: center;
}

.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: #255fe0;
  --bs-btn-hover-border-color: #255fe0;
  --bs-btn-active-bg: #1f56d0;
  --bs-btn-active-border-color: #1f56d0;
}

.btn-outline-primary {
  --bs-btn-color: var(--app-primary);
  --bs-btn-border-color: #bfd4ff;
  --bs-btn-hover-bg: var(--app-primary-soft);
  --bs-btn-hover-border-color: #9fbeff;
  --bs-btn-hover-color: #255fe0;
}

.navbar-toggler {
  border-color: #c8dcff;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.12rem rgba(47, 109, 246, 0.2);
}

.dropdown-menu {
  border: 1px solid var(--app-border);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(47, 109, 246, 0.08);
}

.dropdown-item:active {
  background: var(--app-primary-soft);
  color: #1f56d0;
}

.alert {
  border-radius: 10px;
  border-width: 1px;
}

.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: #ecfeff;
  border-color: #bae6fd;
  color: #0c4a6e;
}

.alert-warning {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.modal-content {
  border: 1px solid var(--app-border);
  border-radius: 12px;
}

.nav-tabs {
  border-bottom-color: var(--app-border);
}

.nav-tabs .nav-link {
  color: var(--app-text-muted);
  border: 1px solid transparent;
}

.nav-tabs .nav-link.active {
  color: var(--app-primary);
  background: var(--app-primary-soft);
  border-color: var(--app-border) var(--app-border) #ffffff;
}

.ai-markdown h1,
.ai-markdown h2,
.ai-markdown h3,
.ai-markdown h4 {
  margin-top: 0.55rem;
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.ai-markdown {
  font-size: 0.96rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.ai-markdown p {
  margin-bottom: 0.5rem;
}

.ai-markdown ul,
.ai-markdown ol {
  margin-bottom: 0.55rem;
  padding-left: 1.2rem;
}

.ai-markdown li + li {
  margin-top: 0.25rem;
}

.ai-markdown p + ul,
.ai-markdown p + ol,
.ai-markdown pre + p,
.ai-markdown p + pre {
  margin-top: 0.55rem;
}

.ai-markdown code {
  background: #f3f6ff;
  border: 1px solid #dbe7ff;
  border-radius: 4px;
  padding: 0.05rem 0.28rem;
}

.ai-markdown pre {
  background: #f8fbff;
  border: 1px solid #dbe7ff;
  border-radius: 8px;
  padding: 0.6rem;
  overflow: auto;
}

.ai-markdown pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.ai-markdown hr {
  border: 0;
  border-top: 1px solid var(--app-border);
  margin: 0.85rem 0;
}

.ai-markdown blockquote {
  margin: 0.7rem 0;
  padding: 0.55rem 0.8rem;
  border-left: 4px solid #9fbeff;
  background: #f5f9ff;
  border-radius: 8px;
  color: #334155;
}

.ai-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.65rem 0;
  font-size: 0.92em;
}

.ai-markdown th,
.ai-markdown td {
  border: 1px solid var(--app-border);
  padding: 0.45rem 0.55rem;
  vertical-align: top;
}

.ai-markdown thead th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
}

.ai-markdown a {
  color: #255fe0;
  text-decoration: none;
}

.ai-markdown a:hover {
  text-decoration: underline;
}

/* 编程提交详情：Ace 只读视图隐藏光标，避免误以为可编辑 */
.ace-readonly-view .ace_cursor,
.ace-readonly-view .ace_hidden-cursors .ace_cursor {
  opacity: 0 !important;
  display: none !important;
}

/* —— 编程题库 / 做题页 —— */
.program-bank-hero {
  border-radius: var(--app-radius-md);
  background: #ffffff;
  border: 1px solid var(--app-border);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.15rem;
  box-shadow: none;
}

.program-bank-hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--app-text);
  margin-bottom: 0.35rem;
}

.program-bank-hero-meta {
  font-size: 0.875rem;
  color: var(--app-text-muted);
  line-height: 1.5;
}

.program-bank-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-primary);
}

.program-bank-table-wrap {
  border-radius: var(--app-radius-md);
  overflow: hidden;
  border: 1px solid var(--app-border);
  box-shadow: none;
  background: var(--app-surface);
}

.program-bank-table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: #64748b;
  border-bottom: 2px solid var(--app-border);
  padding: 0.8rem 1rem;
  white-space: nowrap;
}

.program-bank-table tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom-color: #f1f5f9;
}

.program-bank-table tbody tr {
  transition: background-color 0.14s ease;
}

.program-bank-table tbody tr:hover {
  background-color: #f8fafc;
}

.program-bank-table tbody tr:last-child td {
  border-bottom: 0;
}

.program-bank-table .col-id {
  font-variant-numeric: tabular-nums;
  color: var(--app-text-muted);
  font-weight: 600;
  width: 3.5rem;
}

.program-bank-table .title-link {
  font-weight: 600;
  color: var(--app-text);
  text-decoration: none;
  line-height: 1.4;
}

.program-bank-table .title-link:hover {
  color: var(--app-primary);
}

.badge-diff-easy {
  background: #f0f6ff !important;
  color: #2457c5 !important;
  border: 1px solid #cfe0ff;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.6em;
}

.badge-diff-medium {
  background: #e8f1ff !important;
  color: #1f4fb8 !important;
  border: 1px solid #bdd4ff;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.6em;
}

.badge-diff-hard {
  background: #dce9ff !important;
  color: #1b3f9c !important;
  border: 1px solid #9fbeff;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.6em;
}

.badge-diff-none {
  background: #f8fafc !important;
  color: #64748b !important;
  border: 1px solid #dbe7ff;
  font-weight: 500;
  font-size: 0.72rem;
  padding: 0.35em 0.6em;
}

.program-tag-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--app-border);
  color: #475569;
  margin: 0.12rem 0.28rem 0.12rem 0;
}

a.program-tag-pill {
  text-decoration: none;
  color: var(--app-primary);
  border-color: #c5d4f7;
}

a.program-tag-pill:hover {
  background: var(--app-primary-soft);
  border-color: var(--app-primary);
  color: var(--app-primary);
}

.program-bank-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--app-text-muted);
  border: 2px dashed var(--app-border);
  border-radius: var(--app-radius-md);
  background: #ffffff;
}

.program-bank-empty-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  opacity: 0.65;
}

.program-pagination .page-link {
  border-radius: 0.45rem;
  margin: 0 0.28rem;
  border: 1px solid #e5e7eb;
  color: #475569;
  font-weight: 500;
  min-width: 2rem;
  text-align: center;
  background: #fff;
  box-shadow: none;
  transition: all 0.16s ease;
  padding: 0.5rem 0.92rem;
}

.program-pagination .page-link:hover {
  color: #1e3a5f;
  border-color: #b8d0ff;
  background: #f0f6ff;
  transform: none;
}

.program-pagination .page-item.active .page-link {
  background: #2f6df6;
  border-color: #2f6df6;
  color: #fff;
  box-shadow: none;
}

.program-pagination .page-item:first-child .page-link,
.program-pagination .page-item:last-child .page-link {
  padding-left: 1.1rem;
  padding-right: 1.1rem;
  font-size: 0.82rem;
}

.program-submissions-page nav[aria-label="分页"] {
  margin-top: 1.25rem !important;
  margin-bottom: 0.55rem;
}

@media (max-width: 768px) {
  .program-pagination .page-link {
    padding: 0.34rem 0.72rem;
    margin: 0 0.18rem;
    min-width: 2rem;
    font-size: 0.8rem;
  }
}

.program-submissions-table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background: #f8fafc;
  border-bottom-width: 1px;
}

.program-submissions-table td {
  vertical-align: middle;
}

.program-submissions-page .badge {
  min-width: 3.6rem;
  text-align: center;
}

.program-result-badge {
  min-width: 4.1rem;
  padding: 0.35rem 0.62rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.program-result-pass {
  color: #14532d !important;
  background: #f0fdf4 !important;
  border: 1px solid #bbf7d0;
}

.program-result-fail {
  color: #991b1b !important;
  background: #fef2f2 !important;
  border: 1px solid #fecaca;
}

.program-result-error {
  color: #9a3412 !important;
  background: #fff7ed !important;
  border: 1px solid #fed7aa;
}

.program-result-pending {
  color: #475569 !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1;
}

.program-problem-header .problem-title {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.25rem;
}

.program-problem-io pre {
  border-radius: 10px;
  border: 1px solid var(--app-border);
  background: #f8fafc !important;
  font-size: 0.85rem;
}

#program-debug-panel pre {
  border-radius: 8px;
  border: 1px solid var(--app-border);
  background: #fff !important;
}

/* 做题页 Ace 编辑区：适中高度，随窗口变化 */
#program-editor.program-code-editor {
  min-height: clamp(280px, 38vh, 560px);
  width: 100%;
}

/* 做题页：大屏两列（题面 | 编辑器） */
@media (min-width: 992px) {
  .program-problem-two-col .program-problem-pane-left {
    flex: 0 0 30%;
    max-width: 30%;
  }

  .program-problem-two-col .program-problem-pane-right {
    flex: 0 0 70%;
    max-width: 70%;
  }

  .program-problem-two-col .program-problem-pane-left {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-right: 0.25rem;
  }

  .program-problem-two-col .program-problem-pane-right {
    position: sticky;
    top: 76px;
    align-self: flex-start;
  }

  .program-problem-two-col #program-editor.program-code-editor {
    min-height: calc(100vh - 320px);
    max-height: calc(100vh - 260px);
  }
}

.program-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

/*
 * 首页题集卡片：固定断点列数（对齐原 col-12 / col-sm-6 / col-lg-4）。
 * 勿用 auto-fit + minmax：列数会随“当前行是否排满”变化，最后一行被拉高、其它页全窄，显得翻页后卡片变小。
 */
.home-question-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 576px) {
  .home-question-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .home-question-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.home-question-grid > .card {
  min-width: 0;
  /** 铺满网格单元，避免与 SSR 占位宽度不一致 */
  width: 100%;
}

.home-question-grid > .home-set-empty {
  grid-column: 1 / -1;
}

.home-track-group .btn.active,
.home-type-group .btn.active {
  color: #fff;
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.home-type-group {
  gap: 0.35rem;
}

.home-type-group .btn {
  border-radius: 0.375rem !important;
}

.home-set-card .card-title {
  font-size: 1.05rem;
  line-height: 1.4;
}

/* 首页增强（方案 A） */
.app-home-hero {
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 60%);
}

.app-home-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.app-home-metric {
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: #f8fbff;
  padding: 0.65rem 0.75rem;
}

.app-home-metric .k {
  font-size: 1.2rem;
  line-height: 1.1;
  font-weight: 700;
  color: #1f56d0;
}

.app-home-metric .v {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--app-text-muted);
}

/* exam 页面布局增强 */
.exam-bottom-bar {
  position: sticky;
  bottom: 8px;
  z-index: 20;
  border-color: #cfe0ff;
  box-shadow: 0 4px 14px rgba(47, 109, 246, 0.08);
}

.app-question-index .question-nav-btn {
  margin-top: 0.35rem;
}

@media (min-width: 1200px) {
  .app-question-index {
    position: sticky;
    top: 84px;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
}

/* exam 填空输入框美化 */
input.gap_filling {
  width: min(100%, 420px);
  height: 2.2rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #c9dafc;
  border-radius: 8px;
  background: #f9fbff;
  color: #1e3a5f;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

input.gap_filling:hover {
  border-color: #aac6ff;
  background: #ffffff;
}

input.gap_filling:focus {
  border-color: #2f6df6;
  background: #ffffff;
  box-shadow: 0 0 0 0.12rem rgba(47, 109, 246, 0.16);
}

@media (max-width: 768px) {
  .app-home-metric-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.1rem;
  }

  .app-home-metric-grid {
    display: flex;
    gap: 0.6rem;
    width: max-content;
    min-width: 100%;
  }

  .app-home-metric {
    min-width: 138px;
  }
}

@media (max-width: 768px) {
  .app-main {
    width: 95vw;
    margin-top: 14px;
  }

  .app-content {
    padding: 0.9rem;
  }

  .app-question-index {
    position: static;
    top: auto;
  }
}

/* 题干：保留文本中的换行（HTML 默认会把换行折叠成空格） */
.question-stem-multiline {
  white-space: pre-line;
}

/* 编程题 / 题集 Markdown 题面 */
.program-stem-markdown {
  font-size: 0.9375rem;
  line-height: 1.7;
  word-break: break-word;
  color: var(--app-text, #1e3a5f);
}

.program-problem-description {
  /* 左侧窄栏内题面：避免公式撑破布局 */
  min-width: 0;
}

.program-stem-markdown > *:first-child {
  margin-top: 0;
}

.program-stem-markdown p {
  margin-bottom: 0.75rem;
}

.program-stem-markdown p:last-child {
  margin-bottom: 0;
}

.program-stem-markdown h1,
.program-stem-markdown h2,
.program-stem-markdown h3,
.program-stem-markdown h4,
.program-stem-markdown h5,
.program-stem-markdown h6 {
  margin-top: 1.15rem;
  margin-bottom: 0.5rem;
  font-weight: 650;
  color: var(--app-text, #1e3a5f);
  line-height: 1.35;
}

.program-stem-markdown h1:first-child,
.program-stem-markdown h2:first-child,
.program-stem-markdown h3:first-child {
  margin-top: 0;
}

.program-stem-markdown h1 {
  font-size: 1.2rem;
}

.program-stem-markdown h2 {
  font-size: 1.1rem;
}

.program-stem-markdown h3,
.program-stem-markdown h4 {
  font-size: 1.02rem;
}

.program-stem-markdown hr {
  margin: 1rem 0;
  border: 0;
  border-top: 1px solid var(--app-border, #dbe7ff);
  opacity: 1;
}

.program-stem-markdown pre {
  background: #f1f5f9;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
  overflow-x: auto;
  border: 1px solid var(--app-border, #e2e8f0);
  margin-bottom: 0.85rem;
}

.program-stem-markdown pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.program-stem-markdown :not(pre) > code {
  background: rgba(47, 109, 246, 0.08);
  padding: 0.12em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
}

.program-stem-markdown code {
  font-size: 0.875em;
}

.program-stem-markdown ul,
.program-stem-markdown ol {
  padding-left: 1.35rem;
  margin-bottom: 0.75rem;
}

.program-stem-markdown li {
  margin-bottom: 0.35rem;
}

.program-stem-markdown li:last-child {
  margin-bottom: 0;
}

.program-stem-markdown table {
  width: 100%;
  font-size: 0.875rem;
  margin-bottom: 0.85rem;
  border-collapse: collapse;
}

.program-stem-markdown th,
.program-stem-markdown td {
  border: 1px solid var(--app-border, #dbe7ff);
  padding: 0.4rem 0.55rem;
  vertical-align: top;
}

.program-stem-markdown th {
  background: #f8fafc;
  font-weight: 600;
}

.program-stem-markdown blockquote {
  margin: 0 0 0.85rem;
  padding: 0.5rem 0 0.5rem 0.85rem;
  border-left: 3px solid var(--app-border, #dbe7ff);
  color: var(--app-text-muted, #64748b);
  background: rgba(248, 250, 252, 0.8);
  border-radius: 0 8px 8px 0;
}

/* MathJax 3：窄栏内公式（含误用行内 $ 包 cases 时的超长行）可横向滚动 */
.program-stem-markdown mjx-container[jax="CHTML"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  vertical-align: middle;
}

.program-stem-markdown mjx-container[jax="CHTML"][display="true"] {
  display: block;
  padding: 0.35rem 0;
}

/* 显示公式整块绕过 marked，单独容器便于留白与滚动 */
.program-stem-math-display {
  margin: 0.65rem 0 1rem;
  overflow-x: auto;
  max-width: 100%;
}

/* 编程题「智能问答」/ 助手长文：层级更清晰、减少多余硬换行观感 */
.program-ai-hint {
  font-size: 0.9rem;
  line-height: 1.62;
}

.program-ai-hint h3 {
  margin-top: 1rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--app-border, #dbe7ff);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--app-primary, #2f6df6);
}

.program-ai-hint h3:first-child {
  margin-top: 0;
}

.program-ai-hint p {
  margin-bottom: 0.55rem;
}

.program-ai-hint ul,
.program-ai-hint ol {
  margin-bottom: 0.55rem;
}

.program-ai-hint li {
  margin-bottom: 0.28rem;
}

.program-ai-hint strong {
  font-weight: 650;
  color: var(--app-text, #1e3a5f);
}

.program-ai-hint pre {
  margin-top: 0.45rem;
  margin-bottom: 0.65rem;
}

/* 学习主路径界面（占位骨架，沿用现站色） */
.app-main:has(.learn-page) {
  width: min(1080px, 95vw);
}

.app-main:has(.is-subject-open) {
  width: 100%;
  margin: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-main:has(.learn-page) .app-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.learn-crumb {
  color: var(--app-text-muted);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.learn-crumb a {
  color: inherit;
  text-decoration: none;
}

.learn-crumb a:hover {
  color: var(--app-primary);
  text-decoration: underline;
}

.learn-h1 {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.learn-h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.15rem 0 0.35rem;
}

.learn-h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.learn-strong {
  font-weight: 650;
}

.learn-muted {
  color: var(--app-text-muted);
  font-size: 0.9rem;
}

.learn-kicker {
  font-size: 0.78rem;
  color: var(--app-text-muted);
  font-weight: 650;
  margin-bottom: 0.35rem;
}

.learn-subject-row,
.learn-actions,
.learn-num-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.learn-actions {
  width: 100%;
}

.learn-actions.w-auto {
  width: auto;
}

.learn-graph-page {
  display: none;
}

.learn-home-subjects.is-expanded .learn-graph-page {
  display: block !important;
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(135deg, #f8fbff, #f5f8ff);
}

.learn-home-graph,
.learn-home-graph.knowledge-graph-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  z-index: 1;
}

.learn-home-graph .vis-network,
.learn-home-graph.knowledge-graph-canvas canvas {
  background: transparent !important;
}

.learn-legend-panel {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 100;
  width: 200px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.learn-legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 0.85rem;
  color: #1a1a1a;
  cursor: pointer;
}

.learn-legend-caret {
  color: #6b6b6b;
  font-size: 0.75rem;
}

.learn-legend-body {
  padding: 16px;
}

.learn-legend-panel.is-collapsed {
  width: 80px;
}

.learn-legend-panel.is-collapsed .learn-legend-header {
  justify-content: center;
  border-bottom: 0;
}

.learn-legend-panel.is-collapsed .learn-legend-caret,
.learn-legend-panel.is-collapsed .learn-legend-body {
  display: none;
}

.learn-legend-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.learn-legend-reset:hover {
  background: #f1f5f9;
}

.learn-legend-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 10px;
}

.learn-legend-row,
.learn-legend-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #6b6b6b;
  margin-bottom: 8px;
}

.learn-legend-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 12px 0;
}

.learn-line {
  display: inline-block;
  width: 1.15rem;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.learn-line-tree {
  background: #bfd4ff;
}

.learn-line-rel {
  height: 0;
  border-bottom: 3px dashed #2f6df6;
  background: none;
}

.learn-line-pre {
  background: #e05252;
}

.learn-subject-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.learn-home-subjects.is-expanded .learn-subject-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-width: 90vw;
}

.learn-continue-compact {
  margin-bottom: 0.75rem;
}

.learn-home-subjects {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.learn-page.is-subject-open,
.learn-page.is-subject-open .learn-home-subjects {
  position: relative;
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.learn-subject-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35rem;
  min-height: 240px;
  padding: 1.7rem 1.5rem;
  text-align: left;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  cursor: pointer;
}

.learn-subject-tile:hover,
.learn-subject-tile.is-active {
  border-color: #9fbeff;
  background: var(--app-primary-soft);
}

.learn-subject-tile-kicker {
  font-size: 0.78rem;
  color: var(--app-text-muted);
}

.learn-subject-tile-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--app-text);
}

.learn-home-subjects.is-expanded .learn-subject-tile {
  min-height: 0;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  align-items: center;
}

.learn-home-subjects.is-expanded .learn-subject-tile:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.learn-home-subjects.is-expanded .learn-subject-tile.is-active {
  background: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.learn-home-subjects.is-expanded .learn-subject-tile-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: #64748b;
}

.learn-home-subjects.is-expanded .learn-subject-tile.is-active .learn-subject-tile-title {
  color: var(--app-primary);
  font-weight: 600;
}

.learn-home-subjects.is-expanded .learn-subject-tile .learn-muted,
.learn-home-subjects.is-expanded .learn-subject-tile-kicker {
  display: none;
}

@media (max-width: 767.98px) {
  .learn-subject-bar {
    grid-template-columns: 1fr;
  }

  .learn-home-subjects.is-expanded .learn-subject-bar {
    padding: 8px 12px;
    border-radius: 20px;
  }

  .learn-legend-panel {
    display: none;
  }
}

.learn-subject-row {
  margin-bottom: 1rem;
}

.learn-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--app-border);
  background: #fff;
  color: var(--app-text);
  border-radius: 999px;
  padding: 0.28rem 0.8rem;
  font-size: 0.88rem;
  text-decoration: none;
}

button.learn-pill {
  cursor: pointer;
}

.learn-pill:hover {
  color: var(--app-primary);
  border-color: #9fbeff;
}

.learn-pill.is-active {
  background: var(--app-primary-soft);
  border-color: #9fbeff;
  color: var(--app-primary);
  font-weight: 650;
}

.learn-tag {
  display: inline-flex;
  border: 1px solid var(--app-border);
  background: #fff;
  color: var(--app-text-muted);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
}

.learn-card,
.learn-catalog,
.learn-mock-bar,
.learn-callout {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  margin-bottom: 0.85rem;
}

.learn-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0;
  font-weight: 650;
}

.learn-card-body {
  padding: 0.85rem 1rem 1rem;
}

.learn-page-head,
.learn-catalog-head,
.learn-mock-bar,
.learn-inline-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.learn-page-head {
  margin-bottom: 1rem;
}

.learn-catalog {
  padding: 1rem 1.1rem 0.4rem;
}

.learn-catalog-head {
  margin-bottom: 0.75rem;
}

.learn-stat {
  text-align: right;
}

.learn-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.learn-stat-label {
  font-size: 0.78rem;
  color: var(--app-text-muted);
}

.learn-node {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid var(--app-border);
}

.learn-node:hover {
  color: inherit;
}

.learn-node-num {
  width: 28px;
  color: var(--app-text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.learn-node-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.learn-node-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.learn-node-go {
  color: var(--app-text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.learn-node-current {
  border-top: 1px solid var(--app-border);
  border-bottom: 1px solid var(--app-border);
  padding: 1rem 0;
  justify-content: space-between;
}

.learn-node-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  color: var(--app-text-muted);
  font-size: 0.82rem;
}

.learn-mock-bar {
  padding: 0.95rem 1rem;
  align-items: center;
}

.learn-stem {
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0.4rem 0 1rem;
}

.learn-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.learn-option {
  text-align: left;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
}

.learn-option.is-selected {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

.learn-option.is-correct {
  border-color: #16a34a;
  background: #f0fdf4;
}

.learn-option.is-wrong {
  border-color: #dc2626;
  background: #fef2f2;
}

.learn-option:disabled {
  cursor: default;
}

.learn-grade {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  font-weight: 650;
}

.learn-grade.is-ok {
  color: #15803d;
}

.learn-grade.is-bad {
  color: #b91c1c;
}

.learn-grade.is-warn {
  color: #b45309;
}

.learn-explain {
  border: 1px solid var(--app-border);
  background: var(--app-primary-soft);
  border-radius: var(--app-radius-md);
  padding: 0.9rem 1rem;
}

.learn-explain-title {
  font-weight: 650;
  margin-bottom: 0.35rem;
}

.learn-video {
  min-height: 200px;
  border: 1px solid var(--app-border);
  background: var(--app-primary-soft);
  border-radius: var(--app-radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.learn-code {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.learn-md {
  color: var(--app-text);
  font-size: 0.95rem;
  line-height: 1.7;
}

.learn-md > :first-child {
  margin-top: 0;
}

.learn-md > :last-child {
  margin-bottom: 0;
}

.learn-md h2,
.learn-md h3,
.learn-md h4 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 1rem 0 0.45rem;
}

.learn-md p,
.learn-md ul,
.learn-md ol {
  margin: 0 0 0.75rem;
}

.learn-md li + li {
  margin-top: 0.2rem;
}

.learn-md code {
  background: #eef4ff;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  font-size: 0.88em;
}

.learn-md pre {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  margin: 0 0 0.85rem;
}

.learn-md pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

.learn-md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.35rem 0 1rem;
  font-size: 0.88rem;
}

.learn-md th,
.learn-md td {
  border: 1px solid var(--app-border);
  padding: 0.45rem 0.6rem;
  vertical-align: top;
}

.learn-md th {
  background: #eef4ff;
  font-weight: 650;
}

.learn-md tr:nth-child(even) td {
  background: #f8fbff;
}

.learn-points p,
.learn-points ul {
  margin-bottom: 0.85rem;
}

.learn-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.learn-tree,
.learn-outline {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.learn-tree a,
.learn-outline a {
  color: inherit;
  text-decoration: none;
}

.learn-tree a:hover,
.learn-outline a:hover {
  color: var(--app-primary);
}

.learn-tree-leaf {
  padding-left: 1rem;
  font-size: 0.9rem;
}

.learn-tree-current {
  font-weight: 650;
}

.learn-callout {
  padding: 0.9rem 1rem;
}

.learn-inline-meta {
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.learn-num-row {
  margin: 0.5rem 0 1rem;
}

@media (max-width: 767.98px) {
  .learn-split,
  .learn-node-current,
  .learn-page-head,
  .learn-catalog-head,
  .learn-mock-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .learn-stat {
    text-align: left;
  }

  .learn-node-go {
    display: none;
  }
}

/* 编程题提交评测（做题页内嵌，非全屏） */
.program-judge-panel {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f7fc 100%);
}

.program-judge-panel.is-pass {
  background: #f3fbf6;
  border-color: #b7e4c7;
}

.program-judge-panel.is-fail {
  background: #fff7f4;
  border-color: #f4c7b8;
}

.program-judge-panel.is-error {
  background: #fffaf0;
  border-color: #ecd9a8;
}

.program-judge-pending {
  display: none;
  align-items: center;
  gap: 0.75rem;
}

.program-judge-panel.is-pending .program-judge-pending {
  display: flex;
}

.program-judge-spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--app-border);
  border-top-color: var(--app-primary);
  animation: program-judge-spin 0.7s linear infinite;
}

.program-judge-title {
  font-weight: 700;
  color: var(--app-text);
  font-size: 0.98rem;
}

.program-judge-sub {
  margin: 0.15rem 0 0;
  color: var(--app-text-muted);
  font-size: 0.85rem;
}

.program-judge-badge-pass {
  background: #198754;
  color: #fff;
}

.program-judge-badge-fail {
  background: #dc3545;
  color: #fff;
}

.program-judge-badge-error {
  background: #6c757d;
  color: #fff;
}

@keyframes program-judge-spin {
  to { transform: rotate(360deg); }
}

.learn-oj-state {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
}

.learn-oj-state.is-todo {
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.learn-oj-state.is-tried {
  color: #9a6700;
  background: #fff8e8;
  border: 1px solid #ecd9a8;
}

.learn-oj-state.is-passed {
  color: #146c43;
  background: #eef8f1;
  border: 1px solid #b7e4c7;
}

.learn-oj-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.learn-card.is-oj-tried {
  border-color: #ecd9a8;
}

.learn-card.is-oj-passed {
  border-color: #b7e4c7;
  background: #f7fdf9;
}

.learn-oj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.1rem;
  border-top: 1px solid var(--app-border);
}

.learn-oj-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.learn-oj-row-title {
  flex: 1 1 12rem;
  font-weight: 600;
}

.program-bank-table tbody tr.is-oj-passed {
  background: #f7fdf9;
}

.program-bank-table tbody tr.is-oj-tried {
  background: #fffdf6;
}

.program-bank-table .col-oj-state {
  width: 5.5rem;
  white-space: nowrap;
}
