/* 课本背单词：纸张底色 + 墨绿主色，英文词头用衬线体 */
:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1c2a27;
  --muted: #6b7a75;
  --line: #e3ddd0;
  --accent: #1f6f5c;
  --accent-ink: #fffdf8;
  --accent-soft: #dcebe4;
  --no: #c2523a;
  --no-soft: #f7e3dc;
  --amber: #a86a12;
  --amber-soft: #f6e9cf;
  --vowel: #b45309;
  --shadow: 0 1px 2px rgba(28, 42, 39, .06), 0 8px 24px rgba(28, 42, 39, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --ipa: "Lucida Sans Unicode", "Segoe UI", "Noto Sans", sans-serif;
  --tabbar: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a19;
    --surface: #1d2524;
    --ink: #e8ece9;
    --muted: #93a19c;
    --line: #2d3836;
    --accent: #5cc2a3;
    --accent-ink: #10201c;
    --accent-soft: #1f3a33;
    --no: #ef8a72;
    --no-soft: #40241d;
    --amber: #e0b060;
    --amber-soft: #3a2f18;
    --vowel: #f0a85a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 20px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom));
}
#app.bare { padding-bottom: 24px; }

/* ---------- 通用部件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px;
  border-radius: 14px; font-weight: 600; font-size: 17px;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.no { background: var(--no-soft); color: var(--no); }
.btn small { font-weight: 400; font-size: 13px; opacity: .85; }
.link { color: var(--accent); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title { font-size: 13px; color: var(--muted); letter-spacing: .08em; margin: 26px 4px 10px; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.due { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.no { background: var(--no-soft); color: var(--no); }
.badge.plain { background: var(--line); color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }
.input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); font-size: 17px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.error { color: var(--no); font-size: 14px; min-height: 22px; margin: 4px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; max-width: calc(100vw - 48px); box-shadow: var(--shadow);
}

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; max-width: 186px; height: var(--tabbar);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px; position: relative;
}
#tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }
#tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; top: -1px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}

/* ---------- 登录 ---------- */
.auth { padding-top: 9vh; }
.brand { font-family: var(--serif); font-size: 44px; line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
.brand em { font-style: italic; color: var(--accent); }
.auth .lead { color: var(--muted); margin: 10px 0 30px; }
.tabs { display: flex; gap: 22px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 10px 2px; color: var(--muted); font-size: 17px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; border-color: var(--accent); }

/* ---------- 选课本 ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; }
.book {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; margin-bottom: 10px;
}
.book[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.book .spine {
  flex: none; width: 46px; height: 60px; border-radius: 4px 8px 8px 4px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 22px;
  border-left: 5px solid color-mix(in srgb, var(--accent) 70%, #000);
}
.book .cover { flex: none; width: 50px; height: 68px; object-fit: cover; border-radius: 3px 6px 6px 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); background: var(--line); }
.book h3 { font-size: 17px; }

/* ---------- 首页 ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.book-switch { text-align: left; }
.book-switch .t { font-size: 22px; font-weight: 700; line-height: 1.25; }
.book-switch .s { font-size: 13px; color: var(--muted); }
.streak { text-align: right; flex: none; }
.streak b { font-family: var(--serif); font-size: 30px; line-height: 1; color: var(--accent); }
.today { margin-top: 18px; padding: 16px; display: flex; gap: 16px; align-items: flex-end; }
.today .nums { display: flex; gap: 20px; flex: 1; }
.today .num b { display: block; font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.today .num span { font-size: 12px; color: var(--muted); }
.week { display: flex; gap: 5px; align-items: flex-end; height: 46px; }
.week i { display: block; width: 9px; min-height: 3px; border-radius: 3px; background: var(--line); }
.week i.on { background: var(--accent); }
.week i.now { outline: 2px solid var(--accent-soft); }

.mode {
  display: block; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mode[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.mode .name { font-size: 18px; font-weight: 700; }
.mode .desc { font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; }
.bar .m { background: var(--accent); }
.bar .l { background: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.mode .nums { font-size: 12px; color: var(--muted); display: flex; gap: 12px; }
.count-row { margin: 4px 0 18px; }
.count-row input { width: 76px; min-height: 36px; border-radius: 999px; text-align: center; font-size: 14px; padding: 0 8px; }
.start-box { display: grid; gap: 10px; }
.start-box .btn { min-height: 58px; flex-direction: column; gap: 0; box-shadow: var(--shadow); }

/* ---------- 学习 ---------- */
.study { display: flex; flex-direction: column; min-height: calc(100dvh - 44px); }
.study-top { display: flex; align-items: center; gap: 12px; }
.study-top .x { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--muted); margin-left: -8px; }
.study-top .bar { flex: 1; margin: 0; height: 8px; border-radius: 4px; }
.study-top .bar i { background: var(--accent); transition: width .25s ease; }
.study-top .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.flash { flex: 1; display: flex; flex-direction: column; margin: 16px 0; padding: 26px 20px; overflow: hidden; }
.flash .tag { align-self: flex-start; }
.front { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 20px 0; }
.headword { font-family: var(--serif); font-size: clamp(34px, 11vw, 52px); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.headword.long { font-size: clamp(24px, 7vw, 34px); }
.phone { font-family: var(--ipa); color: var(--muted); font-size: 16px; }
/* 拼读：每组字母一列，上面是字母，下面是它的音标 */
.phonics { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 4px; letter-spacing: 0; }
.back .phonics { justify-content: flex-start; }
.phonics .ph { display: inline-flex; flex-direction: column; align-items: center; }
.phonics .ph b { padding: 0 1px 3px; border-bottom: 3px solid; line-height: 1.1; }
.phonics .ph i { font: 400 14px/1.3 var(--ipa); margin-top: 4px; color: var(--muted); }
.phonics .gap { width: .3em; }
.phonics .c b { border-color: color-mix(in srgb, var(--ink) 28%, transparent); }
.phonics .v b, .phonics .v i { color: var(--vowel); }
.phonics .s b { color: var(--muted); font-weight: 400; opacity: .6; border-bottom-style: dotted; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; background: currentColor; }
.legend .v { color: var(--vowel); }
.legend .s { opacity: .6; }
.speak {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.speak.big { width: 104px; height: 104px; }
.speak svg { width: 22px; height: 22px; }
.speak.big svg { width: 44px; height: 44px; }
.speak.playing { animation: pulse .7s ease; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.hint { color: var(--muted); font-size: 14px; }
.back { animation: rise .2s ease; margin-top: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.back .head { display: flex; align-items: center; gap: 12px; margin: 10px 0 2px; }
.back .headword { font-size: clamp(28px, 8vw, 38px); }
.trans { list-style: none; padding: 0; margin: 14px 0 0; }
.trans li { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; font-size: 18px; }
.trans .pos { flex: none; font-family: var(--serif); font-style: italic; color: var(--accent); font-size: 15px; min-width: 30px; }
.front .trans { margin: 0; text-align: left; }
.front .trans li { font-size: 21px; }
.extra { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.extra h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); letter-spacing: .08em; font-weight: 400; }
.extra p { font-size: 15px; }
.extra p + p { margin-top: 8px; }
.extra .en { font-family: var(--serif); font-size: 16.5px; }
.extra .cn { color: var(--muted); display: block; font-size: 14px; }
.verdict { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 4px; }
.verdict.ok { color: var(--accent); }
.verdict.no { color: var(--no); }
.typed { font-family: var(--serif); font-size: 20px; color: var(--no); text-decoration: line-through; overflow-wrap: anywhere; }
.spell-input {
  width: 100%; max-width: 380px; min-height: 58px; text-align: center;
  font-family: var(--serif); font-size: 26px; letter-spacing: .02em;
  border: 0; border-bottom: 2px solid var(--line); background: transparent; border-radius: 0;
}
.spell-input:focus { outline: none; border-color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: sticky; bottom: 16px; }
.actions.single { grid-template-columns: 1fr; }
.actions .btn { min-height: 60px; font-size: 19px; box-shadow: var(--shadow); }
.actions .btn.no { background: var(--surface); border: 1.5px solid var(--no); color: var(--no); }
.cn-hint { color: var(--muted); font-size: 15px; max-width: 100%; }
.mic {
  width: 84px; height: 84px; border-radius: 50%; margin-top: 8px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: var(--shadow); transition: transform .1s ease, background .15s ease;
}
.mic svg { width: 36px; height: 36px; }
.mic:active { transform: scale(.96); }
.mic.on { background: var(--no); animation: breathe 1.2s ease-in-out infinite; }
.mic[disabled] { opacity: .5; }
@keyframes breathe { 50% { box-shadow: 0 0 0 12px var(--no-soft); } }
.level { width: 120px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.level i { display: block; height: 100%; background: var(--no); transform: scaleX(0); transform-origin: left; transition: transform .08s linear; }
.speech-result { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.phones { font-family: var(--ipa); font-size: 30px; line-height: 1.4; letter-spacing: .04em; color: var(--muted); overflow-wrap: anywhere; }
.phones .ok { color: var(--accent); }
.phones .bad { color: var(--no); font-weight: 700; text-decoration: underline wavy; text-underline-offset: 6px; }
.phone-notes { margin: 8px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.phone-notes b { color: var(--no); font-family: var(--ipa); }
.keys { text-align: center; font-size: 12px; color: var(--muted); margin-top: 12px; }
@media (hover: none) { .keys { display: none; } }

.done { text-align: center; padding-top: 6vh; }
.done h1 { font-family: var(--serif); font-size: 40px; }
.done .nums { display: flex; justify-content: center; gap: 34px; margin: 24px 0; }
.done .num b { display: block; font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.done .num span { font-size: 13px; color: var(--muted); }
.done .list { text-align: left; margin: 0 0 20px; }

/* ---------- 词表 ---------- */
.word-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.word-row .w { font-family: var(--serif); font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.word-row .w .phone { font-weight: 400; }
.word-row .c { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.word-row .state { flex: none; text-align: right; font-size: 12px; color: var(--muted); display: grid; gap: 3px; justify-items: end; }
.word-row .speak { width: 38px; height: 38px; }
.toolbar { display: grid; gap: 10px; margin-bottom: 6px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; }

/* ---------- 我的 ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; min-height: 58px; }
.setting + .setting { border-top: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 6px 14px; font-size: 14px; color: var(--muted); min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.rules { padding: 16px; font-size: 14px; color: var(--muted); }
.rules li { margin: 4px 0; }
.rules ul { margin: 0; padding-left: 18px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
