:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7489;
  --line: #e4e8f0;
  --primary: #2f6fed;
  --primary-soft: #e8f0ff;
  --math: #2f6fed;
  --chinese: #e0533d;
  --english: #13a37a;
  --warn: #f08c00;
  --danger: #d63a3a;
  --ok: #13a37a;
  --purple: #7a4ed8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 6px 18px rgba(20, 30, 60, .05);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; cursor: pointer; }
.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; }
.logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2f6fed, #7b5cff); color: #fff; font-size: 17px;
}
.kid {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 3px 10px 3px 3px; cursor: pointer; font-size: 14px; font-weight: 600; max-width: 60vw;
}
.kid .av { width: 28px; height: 28px; font-size: 14px; }
.kid span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kid small { color: var(--muted); font-weight: 400; }
.demo { background: #fff6e0; color: #8a5a00; text-align: center; font-size: 12px; padding: 5px 12px; }

main { max-width: 680px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 24px); }
.loading-page { padding: 80px 0; }

/* 底部导航 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.nav a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; color: var(--muted); position: relative; user-select: none; }
.nav a i { font-style: normal; font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .6; transition: .15s; }
.nav a.on { color: var(--primary); font-weight: 700; }
.nav a.on i { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--danger); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-style: normal; }

h1 { font-size: 21px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  border: 0; border-radius: 12px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  background: var(--primary); color: #fff; transition: transform .06s, opacity .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.plain { background: transparent; color: var(--muted); padding: 6px 10px; font-weight: 500; min-height: 34px; }
.btn.danger { background: #fdeaea; color: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.bad { background: #fdeaea; color: var(--danger); }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #fff; flex: none; }

.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef1f7; color: #4a5368; white-space: nowrap; line-height: 1.6; }
.chip.math { background: #e8f0ff; color: var(--math); }
.chip.chinese { background: #fdecea; color: var(--chinese); }
.chip.english { background: #e3f6ef; color: var(--english); }
.chip.warn { background: #fff3e0; color: #b86400; }
.chip.ok { background: #e3f6ef; color: var(--ok); }
.chip.danger { background: #fdeaea; color: var(--danger); }

/* 分段选择 */
.seg { display: flex; background: #e9edf5; padding: 3px; border-radius: 12px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 15px; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.subjects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.subj { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 4px; text-align: center; cursor: pointer; font-weight: 700; font-size: 16px; user-select: none; }
.subj .ico { font-size: 24px; display: block; line-height: 1.3; }
.subj.on.math { border-color: var(--math); background: #f1f6ff; color: var(--math); }
.subj.on.chinese { border-color: var(--chinese); background: #fff4f2; color: var(--chinese); }
.subj.on.english { border-color: var(--english); background: #effbf6; color: var(--english); }

.step { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 18px 0 10px; }
.step:first-child { margin-top: 0; }
.step b { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; display: grid; place-items: center; }

.shoot { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.shoot label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 14px; padding: 16px 8px; cursor: pointer; font-weight: 700; user-select: none; }
.shoot .cam { background: linear-gradient(135deg, #2f6fed, #5b7dff); color: #fff; font-size: 17px; }
.shoot .cam i { font-size: 30px; font-style: normal; }
.shoot .gal { background: var(--primary-soft); color: var(--primary); font-size: 15px; }
.shoot .gal i { font-size: 24px; font-style: normal; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: #eee; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }

label.field { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=password], input[type=tel], select, textarea {
  width: 100%; border: 1px solid #d5dbe7; border-radius: 12px; padding: 11px 12px; background: #fff; outline: none; font-size: 16px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 76px; resize: vertical; }

/* 任务进度 */
.job { display: flex; gap: 12px; align-items: center; }
.job .spinner { width: 30px; height: 30px; border-width: 3px; margin: 0; flex: none; }
.spinner { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: #edf0f6; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress div { height: 100%; background: linear-gradient(90deg, #7aa7ff, #2f6fed); transition: width 1s linear; }

/* 错题卡 */
.mistake .head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.mistake .q { white-space: pre-wrap; font-weight: 600; margin: 4px 0 8px; word-break: break-word; }
.mistake.compact .q { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0; }
.mistake.compact .body { display: none; }
.mistake.compact { cursor: pointer; }
.kp { font-size: 13px; color: var(--muted); }
.kp b { color: var(--text); }
.ans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.ans > div { border-radius: 10px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.ans .wrong { background: #fdf0ef; }
.ans .right { background: #ebf8f2; }
.ans span { display: block; font-size: 12px; color: var(--muted); }
.reason { background: #fff8e8; border-radius: 10px; padding: 8px 10px; font-size: 14px; margin-bottom: 10px; }
.explain { white-space: pre-wrap; font-size: 15px; border-left: 3px solid var(--primary); padding-left: 10px; margin: 8px 0; }
.tip { font-size: 14px; color: var(--purple); background: #f3eeff; display: inline-block; padding: 4px 10px; border-radius: 8px; margin: 4px 0 8px; }
details { margin-top: 6px; }
details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14px; padding: 6px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▸ '; }
details[open] > summary::before { content: '▾ '; }
.similar { padding-left: 22px; margin: 4px 0; }
.similar li { margin-bottom: 8px; white-space: pre-wrap; }
.similar .a { color: var(--ok); font-size: 14px; }
.mistake.mastered { opacity: .7; }
.photo img { max-width: 100%; border-radius: 10px; margin-top: 8px; display: block; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* 统计 */
.bars .bar { margin: 7px 0; font-size: 14px; }
.bars .bar .label { display: flex; justify-content: space-between; gap: 8px; }
.bars .track { height: 8px; background: #edf0f6; border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bars .fill { height: 100%; background: linear-gradient(90deg, #ff8a65, #e0533d); border-radius: 99px; }
.bars .fill.blue { background: linear-gradient(90deg, #7aa7ff, #2f6fed); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: 14px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 24px; line-height: 1.25; }
.kpi span { font-size: 12px; color: var(--muted); }

.filter { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.filter button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 14px; cursor: pointer; font-size: 14px; white-space: nowrap; flex: none; }
.filter button.on { background: var(--text); color: #fff; border-color: var(--text); }

/* 复习卡 */
.review-card { min-height: 300px; display: flex; flex-direction: column; }
.review-card .q { font-size: 18px; font-weight: 600; white-space: pre-wrap; margin: 10px 0 16px; flex: 1; }
.review-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.stars { letter-spacing: 2px; }
.reveal { background: #ebf8f2; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; white-space: pre-wrap; }
.celebrate { text-align: center; padding: 40px 10px; }
.celebrate .big { font-size: 56px; }

/* 学习方案 */
.plan-summary { font-size: 15px; background: linear-gradient(135deg, #eef3ff, #f6f0ff); border-radius: var(--radius); padding: 14px 16px; }
.prio { border-left: 4px solid var(--warn); }
.prio.l0 { border-left-color: var(--danger); }
.prio.l2 { border-left-color: var(--ok); }
.days { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.day { background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.day h4 { margin: 0; display: flex; justify-content: space-between; align-items: center; }
.day ul, .card ul { padding-left: 20px; margin: 6px 0 0; }
.day li { font-size: 14px; }
.encourage { text-align: center; font-size: 17px; font-weight: 700; color: var(--purple); padding: 18px; }

/* 我的 */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 22px; letter-spacing: 3px; font-weight: 700; background: #f4f6fb; border-radius: 10px; padding: 8px 12px; text-align: center; user-select: all; }

/* 底部弹层 */
.sheet-mask { position: fixed; inset: 0; background: rgba(15,20,35,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet-panel { background: #fff; width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: up .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); transform: translateX(-50%); background: rgba(20,25,40,.92); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 99; max-width: 88vw; font-size: 15px; text-align: center; }
.toast.err { background: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 44px 10px; }
.empty .big { font-size: 48px; display: block; margin-bottom: 6px; }
.gate { max-width: 380px; margin: 40px auto; text-align: center; }
.gate .logo { width: 64px; height: 64px; font-size: 32px; border-radius: 18px; margin: 0 auto 12px; }

/* 练习卷（打印） */
.paper { background: #fff; padding: 22px; border-radius: 6px; box-shadow: var(--shadow); }
.paper h1 { text-align: center; font-size: 20px; }
.paper .meta { display: flex; flex-wrap: wrap; gap: 2px 16px; justify-content: space-between; border-bottom: 2px solid #333; padding-bottom: 6px; margin-bottom: 12px; font-size: 14px; }
.paper ol { padding-left: 24px; }
.paper li { margin-bottom: 22px; white-space: pre-wrap; }
.paper .blank { height: 46px; }
.paper .answers li { margin-bottom: 6px; }

@media (min-width: 700px) {
  main { padding-top: 20px; }
  .nav { left: 50%; transform: translateX(-50%); max-width: 680px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
@media (max-width: 380px) {
  .ans { grid-template-columns: 1fr; }
  .kpi b { font-size: 20px; }
}

@media print {
  .topbar, .nav, .demo, .no-print, .btn, .toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card, .day, .kpi, .paper { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .paper { border: 0; }
  .page-break { break-before: page; }
}
