/* 小步星球 StepPlanet — 设计系统 */
:root {
  --bg: #f4f5fb; --card: #ffffff; --ink: #1f2330; --ink2: #5b6472; --ink3: #9aa3b2;
  --line: #e8eaf2; --brand: #6366f1; --brand2: #8b5cf6; --brand-soft: #eef0ff;
  --math: #2563eb; --math-soft: #e8f0fe; --amc: #ea580c; --amc-soft: #fef0e6;
  --cn: #e11d48; --cn-soft: #fdeef2; --ok: #10b981; --ok-soft: #e7f8f1;
  --bad: #ef4444; --bad-soft: #fdeaea; --gold: #f59e0b;
  --radius: 18px; --shadow: 0 6px 24px rgba(31,35,48,.07);
  --tab-h: 62px;
}
[data-theme="dark"] {
  --bg: #12141d; --card: #1c1f2b; --ink: #eef0f6; --ink2: #aeb6c6; --ink3: #6b7385;
  --line: #2a2e3d; --brand: #818cf8; --brand-soft: #262a45; --math-soft: #1d2a44;
  --amc-soft: #3a2717; --cn-soft: #3c1f29; --ok-soft: #16352b; --bad-soft: #3b1f24;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.65; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}
#app { max-width: 760px; margin: 0 auto; padding: 14px 14px 30px; }
.boot { text-align: center; padding: 40vh 0 0; color: var(--ink3); }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }

/* ---- 通用组件 ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
h1 { font-size: 1.45rem; margin: 6px 0 4px; }
h2 { font-size: 1.12rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--ink2); font-size: .9rem; }
.tiny { color: var(--ink3); font-size: .8rem; }
.big { font-size: 1.9rem; font-weight: 700; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.tag.blue { background: var(--math-soft); color: var(--math); }
.tag.orange { background: var(--amc-soft); color: var(--amc); }
.tag.rose { background: var(--cn-soft); color: var(--cn); }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.tag.gray { background: var(--line); color: var(--ink2); }
.tag.gold { background: #fdf3dd; color: #b45309; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 14px; padding: 11px 18px; font-size: .95rem; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; transition: transform .06s, opacity .2s;
  min-height: 44px;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.soft { background: var(--line); color: var(--ink); }
.btn.green { background: var(--ok); }
.btn.orange { background: var(--amc); }
.btn.blue { background: var(--math); }
.btn.rose { background: var(--cn); }
.btn.sm { padding: 7px 13px; min-height: 36px; font-size: .85rem; border-radius: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 13px; padding: 11px 14px;
  font-size: 1rem; font-family: inherit; background: var(--card); color: var(--ink); outline: none;
}
input:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 130px; resize: vertical; }
label.fld { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--ink2); }
label.fld > div { margin-bottom: 5px; }

/* ---- 底部导航 ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(31,35,48,.06);
}
#tabbar .wrap { display: flex; width: 100%; max-width: 760px; }
#tabbar a {
  flex: 1; text-align: center; padding: 8px 0 6px; color: var(--ink3); font-size: .72rem; font-weight: 600;
}
#tabbar a .ico { display: block; font-size: 1.45rem; line-height: 1.2; }
#tabbar a.on { color: var(--brand); }
#tabbar .dot { position: absolute; margin-left: 14px; margin-top: -34px; background: var(--bad); color: #fff;
  border-radius: 99px; font-size: .62rem; padding: 1px 6px; }

/* ---- 头部 ---- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand2) 100%);
  color: #fff; border-radius: 22px; padding: 20px 20px 18px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.hero::after { content: "✦"; position: absolute; right: -6px; top: -18px; font-size: 5.5rem; opacity: .14; }
.hero .sub { opacity: .92; font-size: .9rem; }
.xpbar { height: 8px; background: rgba(255,255,255,.28); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.xpbar > div { height: 100%; background: #ffd76a; border-radius: 99px; transition: width .5s; }

/* ---- 任务卡 ---- */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 13px 4px; border-bottom: 1px dashed var(--line); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.task.done .t-title { text-decoration: line-through; color: var(--ink3); }
.task .t-title { font-weight: 600; }
.task .t-meta { font-size: .82rem; color: var(--ink2); }

