/* ============================================================
   components.css — 通用组件
   ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 650;
  border: 1px solid transparent; transition: var(--transition); white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-strong); color: var(--on-brand); box-shadow: var(--shadow); }
.btn--soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn--soft:hover { background: color-mix(in srgb, var(--brand-soft) 70%, var(--brand) 14%); }
.btn--ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: var(--fs-xs); }
.btn--lg { padding: 12px 22px; font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft);
  font-size: 16px; transition: var(--transition);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }

/* ---------- 卡片 / 面板 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card--pad { padding: var(--s5); }
.card--hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); border-color: var(--line-strong); }
.card--link { cursor: pointer; }
.panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- 徽章 / 标签 / 药丸 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 650; line-height: 1.5;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge--brand { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.badge--info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { font-family: var(--font-code); font-size: 11px; color: var(--ink-mute); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; }
.tag--ok { color: var(--ok); background: var(--ok-soft); font-weight: 800; }
.problem-meta, .tag-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag-line span {
  display: inline-flex; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-soft); font-size: var(--fs-xs);
}

/* ---------- 代码块 ---------- */
.code-box {
  position: relative; margin: var(--s3) 0; border-radius: var(--r);
  background: var(--code-bg); border: 1px solid var(--code-line); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.code-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: 7px 12px; background: var(--code-bg-2); border-bottom: 1px solid var(--code-line);
}
.code-dots { display: flex; gap: 5px; }
.code-dots i { width: 10px; height: 10px; border-radius: 50%; background: #2e4a40; display: block; }
.code-dots i:nth-child(1){ background:#e06c61 } .code-dots i:nth-child(2){ background:#e0b341 } .code-dots i:nth-child(3){ background:#56c489 }
.code-lang { font-family: var(--font-code); font-size: 11px; color: var(--code-gutter); letter-spacing: .04em; }
.code-copy {
  margin-left: auto; font-size: 11px; color: var(--code-gutter); font-family: var(--font-code); font-weight: 700;
  padding: 3px 9px; border-radius: 6px; transition: var(--transition);
}
.code-copy:hover { color: var(--code-ink); background: rgba(255,255,255,.06); }
.code-copy.is-done { color: var(--ok); }
.code-copy.is-error { color: var(--danger); }
.code-body {
  margin: 0; padding: var(--s3) var(--s4); overflow-x: hidden;
  font-family: var(--font-code); font-size: var(--fs-code); line-height: var(--lh-code);
  color: var(--code-ink); font-variant-ligatures: none; tab-size: 4; font-weight: 600;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.code-body .cl { display: block; white-space: pre-wrap; }
.code-body .cl::before {
  content: attr(data-ln); display: inline-block; width: 2.2em; margin-right: 1.1em;
  text-align: right; color: var(--code-gutter); user-select: none; opacity: .7;
}
.tok-kw { color: var(--tok-kw); } .tok-type { color: var(--tok-type); }
.tok-fn { color: var(--tok-fn); } .tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); } .tok-cmt { color: var(--tok-cmt); font-style: italic; }
.tok-pre { color: var(--tok-pre); } .tok-op { color: var(--tok-op); }

/* 运行输出 */
.code-out { margin: calc(var(--s3) * -1 + 2px) 0 var(--s3); border: 1px solid var(--line); border-top: none; border-radius: 0 0 var(--r) var(--r); background: var(--surface-2); padding: 10px 14px; }
.code-out-tag { display: inline-block; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-mute); letter-spacing: .04em; margin-bottom: 5px; }
.code-out pre { font-family: var(--font-code); font-size: var(--fs-sm); color: var(--ink); white-space: pre-wrap; line-height: 1.5; }

/* 行内代码 */
.ic { font-family: var(--font-code); font-size: .92em; background: var(--surface-2); color: var(--brand-ink); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); }
[data-theme="dark"] .ic { color: var(--brand-strong); }

