:root {
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #10131A;
  --sub: #6B7385;
  --line: #EDEFF4;
  --blue: #3B7CF6;
  --blue-soft: #EAF1FF;
  --indigo: #6A5CFF;
  --indigo-soft: #EFEDFF;
  --orange: #FF8A3D;
  --green: #1FB865;
  --green-soft: #E7F8EF;
  --red: #F04438;
  --red-soft: #FEECEA;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16,19,26,.04), 0 8px 24px rgba(16,19,26,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { touch-action: manipulation; }

button { font-family: inherit; border: 0; background: none; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

#app {
  min-height: 100%;
  padding-bottom: calc(64px + var(--safe-b));
}

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(245,246,250,.86);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  min-height: calc(44px + var(--safe-t));
}
.top-title { font-size: 18px; font-weight: 600; letter-spacing: .2px; flex: 1; text-align: center; }
.back-btn, .top-action {
  width: 36px; height: 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue); flex: 0 0 auto;
}
.back-btn:active, .top-action:active { background: rgba(0,0,0,.05); }
.top-action { font-size: 15.5px; font-weight: 500; color: var(--blue); width: auto; padding: 0 6px; }

#view { padding: 4px 16px 24px; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  padding: 8px 8px calc(6px + var(--safe-b));
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid rgba(0,0,0,.07);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; color: #9AA1AE; padding: 4px 0; border-radius: 12px;
}
#tabbar svg { width: 24px; height: 24px; }
#tabbar a.active { color: var(--blue); }
#tabbar a.active span { font-weight: 600; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.h1 { font-size: 28px; font-weight: 700; letter-spacing: -.4px; margin: 6px 0 2px; }
.h2 { font-size: 20px; font-weight: 650; margin: 20px 4px 10px; letter-spacing: -.2px; }
.muted { color: var(--sub); font-size: 14.5px; line-height: 1.55; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: #F1F3F8; color: var(--sub); white-space: nowrap;
}
.pill.blue { background: var(--blue-soft); color: #2563EB; }
.pill.indigo { background: var(--indigo-soft); color: #5A4BE0; }
.pill.green { background: var(--green-soft); color: #128C4C; }
.pill.red { background: var(--red-soft); color: #C7382C; }
.pill.orange { background: #FFF1E6; color: #C25F17; }

/* 首页头部 */
.hero {
  padding: 10px 4px 6px;
}
.hero-eyebrow { font-size: 14.5px; color: var(--sub); font-weight: 500; }

.countdown {
  margin-top: 14px;
  background: linear-gradient(135deg, #4B7BFF 0%, #6A5CFF 55%, #8B5CFF 100%);
  border-radius: 20px; padding: 18px;
  color: #fff; box-shadow: 0 10px 26px rgba(76,110,255,.28);
  position: relative; overflow: hidden;
}
.countdown::after {
  content: ''; position: absolute; right: -30px; top: -40px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.countdown .cd-num { font-size: 38px; font-weight: 800; letter-spacing: -1.5px; line-height: 1.05; }
.countdown .cd-label { font-size: 14px; opacity: .85; margin-top: 4px; }

/* 科目大卡 */
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.subject-card {
  border-radius: 20px; padding: 16px 14px; color: #fff; position: relative; overflow: hidden;
  min-height: 138px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 8px 20px rgba(16,19,26,.10);
}
.subject-card.en { background: linear-gradient(150deg, #3B7CF6, #2E5BEF); }
.subject-card.math { background: linear-gradient(150deg, #7C5CFF, #5B3FE0); }
.subject-card.cn { background: linear-gradient(150deg, #F0745C, #D8503C); grid-column: span 2; min-height: 104px; }
.subject-card .sc-title { font-size: 20.5px; font-weight: 700; letter-spacing: -.3px; }
.subject-card .sc-sub { font-size: 13px; opacity: .82; margin-top: 3px; }
.subject-card .sc-num { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.subject-card .sc-unit { font-size: 12.5px; opacity: .8; }
.sc-ring { position: absolute; right: 10px; top: 10px; opacity: .9; }
.sc-glow { position: absolute; right: -34px; bottom: -46px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.12); }

/* 进度条 */
.bar { height: 6px; border-radius: 99px; background: #EFF1F6; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--blue); transition: width .5s ease; }

/* 列表条目 */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--card); border-radius: 16px; margin-bottom: 9px;
  box-shadow: 0 1px 2px rgba(16,19,26,.04);
  transition: transform .12s ease;
}
.list-item:active { transform: scale(.982); }
.li-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 16.5px; font-weight: 700; color: #fff;
}
.li-body { flex: 1; min-width: 0; }
.li-title { font-size: 16.5px; font-weight: 600; letter-spacing: -.1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 13.5px; color: var(--sub); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-right { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.chev { color: #C7CCD6; }

/* 分组切换 */
.segmented {
  display: flex; gap: 4px; background: #ECEEF4; padding: 4px; border-radius: 13px;
  margin: 8px 0 14px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 1 0 auto; padding: 8px 14px; border-radius: 10px; font-size: 14.5px;
  font-weight: 550; color: var(--sub); white-space: nowrap; transition: all .18s;
}
.segmented button.on { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(16,19,26,.10); }

/* 英语练习模式：按顺序 / 混着来 */
.segmented.small { margin: 6px 0 12px; }
.segmented.small button { padding: 6px 12px; font-size: 14px; }
.mixcard {
  background: linear-gradient(135deg, #EEF3FF 0%, #F4EEFF 100%);
  border-radius: 16px; padding: 15px 16px; margin-bottom: 14px;
}
.mix-t { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.mix-d { font-size: 14px; color: #5B6472; margin: 6px 0 13px; line-height: 1.65; }
.mixhint { font-size: 14px; color: var(--sub); margin: -4px 2px 14px; line-height: 1.6; }

/* 专题筛选 chips */
.chips {
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: -2px 0 14px; padding: 2px 2px 2px 0;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; color: #5B6478;
  background: #fff; border: 1px solid #E6E9F0; white-space: nowrap; transition: all .16s;
}
.chips button.on {
  background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px rgba(106,92,255,.24);
}
.chips button:active { transform: scale(.97); }

/* 学习详情内容 */
.lesson-head { padding: 6px 2px 14px; }
.lesson-title { font-size: 25px; font-weight: 750; letter-spacing: -.5px; line-height: 1.3; }
.lesson-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.block-p { font-size: 16.5px; line-height: 1.72; color: #2B3040; margin: 0 0 12px; }
.block-h { font-size: 16.5px; font-weight: 700; margin: 18px 0 10px; display: flex; align-items: center; gap: 7px; }
.block-h::before { content: ''; width: 3px; height: 14px; border-radius: 2px; background: var(--blue); }
.block-h.math::before { background: var(--indigo); }
.block-h.cn::before { background: #E0603F; }

.num-list { counter-reset: n; margin: 0 0 12px; padding: 0; list-style: none; }
.num-list li {
  counter-increment: n; position: relative; padding-left: 30px;
  font-size: 16px; line-height: 1.72; color: #2B3040; margin-bottom: 10px;
}
.num-list li::before {
  content: counter(n); position: absolute; left: 0; top: 2px;
  width: 21px; height: 21px; border-radius: 50%; background: var(--blue-soft); color: #2563EB;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.num-list.math li::before { background: var(--indigo-soft); color: #5A4BE0; }
.num-list.cn li::before { background: #FDECE7; color: #C4492E; }

.formula {
  background: #F7F8FC; border: 1px solid #EDEFF6; border-radius: 12px;
  padding: 11px 13px; font-size: 15.5px; line-height: 1.7; color: #2B3040;
  margin-bottom: 9px; font-weight: 550; word-break: break-word;
}
.tip {
  background: #FFF8ED; border-left: 3px solid #FFB454; border-radius: 10px;
  padding: 11px 13px; font-size: 15px; line-height: 1.68; color: #7A5218; margin-bottom: 9px;
}
.example {
  background: #F3F7FF; border: 1px solid #E3ECFF; border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.example .ex-q { font-size: 16px; font-weight: 650; line-height: 1.65; margin-bottom: 10px; color: #1A2740; }
.example .ex-step { font-size: 15.5px; line-height: 1.7; color: #34405C; padding-left: 16px; position: relative; margin-bottom: 7px; }
.example .ex-step::before { content: '·'; position: absolute; left: 4px; font-weight: 900; color: #6A8CFF; }
.example .ex-ans { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #CFDDFF; font-size: 15.5px; font-weight: 650; color: #24509E; }

/* 单词卡 */
.word {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.word:last-child { border-bottom: 0; }
.word .w-en { font-size: 18px; font-weight: 650; letter-spacing: -.2px; }
.word .w-ph { font-size: 14px; color: #8A92A3; font-family: -apple-system, "SF Pro"; }
.word .w-pos { font-size: 12.5px; color: #A3AAB8; font-style: italic; }
.word .w-cn { font-size: 15px; color: #4B5468; width: 100%; }
.word .w-eg { font-size: 14px; color: #7C8598; width: 100%; margin-top: 2px; line-height: 1.5; }
.word .w-eg i { color: #A8AFBD; font-style: normal; }

/* 短语 */
.phrase { padding: 12px 0; border-bottom: 1px solid var(--line); }
.phrase:last-child { border-bottom: 0; }
.phrase .p-en { font-size: 17px; font-weight: 620; line-height: 1.5; }
.phrase .p-cn { font-size: 15px; color: #59627A; margin-top: 4px; line-height: 1.5; }
.phrase .p-note { font-size: 13.5px; color: #98A0B0; margin-top: 4px; }

/* 练习 */
.quiz-wrap { padding-top: 4px; }
.q-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.q-progress .bar { flex: 1; }
.q-count { font-size: 14px; color: var(--sub); font-weight: 600; font-variant-numeric: tabular-nums; }
.q-text { font-size: 19px; font-weight: 650; line-height: 1.62; margin-bottom: 18px; letter-spacing: -.2px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px;
  width: 100%; text-align: left; padding: 14px 15px; margin-bottom: 10px;
  background: #fff; border: 1.5px solid #E6E9F0; border-radius: 14px;
  font-size: 16.5px; line-height: 1.5; transition: all .16s;
}
.opt:active { transform: scale(.985); }
.opt .opt-key {
  flex: 0 0 auto; width: 23px; height: 23px; border-radius: 50%;
  background: #F1F3F8; color: #7A8398; font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.opt.correct { border-color: #34C77B; background: var(--green-soft); }
.opt.correct .opt-key { background: #34C77B; color: #fff; }
.opt.wrong { border-color: #F97066; background: var(--red-soft); }
.opt.wrong .opt-key { background: #F97066; color: #fff; }
.opt.dim { opacity: .55; }
.opt[disabled] { cursor: default; }

.feedback { border-radius: 14px; padding: 13px 15px; margin-top: 6px; font-size: 15.5px; line-height: 1.68; }
.feedback.ok { background: var(--green-soft); color: #14713F; }
.feedback.no { background: var(--red-soft); color: #A32E23; }
.feedback b { font-weight: 700; }

.btn-primary {
  width: 100%; padding: 15px; border-radius: 15px; background: var(--blue);
  color: #fff; font-size: 17px; font-weight: 650; letter-spacing: .2px;
  box-shadow: 0 8px 20px rgba(59,124,246,.28); transition: transform .12s;
}
.btn-primary:active { transform: scale(.978); }
.btn-primary.math { background: var(--indigo); box-shadow: 0 8px 20px rgba(106,92,255,.28); }
.btn-primary.cn { background: linear-gradient(140deg,#E96B4F,#D24C35); box-shadow: 0 8px 20px rgba(224,96,63,.26); }
.btn-ghost {
  width: 100%; padding: 14px; border-radius: 15px; background: #fff;
  border: 1.5px solid #E6E9F0; font-size: 16.5px; font-weight: 600; color: #4B5468;
}
.sticky-cta {
  position: sticky; bottom: calc(8px + var(--safe-b)); margin-top: 18px; padding-top: 8px;
}

/* 结算 */
.result { text-align: center; padding: 26px 10px 10px; }
.result .score { font-size: 54px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.result .score small { font-size: 18px; font-weight: 600; color: var(--sub); letter-spacing: 0; }
.result .rmsg { font-size: 16.5px; color: var(--sub); margin-top: 10px; }
.result-emoji { font-size: 44px; margin-bottom: 8px; }

/* 家长页 */
.gate { text-align: center; padding: 40px 10px; }
.gate-icon {
  width: 64px; height: 64px; border-radius: 20px; background: var(--blue-soft);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
  color: var(--blue);
}
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 22px 0; }
.pin-dot { width: 13px; height: 13px; border-radius: 50%; background: #E3E7EF; }
.pin-dot.on { background: var(--blue); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; }
.keypad button {
  height: 54px; border-radius: 14px; background: #fff; font-size: 22px; font-weight: 500;
  box-shadow: 0 1px 3px rgba(16,19,26,.06);
}
.keypad button:active { background: #EDF0F7; }
.keypad button.blank { background: transparent; box-shadow: none; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat {
  background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 1px 2px rgba(16,19,26,.04);
}
.stat .s-num { font-size: 27px; font-weight: 750; letter-spacing: -.8px; }
.stat .s-num small { font-size: 13.5px; font-weight: 600; color: var(--sub); margin-left: 2px; }
.stat .s-label { font-size: 13.5px; color: var(--sub); margin-top: 2px; }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 108px; padding: 6px 2px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .col i {
  display: block; width: 100%; max-width: 26px; border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, #7FA3FF, #3B7CF6); min-height: 4px;
  transition: height .5s ease;
}
.chart .col span { font-size: 12px; color: #98A0B0; }

.mastery { margin-bottom: 13px; }
.mastery .m-row { display: flex; justify-content: space-between; font-size: 14.5px; margin-bottom: 6px; }
.mastery .m-name { font-weight: 550; color: #2B3040; }
.mastery .m-val { color: var(--sub); font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 54px 20px; color: var(--sub); }
.empty .e-emoji { font-size: 36px; margin-bottom: 10px; opacity: .5; }
.empty .e-text { font-size: 15.5px; line-height: 1.6; }

.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 16.5px;
}
.settings-row:last-child { border-bottom: 0; }
.danger { color: var(--red); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(10px);
  background: rgba(23,26,33,.92); color: #fff; font-size: 15px; padding: 10px 18px;
  border-radius: 12px; opacity: 0; transition: all .24s; z-index: 200; pointer-events: none;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  #view, #topbar { max-width: 620px; margin: 0 auto; }
  #tabbar { max-width: 620px; left: 50%; transform: translateX(-50%); border-radius: 18px 18px 0 0; }
}

/* 语文：原文 / 名句 / 字词条 */
.verse {
  background: #FCF9F6; border: 1px solid #F1E6DE; border-radius: 14px;
  padding: 14px 15px; margin-bottom: 12px;
}
.verse-line {
  font-size: 16.5px; line-height: 1.95; color: #2A2118;
  font-family: "Songti SC", "STSong", "Source Han Serif SC", serif;
  letter-spacing: .2px;
}
.verse-title {
  font-size: 15px; font-weight: 700; color: #A8552F;
  margin: 10px 0 6px; letter-spacing: .3px;
}
.verse-title:first-child { margin-top: 0; }
.quote {
  border-left: 3px solid #E9A78F; background: #FDF7F4;
  padding: 10px 13px; border-radius: 0 10px 10px 0; margin-bottom: 9px;
}
.quote .q-text {
  font-size: 16px; line-height: 1.7; color: #35241C; font-weight: 600;
  font-family: "Songti SC", "STSong", serif;
}
.quote .q-trans { font-size: 14.5px; line-height: 1.65; color: #7A6A62; margin-top: 5px; }
.cn-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 10px; }
.cn-item { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cn-item:last-child { border-bottom: 0; }
.cn-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.cn-w { font-size: 16.5px; font-weight: 650; color: #1E2433; }
.cn-py { font-size: 13.5px; color: #8A93A6; font-weight: 500; }
.cn-cn { font-size: 15px; line-height: 1.68; color: #495267; margin-top: 3px; }
.cn-note { font-size: 14px; line-height: 1.6; color: #9A6B4E; margin-top: 3px; }

/* 记忆卡片 */
.mem-card {
  background: linear-gradient(150deg, #4E86F7, #3B6EE8);
  border-radius: 20px; min-height: 240px; padding: 26px 22px;
  color: #fff; text-align: center; cursor: pointer;
  box-shadow: 0 12px 28px rgba(59,110,232,.30);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;
  margin-top: 16px; user-select: none; -webkit-user-select: none;
  transition: transform .15s ease;
}
.mem-card:active { transform: scale(.985); }
.mem-card.open { background: linear-gradient(150deg, #FFFFFF, #F2F6FF); color: #1E2433; box-shadow: 0 8px 22px rgba(30,41,59,.14); }
.mem-face { display: flex; flex-direction: column; align-items: center; gap: 9px; width: 100%; }
.mem-en { font-size: 32px; font-weight: 750; letter-spacing: .3px; line-height: 1.3; }
.mem-ph { font-size: 15.5px; opacity: .92; }
.mem-ph i { font-style: normal; opacity: .8; font-size: 14px; margin-left: 4px; }
.mem-hint { font-size: 13.5px; opacity: .85; margin-top: 14px; }
.mem-cn { font-size: 26px; font-weight: 700; color: #1E2433; }
.mem-eg { font-size: 16.5px; line-height: 1.65; color: #33415C; margin-top: 4px; }
.mem-egcn { font-size: 14.5px; line-height: 1.6; color: #7A8499; }
.mem-btns { display: flex; gap: 8px; margin-top: 14px; }
.mem-btn {
  flex: 1; padding: 13px 6px; border-radius: 14px; border: none; font-size: 16px; font-weight: 650;
  background: #fff; color: #333; box-shadow: 0 2px 8px rgba(16,19,26,.08);
}
.mem-btn.no { background: #FEECEB; color: #C0362C; }
.mem-btn.fuzzy { background: #FFF3E4; color: #B26A0A; }
.mem-btn.ok { background: #E5F7EC; color: #178A50; }

/* 同步设置 */
.sync-row { margin-top: 10px; }
.sync-input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  font-size: 16.5px; background: #fff; color: var(--text); outline: none;
}
.sync-input:focus { border-color: #6A5CFF; }
