/* 英语小达人 PWA — 蓝色主题 */
:root {
  --blue: #1565C0;
  --blue-light: #42A5F5;
  --blue-bg: #E3F2FD;
  --blue-deep: #0D47A1;
  --sky: #039BE5;
  --cyan: #00838F;
  --indigo: #3949AB;
  --green: #2E7D32;
  --green-bg: #E8F5E9;
  --red: #C62828;
  --red-bg: #FFEBEE;
  --amber: #F9A825;
  --ink: #1F2D3D;
  --ink-2: #5B6B7B;
  --line: #E2E8F0;
  --bg: #F2F6FC;
  --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(21, 101, 192, .08);
  --tab-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 16px; }
.loading { padding: 80px 24px; text-align: center; color: var(--ink-2); }

#app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  background: var(--bg);
}
#app.no-tab { padding-bottom: 0; }

.page { padding: calc(14px + env(safe-area-inset-top)) 18px 24px; }
.page.no-top { padding-top: 14px; }

h1, h2, h3 { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }

/* ---------- 顶部栏（子页面） ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: var(--blue); color: #fff;
}
.topbar .back {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.topbar .back:active { background: rgba(255,255,255,.18); }
.topbar .ttl { font-size: 18px; font-weight: 700; }
.topbar .sub { font-size: 12px; opacity: .85; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card.blue { background: var(--blue-bg); box-shadow: none; }
.sec-title { font-size: 18px; font-weight: 700; margin: 4px 0 2px; }
.sec-sub { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }

.home-title { font-size: 26px; font-weight: 800; }
.progress-wrap { background: #D6E4F5; border-radius: 99px; height: 12px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--blue-light), var(--blue)); border-radius: 99px; transition: width .4s; }
.progress-bar.thin { height: 10px; }

.stat-line { display: flex; justify-content: space-between; align-items: baseline; }
.stat-num { font-size: 20px; font-weight: 800; color: var(--blue-deep); }

/* 功能入口卡 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.feat {
  border-radius: var(--radius); padding: 18px 16px; color: #fff;
  min-height: 108px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.feat:active { transform: scale(.97); }
.feat .ico { font-size: 26px; }
.feat .t { font-size: 17px; font-weight: 700; }
.feat .d { font-size: 12px; opacity: .92; margin-top: 2px; }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 99px;
  background: #fff; color: var(--ink-2); font-size: 14px;
  border: 1.5px solid var(--line); white-space: nowrap;
}
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
.chip.mini { padding: 4px 10px; font-size: 13px; }

/* 按钮 */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border-radius: 12px;
  background: var(--blue); color: #fff; font-size: 16px; font-weight: 700;
}
.btn:active { opacity: .85; }
.btn.ghost { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.light { background: var(--blue-bg); color: var(--blue-deep); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.gray { background: #EDF1F6; color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 12px; }

/* 选项按钮 */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  text-align: left; padding: 13px 15px; border-radius: 12px;
  background: #fff; border: 1.5px solid var(--line); font-size: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.opt .k {
  flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--blue-bg);
  color: var(--blue); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.opt.ok { border-color: var(--green); background: var(--green-bg); }
.opt.ok .k { background: var(--green); color: #fff; }
.opt.bad { border-color: var(--red); background: var(--red-bg); }
.opt.bad .k { background: var(--red); color: #fff; }

.field {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; outline: none;
  font-size: 17px;
}
.field:focus { border-color: var(--blue); }

.feedback { border-radius: 12px; padding: 13px 15px; font-size: 15px; line-height: 1.55; }
.feedback.ok { background: var(--green-bg); color: var(--green); }
.feedback.bad { background: var(--red-bg); color: var(--red); }

.passage {
  background: #F6F9FE; border-left: 4px solid var(--blue-light);
  border-radius: 8px; padding: 12px 14px; font-size: 15px; line-height: 1.7; white-space: pre-wrap;
}
.q-stem { font-size: 19px; line-height: 1.65; font-weight: 600; white-space: pre-wrap; }
.q-stem .blank { color: var(--blue); font-weight: 800; }
.tag { display: inline-block; font-size: 12px; color: var(--blue); background: var(--blue-bg);
  border-radius: 6px; padding: 2px 8px; margin-right: 6px; }

/* ---------- 单词卡 ---------- */
.flash {
  border-radius: 20px; background: #fff; box-shadow: 0 6px 24px rgba(21,101,192,.12);
  min-height: 300px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 28px 20px;
}
.flash .en { font-size: 38px; font-weight: 800; color: var(--blue-deep); word-break: break-word; }
.flash .ph { font-size: 17px; color: var(--ink-2); margin-top: 8px; }
.flash .cn { font-size: 24px; font-weight: 700; margin-top: 6px; }
.flash .ex { font-size: 15px; color: var(--ink-2); margin-top: 16px; line-height: 1.6; }
.speak {
  width: 52px; height: 52px; border-radius: 50%; background: var(--blue-bg);
  color: var(--blue); font-size: 24px; display: flex; align-items: center; justify-content: center;
}
.speak:active { background: #BBDEFB; }

.list-item {
  background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
}
.list-item.tappable { cursor: pointer; -webkit-tap-highlight-color: rgba(21,101,192,.12); transition: background .12s, transform .08s; }
.list-item.tappable:active { background: #EAF3FE; transform: scale(.99); }
.list-item .chevron { color: #9AB4D0; font-size: 22px; font-weight: 700; line-height: 1; flex: 0 0 auto; }
.dots3 { letter-spacing: 2px; color: var(--blue-light); font-weight: 800; }
.mastery { display: inline-flex; gap: 3px; }
.mastery i { width: 7px; height: 7px; border-radius: 50%; background: #CFE0F3; display: inline-block; }
.mastery i.on { background: var(--blue); }

/* ---------- 底部选项卡 ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: none;
  justify-content: space-around;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  max-width: 760px; margin: 0 auto;
}
#tabbar.show { display: flex; }
#tabbar a {
  flex: 1; text-align: center; padding: 7px 0 8px;
  color: #8AA0B6; text-decoration: none; font-size: 11px;
}
#tabbar a .bi { font-size: 21px; line-height: 1.25; display: block; }
#tabbar a.on { color: var(--blue); font-weight: 700; }

/* ---------- 语法讲解 ---------- */
.lesson-h { font-size: 19px; font-weight: 800; margin: 22px 0 8px; color: var(--blue-deep); }
.lesson-p { font-size: 16px; line-height: 1.85; }
.lesson-p b, .lesson-p strong { color: #D84315; }
.formula { background: #F5F9FF; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-top: 10px; }
.formula .ft { font-size: 13px; color: var(--ink-2); margin-bottom: 9px; font-weight: 700; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { border-radius: 10px; padding: 9px 12px; font-weight: 700; font-size: 15px; position: relative;
  display: flex; flex-direction: column; align-items: center; color: #fff; }
.slot small { font-weight: 400; font-size: 11px; opacity: .92; margin-top: 3px; white-space: nowrap; }
.slot.subject { background: #42A5F5; }
.slot.verb { background: #EF5350; }
.slot.object { background: #66BB6A; }
.slot.fixed { background: #AB47BC; }
.slot.wh { background: #FF9800; }
.slot.aux { background: #26C6DA; }
.slot.adj { background: #EC8A3D; }
.slot.note { background: transparent; color: var(--ink-2); padding: 9px 2px; }

.example-card { border-left: 4px solid var(--blue-light); background: #fff; border-radius: 10px;
  padding: 12px 14px; margin-top: 10px; box-shadow: var(--shadow); }
.example-card .en { font-size: 16px; font-weight: 600; line-height: 1.6; }
.example-card .zh { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.tip-card { border-radius: 12px; padding: 12px 14px; margin-top: 10px; font-size: 15px; line-height: 1.7; }
.tip-card.warn { background: #FFF4E5; color: #A05200; }
.tip-card.good { background: var(--green-bg); color: var(--green); }

table.cmp { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); margin-top: 10px; font-size: 14.5px; }
table.cmp th { background: var(--blue); color: #fff; padding: 10px; text-align: left; font-weight: 700; }
table.cmp td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cmp tr:last-child td { border-bottom: none; }

.rules-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.rule-branch { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.rule-branch .rb-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rule-branch .cond { font-weight: 700; }
.rule-branch .arrow { color: var(--blue); font-weight: 800; }
.rule-branch .res { color: var(--blue-deep); font-weight: 700; }
.rule-branch .ex { color: var(--ink-2); font-size: 13.5px; margin-top: 5px; }

.freq-track { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.freq-row { display: flex; align-items: center; gap: 10px; }
.freq-row .w { width: 86px; font-weight: 700; flex: 0 0 86px; }
.freq-row .bar { flex: 1; background: #E7EFF9; border-radius: 99px; height: 22px; position: relative; overflow: hidden; }
.freq-row .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--blue-light), var(--blue)); }
.freq-row .bar span { position: absolute; right: 8px; top: 0; line-height: 22px; font-size: 12px; color: #fff; font-weight: 700; }
.freq-row .ex { flex: 0 0 100%; color: var(--ink-2); font-size: 12.5px; padding-left: 96px; }

.tl-wrap { background: #fff; border-radius: 14px; padding: 16px 14px 10px; margin-top: 10px; box-shadow: var(--shadow); }
.tl-svg { width: 100%; height: auto; display: block; }
.tl-caption { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; line-height: 1.6; }

.pos-wrap { background: #fff; border-radius: 14px; padding: 16px; margin-top: 10px; box-shadow: var(--shadow); }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pos-cell { position: relative; height: 150px; border: 2px dashed #BBD6F2; border-radius: 12px; }
.pos-ball { position: absolute; width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transform: translate(-50%, -50%); box-shadow: 0 3px 8px rgba(21,101,192,.4); }
.pos-sent { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; text-align: center; }

.quiz-block { background: #fff; border: 2px solid #D5E5F8; border-radius: 16px; padding: 16px; margin-top: 14px; }
.quiz-block .qb-title { display: inline-block; background: var(--blue); color: #fff; font-size: 13px;
  padding: 3px 10px; border-radius: 8px; font-weight: 700; margin-bottom: 10px; }
.wo-tokens { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.wo-token { padding: 9px 14px; border-radius: 10px; background: var(--blue-bg); color: var(--blue-deep);
  font-weight: 700; font-size: 16px; }
.wo-token.used { opacity: .35; }
.wo-answer { min-height: 52px; border: 2px dashed #BBD6F2; border-radius: 12px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mcell { padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 15px; font-weight: 600; }
.mcell.on { border-color: var(--blue); background: var(--blue-bg); }
.mcell.ok { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.mcell.bad { border-color: var(--red) !important; background: var(--red-bg) !important;
  animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 课文 */
.txt-line { background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.txt-line .sp { color: var(--blue); font-weight: 800; margin-right: 6px; }
.txt-line .en { font-size: 17px; line-height: 1.6; }
.txt-line .cn { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.txt-toggle { color: var(--blue); font-size: 13px; font-weight: 700; }

.result-ring { width: 130px; height: 130px; border-radius: 50%; margin: 8px auto 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: conic-gradient(var(--blue) var(--p), #DCE8F7 0); }
.result-ring i { width: 104px; height: 104px; border-radius: 50%; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-style: normal; }
.result-ring b { font-size: 30px; color: var(--blue-deep); }
.result-ring span { font-size: 12px; color: var(--ink-2); }

.empty { text-align: center; color: var(--ink-2); padding: 60px 20px; }
.empty .big { font-size: 46px; margin-bottom: 10px; }
