/* ============ 自主学习星球 ============ */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #2c3140;
  --ink2: #5b6172;
  --ink3: #9aa0b0;
  --line: #e9e4da;
  --violet: #7c5cff;
  --violet-soft: #efebff;
  --orange: #ff8a3d;
  --orange-soft: #fff1e6;
  --teal: #18b89b;
  --teal-soft: #e4f7f2;
  --gold: #f5a623;
  --gold-soft: #fdf3dd;
  --red: #e5484d;
  --red-soft: #fdecec;
  --radius: 18px;
  --shadow-sm: 0 2px 8px rgba(44, 49, 64, .05);
  --shadow: 0 10px 30px -14px rgba(44, 49, 64, .18);
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.6; min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14.5px; color: var(--ink); }
h1, h2, h3, h4 { line-height: 1.35; }
b, strong { font-weight: 650; }
img, svg { vertical-align: middle; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: rgba(246, 244, 239, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-ico { font-size: 26px; }
.brand-txt b { font-size: 16.5px; display: block; line-height: 1.2; }
.brand-txt small { font-size: 11px; color: var(--ink3); }
.top-right { display: flex; gap: 8px; align-items: center; }
.coin-chip {
  background: var(--gold-soft); border: 1px solid #f2e2bb; color: #9a6b00;
  border-radius: 999px; padding: 6px 13px; font-size: 13.5px; font-weight: 600;
  transition: .15s;
}
.coin-chip:active { transform: scale(.95); }
.stage-chip {
  background: var(--violet-soft); border: 1px solid #ddd3ff; color: var(--violet);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600;
}

/* ---------- 布局 ---------- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 18px 18px 30px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2e { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.section { margin-top: 16px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-head h2 { font-size: 17.5px; }
.section-head .sub { font-size: 12px; color: var(--ink3); }
.section-head .push { margin-left: auto; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 18px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card h3 { font-size: 15.5px; margin-bottom: 8px; }
.card .hint { font-size: 12px; color: var(--ink3); margin-top: 8px; }
.label { font-size: 11px; letter-spacing: .14em; color: var(--ink3); font-weight: 600; }

/* ---------- hero ---------- */
.hero {
  border-radius: 22px; padding: 22px 22px 20px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #7c5cff 0%, #9d7bff 55%, #b18cff 100%);
  box-shadow: 0 16px 34px -16px rgba(124, 92, 255, .55);
}
.hero .label { color: rgba(255,255,255,.75); }
.hero h1 { font-size: 23px; margin: 6px 0 4px; }
.hero p { font-size: 13.5px; color: rgba(255,255,255,.88); }
.hero .deco-star { position: absolute; right: -14px; top: -20px; font-size: 120px; opacity: .16; }
.hero-row { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .ring-txt b { font-size: 19px; }
.ring .ring-txt small { font-size: 10px; color: rgba(255,255,255,.8); }
.hero-steps { flex: 1; min-width: 0; }
.hero-steps .hs-line { font-size: 13px; color: rgba(255,255,255,.9); margin-bottom: 8px; }
.stage-dots { display: flex; gap: 4px; }
.stage-dots span { flex: 1; height: 7px; border-radius: 99px; background: rgba(255,255,255,.28); }
.stage-dots span.on { background: #ffd98a; }
.stage-dots span.cur { outline: 2px solid rgba(255,255,255,.65); outline-offset: 1.5px; }
.hs-cap { display: flex; justify-content: space-between; font-size: 10.5px; color: rgba(255,255,255,.72); margin-top: 5px; }

/* ---------- 任务 ---------- */
.task {
  display: flex; gap: 13px; align-items: flex-start; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.task + .task { margin-top: 10px; }
.task .t-ico {
  width: 42px; height: 42px; border-radius: 13px; flex: none; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.task .t-body { flex: 1; min-width: 0; }
.task .t-body strong { font-size: 15px; display: block; }
.task .t-meta { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.tag-self { color: var(--teal); background: var(--teal-soft); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
.tag-coach { color: var(--orange); background: var(--orange-soft); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
.task .t-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.t-note { font-size: 12px; color: var(--ink2); background: #faf8f4; border-radius: 10px; padding: 7px 10px; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--violet); color: #fff; border-radius: 12px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; transition: .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn.b-teal { background: var(--teal); }
.btn.b-orange { background: var(--orange); }
.btn.b-ghost { background: #fff; color: var(--ink2); border: 1px solid var(--line); }
.btn.b-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.wide { width: 100%; padding: 12px; font-size: 14.5px; border-radius: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink2);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; transition: .15s;
}
.chip.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 宠物 ---------- */
.pet-room {
  position: relative; border-radius: 22px; padding: 18px 16px 14px; text-align: center;
  background: linear-gradient(180deg, #eef4ff 0%, #fdf6ec 100%);
  border: 1px solid var(--line); overflow: hidden;
}
.pet-room .room-sun { position: absolute; right: 18px; top: 14px; font-size: 30px; }
.pet-room .room-cloud { position: absolute; left: 22px; top: 26px; font-size: 20px; opacity: .7; }
.pet-stage-name { font-size: 12.5px; color: var(--violet); font-weight: 700; letter-spacing: .08em; }
.pet-speech {
  display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 14px; font-size: 13px; color: var(--ink2); margin: 10px auto 4px; max-width: 92%;
  box-shadow: var(--shadow-sm);
}
.pet-svg { width: 190px; max-width: 60vw; display: block; margin: 2px auto 0; }
.pet-touch { display: block; margin: 0 auto; border-radius: 20px; transition: .15s; }
.pet-touch:active { transform: scale(.94); }
.pet-hearts { font-size: 15px; color: #ff9db5; letter-spacing: 6px; margin-top: 2px; }
.room-cap { font-size: 11.5px; color: var(--ink3); margin-top: 8px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes chew { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06,.94); } }
@keyframes zzz { 0%,100% { transform: scale(1); } 50% { transform: scale(.97) translateY(3px); } }
@keyframes popheart { 0% { transform: translateY(0) scale(.6); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-46px) scale(1.15); opacity: 0; } }
.pet-wrap { animation: bob 2.6s ease-in-out infinite; }
.pet-wrap.mood-happy { animation: wiggle .5s ease-in-out 3; }
.pet-wrap.mood-eat { animation: chew .4s ease-in-out 4; }
.pet-wrap.mood-sleep { animation: zzz 2.4s ease-in-out infinite; }
.pet-food-pop { position: absolute; left: 50%; top: 34%; font-size: 30px; transform: translateX(-50%); pointer-events: none; }
.pet-food-pop.show { animation: popheart 1.4s ease-out forwards; }
.food-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.food-menu button {
  border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 11px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: .15s;
}
.food-menu button:hover { border-color: #f2c98c; box-shadow: var(--shadow-sm); }
.food-menu .f-ico { font-size: 24px; }
.food-menu strong { font-size: 12.5px; }
.food-menu small { font-size: 11px; color: var(--gold); font-weight: 700; }
.stage-track { margin-top: 4px; }
.bar { height: 9px; background: #efece5; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--violet), #b18cff); transition: width .4s; }
.bar.bar-teal i { background: var(--teal); }
.bar.bar-gold i { background: linear-gradient(90deg, var(--gold), #ffce6b); }
.stage-ladder { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 10px; }
.stage-ladder .sl { text-align: center; border-radius: 12px; padding: 8px 4px; background: #faf8f4; border: 1px solid var(--line); }
.stage-ladder .sl.on { background: var(--violet-soft); border-color: #ddd3ff; }
.stage-ladder .sl b { font-size: 17px; display: block; line-height: 1.3; }
.stage-ladder .sl small { font-size: 10.5px; color: var(--ink3); }
.stage-ladder .sl.on small { color: var(--violet); font-weight: 700; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 13px 12px; text-align: center; box-shadow: var(--shadow-sm); }
.stat b { font-size: 21px; display: block; }
.stat small { font-size: 11.5px; color: var(--ink3); }

/* ---------- 周计划 ---------- */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; align-items: stretch; }
.week-grid .wd { text-align: center; display: flex; flex-direction: column; }
.week-grid .wd .wd-box { flex: 1; }
.week-grid .wd .wd-head { font-size: 11px; color: var(--ink3); margin-bottom: 5px; }
.week-grid .wd .wd-box {
  border: 1px dashed #d9d2c4; border-radius: 12px; min-height: 74px; padding: 7px 4px;
  background: #fbfaf7; font-size: 11px; color: var(--ink2); display: flex; flex-direction: column; gap: 3px; justify-content: flex-start;
}
.week-grid .wd.today .wd-box { border-style: solid; border-color: var(--violet); background: var(--violet-soft); }
.week-grid .wd .wd-item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 4px; line-height: 1.35; }
.week-grid .wd .wd-item.done { background: var(--teal-soft); border-color: #bfe9df; color: #0d7d68; text-decoration: line-through; }

/* ---------- 错题 ---------- */
.mistake { border-left: 4px solid var(--orange); }
.mistake.m-teal { border-left-color: var(--teal); }
.mk-top { display: flex; align-items: center; gap: 8px; }
.mk-top strong { font-size: 14.5px; flex: 1; min-width: 0; }
.pill { font-size: 11px; border-radius: 99px; padding: 2px 9px; font-weight: 600; }
.pill.p-orange { background: var(--orange-soft); color: #c05a10; }
.pill.p-teal { background: var(--teal-soft); color: #0d7d68; }
.pill.p-violet { background: var(--violet-soft); color: var(--violet); }
.pill.p-gold { background: var(--gold-soft); color: #9a6b00; }
.pill.p-gray { background: #f0eee9; color: var(--ink3); }
.mk-dates { font-size: 12px; color: var(--ink3); margin-top: 6px; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink2); font-weight: 600; margin-bottom: 5px; }
.form-row input[type="text"], .form-row input[type="number"], .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: #fcfbf9; outline: none; transition: .15s;
}
.form-row textarea { min-height: 74px; resize: vertical; line-height: 1.6; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--violet); background: #fff; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rate-row .chip.on.r-good { background: var(--teal); border-color: var(--teal); }
.rate-row .chip.on.r-mid { background: var(--gold); border-color: var(--gold); }
.rate-row .chip.on.r-hard { background: var(--red); border-color: var(--red); }

/* ---------- 复盘三问 ---------- */
.ask { margin-bottom: 14px; }
.ask .a-ico { font-size: 18px; margin-right: 6px; }
.ask label { font-weight: 700; font-size: 14px; }
.ask .a-sub { font-size: 12px; color: var(--ink3); margin: 2px 0 7px; }
.review-log { border-left: 3px solid #e5dfD3; padding-left: 12px; margin-left: 4px; }
.review-log .rl-item { position: relative; padding-bottom: 14px; }
.review-log .rl-item::before {
  content: ""; position: absolute; left: -17.5px; top: 6px; width: 8px; height: 8px;
  border-radius: 99px; background: var(--violet);
}
.review-log .rl-date { font-size: 11.5px; color: var(--ink3); }
.review-log .rl-item p { font-size: 13px; color: var(--ink2); margin-top: 2px; }

/* ---------- 闯关 ---------- */
.quiz-opt {
  display: block; width: 100%; text-align: left; border: 1.5px solid var(--line);
  border-radius: 13px; padding: 11px 14px; margin-top: 9px; font-size: 14px; background: #fff; transition: .15s;
}
.quiz-opt:hover { border-color: #c9bcff; }
.quiz-opt.right { border-color: var(--teal); background: var(--teal-soft); }
.quiz-opt.wrong { border-color: var(--red); background: var(--red-soft); }
.quiz-opt[disabled] { cursor: default; }
.quiz-prog { display: flex; gap: 5px; margin: 10px 0 4px; }
.quiz-prog i { flex: 1; height: 6px; border-radius: 99px; background: #efece5; }
.quiz-prog i.on { background: var(--violet); }

/* ---------- 足迹/时间轴 ---------- */
.tl { border-left: 3px solid #eae4d8; padding-left: 14px; margin-left: 4px; }
.tl .tl-item { position: relative; padding-bottom: 13px; }
.tl .tl-item::before {
  content: ""; position: absolute; left: -19.5px; top: 5px; width: 10px; height: 10px;
  border-radius: 99px; background: var(--gold); border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--gold-soft);
}
.tl .tl-date { font-size: 11.5px; color: var(--ink3); }
.tl .tl-item p { font-size: 13px; color: var(--ink2); }
.tl .tl-item b { font-size: 13.5px; }

/* ---------- 趋势图 ---------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 110px; padding-top: 6px; }
.t-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.t-col .t-bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: #cfc4ff; min-height: 4px; }
.t-col.cur .t-bar { background: var(--violet); }
.t-col small { font-size: 10.5px; color: var(--ink3); }
.t-col .t-num { font-size: 11px; color: var(--ink2); font-weight: 600; }

/* ---------- 徽章 ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge {
  text-align: center; border-radius: 13px; padding: 9px 5px 7px;
  border: 1px solid var(--line); background: #fbfaf7;
}
.badge.got { background: var(--gold-soft); border-color: #f2e2bb; }
.badge .b-ico { font-size: 21px; display: block; line-height: 1.25; }
.badge b { font-size: 11.5px; display: block; margin-top: 3px; }
.badge small { font-size: 10px; color: var(--ink3); }
.badge:not(.got) { opacity: .55; filter: grayscale(.7); }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(30, 27, 45, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 640px) { .modal-mask { align-items: center; } }
.modal-card {
  background: #fff; border-radius: 22px 22px 0 0; width: 100%; max-width: 480px;
  max-height: 86vh; overflow-y: auto; padding: 20px 20px 24px;
}
@media (min-width: 640px) { .modal-card { border-radius: 22px; } }
.modal-card h3 { font-size: 16.5px; margin-bottom: 12px; }
.modal-foot { display: flex; gap: 10px; margin-top: 16px; }
.modal-foot .btn { flex: 1; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(44, 49, 64, .92); color: #fff; border-radius: 99px; padding: 9px 20px;
  font-size: 13px; z-index: 99; pointer-events: none; animation: toastin .22s ease-out;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- tabbar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; max-width: 640px; margin: 0 auto;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
}
#tabbar button { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; color: var(--ink3); flex: 1; padding: 3px 0; border-radius: 10px; }
#tabbar button .tb-ico { font-size: 20px; line-height: 1.2; }
#tabbar button.active { color: var(--violet); font-weight: 700; }
#tabbar button.active .tb-ico { transform: scale(1.12); }

/* ---------- 空态 ---------- */
.empty { text-align: center; color: var(--ink3); font-size: 13px; padding: 22px 10px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .grid-2, .grid-2e, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 14px 13px 26px; }
  .topbar { padding: 10px 13px; }
  .brand-txt small { display: none; }
  .hero { padding: 18px 16px 16px; }
  .hero h1 { font-size: 20px; }
  .week-grid { gap: 4px; }
  .week-grid .wd .wd-box { min-height: 64px; font-size: 10px; padding: 5px 3px; }
  .stage-ladder { gap: 4px; }
  .stage-ladder .sl { padding: 6px 2px; }
  .stage-ladder .sl b { font-size: 14px; }
  .stage-ladder .sl small { font-size: 9.5px; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .section { margin-top: 14px; }
  .card { padding: 15px 14px; }
  .pet-svg { width: 160px; }
  .food-menu { gap: 6px; }
}
