:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #12233a;
  --muted: #5a6b82;
  --line: #e2e8f0;
  --primary: #0f2744;
  --accent: #e8910c;
  --accent-soft: #fff4e0;
  --ok: #0d8a5a;
  --ok-soft: #e6f7ef;
  --warn: #c45c12;
  --danger: #c62828;
  --trap: #9b1c4a;
  --follow: #1d5bbf;
  --challenge: #6b3fa0;
  --base: #0f766e;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(15, 39, 68, 0.08);
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  min-height: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; background: var(--bg); position: relative; box-shadow: 0 0 0 1px var(--line); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #0f2744 0%, #163359 100%);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #1a1200; font-weight: 800;
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; opacity: 0.72; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 12px;
  background: rgba(255,255,255,0.12); color: #fff; font-size: 20px; cursor: pointer;
  flex-shrink: 0;
}
.icon-btn.hidden { display: none; }

.main { flex: 1; padding: 16px 16px calc(24px + var(--safe-b)); }

.hero {
  background: linear-gradient(135deg, #0f2744, #1e4a7a);
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: 22px; letter-spacing: 0.02em; }
.hero p { margin: 0; opacity: 0.85; font-size: 14px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,0.14);
}
.chip.accent { background: var(--accent); color: #1a1200; }
.chip.soft { background: #eef2f7; color: var(--muted); }
.chip.base { background: #d1fae5; color: var(--base); }
.chip.trap { background: #fce7f0; color: var(--trap); }
.chip.followup { background: #dbeafe; color: var(--follow); }
.chip.challenge { background: #ede9fe; color: var(--challenge); }
.chip.disabled-note { background: #f1f5f9; color: #94a3b8; }

.section-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin: 8px 0 10px; letter-spacing: 0.04em;
}

.card-grid { display: grid; gap: 12px; }
.entry-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-align: left;
  box-shadow: var(--shadow); cursor: pointer; width: 100%;
  transition: transform .12s ease, border-color .12s;
}
.entry-card:active { transform: scale(0.985); }
.entry-card .ico {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.entry-card h3 { margin: 0 0 4px; font-size: 17px; }
.entry-card p { margin: 0; font-size: 13px; color: var(--muted); }
.ico.a { background: #e8f0ff; color: #1d5bbf; }
.ico.b { background: #fff4e0; color: #c45c12; }
.ico.c { background: #e6f7ef; color: #0d8a5a; }

.notice {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: #fff8eb; border: 1px solid #f5d9a6; font-size: 13px; color: #7a4e00;
}
.notice strong { color: #5c3a00; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.panel p, .panel li { color: var(--ink); font-size: 14.5px; }
.panel ul { margin: 8px 0; padding-left: 1.2em; }
.lesson-nav { display: flex; gap: 8px; margin-top: 16px; }
.lesson-dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.dot.on { background: var(--accent); width: 20px; border-radius: 999px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 18px; border-radius: 14px;
  border: 1px solid transparent; font-weight: 700; font-size: 15px;
  cursor: pointer; width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: #1a1200; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-soft { background: #eef3f9; color: var(--primary); }
.btn:disabled, .btn[disabled] {
  background: #e8edf3 !important; color: #94a3b8 !important;
  border-color: #e8edf3 !important; cursor: not-allowed;
}
.btn-row { display: grid; gap: 10px; margin-top: 12px; }
.btn-row.two { grid-template-columns: 1fr 1fr; }

.choice-list { display: grid; gap: 10px; }
.choice {
  min-height: var(--tap); padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; text-align: left;
  font-weight: 600; cursor: pointer; position: relative;
}
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.disabled {
  background: #f8fafc; color: #94a3b8; border-style: dashed; cursor: not-allowed;
}
.choice .tag {
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: #e2e8f0; color: #64748b;
  vertical-align: middle;
}
.step-bar {
  display: flex; gap: 6px; margin-bottom: 14px;
}
.step-bar span {
  flex: 1; height: 4px; border-radius: 999px; background: #dbe3ee;
}
.step-bar span.on { background: var(--accent); }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.filter-pill {
  min-height: 36px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.filter-pill.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.empty {
  text-align: center; padding: 40px 16px; color: var(--muted);
  background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--line);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--muted);
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.form-group textarea { min-height: 88px; resize: vertical; }
.progress {
  height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0 4px;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f5b84a); width: 0%; }

.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.q-progress { font-size: 13px; color: var(--muted); margin-left: auto; font-weight: 600; }
.q-stem {
  font-size: 18px; font-weight: 700; line-height: 1.45; margin: 0 0 16px;
}
.answer-area textarea {
  width: 100%; min-height: 120px; padding: 14px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; margin-bottom: 12px;
}
.skill-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.skill {
  min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line);
  background: #fff; font-weight: 700; cursor: pointer;
}
.skill.on-ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.skill.on-weak { border-color: var(--warn); background: #fff3e8; color: var(--warn); }

.reveal {
  margin-top: 14px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
}
.reveal .block { padding: 14px; }
.reveal .block + .block { border-top: 1px solid var(--line); }
.reveal .label { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.reveal .answer { font-size: 14.5px; white-space: pre-wrap; }
.reveal .why { font-size: 14px; color: #334155; }
.ph {
  background: #fff4e0; color: #9a5b00; padding: 1px 4px; border-radius: 4px; font-weight: 700;
}
.parent-hint {
  font-size: 12px; color: var(--follow); background: #eff6ff; padding: 8px 10px;
  border-radius: 10px; margin-bottom: 10px;
}

.sticky-actions {
  position: sticky; bottom: 0; margin: 16px -16px calc(-16px - var(--safe-b));
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(244,246,250,0), var(--bg) 28%);
  display: grid; gap: 8px;
}

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat {
  background: #f8fafc; border-radius: 12px; padding: 12px 8px; text-align: center;
}
.stat .n { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat .l { font-size: 11px; color: var(--muted); }

.demo-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 10px;
}
.demo-card h4 { margin: 0 0 6px; font-size: 15px; }
.demo-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }

.footer-note { text-align: center; font-size: 12px; color: #94a3b8; margin-top: 20px; }

@media (min-width: 481px) {
  #app { min-height: 100vh; margin-top: 0; border-radius: 0; }
}

/* ---- Mode skins (IT交接备注 / 视觉规范) ---- */
body[data-mode="lesson"] { --bg: #f0f4f8; }
body[data-mode="demos"] { --bg: #f4f6fa; }
body[data-mode="train"] { --bg: #eef2f7; }
body[data-mode="mock"] { --bg: #f4f6fa; }
body[data-mode="lesson"] #app,
body[data-mode="demos"] #app,
body[data-mode="train"] #app,
body[data-mode="mock"] #app { background: var(--bg); }

.entry-card.is-primary { border-left: 4px solid var(--accent); }
.entry-card.is-secondary { box-shadow: none; opacity: 0.92; }

/* Demo cover thumb */
.cover-thumb {
  width: 96px; height: 54px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(15, 39, 68, 0.12), rgba(15, 39, 68, 0.28));
  display: grid; place-items: center; color: var(--primary); font-size: 18px; font-weight: 800;
}
.demo-card {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  transition: transform .12s ease, border-color .12s;
}
.demo-card:active { transform: scale(0.985); }
.demo-card .demo-body { flex: 1; min-width: 0; }
.demo-card.is-placeholder { cursor: default; opacity: 0.85; }
.demo-card.is-placeholder:active { transform: none; }
.demo-card.is-active { border-color: var(--accent); }

.demo-player {
  margin-bottom: 12px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #000;
}
.demo-player .ratio-16x9 {
  position: relative; width: 100%; padding-top: 56.25%;
}
.demo-player .ratio-16x9 iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.demo-player-meta { padding: 12px 14px; background: var(--surface); }
.demo-caution {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: #fff8eb; border: 1px solid #f5d9a6; font-size: 13px; color: #7a4e00;
}
.demo-placeholder-box {
  padding: 28px 16px; text-align: center; color: var(--muted);
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 12px;
}

/* Bubbles (shell — train/mock later) */
.bubble {
  max-width: 92%; margin: 0 0 10px; padding: 12px 14px;
  border-radius: 16px; font-size: 14.5px; line-height: 1.5;
  border: 1px solid var(--line); background: #fff;
}
.bubble.user {
  margin-left: auto; background: var(--primary); color: #fff; border-color: var(--primary);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.system { border-bottom-left-radius: 6px; }
.bubble.auditor { border-bottom-left-radius: 6px; }
.bubble.frame {
  background: var(--accent-soft); border-color: transparent;
  border-left: 3px solid var(--accent); border-radius: 14px;
}
.bubble.why {
  background: #eef2f7; border-color: transparent;
  border-left: 3px solid var(--follow); border-radius: 14px;
}
.bubble .bubble-label {
  display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 6px;
}
.bubble.user .bubble-label { color: rgba(255,255,255,0.75); }

/* Eval result shells (visual only) */
.eval-pass, .eval-soft, .eval-hard, .eval-boundary {
  margin: 0 0 10px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid transparent; border-left-width: 3px; font-size: 14.5px;
}
.eval-pass { border-left-color: #0d8a5a; background: #e6f7ef; }
.eval-soft { border-left-color: #c45c12; background: #fff3e8; }
.eval-hard { border-left-color: #c62828; background: #fdecea; }
.eval-boundary { border-left-color: #475569; background: #f1f5f9; }
.eval-pass .eval-tag,
.eval-soft .eval-tag,
.eval-hard .eval-tag,
.eval-boundary .eval-tag {
  display: inline-block; font-size: 12px; font-weight: 800; margin-bottom: 6px;
}
.eval-pass .eval-tag { color: #0d8a5a; }
.eval-soft .eval-tag { color: #c45c12; }
.eval-hard .eval-tag { color: #c62828; }
.eval-boundary .eval-tag { color: #475569; }

.tip-panel {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: #fff8eb; border: 1px solid #f5d9a6; font-size: 13px; color: #7a4e00;
}
.tip-panel.danger {
  background: #fdecea; border-color: #f5c2c0; color: #8b1e1e;
}

.red-lines {
  margin: 12px 0 0; padding: 12px; border-radius: 12px;
  background: #fdecea; border: 1px solid #f5c2c0;
}
.red-lines .label { font-size: 12px; font-weight: 800; color: var(--danger); margin-bottom: 6px; }
.red-lines ul { margin: 0; padding-left: 1.2em; }
.red-lines li { font-size: 14px; color: #7f1d1d; }


/* shell aliases for learn/demos */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-pill { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.filter-pill.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.demo-player { margin-bottom: 12px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; }
.ratio-16x9 { position: relative; width: 100%; padding-top: 56.25%; }
.ratio-16x9 iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.demo-player-meta { padding: 12px 14px; background: var(--surface); }
.demo-caution { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #fff8eb; border: 1px solid #f5d9a6; font-size: 13px; color: #7a4e00; }
.demo-placeholder-box { padding: 28px 16px; text-align: center; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 12px; }
.demo-card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; cursor: pointer; }
.demo-card.is-placeholder { opacity: 0.85; }
.demo-card.is-active { border-color: var(--accent); }
.cover-thumb { width: 96px; height: 54px; border-radius: 10px; flex-shrink: 0; background: linear-gradient(135deg, rgba(15,39,68,.12), rgba(15,39,68,.28)); display: grid; place-items: center; color: var(--primary); font-weight: 800; }
.demo-body { flex: 1; min-width: 0; }
.demo-body h4 { margin: 0 0 6px; font-size: 15px; }
.demo-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.chip.disabled-note { background: #f1f5f9; color: #94a3b8; }
.red-lines { margin: 12px 0 0; padding: 12px; border-radius: 12px; background: #fdecea; border: 1px solid #f5c2c0; }
.red-lines .label { font-size: 12px; font-weight: 800; color: var(--danger); margin-bottom: 6px; }
.lesson-dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.lesson-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.lesson-dots .dot.on { background: var(--accent); width: 20px; border-radius: 999px; }
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.entry-card.is-primary { border-left: 4px solid var(--accent); }
.empty .big, .demo-placeholder-box .big { font-size: 40px; margin-bottom: 8px; }


/* ---- Train session (先问后讲) ---- */
.answer-area.hidden { display: none; }
.train-thread { margin-top: 4px; }
.bubble .bubble-body { white-space: pre-wrap; word-break: break-word; }
.bubble.frame .bubble-label { color: #9a5b00; }
.bubble.why .bubble-label { color: var(--follow); }
body[data-mode="train"] .sticky-actions {
  background: linear-gradient(180deg, rgba(238,242,247,0), var(--bg) 28%);
}

/* ---- Mock room (纠偏链) ---- */
.mock-thread { margin-top: 4px; }
.eval-bar .eval-body { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.5; }
.btn-lock,
.btn[data-locked="1"] {
  opacity: 0.45;
  position: relative;
  pointer-events: none;
  cursor: not-allowed;
}
.btn-lock::after,
.btn[data-locked="1"]::after {
  content: "答后解锁";
  position: absolute;
  right: 10px;
  top: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}
.btn-accent.is-holding {
  filter: brightness(0.88);
  transform: scale(0.98);
  box-shadow: inset 0 0 0 2px rgba(26, 18, 0, 0.18);
}
body[data-mode="mock"] .sticky-actions {
  background: linear-gradient(180deg, rgba(244, 246, 250, 0), var(--bg) 28%);
}
.skill-row.hidden { display: none; }