/* ---- 章节/专题列表 ---- */
.chapter { margin-bottom: 10px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.chapter > .head { padding: 13px 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.sec { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.sec:active { background: var(--brand-soft); }
.sec .num { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex: none; }
.sec .s-title { flex: 1; }
.st-未 { background: var(--line); color: var(--ink2); }
.st-预习中 { background: #fdf3dd; color: #b45309; }
.st-已学 { background: var(--math-soft); color: var(--math); }
.st-掌握 { background: var(--ok-soft); color: var(--ok); }

/* ---- 知识卡 ---- */
.know .sec-goal { font-size: 1.02rem; font-weight: 600; padding: 10px 14px; background: var(--brand-soft); border-radius: 13px; margin-bottom: 12px; }
.know h4 { margin: 14px 0 6px; font-size: .95rem; }
.know .why { border-left: 4px solid var(--brand); padding: 8px 12px; background: var(--card); border-radius: 0 12px 12px 0; }
.know .model { border-left: 4px solid var(--ok); padding: 8px 12px; background: var(--card); border-radius: 0 12px 12px 0; }
.example { background: var(--math-soft); border-radius: 13px; padding: 10px 14px; margin-bottom: 8px; }
.example b { color: var(--math); }
.pitfall { background: var(--bad-soft); border-radius: 13px; padding: 9px 14px; margin-bottom: 8px; font-size: .92rem; }
.pitfall::before { content: "⚠️ "; }

/* ---- 做题 ---- */
.q-card { margin-bottom: 14px; }
.q-stem { font-size: 1.03rem; font-weight: 600; white-space: pre-wrap; }
.q-opt { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1.8px solid var(--line);
  border-radius: 14px; margin-top: 9px; cursor: pointer; font-size: .98rem; }
.q-opt .ltr { font-weight: 800; color: var(--ink3); flex: none; }
.q-opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.q-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.q-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-input { margin-top: 10px; }
.sol { border-radius: 13px; padding: 11px 14px; margin-top: 10px; font-size: .93rem; white-space: pre-wrap; }
.sol.ok { background: var(--ok-soft); }
.sol.bad { background: var(--bad-soft); }
.sol .lbl { font-weight: 800; margin-bottom: 4px; display: block; }
.fillin { display: flex; gap: 8px; margin-top: 10px; }
.fillin input { flex: 1; }

/* ---- 徽章/其他 ---- */
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; text-align: center; }
.badge-cell { background: var(--card); border-radius: 15px; padding: 12px 4px; box-shadow: var(--shadow); }
.badge-cell .bi { font-size: 1.7rem; }
.badge-cell.off { opacity: .32; filter: grayscale(1); }
.badge-cell .bn { font-size: .72rem; color: var(--ink2); }
.streak-flame { font-size: 1.25rem; }
.heat { display: flex; gap: 4px; margin-top: 6px; }
.heat i { flex: 1; height: 22px; border-radius: 5px; background: var(--line); }
.heat i.l1 { background: #c7d2fe; } .heat i.l2 { background: #a5b4fc; } .heat i.l3 { background: #818cf8; } .heat i.l4 { background: #6366f1; }
[data-theme="dark"] .heat i.l1 { background: #37415f; } [data-theme="dark"] .heat i.l2 { background: #44508c80; }
[data-theme="dark"] .heat i.l3 { background: #5d6cd0; } [data-theme="dark"] .heat i.l4 { background: #818cf8; }

/* ---- 模考 ---- */
.mock-top { position: sticky; top: 0; z-index: 40; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 12px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; color: var(--amc); }
.timer.low { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav b { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px;
  background: var(--line); font-size: .8rem; cursor: pointer; }
.qnav b.ans { background: var(--math-soft); color: var(--math); }
.qnav b.cur { outline: 2.5px solid var(--brand); }

/* ---- 模态/吐司 ---- */
#toast { position: fixed; bottom: calc(var(--tab-h) + 20px); left: 0; right: 0; display: flex; flex-direction: column;
  align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
#toast div { background: rgba(31,35,48,.92); color: #fff; padding: 10px 20px; border-radius: 99px; font-size: .9rem;
  max-width: 86%; animation: pop .25s; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
#modal { position: fixed; inset: 0; z-index: 90; display: none; }
#modal.show { display: flex; align-items: flex-end; justify-content: center; }
#modal .mask { position: absolute; inset: 0; background: rgba(10,12,20,.5); }
#modal .sheet { position: relative; width: 100%; max-width: 760px; max-height: 86vh; overflow-y: auto;
  background: var(--card); border-radius: 24px 24px 0 0; padding: 18px 18px 30px; animation: up .25s; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

/* ---- 语文 ---- */
.book-cover { width: 100%; aspect-ratio: 3/4; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.25); padding: 10px; text-align: center; }
.book-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 16px; border-radius: 99px; background: var(--card); color: var(--ink2);
  font-weight: 600; font-size: .88rem; box-shadow: var(--shadow); }
.tabs a.on { background: var(--brand); color: #fff; }
.essay-fb h4 { margin: 13px 0 6px; color: var(--brand); }
.essay-fb .upg { background: var(--brand-soft); border-radius: 12px; padding: 10px 13px; margin-bottom: 8px; font-size: .93rem; }
.essay-fb .upg .from { color: var(--ink3); text-decoration: line-through; }
.essay-fb .upg .to { color: var(--ok); font-weight: 600; }

/* ---- 家长报表 ---- */
table.rep { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.rep th, table.rep td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.rep th { color: var(--ink2); font-weight: 600; }
.meter { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 60px; }
.meter > i { display: block; height: 100%; background: var(--ok); }
.tutor-log { max-height: 46vh; overflow-y: auto; }
.tutor-msg { margin-bottom: 10px; padding: 10px 13px; border-radius: 15px; font-size: .95rem; white-space: pre-wrap; }
.tutor-msg.me { background: var(--brand); color: #fff; margin-left: 44px; border-bottom-right-radius: 4px; }
.tutor-msg.ai { background: var(--card); box-shadow: var(--shadow); margin-right: 44px; border-bottom-left-radius: 4px; }
@media (max-width: 420px) { .grid2.tight { grid-template-columns: 1fr; } }
