/* ============================================================
 *  记得 jìde — 样式
 * ============================================================ */
:root {
  --bg: #fff7ef;
  --bg2: #ffeede;
  --ink: #2d2a26;
  --muted: #8a8077;
  --card: #ffffff;
  --line: #f0e6da;
  --zh: #ef5b3b;        /* 语文 暖橙红 */
  --zh-soft: #fff0ec;
  --en: #2f9be0;        /* 英语 天蓝 */
  --en-soft: #ebf6ff;
  --good: #38b46a;
  --hard: #f4a72c;
  --again: #ec5f5f;
  --shadow: 0 10px 30px rgba(120, 80, 40, .10);
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: 16px;
}
#app { max-width: 640px; margin: 0 auto; padding: 14px 16px 60px; }
button { font-family: inherit; cursor: pointer; border: none; }
h2 { font-size: 1.3rem; margin: 0; }
h3 { font-size: 1.02rem; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.5; }
code { background: #f3ece2; border-radius: 6px; padding: 1px 6px; font-size: .85em; }

/* ---------- 顶部条 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.brand-logo { font-size: 1.5rem; }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: .5px; }
.brand-name small { font-weight: 500; color: var(--muted); font-size: .65rem; margin-left: 3px; }
.stat-pills { display: flex; gap: 7px; flex-wrap: wrap; }
.pill { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .82rem; font-weight: 700; box-shadow: 0 2px 6px rgba(120,80,40,.05); display: inline-flex; align-items: center; gap: 5px; }
.pill.ring .ringbar { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--good) calc(var(--p) * 1%), #eee 0); display: inline-block; }

/* ---------- 首页 ---------- */
.tagline { text-align: center; color: var(--muted); font-size: .95rem; margin: 4px 0 18px; }
.tagline b { color: var(--zh); }
.subject-card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); border: 1.5px solid var(--line); }
.subject-card header { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.subj-icon { font-size: 2.1rem; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.subject-card.chinese .subj-icon { background: var(--zh-soft); }
.subject-card.english .subj-icon { background: var(--en-soft); }
.subject-card h2 { font-size: 1.22rem; }
.subj-sub { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.counts { display: flex; gap: 10px; margin-bottom: 12px; }
.count { flex: 1; background: #faf6f0; border-radius: 14px; padding: 10px; text-align: center; }
.count b { display: block; font-size: 1.7rem; line-height: 1; font-weight: 800; }
.count span { font-size: .76rem; color: var(--muted); }
.count.due.hot b { color: var(--zh); }
.count.due.hot { background: var(--zh-soft); }
.count.got b { color: var(--good); }
.progress-line { height: 7px; background: #f0e6da; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, var(--good), #74d39a); border-radius: 6px; transition: width .4s; }
.subj-actions { display: flex; gap: 10px; margin-bottom: 10px; }

.btn { flex: 1; padding: 14px 16px; border-radius: 15px; font-size: 1rem; font-weight: 800; background: #f1ebe3; color: var(--ink); transition: transform .08s, box-shadow .2s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--zh), #ff7a52); color: #fff; box-shadow: 0 6px 16px rgba(239,91,59,.32); }
.btn.accent { background: linear-gradient(135deg, var(--en), #5bb8f0); color: #fff; box-shadow: 0 6px 16px rgba(47,155,224,.30); }
.btn.ghost, .btn.ghost:disabled { background: #f1ebe3; color: var(--muted); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { width: 100%; flex: none; padding: 16px; }
.link-btn { background: none; color: var(--muted); font-size: .85rem; font-weight: 600; padding: 6px 2px; width: 100%; text-align: left; }
.link-btn.danger { color: var(--again); }
.home-foot { text-align: center; margin-top: 6px; }
.home-foot .link-btn { text-align: center; }

/* ---------- 学习页 ---------- */
.study-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.back { background: #fff; border: 1.5px solid var(--line); width: 38px; height: 38px; border-radius: 12px; font-size: 1.1rem; flex: none; color: var(--muted); font-weight: 700; }
.sbar { flex: 1; height: 10px; background: #f0e6da; border-radius: 6px; overflow: hidden; }
.sbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--good), #74d39a); transition: width .3s; }
.counter { font-weight: 800; font-size: .9rem; color: var(--muted); min-width: 52px; text-align: right; }
.tags { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tag { font-size: .76rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.tag.new { background: var(--en-soft); color: var(--en); }
.tag.review { background: var(--zh-soft); color: var(--zh); }
.tag.muted { background: #f1ebe3; color: var(--muted); font-weight: 600; }
.stage { display: inline-flex; gap: 3px; margin-left: auto; }
.stage .dot { width: 8px; height: 8px; border-radius: 50%; background: #e6dccd; }
.stage .dot.on { background: var(--good); }

.card { background: var(--card); border-radius: 26px; box-shadow: var(--shadow); border: 1.5px solid var(--line); min-height: 320px; display: grid; place-items: center; padding: 28px 20px; cursor: pointer; transition: transform .12s; position: relative; }
.card:active { transform: scale(.99); }
.face { text-align: center; width: 100%; }

/* 中文卡 */
.face.zh .pinyin { font-size: 1.5rem; color: var(--zh); font-weight: 700; letter-spacing: 1px; min-height: 1.6em; }
.face.zh .pinyin.ph { opacity: 0; }
.face.zh .hanzi { font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif; font-size: 7.5rem; line-height: 1.05; font-weight: 600; margin: 6px 0 10px; }
.face.zh .words { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin: 8px 0 16px; }
.face.zh .words .w { background: var(--zh-soft); color: var(--zh); font-weight: 700; padding: 7px 14px; border-radius: 12px; font-size: 1.15rem; }
.face.zh .prompt-hint { color: var(--muted); font-size: .9rem; margin-top: 16px; }

/* 英文卡 */
.face.en .word { font-size: 3.2rem; font-weight: 800; letter-spacing: .5px; margin-bottom: 12px; word-break: break-word; }
.face.en .meaning { font-size: 1.7rem; font-weight: 700; margin: 14px 0 6px; }
.face.en .meaning .pos { color: var(--muted); font-size: 1rem; font-style: italic; font-weight: 600; margin-right: 6px; }
.face.en .example { color: #6b6258; font-size: 1.05rem; background: var(--en-soft); padding: 12px 16px; border-radius: 14px; margin-top: 10px; line-height: 1.5; cursor: pointer; }
.face.en .prompt-hint { color: var(--muted); font-size: .95rem; margin-top: 10px; }

.speak { background: var(--en-soft); color: var(--en); border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: .95rem; margin-top: 4px; }
.face.zh .speak { background: var(--zh-soft); color: var(--zh); }

.reveal-hint { margin-top: 18px; }
.rating { display: flex; gap: 10px; margin-top: 18px; }
.rate { flex: 1; padding: 14px 6px; border-radius: 16px; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; transition: transform .08s; }
.rate:active { transform: scale(.94); }
.rate b { font-size: 1.1rem; }
.rate small { font-size: .72rem; font-weight: 600; opacity: .92; }
.rate.again { background: linear-gradient(135deg, var(--again), #f47e7e); }
.rate.hard { background: linear-gradient(135deg, var(--hard), #ffc163); }
.rate.good { background: linear-gradient(135deg, var(--good), #5fcf8b); }

/* ---------- 完成页 ---------- */
.complete { text-align: center; padding-top: 18px; }
.cele { font-size: 4.5rem; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.complete h2 { margin: 8px 0; }
.cele-sub { color: var(--muted); margin-bottom: 22px; }
.cele-sub b { color: var(--zh); }
.cele-stats { display: flex; gap: 12px; justify-content: center; margin-bottom: 26px; }
.cele-stats div { background: #fff; border-radius: 16px; padding: 16px 10px; min-width: 92px; box-shadow: var(--shadow); }
.cele-stats b { display: block; font-size: 1.5rem; }
.cele-stats span { font-size: .78rem; color: var(--muted); }
.cele-actions { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto; }
.cele-actions .btn { flex: none; }

/* ---------- 管理 / 设置 ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.import-box { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1.5px solid var(--line); margin-bottom: 20px; }
.import-box h3 { margin: 0 0 8px; }
.unit-title-input, #importText { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: .95rem; font-family: inherit; margin: 10px 0; background: #fdfaf6; }
#importText { resize: vertical; line-height: 1.6; }
.unit-title-input:focus, #importText:focus { outline: none; border-color: var(--en); }
.list-title { margin: 22px 0 10px; }
.unit-list { display: flex; flex-direction: column; gap: 10px; }
.unit-row { background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 3px 10px rgba(120,80,40,.05); border: 1.5px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.unit-info { flex: 1; min-width: 140px; }
.unit-info b { display: block; font-size: .98rem; }
.unit-info span { font-size: .78rem; color: var(--muted); }
.unit-bar { width: 90px; height: 7px; background: #f0e6da; border-radius: 5px; overflow: hidden; }
.unit-bar span { display: block; height: 100%; background: var(--good); }
.mini { padding: 6px 12px; border-radius: 10px; font-size: .8rem; font-weight: 700; background: #f1ebe3; }
.mini.danger { background: var(--zh-soft); color: var(--again); }
.manage-foot { margin-top: 26px; text-align: center; }

.setting-row { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 3px 10px rgba(120,80,40,.05); border: 1.5px solid var(--line); }
.setting-row label { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; background: #f1ebe3; font-size: 1.3rem; font-weight: 800; color: var(--ink); }
.stepper b { min-width: 28px; text-align: center; font-size: 1.2rem; }
.toggle { width: 52px; height: 30px; border-radius: 999px; background: #ddd3c5; position: relative; transition: background .2s; }
.toggle.on { background: var(--good); }
.toggle span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.toggle.on span { left: 25px; }
.backup-actions { display: flex; gap: 10px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; }
.ver { text-align: center; color: var(--muted); font-size: .76rem; margin-top: 24px; }

/* ---------- 彩带 ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.confetti span { position: absolute; top: -30px; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(360deg); opacity: 0; } }

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
  #app { padding: 12px 12px 50px; }
  .face.zh .hanzi { font-size: 6rem; }
  .face.en .word { font-size: 2.6rem; }
  .face.en .meaning { font-size: 1.45rem; }
  .stat-pills { width: 100%; }
  .pill { font-size: .76rem; padding: 4px 9px; }
  .rate b { font-size: 1rem; }
}
@media (min-width: 641px) {
  .face.zh .hanzi { font-size: 8.5rem; }
}
