/* ==========================================================================
   少儿 C++ 闯关课堂 —— 样式表
   浅色主题、圆角卡片、大字号，面向 8-14 岁学习者
   ========================================================================== */

:root {
  --bg: #eef4ff;
  --bg-2: #fff7ee;
  --card: #ffffff;
  --ink: #1e293b;
  --ink-2: #5b6779;
  --ink-3: #94a3b8;
  --line: #e2e9f6;
  --line-2: #eef2fa;

  --brand: #3b6df6;
  --brand-soft: #e8efff;
  --brand-deep: #2450cc;
  --accent: #ff8a3d;
  --accent-soft: #fff0e4;

  --ok: #12a150;
  --ok-soft: #e6f9ee;
  --no: #e5484d;
  --no-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fff6e8;
  --note: #7c3aed;
  --note-soft: #f3ecff;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 28px rgba(31, 58, 122, .09);
  --shadow-sm: 0 4px 14px rgba(31, 58, 122, .07);
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, #dfe9ff 0%, rgba(223, 233, 255, 0) 62%),
    radial-gradient(900px 460px at 98% 2%, #ffeede 0%, rgba(255, 238, 222, 0) 58%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 780px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------ 顶部导航 ------------------------------ */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1000px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 18px; color: var(--ink);
  letter-spacing: .2px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--brand), #6f9bff);
  box-shadow: 0 4px 12px rgba(59, 109, 246, .32);
}
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 13px; border-radius: 11px; color: var(--ink-2);
  font-size: 15px; font-weight: 600; white-space: nowrap;
}
.nav-links a:hover { background: var(--brand-soft); color: var(--brand-deep); text-decoration: none; }
.nav-links a.active { background: var(--brand); color: #fff; }
.nav-links a.active:hover { background: var(--brand-deep); color: #fff; }

.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 3px;
  border-radius: 999px; background: var(--no); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 19px; text-align: center;
  vertical-align: 1px;
}
.badge[data-zero="1"] { display: none; }

/* ------------------------------ 通用元件 ------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 22px 24px; margin-bottom: 18px;
}
.card-tight { padding: 16px 18px; }

h1 { font-size: 30px; line-height: 1.35; margin: 0 0 10px; letter-spacing: -.3px; }
h2 { font-size: 23px; line-height: 1.4; margin: 0 0 12px; letter-spacing: -.2px; }
h3 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

code {
  font-family: var(--mono); font-size: .9em;
  background: #f1f5fd; color: #b02a6b;
  padding: 2px 6px; border-radius: 6px;
  word-break: break-word;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 20px; border-radius: 13px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 16px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: .16s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); border-color: #cfd9ee; text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #5c8bff);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(59, 109, 246, .3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-deep), #4a7bf5); }
.btn-accent {
  background: linear-gradient(135deg, #ff9a52, var(--accent));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(255, 138, 61, .3);
}
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--line); color: var(--ink-2); }
.btn-sm { padding: 7px 13px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ 首页 Hero ------------------------------ */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #f6f9ff 55%, #fff6ee 100%);
  border: 1px solid var(--line); border-radius: 24px;
  padding: 34px 32px; margin: 26px 0 22px; box-shadow: var(--shadow);
}
.hero h1 { font-size: 34px; margin-bottom: 12px; }
.hero .lead { font-size: 17px; color: var(--ink-2); max-width: 560px; margin-bottom: 20px; }
.hero .blob {
  position: absolute; right: -70px; top: -70px; width: 260px; height: 260px;
  border-radius: 50%; background: radial-gradient(circle at 30% 30%, #ffe0c4, rgba(255, 224, 196, 0));
}
.hero .blob.b2 {
  right: auto; left: -80px; bottom: -110px; top: auto;
  background: radial-gradient(circle at 50% 50%, #d8e4ff, rgba(216, 228, 255, 0));
}
.hero-inner { position: relative; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.entry {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  transition: .18s; color: inherit; height: 100%;
}
.entry:hover {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: #c9d8f7; text-decoration: none;
}
.entry .ico { font-size: 26px; display: block; margin-bottom: 8px; }
.entry .t { font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.entry .d { font-size: 14px; color: var(--ink-2); line-height: 1.6; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  flex: 1 1 140px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 25px; font-weight: 800; line-height: 1.2; }
.stat .l { font-size: 13px; color: var(--ink-2); }

/* ------------------------------ 进度条 ------------------------------ */
.bar { height: 9px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #6f9bff); transition: width .35s; }
.bar.ok > i { background: linear-gradient(90deg, #21b45f, #57d489); }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* ------------------------------ 代码块 ------------------------------ */
.code {
  position: relative; margin: 14px 0; padding: 15px 17px;
  background: #f7f9fd; border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow-x: auto;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.75;
  color: #24304a; white-space: pre; tab-size: 4;
}
.code code { background: none; padding: 0; color: inherit; font-size: inherit; }

.tok-com { color: #94a3b8; font-style: italic; }
.tok-str { color: #c2410c; }
.tok-num { color: #7c3aed; }
.tok-kw  { color: #2563eb; font-weight: 600; }
.tok-type{ color: #0891b2; font-weight: 600; }
.tok-pre { color: #db2777; font-weight: 600; }
.tok-fn  { color: #0d9488; }

/* ------------------------------ 课程内容块 ------------------------------ */
.block { margin-bottom: 16px; }
.block:last-child { margin-bottom: 0; }

.block-tip, .block-warn, .block-note, .block-try {
  border-radius: var(--radius-sm); padding: 14px 17px;
  border-left: 4px solid; font-size: 15.5px; line-height: 1.7;
}
.block-tip  { background: var(--brand-soft); border-color: var(--brand); }
.block-warn { background: var(--warn-soft); border-color: var(--accent); }
.block-note { background: var(--note-soft); border-color: var(--note); }
.block-try  { background: var(--ok-soft); border-color: var(--ok); }
.block-tip .bt, .block-warn .bt, .block-note .bt, .block-try .bt {
  font-weight: 800; margin-bottom: 5px; display: block; font-size: 15px;
}
.block-tip  .bt { color: var(--brand-deep); }
.block-warn .bt { color: var(--warn); }
.block-note .bt { color: #6d28d9; }
.block-try  .bt { color: #0f7a3d; }

.block-steps ol { margin: 0; padding-left: 22px; }
.block-steps li { margin-bottom: 6px; }
.block-steps li:last-child { margin-bottom: 0; }

.tbl { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0; }
.tbl th, .tbl td { padding: 9px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: #f4f7fe; font-weight: 700; }
.tbl tr:nth-child(even) td { background: #fafcff; }

/* ------------------------------ 课程列表 ------------------------------ */
.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card);
  margin-bottom: 10px; cursor: pointer; transition: .16s; color: inherit;
}
.lesson-item:hover { border-color: #c9d8f7; transform: translateX(3px); text-decoration: none; }
.lesson-item.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--shadow-sm); }
.lesson-item .num {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: var(--line-2); color: var(--ink-2);
}
.lesson-item.active .num { background: var(--brand); color: #fff; }
.lesson-item .done .num, .lesson-item.done .num { background: var(--ok); color: #fff; }
.lesson-item .body { flex: 1; min-width: 0; }
.lesson-item .t { display: block; font-weight: 700; font-size: 16px; line-height: 1.45; }
.lesson-item .m { display: block; font-size: 13px; color: var(--ink-2); line-height: 1.5; margin-top: 2px; }
.lesson-item .mark { flex: none; font-size: 18px; }

/* ------------------------------ 选择题 ------------------------------ */
.q-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.q-head .bar { flex: 1; min-width: 120px; }
.q-meta { font-size: 14px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }

.tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-deep);
}
.tag.d1 { background: #e6f9ee; color: #0f7a3d; }
.tag.d2 { background: #fff6e8; color: var(--warn); }
.tag.d3 { background: #fdecec; color: #b91c1c; }
.tag.plain { background: var(--line-2); color: var(--ink-2); }

.q-stem { font-size: 17.5px; font-weight: 700; margin-bottom: 4px; line-height: 1.6; }

.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  padding: 13px 16px; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; font-family: inherit; font-size: 16.5px; color: var(--ink);
  text-align: left; cursor: pointer; transition: .15s; line-height: 1.6;
}
.opt:hover:not(:disabled) { border-color: var(--brand); background: #f8fbff; transform: translateX(2px); }
.opt:disabled { cursor: default; }
.opt .k {
  flex: none; width: 27px; height: 27px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: var(--line-2); color: var(--ink-2); margin-top: 1px;
}
.opt .v { flex: 1; word-break: break-word; font-family: var(--mono); font-size: 15.5px; }
.opt .v.plain { font-family: inherit; font-size: 16.5px; }

.opt.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-correct .k { background: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--no); background: var(--no-soft); }
.opt.is-wrong .k { background: var(--no); color: #fff; }
.opt.is-picked { box-shadow: 0 0 0 3px rgba(59, 109, 246, .16); }

/* ------------------------------ 反馈 / 讲解 ------------------------------ */
.fb { margin-top: 18px; border-radius: var(--radius); border: 1px solid; overflow: hidden; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.fb-ok { border-color: #a9e6c4; background: var(--ok-soft); }
.fb-no { border-color: #f4c2c3; background: var(--no-soft); }

.fb-title {
  padding: 13px 18px; font-weight: 800; font-size: 17px;
  display: flex; align-items: center; gap: 9px;
}
.fb-ok .fb-title { color: #0f7a3d; }
.fb-no .fb-title { color: #b91c1c; }

.fb-body { background: #fff; border-top: 1px solid rgba(0, 0, 0, .06); padding: 16px 18px; }

.fb-line { display: flex; gap: 10px; margin-bottom: 10px; font-size: 15.5px; align-items: flex-start; }
.fb-line .lb { flex: none; font-weight: 800; color: var(--ink-2); min-width: 74px; }
.fb-line .tx { flex: 1; }
.fb-line .tx b { font-family: var(--mono); }

.why {
  display: block; margin-top: 5px; padding: 8px 12px;
  background: #f7f9fd; border-radius: 9px; border-left: 3px solid var(--ink-3);
  font-size: 14.5px; color: var(--ink-2); line-height: 1.65;
}
.why.good { border-left-color: var(--ok); background: var(--ok-soft); color: #0f6b37; }
.why.bad { border-left-color: var(--no); background: var(--no-soft); color: #a12024; }

.steps-title { font-weight: 800; margin: 16px 0 8px; font-size: 15.5px; color: var(--ink); }
.steps-list { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps-list li {
  position: relative; padding: 9px 0 9px 40px; font-size: 15.5px; line-height: 1.7;
  border-bottom: 1px dashed var(--line);
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 9px;
  width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: 13px; font-weight: 800;
}

.fb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }

/* ------------------------------ 设置面板 ------------------------------ */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field > .lb { font-weight: 800; margin-bottom: 9px; font-size: 15.5px; display: block; }

.chips { display: flex; gap: 9px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; font-family: inherit; font-size: 15px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; transition: .15s;
}
.chip:hover { border-color: #c9d8f7; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.chip .em { font-size: 16px; }

/* ------------------------------ 错题本 ------------------------------ */
.mis-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); margin-bottom: 14px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.mis-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  cursor: pointer; flex-wrap: wrap;
}
.mis-head:hover { background: #fafcff; }
.mis-head .t { flex: 1; font-weight: 700; min-width: 180px; }
.mis-head .times {
  flex: none; font-size: 13px; font-weight: 700;
  background: var(--no-soft); color: #b91c1c;
  padding: 3px 10px; border-radius: 999px;
}
.mis-body { border-top: 1px solid var(--line); padding: 16px 18px; background: #fdfefe; }

.empty { text-align: center; padding: 44px 20px; color: var(--ink-2); }
.empty .e { font-size: 42px; display: block; margin-bottom: 10px; }

/* ------------------------------ 主题掌握度 ------------------------------ */
.topic-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.topic-row .nm { flex: none; width: 132px; font-size: 14.5px; font-weight: 600; }
.topic-row .bar { flex: 1; }
.topic-row .pc { flex: none; width: 62px; text-align: right; font-size: 14px; color: var(--ink-2); font-weight: 700; }

/* ------------------------------ 结算页 ------------------------------ */
.result-hero { text-align: center; padding: 26px 20px; }
.result-hero .big { font-size: 54px; font-weight: 800; line-height: 1.1; }
.result-hero .big.ok { color: var(--ok); }
.result-hero .big.mid { color: var(--warn); }
.result-hero .big.bad { color: var(--no); }

/* ------------------------------ 提示条 ------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(16px);
  background: #1e293b; color: #fff; padding: 12px 22px; border-radius: 13px;
  font-size: 15px; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, .24);
  opacity: 0; pointer-events: none; transition: .24s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------ 页脚 ------------------------------ */
.footer {
  margin: 46px 0 30px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-3); text-align: center; line-height: 1.9;
}

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 860px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 26px 22px; }
  .hero h1 { font-size: 27px; }
}
@media (max-width: 620px) {
  body { font-size: 16px; }
  .wrap, .wrap-narrow { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nav-inner { padding: 9px 14px; gap: 10px; }
  .brand { font-size: 16px; }
  .brand .logo { width: 30px; height: 30px; font-size: 16px; }
  .nav-links a { padding: 6px 9px; font-size: 14px; }
  h1 { font-size: 24px; }
  .hero h1 { font-size: 23px; }
  .card { padding: 17px 16px; }
  .code { font-size: 13px; padding: 12px 13px; }
  .fb-line { flex-direction: column; gap: 2px; }
  .fb-line .lb { min-width: 0; }
  .topic-row .nm { width: 96px; font-size: 13.5px; }
  .result-hero .big { font-size: 42px; }
}

@media print {
  .nav, .btn, .footer, .toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}