/* ---------- 表格 ---------- */
.data-table { width: 100%; border-collapse: collapse; margin: var(--s3) 0; font-size: var(--fs-sm); }
.data-table th, .data-table td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); }
.data-table thead th { background: var(--surface-2); color: var(--ink-soft); font-weight: 650; font-size: var(--fs-xs); letter-spacing: .02em; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td:first-child { font-family: var(--font-code); color: var(--brand-ink); }
[data-theme="dark"] .data-table td:first-child { color: var(--brand-strong); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.table-wrap .data-table { margin: 0; }
.table-wrap .data-table th, .table-wrap .data-table td { border-bottom: 1px solid var(--line); }
.table-wrap .data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- 概念图:流程 / 内存盒子 ---------- */
.concept-card {
  margin: var(--s3) 0; padding: var(--s4); border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface-2);
}
.concept-title { font-weight: 750; color: var(--ink); margin-bottom: var(--s3); }
.concept-flow {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3); align-items: stretch;
}
.concept-step {
  min-width: 0; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); padding: var(--s3);
}
.concept-step-label {
  display: inline-flex; margin-bottom: 6px; padding: 2px 7px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink);
  font-size: var(--fs-xs); font-family: var(--font-code); font-weight: 700;
}
.concept-step b { display: block; margin-bottom: 4px; }
.concept-step p { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.65; }
.concept-arrow { display: none; }
.concept-note { margin: var(--s3) 0 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.65; }
.memory-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: var(--s3); }
.memory-cell {
  min-width: 0; padding: var(--s3); border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
}
.memory-name {
  display: block; margin-bottom: 6px; color: var(--ink-mute);
  font-family: var(--font-code); font-size: var(--fs-xs); font-weight: 700;
}
.memory-cell strong {
  display: block; font-family: var(--font-code); font-size: var(--fs-lg);
  color: var(--brand-ink); overflow-wrap: anywhere;
}
.memory-cell small { display: block; margin-top: 6px; color: var(--ink-soft); line-height: 1.55; }
.memory-cell--alias { border-color: color-mix(in srgb, var(--brand) 38%, var(--line)); background: var(--brand-soft); }
.memory-cell--copy { border-color: color-mix(in srgb, var(--warn) 42%, var(--line)); background: var(--warn-soft); }
.computer-layout { display: grid; grid-template-columns: minmax(180px, .9fr) minmax(240px, 1.35fr); gap: var(--s4); }
.computer-panel {
  min-width: 0; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); padding: var(--s4);
}
.panel-label {
  color: var(--ink-mute); font-size: var(--fs-xs); font-weight: 750;
  letter-spacing: .02em; margin-bottom: var(--s3);
}
.monitor-shape {
  height: 96px; border: 2px solid var(--brand); border-radius: 8px;
  display: grid; place-items: center; color: var(--brand-ink);
  font-weight: 750; background: var(--brand-soft);
}
.input-shapes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s3); }
.input-shapes span {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px; text-align: center; color: var(--ink-soft); font-size: var(--fs-sm);
}
.computer-panel p { margin: var(--s3) 0 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.65; }
.host-case {
  border: 2px solid color-mix(in srgb, var(--ink) 18%, var(--line));
  border-radius: 10px; padding: var(--s3); background: var(--surface-2);
}
.host-title { font-weight: 750; margin-bottom: var(--s3); color: var(--ink); }
.computer-parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.computer-part {
  min-width: 0; padding: var(--s3); border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
}
.computer-part span { display: block; font-family: var(--font-code); font-weight: 800; color: var(--brand-ink); margin-bottom: 5px; }
.computer-part b { display: block; font-size: var(--fs-sm); margin-bottom: 5px; }
.computer-part small { display: block; color: var(--ink-soft); line-height: 1.55; }
@media (max-width: 760px) {
  .computer-layout { grid-template-columns: 1fr; }
  .computer-parts { grid-template-columns: 1fr; }
}
.ascii-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.ascii-group {
  min-width: 0; padding: var(--s3); border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
}
.ascii-group b { display: block; margin-bottom: 8px; color: var(--ink); }
.ascii-mini { display: grid; gap: 6px; }
.ascii-mini span {
  display: flex; justify-content: space-between; gap: var(--s2);
  font-family: var(--font-code); font-size: var(--fs-sm);
}
.ascii-mini code { color: var(--brand-ink); font-weight: 800; }
.ascii-group p { margin: 8px 0 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.6; }
.ascii-details summary {
  cursor: pointer; color: var(--brand-ink); font-weight: 700;
  padding: 8px 0; list-style-position: inside;
}
.ascii-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 6px;
}
.ascii-cell {
  min-width: 0; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 7px; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.ascii-cell span { font-family: var(--font-code); color: var(--ink-mute); font-size: var(--fs-xs); }
.ascii-cell b { font-family: var(--font-code); color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 760px) { .ascii-groups { grid-template-columns: 1fr; } }

/* ---------- 提示框 ---------- */
.callout { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r); margin: var(--s3) 0; border: 1px solid var(--line); background: var(--surface-2); }
.callout .ic-emoji { font-size: 18px; flex: none; line-height: 1.5; }
.callout-body { min-width: 0; } .callout-body b { display: block; margin-bottom: 2px; }
.callout--tip { background: var(--brand-soft); border-color: transparent; }
.callout--warn { background: var(--warn-soft); border-color: transparent; }
.callout--info { background: var(--info-soft); border-color: transparent; }
.callout--danger { background: var(--danger-soft); border-color: transparent; }

