/* ============ 基础与变量 ============ */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --accent: #f59e0b;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --maxw: 760px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}
#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; position: relative; }
a { color: var(--primary); text-decoration: none; }
pre, .q-text, .card-back, .fb-explain, .term-explain, .cmd-scene { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); font-size: 14px; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  max-width: var(--maxw);
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.35);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.topbar-stats {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-size: 13px; font-weight: 600;
}
.stat-xpbar { display: inline-block; width: 56px; height: 8px; background: rgba(255,255,255,0.3); border-radius: 4px; overflow: hidden; }
.stat-xpfill { display: block; height: 100%; background: #fbbf24; border-radius: 4px; transition: width 0.4s; }
.stat-xp { color: #dbeafe; }

/* ============ 底部导航 ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  max-width: var(--maxw); margin: 0 auto;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); font-size: 12px;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon { font-size: 20px; }
.tab.active { color: var(--primary); font-weight: 700; }

/* ============ 视图容器 ============ */
.view { padding: 16px; padding-bottom: 110px; }
.page-title { font-size: 22px; margin-bottom: 4px; }

/* ============ 卡片与区块 ============ */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.section { margin-top: 8px; }
.section-title { font-size: 17px; margin-bottom: 8px; }
.hint-slot { min-height: 4px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 18px;
  border: none; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform 0.06s ease, filter 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); filter: brightness(0.95); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: #f1f5f9; color: var(--ink); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn:focus-visible { outline: 3px solid #93c5fd; }

/* ============ 首页 ============ */
.hero { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; }
.hero-title { font-size: 21px; margin-bottom: 4px; }
.lv-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.lv-badge { background: var(--primary); color: #fff; font-weight: 700; padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.lv-bar { flex: 1; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.lv-fill { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 5px; transition: width 0.4s; }
.lv-num { font-size: 12px; color: var(--muted); }

.task-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px;
}
.task-item.done { opacity: 0.65; }
.task-icon { font-size: 26px; width: 36px; text-align: center; }
.task-mid { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; }
.task-check { font-size: 22px; color: var(--green); font-weight: 800; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; cursor: pointer; transition: transform 0.06s;
}
.quick-card:active { transform: scale(0.97); }
.quick-icon { font-size: 26px; }
.quick-title { font-weight: 700; margin-top: 2px; }

.term-mini {
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border: 1px solid #fde68a; border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.term-en { font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.term-full { font-size: 13px; color: var(--muted); font-style: italic; }
.term-cn { font-size: 20px; font-weight: 700; color: var(--green); }

/* ============ 地图 ============ */
.stage-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 14px;
}
.stage-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; gap: 4px; }
.stage-name { font-weight: 700; font-size: 16px; }
.stage-count { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  display: inline-block; background: var(--primary-soft); color: var(--primary-dark);
  padding: 8px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
}
.chip.weak { background: #ffedd5; color: #c2410c; }
.chip.small { padding: 4px 10px; font-size: 12px; background: #f1f5f9; color: var(--muted); font-weight: 500; }
.ch-label { font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
.ch-list { display: flex; flex-direction: column; gap: 8px; }
.ch-row {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; color: var(--ink);
}
.ch-row.solved { border-color: #bbf7d0; background: #f0fdf4; }
.ch-icon { font-size: 18px; }
.ch-mid { flex: 1; }
.ch-title { font-weight: 600; font-size: 14.5px; }
.ch-go { color: var(--primary); font-size: 13.5px; font-weight: 600; }

/* ============ 做题轮 ============ */
.round-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.round-title { flex: 1; font-weight: 700; font-size: 15.5px; text-align: center; }
.progress { flex: 1.2; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }

.qcard { padding: 18px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; margin-bottom: 10px; }
.badge.calc { background: #ede9fe; color: #6d28d9; }
.badge.mcq { background: var(--primary-soft); color: var(--primary-dark); }
.badge.term { background: #fef3c7; color: #92400e; }
.q-text { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.q-input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; font-size: 16px; margin-bottom: 10px;
}
.q-input:focus { outline: none; border-color: var(--primary); }
.q-input.mono, .term-line { font-family: var(--mono); }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt-btn {
  text-align: left; width: 100%; min-height: 48px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 15.5px; cursor: pointer; transition: border-color 0.1s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.opt-btn:active { background: var(--primary-soft); }
.opt-btn.killed { opacity: 0.35; text-decoration: line-through; pointer-events: none; }

.feedback { border-radius: 12px; padding: 14px; margin-top: 14px; }
.feedback.ok { background: var(--green-soft); border: 1px solid #bbf7d0; }
.feedback.bad { background: var(--red-soft); border: 1px solid #fecaca; }
.fb-head { font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.fb-your { color: var(--red); font-size: 14.5px; }
.fb-right { color: var(--green); font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.fb-explain { font-size: 14.5px; line-height: 1.7; margin: 6px 0; }
.fb-source { font-size: 12px; color: var(--muted); margin-top: 8px; word-break: break-all; }

.hint-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.hint-title { font-weight: 700; margin-bottom: 2px; }

.finish-card { text-align: center; padding: 28px 18px; }
.finish-emoji { font-size: 52px; }
.finish-score { font-size: 22px; font-weight: 800; margin: 8px 0 2px; }

/* ============ 考点卡 ============ */
.card-front-q { font-size: 17px; font-weight: 600; margin: 10px 0 14px; }
.card-back { font-size: 15px; line-height: 1.75; background: #f8fafc; border-radius: 10px; padding: 12px; margin: 10px 0; }
.card-title { font-size: 16px; font-weight: 700; }
.kp-info { margin: 10px 0; font-size: 14.5px; }
.kp-weak { color: #c2410c; font-weight: 700; margin-top: 4px; }
.kp-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ============ 闯关终端 ============ */
.cmd-info { background: #f8fafc; }
.cmd-scene { font-size: 14.5px; margin-bottom: 8px; }
.cmd-topo { font-family: var(--mono); font-size: 13px; background: #0f172a; color: #7dd3fc; border-radius: 10px; padding: 12px; margin: 8px 0; overflow-x: auto; }
.term {
  background: #0f172a; color: #d1fae5; border-radius: var(--radius);
  padding: 14px; min-height: 150px; max-height: 300px; overflow-y: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7; margin-bottom: 14px;
}
.term-line { white-space: pre-wrap; word-break: break-all; }
.term-line.sys { color: #94a3b8; }
.term-line.info { color: #93c5fd; }
.term-line.ok { color: #4ade80; }
.term-line.err { color: #f87171; }
.term-line.hint { color: #fbbf24; }
.term-line.cmd { color: #f1f5f9; }
.term-line.prompt { color: #7dd3fc; font-weight: 700; }
.step-box { border: 2px solid var(--primary-soft); }
.step-prompt { font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.cmd-input-row { display: flex; gap: 8px; }
.cmd-input-row .q-input { flex: 1; margin-bottom: 0; }

/* ============ 复习 ============ */
.box-dist { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 6px 2px; }
.box-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.box-bar { width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; color: transparent; font-size: 0; }
.box-col:first-child .box-bar { background: #94a3b8; }
.box-label { font-size: 11px; color: var(--muted); }

/* ============ 我的 / 设置 ============ */
.stat-cell { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-align: center; }
.stat-icon { font-size: 24px; }
.stat-val { font-size: 22px; font-weight: 800; margin: 2px 0; }
.acc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.acc-name { width: 130px; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-bar { flex: 1; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.acc-fill { display: block; height: 100%; background: var(--green); border-radius: 5px; }
.acc-num { width: 48px; text-align: right; font-size: 12.5px; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.set-input { width: 90px; min-height: 42px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 10px; font-size: 16px; text-align: center; }
.danger-box { border: 1px solid #fecaca; background: #fff7f7; }
.danger-box h3 { margin-bottom: 4px; color: var(--red); }
.danger-box .btn { margin-top: 10px; }

.src-item { padding: 12px 14px; }
.src-name { font-weight: 700; color: var(--primary); }
.rep-item { padding: 12px 14px; }
.rep-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.rep-type { font-weight: 700; color: var(--red); }
.rep-target { font-size: 13.5px; font-weight: 600; margin: 4px 0; }

.about-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.about-row:last-child { border-bottom: none; }
.about-k { width: 84px; flex-shrink: 0; font-weight: 700; color: var(--primary-dark); }
.about-v { flex: 1; }

/* ============ 术语浏览 ============ */
.term-card { text-align: center; padding: 24px 18px; }
.term-card .term-en.small { font-size: 17px; }
.term-card .btn { margin-top: 14px; }

/* ============ Toast / 模态 / 撒花 ============ */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.92); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 14.5px; z-index: 100;
  opacity: 0; transition: all 0.25s; max-width: 86vw; text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 480px;
  padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 17px; margin-bottom: 10px; }
.modal-body { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-text { margin: 4px 0; }
.report-type, .report-text {
  width: 100%; border: 2px solid var(--line); border-radius: 10px;
  font-size: 15px; padding: 10px; margin: 6px 0; font-family: inherit;
}
.report-type:focus, .report-text:focus { outline: none; border-color: var(--primary); }

.confetti {
  position: fixed; top: -30px; z-index: 200; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* ============ 平板横屏适配 ============ */
@media (min-width: 900px) {
  :root { --maxw: 860px; }
  .view { padding: 20px 24px 110px; }
  .grid2 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ============ 图标体系（科技感线性 SVG） ============ */
.ic { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.brand-icon { display: inline-flex; }
.brand-icon .ic { width: 22px; height: 22px; }
.topbar-stats .stat-fire { display: inline-flex; align-items: center; gap: 4px; color: #fff; }
.topbar-stats .ic { width: 15px; height: 15px; }
.tab-icon { display: inline-flex; }
.tab-icon .ic { width: 22px; height: 22px; }
.task-icon { display: flex; justify-content: center; }
.task-icon .ic { width: 24px; height: 24px; color: var(--primary); }
.task-check { display: inline-flex; }
.task-check .ic { width: 24px; height: 24px; }
.quick-icon .ic { width: 26px; height: 26px; color: var(--primary); }
.ch-icon { display: inline-flex; }
.ch-icon .ic { width: 20px; height: 20px; }
.ch-row:not(.solved) .ch-icon .ic { color: var(--primary); }
.ch-row.solved .ch-icon .ic { color: var(--green); }
.ch-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
.ch-label .ic { width: 16px; height: 16px; color: var(--primary); }
.badge { display: inline-flex; align-items: center; gap: 6px; }
.badge .ic { width: 15px; height: 15px; }
.btn .ic { width: 17px; height: 17px; }
.fb-head { display: flex; align-items: center; gap: 6px; }
.fb-head .ic { width: 19px; height: 19px; }
.round-title { display: flex; align-items: center; justify-content: center; gap: 6px; }
.round-title .ic { width: 18px; height: 18px; color: var(--primary); }
.page-title { display: flex; align-items: center; gap: 8px; }
.page-title .ic { width: 24px; height: 24px; color: var(--primary); }
.finish-emoji { display: flex; justify-content: center; margin-bottom: 6px; }
.finish-emoji .ic { width: 58px; height: 58px; }
.stat-icon { display: flex; justify-content: center; }
.stat-icon .ic { width: 24px; height: 24px; color: var(--primary); }
.hint-title { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 2px; }
.hint-title .ic { width: 16px; height: 16px; }
.kp-weak { display: flex; align-items: center; gap: 5px; color: #c2410c; font-weight: 700; margin-top: 4px; }

/* ============ 每日目标卡 ============ */
.goal-card { background: linear-gradient(135deg, #0f172a, #1e3a8a); color: #fff; }
.goal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.goal-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.goal-title .ic { width: 20px; height: 20px; color: #7dd3fc; }
.goal-auto { font-size: 12px; color: #93c5fd; }
.goal-num { font-size: 14px; margin: 2px 0 6px; }
.goal-num b { font-size: 21px; color: #7dd3fc; }
.goal-bar { height: 10px; background: rgba(255, 255, 255, 0.15); border-radius: 5px; overflow: hidden; }
.goal-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #38bdf8, #7dd3fc); border-radius: 5px; transition: width 0.4s; }
.goal-days { display: flex; align-items: flex-end; gap: 5px; height: 36px; margin-top: 10px; }
.goal-day { flex: 1; background: rgba(255, 255, 255, 0.18); border-radius: 3px 3px 0 0; min-height: 3px; }
.goal-day.today { background: #7dd3fc; }
.goal-done { display: inline-flex; align-items: center; gap: 5px; background: rgba(74, 222, 128, 0.18); color: #4ade80; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.goal-done .ic { width: 14px; height: 14px; }

/* ============ 撒花粒子（几何图形，无 Emoji） ============ */
.confetti {
  position: fixed; top: -20px; z-index: 200; pointer-events: none;
  opacity: 0.9; animation: fall linear forwards;
}
