/* 主题色与 iOS 版 Theme 一致（StatusViews.swift） */
:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --field: #E9EBEF;
  --text: #111827; --text2: #6B7280; --muted: #9CA3AF; --line: #E5E7EB;
  --accent: #4F6BED; --accentBg: #EEF1FD; --accentText: #3346C2;
  --newBg: #F1F2F4;
  --hard: #F08A24; --hardBg: #FFF3E6; --hardText: #B45309;
  --ok: #22A06B; --okBg: #E7F6EE; --okText: #157A4F;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1115; --surface: #1A1D23; --field: #23262D;
    --text: #F3F4F6; --text2: #9CA3AF; --muted: #6B7280; --line: #2A2E36;
    --accent: #6C84F5; --accentBg: #1F2747; --accentText: #A9B8FF;
    --newBg: #23262D;
    --hard: #F59E4C; --hardBg: #3A2614; --hardText: #F7B26A;
    --ok: #34C38A; --okBg: #123426; --okText: #5FD6A1;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text);
  height: 100%; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--field); border: none; border-radius: 10px; padding: 10px 12px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); }
a { color: var(--accent); text-decoration: none; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 0 20px calc(20px + env(safe-area-inset-bottom)); }

/* ---------- 通用 ---------- */
.card { background: var(--surface); border-radius: 20px; }
.card.shadow { box-shadow: 0 6px 10px rgba(0,0,0,.07); }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 99px;
  background: var(--newBg); color: var(--text2); white-space: nowrap;
}
.pill.hard { background: var(--hardBg); color: var(--hardText); }
.pill.ok { background: var(--okBg); color: var(--okText); }
.pill.accent { background: var(--accentBg); color: var(--accentText); }

.status-bar { display: flex; height: 5px; border-radius: 99px; background: var(--newBg); overflow: hidden; }
.status-bar > i { display: block; height: 100%; }
.status-bar .m { background: var(--ok); }
.status-bar .d { background: var(--hard); }