/* ---------- 进度条 ---------- */
.progress { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--brand), var(--brand-strong)); transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ---------- 标签页 ---------- */
.tabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.tab { padding: 7px 15px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); transition: var(--transition); display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s3); }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-strong); transition: var(--transition);
}
.textarea { font-family: var(--font-code); font-size: var(--fs-sm); resize: vertical; min-height: 90px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg button { padding: 6px 13px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); transition: var(--transition); }
.seg button.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

/* ---------- 测验 ---------- */
.quiz-q { margin-bottom: var(--s4); padding-bottom: var(--s4); border-bottom: 1px dashed var(--line); }
.quiz-q:last-child { border-bottom: none; }
.quiz-stem { font-weight: 600; margin-bottom: var(--s3); display: flex; gap: var(--s2); }
.quiz-stem .qno { flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-family: var(--font-code); font-size: 12px; font-weight: 700; }
.quiz-options { display: grid; gap: var(--s2); }
.quiz-option {
  display: flex; align-items: flex-start; gap: var(--s3); padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; transition: var(--transition);
}
.quiz-option:hover { border-color: var(--brand); background: var(--surface-2); }
.quiz-option input { margin-top: 3px; accent-color: var(--brand); }
.quiz-option.is-correct { background: var(--ok-soft); border-color: var(--ok); }
.quiz-option.is-wrong { background: var(--danger-soft); border-color: var(--danger); }
.quiz-option.is-picked { background: var(--brand-soft); border-color: var(--brand); }

/* 测验变体卡 */
.variant-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.seg-card { padding: var(--s4); border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface); text-align: center; transition: var(--transition); display: flex; flex-direction: column; gap: 4px; }
.seg-card:hover { border-color: var(--brand); }
.seg-card.is-active { border-color: var(--brand); background: var(--brand-soft); }
.seg-card b { font-size: var(--fs-md); color: var(--brand-ink); }
[data-theme="dark"] .seg-card.is-active b { color: var(--brand-strong); }
.seg-card span { font-size: var(--fs-xs); color: var(--ink-mute); font-family: var(--font-code); }
.quiz-key { font-family: var(--font-code); font-weight: 700; flex: none; color: var(--ink-mute); }
.quiz-explain { margin-top: var(--s2); padding: 9px 13px; background: var(--surface-2); border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--ink-soft); border-left: 3px solid var(--brand); }

