/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f6df5;
  --primary-dark: #3a54c9;
  --primary-light: #e9edff;
  --ok: #17a34a;
  --ok-bg: #e9f9ef;
  --err: #dc2626;
  --err-bg: #fdeaea;
  --warn: #b45309;
  --warn-bg: #fdf3e0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e8f0;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 36, 48, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand-logo { font-size: 26px; }
.brand-name { font-size: 18px; }
.brand-slogan {
  font-size: 12px; color: var(--muted); font-weight: 400;
  border-left: 1px solid var(--border); padding-left: 8px;
}
.topnav { display: flex; gap: 6px; }
.topnav a {
  color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 14px;
}
.topnav a:hover { background: var(--primary-light); text-decoration: none; }
.topnav a.active { background: var(--primary); color: #fff; }

/* ===== 主体 ===== */
.app { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 22px 18px 48px; outline: none; }

/* ===== 通用卡片 ===== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }

/* ===== 首页 / 课程卡 ===== */
.hero { text-align: center; padding: 34px 18px 26px; }
.hero h1 { font-size: 30px; letter-spacing: .5px; }
.hero p { color: var(--muted); margin-top: 8px; font-size: 16px; }
.hero .hero-actions { margin-top: 18px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.section-title { margin: 28px 0 14px; font-size: 19px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.course-card {
  display: flex; flex-direction: column; cursor: pointer; padding: 20px;
  transition: transform .15s ease, box-shadow .15s ease; position: relative; overflow: hidden;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(31,36,48,.1); }
.course-card .icon { font-size: 34px; line-height: 1; }
.course-card .c-title { font-size: 18px; font-weight: 700; margin: 10px 0 4px; }
.course-card .c-desc { color: var(--muted); font-size: 13.5px; flex: 1; }
.course-card .c-meta { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.course-card .chip-new {
  position: absolute; top: 12px; right: -34px; transform: rotate(45deg);
  background: #ff6b6b; color: #fff; font-size: 11px; padding: 4px 38px;
}
.progress-wrap { margin-top: 10px; }
.progress-bar { height: 8px; border-radius: 999px; background: #eef1f8; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4f6df5, #7c8cf8); width: 0; transition: width .4s ease; }
.progress-txt { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 9px 18px; border-radius: 10px; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: all .15s ease; user-select: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 26px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== 进度仪表 ===== */
.dash-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 20px; }
.stat { text-align: center; padding: 16px 10px; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ===== 学习页 ===== */
.lesson-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.lesson-title { font-size: 22px; font-weight: 800; }
.lesson-desc { color: var(--muted); font-size: 14px; }

.steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.step-dot {
  height: 10px; width: 10px; border-radius: 50%; background: #dfe4f0; cursor: pointer;
  transition: all .2s; border: none; padding: 0;
}
.step-dot.done { background: var(--ok); }
.step-dot.cur { background: var(--primary); transform: scale(1.3); }

.section-pad { padding: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-title-inline { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section-type-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-light); color: var(--primary-dark); font-weight: 600;
}

.knowledge { font-size: 15px; color: #333a48; }
.knowledge h3 { font-size: 16px; margin: 12px 0 6px; }
.knowledge ul { padding-left: 22px; margin: 6px 0; }
.knowledge li { margin: 3px 0; }
.knowledge .tip {
  background: var(--primary-light); border-radius: 10px; padding: 10px 14px;
  margin: 12px 0; font-size: 14px;
}
.knowledge .warn-box {
  background: var(--warn-bg); color: var(--warn); border-radius: 10px;
  padding: 10px 14px; margin: 12px 0; font-size: 14px;
}
kbd {
  background: #eef1f8; border: 1px solid #d5dbea; border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 7px; font-family: ui-monospace, Consolas, monospace; font-size: 13px;
}
code {
  background: #f1f3f9; border-radius: 6px; padding: 1.5px 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em;
}

.code-block {
  background: #151b28; color: #d6e2ff; border-radius: 12px; padding: 14px 16px;
  overflow-x: auto; margin: 12px 0; font-size: 14px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  position: relative;
}
.code-block pre { font-family: inherit; }
.code-block .code-title {
  position: absolute; top: 8px; right: 12px; font-size: 11px; color: #7b8ab8;
}
.code-block .lang-tag {
  position: absolute; top: 8px; left: 12px; font-size: 11px; color: #7b8ab8;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ===== 练习 ===== */
.q-content { font-size: 15px; margin-bottom: 16px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 14px;
  cursor: pointer; transition: all .15s; background: #fff;
  font-size: 15px; line-height: 1.5; text-align: left; font-family: inherit; color: var(--text);
}
.option:hover { border-color: var(--primary); background: #fafbff; }
.option .idx {
  flex: 0 0 22px; height: 22px; border-radius: 50%; background: #eef1f8;
  color: var(--muted); font-size: 12px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; margin-top: 2px;
}
.option input[type="checkbox"] { margin-top: 6px; width: 16px; height: 16px; accent-color: var(--primary); }
.option.selected { border-color: var(--primary); background: var(--primary-light); }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong { border-color: var(--err); background: var(--err-bg); }

.single-option.checked { border-color: var(--primary); background: var(--primary-light); }
.single-option.correct { border-color: var(--ok); background: var(--ok-bg); }
.single-option.wrong { border-color: var(--err); background: var(--err-bg); }
.single-option .radio {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c6cddd;
  flex: 0 0 18px; margin-top: 3px; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.single-option.checked .radio { border-color: var(--primary); }
.single-option.checked .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.single-option.correct .radio { border-color: var(--ok); }
.single-option.correct .radio::after { content: "✓"; color: var(--ok); font-weight: 800; background: transparent; width: auto; height: auto; }
.single-option.wrong .radio { border-color: var(--err); }
.single-option.wrong .radio::after { content: "✕"; color: var(--err); font-weight: 800; background: transparent; width: auto; height: auto; }

.fill-input {
  width: 100%; max-width: 460px; padding: 11px 14px; font-size: 15px;
  border: 1.5px solid var(--border); border-radius: 10px; outline: none;
  font-family: inherit; background: #fff; transition: border-color .15s;
}
.fill-input:focus { border-color: var(--primary); }
.fill-input.ok { border-color: var(--ok); background: var(--ok-bg); }
.fill-input.err { border-color: var(--err); background: var(--err-bg); }

.ans-input-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mono-input { font-family: ui-monospace, Consolas, monospace; max-width: 320px; }

.feedback {
  margin-top: 16px; border-radius: 10px; padding: 12px 16px; font-size: 14.5px;
  display: none; border: 1px solid transparent;
}
.feedback.show { display: block; animation: fadeUp .25s ease; }
.feedback.good { background: var(--ok-bg); color: #0e7a3c; border-color: #bfe8ce; }
.feedback.bad { background: var(--err-bg); color: #a01f1f; border-color: #f5c6c6; }
.feedback.info { background: var(--primary-light); color: var(--primary-dark); border-color: #c9d4fb; }

.qa-desc { font-size: 14px; color: var(--muted); margin: 6px 0 14px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.choice-item {
  display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; font-size: 14.5px;
  transition: all .15s; user-select: none;
}
.choice-item:hover { border-color: var(--primary); }
.choice-item input { width: 16px; height: 16px; accent-color: var(--primary); }
.choice-item.checked { border-color: var(--primary); background: var(--primary-light); }

.action-row { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== 侧栏说明卡片 ===== */
.side-note {
  background: #f8f9fe; border: 1px dashed #c9d4fb; border-radius: 12px;
  padding: 14px 16px; margin: 16px 0; font-size: 13.5px; color: #4a5578;
}
.side-note b { color: var(--primary-dark); }

/* ===== 成就页 ===== */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge-card { text-align: center; padding: 20px 12px; }
.badge-card .b-icon { font-size: 40px; line-height: 1.2; filter: grayscale(1) opacity(.4); }
.badge-card.unlocked .b-icon { filter: none; }
.badge-card .b-name { font-weight: 700; font-size: 14px; margin-top: 8px; }
.badge-card.unlocked .b-name { color: var(--text); }
.badge-card .b-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge-card.unlocked { border-color: #ffd9a0; background: linear-gradient(160deg, #fffbf3, #fff); }
.badge-card.locked { opacity: .75; }

/* ===== 页脚 ===== */
.footer { text-align: center; font-size: 13px; color: var(--muted); padding: 18px; border-top: 1px solid var(--border); background: #fff; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 20px);
  background: #1f2430; color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 动画 ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view { animation: fadeUp .25s ease; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pop { animation: pop .4s ease; }
.bounce { display: inline-block; }
.bounce.b { animation: bounceA .6s ease; }
@keyframes bounceA { 0%,100% { transform: translateY(0);} 40% { transform: translateY(-8px);} }

/* ===== 通用工具 ===== */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.center { text-align: center; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 46px; display: block; margin-bottom: 10px; }
.end-note { text-align: center; padding: 8px 0 2px; }
.end-note .big { font-size: 40px; }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 24px; }
  .brand-slogan { display: none; }
  .section-pad { padding: 18px; }
}