.thin-progress { height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; flex: 1; }
.thin-progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .2s; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none;
}
.icon-btn.accent { background: var(--accentBg); color: var(--accent); }
.icon-btn.big { width: 52px; height: 52px; font-size: 20px; }
.icon-btn.hero { width: 76px; height: 76px; font-size: 28px; background: var(--accent); color: #fff; box-shadow: 0 6px 10px rgba(79,107,237,.3); }
.icon-btn:disabled, .icon-btn.off { opacity: .4; }

.nav-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
}
.nav-bar .title { flex: 1; text-align: center; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-bar .sub { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ---------- 首页 ---------- */
.home-head { display: flex; align-items: flex-end; justify-content: space-between; padding-top: calc(16px + env(safe-area-inset-top)); }
.home-head .date { font-size: 13px; color: var(--text2); }
.home-head h1 { font-size: 30px; font-weight: 600; }

.today-card { background: var(--accent); border-radius: 24px; padding: 20px; color: #fff; box-shadow: 0 8px 14px rgba(79,107,237,.25); margin-top: 16px; }
.today-card .label { font-size: 14px; font-weight: 500; color: rgba(255,255,255,.78); display: flex; justify-content: space-between; align-items: center; }
.today-card .big { font-size: 44px; font-weight: 600; }
.today-card .big span { font-size: 15px; font-weight: 400; color: rgba(255,255,255,.78); margin-left: 6px; }
.today-card .prog { height: 6px; border-radius: 99px; background: rgba(255,255,255,.2); margin: 12px 0; }
.today-card .prog i { display: block; height: 100%; background: #fff; border-radius: 99px; min-width: 6px; }
.today-card .foot { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: rgba(255,255,255,.78); }
.today-card .go { background: #fff; color: var(--accent); border-radius: 99px; padding: 8px 14px; font-size: 14px; font-weight: 600; }
.streak-chip { font-size: 12px; font-weight: 500; background: rgba(255,255,255,.16); border-radius: 99px; padding: 4px 10px; color: #fff; }

.tiles { display: flex; gap: 12px; margin-top: 16px; }
.tile { flex: 1; text-align: left; border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.tile .t { font-size: 13px; font-weight: 500; display: flex; gap: 5px; align-items: center; }
.tile .n { font-size: 26px; font-weight: 600; }
.tile.hard { background: var(--hardBg); color: var(--hardText); }
.tile.ok { background: var(--okBg); color: var(--okText); }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; font-size: 17px; font-weight: 600; }
.section-head button { font-size: 14px; font-weight: 500; color: var(--accent); }

.book-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 18px; background: var(--surface); margin-bottom: 12px; }
.book-card .cover { width: 44px; height: 54px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; flex: none; }
.book-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.book-card .name { font-size: 16px; font-weight: 600; }
.book-card .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.book-card .chev { color: var(--muted); }

.empty-state { margin-top: 40px; padding: 24px; text-align: center; }
.empty-state .icon-circle { width: 88px; height: 88px; border-radius: 50%; background: var(--accentBg); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 40px; margin-bottom: 14px; }
.empty-state h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text2); margin-bottom: 16px; }
.btn-primary { display: block; width: 100%; min-height: 50px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; }
.btn-link { margin-top: 12px; font-size: 15px; font-weight: 500; color: var(--text); }

/* ---------- 词书详情 / 列表 ---------- */
.action-card { display: flex; gap: 12px; padding: 16px; margin-bottom: 14px; }
.study-btn { flex: 1; display: flex; align-items: center; gap: 12px; text-align: left; }
.study-btn .t1 { font-size: 18px; font-weight: 600; }
.study-btn .t2 { font-size: 12px; color: var(--text2); margin-top: 4px; }
.study-btn.off .t1 { color: var(--muted); }
.listen-btn { width: 46px; height: 52px; border-radius: 14px; background: var(--accentBg); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; flex: none; }
.listen-btn:disabled { background: var(--newBg); color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 99px; background: var(--surface); color: var(--text2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.on { font-weight: 600; }
.chip.on.st { background: var(--newBg); }
.chip.on.new { background: var(--newBg); color: var(--text2); }
.chip.on.dif { background: var(--hardBg); color: var(--hardText); }
.chip.on.mas { background: var(--okBg); color: var(--okText); }
.chip.on.all { background: var(--accentBg); color: var(--accentText); }

.search-box { width: 100%; margin: 4px 0 10px; }
.row-list { background: var(--surface); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: none; }
.row .main { flex: 1; min-width: 0; }
.row .w { font-size: 17px; font-weight: 600; }
.row .m { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .also { font-size: 11px; color: var(--muted); }
.row .act { font-size: 12px; color: var(--accent); flex: none; padding: 6px 8px; border-radius: 8px; background: var(--accentBg); }
.list-note { font-size: 12px; color: var(--text2); padding: 6px 2px 10px; }
.empty-note { padding: 30px 0; text-align: center; color: var(--text2); font-size: 14px; }

/* ---------- 学习卡片 ---------- */
.study-wrap { min-height: calc(100dvh - 70px); display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.card-scene { flex: 1; perspective: 1200px; display: flex; min-height: 320px; }
.card-inner { flex: 1; position: relative; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,.7,.35,1); }
.card-inner.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border-radius: 28px; box-shadow: 0 6px 10px rgba(0,0,0,.07);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px 24px; gap: 14px; text-align: center; overflow: hidden;
}
.card-face.back { transform: rotateY(180deg); overflow-y: auto; justify-content: flex-start; padding-top: 30px; }
.card-face .status { position: absolute; top: 18px; }
.card-face .word { font-size: 42px; font-weight: 600; overflow-wrap: anywhere; }
.card-face .phon { font-size: 16px; color: var(--text2); display: flex; gap: 8px; align-items: center; }
.card-face .meaning { font-size: 20px; font-weight: 500; }
.card-face .ex { font-size: 14px; color: var(--muted); }
.card-face .bookname { font-size: 11px; color: var(--muted); }
.card-face hr { width: 120px; border: none; border-top: 1px solid var(--line); }
.speak-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--accentBg); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.hint { text-align: center; font-size: 12px; color: var(--muted); }
.answer-row { display: flex; gap: 12px; }
.answer-row button { flex: 1; min-height: 56px; border-radius: 18px; font-size: 18px; font-weight: 600; }
.answer-row .no { background: var(--hardBg); color: var(--hardText); }
.answer-row .yes { background: var(--okBg); color: var(--okText); }

.summary { min-height: calc(100dvh - 70px); display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 30px 4px 10px; }
.summary .big-circle { position: relative; width: 96px; height: 96px; }
.summary .big-circle i { position: absolute; inset: 0; border-radius: 50%; background: var(--okBg); }
.summary .big-circle i + i { inset: 14px; background: var(--ok); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px; font-weight: 700; font-style: normal; }
.summary h2 { font-size: 26px; font-weight: 600; }
.summary .sub { font-size: 14px; color: var(--text2); margin-top: -10px; }
.summary .stats { display: flex; gap: 10px; width: 100%; }
.summary .stats > div { flex: 1; border-radius: 18px; padding: 14px 0; text-align: center; }
.summary .stats .n { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .stats .t { font-size: 13px; font-weight: 500; margin-top: 4px; }
.summary .actions { margin-top: auto; display: flex; gap: 12px; width: 100%; }
.summary .actions .ghost { flex: 1; min-height: 54px; border-radius: 18px; background: var(--surface); color: var(--accent); font-size: 17px; font-weight: 600; }
.summary .actions .solid { flex: 1; min-height: 54px; border-radius: 18px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; }

/* ---------- 听单词 ---------- */
.listen-wrap { min-height: calc(100dvh - 70px); display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 6px; }
.listen-top { display: flex; align-items: center; gap: 10px; width: 100%; }
.listen-top .pos { font-size: 14px; font-weight: 500; color: var(--text2); font-variant-numeric: tabular-nums; }
.listen-top .rest { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.word-circle { width: 240px; height: 240px; border-radius: 50%; background: var(--surface); box-shadow: 0 8px 14px rgba(0,0,0,.07); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 28px; text-align: center; margin: auto 0; }
.word-circle .w { font-size: 34px; font-weight: 600; }
.word-circle .m { font-size: 17px; color: var(--text2); }
.wave { display: flex; gap: 4px; align-items: center; height: 36px; }
.wave i { width: 4px; border-radius: 2px; background: var(--accent); opacity: .8; animation: wave 1.1s ease-in-out infinite; animation-play-state: paused; height: 8px; }
.wave.on i { animation-play-state: running; }
@keyframes wave { 0%,100% { transform: scaleY(.6); } 50% { transform: scaleY(1.4); } }
.listen-controls { display: flex; align-items: center; gap: 40px; margin-top: auto; padding-bottom: 20px; }
.listen-note { font-size: 12px; color: var(--muted); }

/* ---------- 设置 / 表单 ---------- */
.form-section { margin-bottom: 22px; }
.form-section > h3 { font-size: 13px; font-weight: 500; color: var(--text2); margin: 0 0 8px 14px; text-transform: none; }
.form-section > .note { font-size: 12px; color: var(--text2); margin: 8px 14px 0; line-height: 1.5; }
.form-card { background: var(--surface); border-radius: 16px; overflow: hidden; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 16px; }
.form-row:last-child { border-bottom: none; }
.form-row .l { flex: 1; }
.form-row select { background: var(--field); max-width: 55%; }
.form-row .stepper { display: flex; align-items: center; gap: 10px; }
.form-row .stepper button { width: 30px; height: 30px; border-radius: 8px; background: var(--field); font-size: 18px; }
.form-row .stepper .v { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.form-row button.link { color: var(--accent); }
.form-row button.danger { color: #E5484D; }
.form-row textarea { width: 100%; min-height: 160px; font-family: ui-monospace, monospace; font-size: 14px; background: var(--field); }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---------- 弹出层 ---------- */
#overlay { position: fixed; inset: 0; z-index: 50; display: none; }
#overlay.on { display: block; }
.dim { position: absolute; inset: 0; background: rgba(0,0,0,.28); }
.dialog, .sheet {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: var(--surface); border-radius: 24px;
  max-width: 340px; width: calc(100% - 56px);
  padding: 24px 20px 18px;
}
.dialog { top: 32%; }
.dialog h3 { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 10px; }
.dialog p { font-size: 14px; color: var(--text2); text-align: center; margin-bottom: 18px; line-height: 1.5; }
.dialog .btns { display: flex; flex-direction: column; gap: 10px; }
.dialog .btns button { min-height: 48px; border-radius: 99px; background: var(--field); font-size: 16px; font-weight: 500; color: var(--accent); }
.dialog .btns button.danger { color: #E5484D; }
.sheet { bottom: 0; border-radius: 24px 24px 0 0; width: 100%; max-width: 520px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.sheet .grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: -10px auto 14px; }
.sheet button.item { display: block; width: 100%; min-height: 50px; border-radius: 14px; font-size: 16px; text-align: center; margin-bottom: 6px; background: var(--field); }
.sheet button.item.danger { color: #E5484D; }
.sheet button.item.cancel { margin-top: 8px; color: var(--text2); }

#toast { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none; }
#toast .t { color: #fff; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 99px; animation: toastin .2s ease-out; }
@keyframes toastin { from { transform: translateY(-12px); opacity: 0; } }