/* ---------- 编程练习 ---------- */
.programming-practice { display: grid; gap: var(--s4); }
.programming-level { display: grid; gap: var(--s3); }
.programming-level-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 0 var(--s1);
}
.programming-level-head span { font-size: var(--fs-lg); font-weight: 800; color: var(--ink); }
.programming-level-head small {
  color: var(--ink-mute); font-family: var(--font-code); font-weight: 700;
}
.programming-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s3); }
.programming-card {
  min-width: 0; padding: var(--s4); border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.programming-card.is-done { border-color: color-mix(in srgb, var(--ok) 38%, var(--line)); background: var(--ok-soft); }
.programming-card h4 { margin: var(--s2) 0; font-size: var(--fs-md); line-height: 1.35; }
.programming-card p { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.7; }
.task-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.task-meta span, .task-meta b {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-family: var(--font-code); font-weight: 800;
}
.task-meta span { color: var(--brand-ink); background: var(--brand-soft); }
.task-meta b { color: var(--ok); background: var(--ok-soft); }
.task-meta b.is-local { color: var(--ink-mute); background: var(--surface-2); }
.programming-card dl {
  display: grid; gap: var(--s2); margin: var(--s3) 0 0;
}
.programming-card dl div {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: var(--s2);
  padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2);
}
.programming-card dt { color: var(--ink-mute); font-size: var(--fs-xs); font-weight: 800; }
.programming-card dd { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.55; overflow-wrap: anywhere; }
.task-hint {
  margin-top: var(--s3); padding: 9px 11px; border-left: 3px solid var(--brand);
  background: var(--brand-soft); border-radius: var(--r-sm);
  color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.6;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  z-index: 100; padding: 11px 20px; border-radius: var(--r-full);
  background: var(--ink); color: var(--paper); font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: var(--transition);
  max-width: 90vw;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 加载动画 ---------- */
.spinner { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--ink-mute); }
.empty .ic-emoji { font-size: 40px; opacity: .6; }

/* ---------- OJ 代码编辑器 ---------- */
.oj-editor { display: block; width: 100%; min-height: 360px; resize: vertical; border: none; outline: none;
  background: var(--code-bg); color: var(--code-ink); font-family: var(--font-code); font-size: var(--fs-code);
  line-height: var(--lh-code); padding: var(--s3) var(--s4); tab-size: 4; font-variant-ligatures: none; }
.oj-editor:focus { box-shadow: inset 0 0 0 2px var(--brand); }

/* ---------- 可视化 ---------- */
.viz-bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: var(--s3); background: var(--surface-2); border-radius: var(--r); }
.viz-bar { flex: 1; min-width: 0; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--brand), var(--brand-strong)); display: flex; align-items: flex-start; justify-content: center; transition: height .3s cubic-bezier(.4,0,.2,1), background .2s; position: relative; }
.viz-bar span { font-family: var(--font-code); font-size: 11px; color: var(--on-brand); margin-top: 4px; font-weight: 700; }
.viz-bar.is-cmp { background: linear-gradient(180deg, var(--accent), #9a6c1c); }
.viz-bar.is-swap { background: linear-gradient(180deg, var(--danger), #9c352e); }
.viz-bar.is-sorted { background: linear-gradient(180deg, var(--ok), #1f6e41); }
.viz-controls { display: flex; gap: var(--s2); flex-wrap: wrap; }
.arr-row { display: flex; gap: 6px; flex-wrap: wrap; }
.arr-cell { display: flex; flex-direction: column; align-items: center; }
.arr-cell .arr-idx { font-family: var(--font-code); font-size: 10px; color: var(--ink-mute); margin-bottom: 3px; }
.arr-cell .arr-val { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface); border: 1.5px solid var(--line-strong); font-family: var(--font-code); font-weight: 700; color: var(--brand-ink); }
[data-theme="dark"] .arr-cell .arr-val { color: var(--brand-strong); }

/* 汉诺塔只表现盘片位置变化，不把讲解文字做成轮播。 */
.hanoi-card { margin: var(--s3) 0; }
.hanoi-frame { display: grid; gap: var(--s3); }
.hanoi-title { font-weight: 800; color: var(--ink); }
.hanoi-frame > p { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.65; }
.hanoi-board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3);
  min-height: 250px; padding: var(--s4) var(--s3) var(--s2);
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
}
.hanoi-tower { display: grid; grid-template-rows: minmax(190px, 1fr) auto; gap: var(--s2); min-width: 0; text-align: center; }
.hanoi-stack { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-height: 190px; padding-bottom: 10px; }
.hanoi-stack::after { content: ""; position: absolute; right: 4%; bottom: 0; left: 4%; height: 10px; border-radius: var(--r-full); background: var(--ink-mute); opacity: .42; }
.hanoi-stack > i { position: absolute; bottom: 8px; left: 50%; width: 8px; height: 168px; border-radius: var(--r-full) var(--r-full) 0 0; background: var(--ink-mute); opacity: .32; transform: translateX(-50%); }
.hanoi-disk { position: relative; z-index: 1; display: grid; place-items: center; height: 36px; margin-top: 3px; border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: var(--r-full); background: linear-gradient(90deg, var(--brand-strong), var(--brand)); color: var(--on-brand); box-shadow: var(--shadow-sm); transition: width .2s ease; }
.hanoi-disk b { font-family: var(--font-code); font-size: var(--fs-xs); }
.hanoi-tower > strong { color: var(--brand-ink); font-family: var(--font-code); font-size: var(--fs-sm); }
.hanoi-move { display: flex; align-items: center; gap: var(--s3); padding: 10px 12px; border-radius: var(--r-sm); background: var(--brand-soft); }
.hanoi-move span { color: var(--ink-mute); font-size: var(--fs-xs); font-weight: 800; }
.hanoi-move b { color: var(--brand-ink); font-family: var(--font-code); }
@media (max-width: 680px) {
  .hanoi-board { min-height: 196px; gap: 5px; padding-inline: 5px; }
  .hanoi-tower { grid-template-rows: minmax(145px, 1fr) auto; }
  .hanoi-stack { min-height: 145px; }
  .hanoi-stack > i { height: 124px; }
  .hanoi-disk { height: 30px; }
}

/* ---------- 真实过程图：图形状态变化是主体，文字只作一句提示 ---------- */
.process-card { margin: var(--s3) 0; }
.process-body { min-width: 0; }
.process-stage { display: grid; gap: var(--s3); }
.process-diagram {
  display: grid; min-height: 210px; place-items: center; overflow: auto;
  padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r);
  background: color-mix(in srgb, var(--surface-2) 74%, var(--surface));
}
.process-stage > p { display: flex; align-items: baseline; gap: var(--s3); margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); }
.process-stage > p b { flex: none; color: var(--brand-ink); }
.process-stage > p span { min-width: 0; }
.process-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: var(--s3); color: var(--ink-mute); font-size: var(--fs-xs); }
.process-legend span { display: inline-flex; align-items: center; gap: 6px; }
.process-legend i { width: 12px; height: 12px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.process-legend i.is-active { border-color: var(--accent); background: var(--accent-soft); }
.process-legend i.is-done { border-color: var(--ok); background: var(--ok-soft); }
.process-legend i.is-muted { opacity: .35; background: var(--surface-3); }
.process-legend i.is-bad { border-color: var(--danger); background: var(--danger-soft); }

.process-cell {
  display: grid; place-items: center; min-width: 48px; min-height: 48px;
  border: 2px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  color: var(--ink); transition: transform .22s ease, opacity .22s ease, border-color .22s ease, background .22s ease;
}
.process-cell > span { color: var(--ink-mute); font: 700 10px/1 var(--font-code); }
.process-cell > b { font: 800 var(--fs-sm)/1.2 var(--font-code); }
.process-cell.is-active { z-index: 1; border-color: var(--accent); background: var(--accent-soft); transform: translateY(-5px); }
.process-cell.is-done { border-color: var(--ok); background: var(--ok-soft); }
.process-cell.is-muted { opacity: .3; transform: scale(.94); }
.process-cell.is-bad { border-color: var(--danger); background: var(--danger-soft); }

.process-array-wrap { width: max-content; min-width: min(100%, 340px); margin: auto; }
.process-array { display: flex; justify-content: center; gap: 7px; }
.process-pointers { position: relative; height: 42px; margin-top: 7px; }
.process-pointer { position: absolute; left: calc(var(--pointer-index) * 55px + 24px); display: grid; justify-items: center; color: var(--accent); transform: translateX(-50%); }
.process-pointer b { font: 850 11px/1 var(--font-code); }
.process-pointer i { font-style: normal; line-height: 1; }

.process-linear { display: flex; align-items: flex-end; justify-content: center; gap: 8px; min-width: 280px; min-height: 150px; }
.process-linear--stack { flex-direction: column-reverse; align-items: center; justify-content: flex-start; }
.process-linear--stack .process-cell { width: min(260px, 70vw); }
.process-linear--queue .process-cell { min-width: 64px; }
.process-base { width: min(300px, 76vw); padding-top: 7px; border-top: 4px solid var(--ink-mute); color: var(--ink-mute); text-align: center; font-size: var(--fs-xs); }
.process-queue-labels { display: flex; justify-content: space-between; width: min(460px, 82vw); margin-top: 8px; color: var(--brand); font: 800 11px var(--font-code); }

.process-grid {
  display: grid; grid-template-columns: repeat(var(--process-columns), minmax(38px, 54px));
  justify-content: center; gap: 6px; width: max-content; min-width: 0;
}
.process-grid .process-cell { min-width: 38px; min-height: 38px; }

.process-graph { display: block; width: min(100%, 720px); min-width: 420px; height: auto; overflow: visible; }
.process-edge line { stroke: var(--line-strong); stroke-width: 3; transition: stroke .22s ease, stroke-width .22s ease, opacity .22s ease; }
.process-edge text { fill: var(--ink-mute); font: 750 12px var(--font-code); paint-order: stroke; stroke: var(--surface); stroke-width: 5px; }
.process-edge.is-active line { stroke: var(--accent); stroke-width: 5; }
.process-edge.is-done line { stroke: var(--ok); stroke-width: 4; }
.process-graph marker path { fill: var(--line-strong); }
.process-node circle { fill: var(--surface); stroke: var(--line-strong); stroke-width: 3; transition: fill .22s ease, stroke .22s ease, opacity .22s ease; }
.process-node-label { fill: var(--ink); font: 850 13px var(--font-code); text-anchor: middle; }
.process-node-badge { fill: var(--brand); font: 850 11px var(--font-code); text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.process-node.is-active circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 5; }
.process-node.is-done circle { fill: var(--ok-soft); stroke: var(--ok); }
.process-node.is-muted { opacity: .28; }
.process-node.is-bad circle { fill: var(--danger-soft); stroke: var(--danger); }

.process-string { display: grid; gap: 18px; width: max-content; min-width: min(100%, 360px); }
.process-string > div { display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; gap: 10px; }
.process-string small { color: var(--ink-mute); font-size: var(--fs-xs); font-weight: 800; }
.process-string > div > div { display: flex; gap: 4px; }
.process-char { display: grid; place-items: center; width: 38px; height: 42px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--surface); font: 850 var(--fs-sm) var(--font-code); transition: transform .22s ease, opacity .22s ease, background .22s ease; }
.process-char.is-gap { visibility: hidden; }
.process-char.is-active { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-4px); }
.process-char.is-done { border-color: var(--ok); background: var(--ok-soft); }

@media (max-width: 680px) {
  .table-wrap--2 .data-table { min-width: 440px; }
  .table-wrap--3 .data-table { min-width: 600px; }
  .table-wrap--4 .data-table { min-width: 720px; }
  .table-wrap .data-table th, .table-wrap .data-table td { line-height: 1.65; vertical-align: top; }
  .process-diagram { min-height: 178px; padding: 12px 8px; }
  .process-stage > p { display: grid; gap: 3px; }
  .process-cell { min-width: 40px; min-height: 43px; }
  .process-array { gap: 4px; }
  .process-pointer { left: calc(var(--pointer-index) * 44px + 20px); }
  .process-grid { grid-template-columns: repeat(var(--process-columns), minmax(31px, 43px)); gap: 4px; }
  .process-grid .process-cell { min-width: 31px; min-height: 34px; font-size: 12px; }
  .process-graph { width: 100%; min-width: 0; max-width: 100%; }
  .process-char { width: 31px; height: 36px; }
  .unit-nav-footer { display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .unit-nav-footer .btn { width: 100%; max-width: 100%; white-space: normal; text-align: center; }
}

/* ---------- 模态 ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(8,18,14,.5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: var(--s4); animation: pop .2s ease both; }
.modal { width: min(560px, 96vw); max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-body { padding: var(--s5); }
