/* ============================================================
   英语学习 · 设计系统（移动优先）
   断点：手机 < 640 · 平板 640–959 · 桌面 ≥ 960
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --ink: #161c2b;
  --ink-2: #5b6577;
  --ink-3: #8e98aa;
  --line: #e7ebf3;
  --line-2: #d5dbe7;

  --primary: #4f6ef7;
  --primary-dark: #3a56d4;
  --primary-soft: #eef1fe;
  --primary-ink: #ffffff;

  --success: #0f9d58;
  --success-soft: #e8f7ef;
  --warn: #d98300;
  --warn-soft: #fff5e6;
  --danger: #e5484d;
  --danger-soft: #fdecec;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 2px 6px rgba(16, 24, 40, 0.05), 0 12px 28px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.16);

  --sidebar-w: 232px;
  --topbar-h: 56px;
  --tabbar-h: 60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .opt, .mark, .choice, .step, [data-view], [data-act] { touch-action: manipulation; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary); }
::selection { background: #d9e2ff; }

/* ---------------- 布局骨架 ---------------- */
.app { display: flex; min-height: 100dvh; }

.sidebar { display: none; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.titles { min-width: 0; }
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-sub {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.date-chip {
  display: none;
  font-size: 12px;
  color: var(--ink-2);
  background: #eef1f8;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); }

.view {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  outline: none;
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 底部标签栏（手机 / 平板） ---------------- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.bb-item {
  flex: 1;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-3);
  font-size: 11px;
  position: relative;
  padding: 6px 0;
}
.bb-ico { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: 0.75; }
.bb-item.active { color: var(--primary); }
.bb-item.active .bb-ico { filter: none; opacity: 1; }
.bb-item .count-badge { position: absolute; top: 2px; right: calc(50% - 26px); }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px; }
.section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
}
.muted { color: var(--ink-3); font-size: 13px; }
.hr { height: 1px; background: var(--line); margin: 16px 0; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 12px; font-size: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); font-weight: 500; }
.btn.ghost:hover { background: #f6f8fd; color: var(--ink); border-color: var(--line-2); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.btn.soft:hover { background: #e3e9ff; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger.ghost { background: #fff; color: var(--danger); border-color: #f3c9cb; }
.btn.lg { min-height: 50px; padding: 0 26px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.ghost-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 10px;
  font-size: 12px;
}
.ghost-btn:hover { border-color: var(--line-2); color: var(--ink); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #eef1f8;
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.hot { background: #fff1e6; color: #b95c00; }
.badge.lv0 { background: #e8f6ee; color: #147a4c; }
.badge.lv4 { background: #e9efff; color: #2f52c8; }
.badge.lv6 { background: #f2eaff; color: #6b3fb5; }
.badge.kind-spelling { background: #e9efff; color: #2f52c8; }
.badge.kind-grammar { background: #fff1e6; color: #b95c00; }
.badge.kind-listening { background: #e8f6ee; color: #147a4c; }
.badge.ok-badge { background: var(--success-soft); color: #147a4c; }

.count-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff6b6b;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item .count-badge { margin-left: auto; }

.kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fafbfd;
  font-size: 11px;
  color: var(--ink-2);
  font-family: Consolas, monospace;
}

/* ---------------- 今日任务 ---------------- */
.hero { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.hero-main {
  padding: 20px;
  background:
    radial-gradient(120% 120% at 0% 0%, #eef2ff 0%, rgba(255, 255, 255, 0) 55%),
    var(--panel);
}
.hero-main h2 {
  margin: 0 0 6px;
  font-size: 21px;
  letter-spacing: -0.3px;
  line-height: 1.3;
}
.hero-main p { margin: 0; color: var(--ink-2); font-size: 13px; }
.hero-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.hero-actions .muted { font-size: 12px; }
.hero-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side-card { padding: 14px 16px; }
.side-card b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.side-card small { color: var(--ink-3); font-size: 12px; }

.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.step {
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.step-name { font-weight: 600; font-size: 12.5px; }
.step-idx { font-size: 11px; color: var(--ink-3); }
.step-val { margin-top: 6px; font-size: 19px; font-weight: 800; letter-spacing: -0.4px; }
.step-desc { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.step.done { border-color: #c2e8d5; background: linear-gradient(180deg, #f5fdf9, #fff); }
.step.done .step-val { color: var(--success); }
.step.active { border-color: #c3d0fb; box-shadow: 0 0 0 3px #eef2ff; }
.step.locked { opacity: 0.6; }
.step-bar { height: 4px; border-radius: 3px; background: #eef1f6; margin-top: 10px; overflow: hidden; }
.step-bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s ease; }
.step.done .step-bar i { background: var(--success); }

/* 学习卡 */
.study { max-width: 720px; margin: 0 auto; }
.study-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.progress-line { height: 6px; border-radius: 4px; background: #e9edf6; overflow: hidden; margin-bottom: 16px; }
.progress-line i { display: block; height: 100%; background: linear-gradient(90deg, #7f97ff, var(--primary)); transition: width 0.25s ease; }

.word-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 34px 20px;
  text-align: center;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.word-big { font-size: 38px; font-family: var(--font-serif); letter-spacing: 0.5px; word-break: break-word; }
.word-ipa { color: var(--ink-2); margin-top: 6px; font-size: 15px; }
.word-pos-cn { margin-top: 16px; font-size: 18px; }
.word-pos { color: var(--ink-3); font-size: 13px; margin-right: 6px; }
.word-ex { margin-top: 16px; font-size: 14px; line-height: 1.7; }
.word-ex-cn { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.speak-btn {
  margin-top: 14px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
}
.speak-btn:hover { border-color: var(--primary); color: var(--primary); }

.mark-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.mark {
  min-height: 56px;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 4px;
  transition: transform 0.08s ease, background 0.15s ease;
}
.mark b { font-size: 15px; font-weight: 700; }
.mark small { font-size: 11px; font-weight: 400; opacity: 0.72; line-height: 1.2; }
.mark:active { transform: scale(0.97); }
.mark-tip { text-align: center; margin-top: 10px; font-size: 12px; color: var(--ink-3); }

/* 学习卡：手机点一下翻面 */
.word-card.flip { cursor: pointer; }
.word-card.flip:active { transform: scale(0.995); }
.word-card.flip:focus-visible { outline: 3px solid #c3d0fb; outline-offset: 2px; }
.flip-hint { margin-top: 18px; font-size: 14px; color: var(--ink-2); }
.flip-hint small { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.mark:active { transform: scale(0.98); }
.mark.know { border-color: #b9e6cd; color: #0f8f52; background: #f4fcf8; }
.mark.fuzzy { border-color: #f0d9a8; color: #a76a00; background: #fffaf0; }
.mark.unknown { border-color: #f3c9cb; color: #c23b3f; background: #fff7f7; }
.mark .kbd { display: none; }

/* 答题 */
.quiz-card {
  max-width: 760px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 20px 18px;
}
.quiz-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 12px; flex-wrap: wrap; }
.quiz-q { font-size: 19px; line-height: 1.65; margin: 6px 0 18px; word-break: break-word; }
.quiz-q .blank { display: inline-block; min-width: 62px; border-bottom: 2px solid var(--primary); text-align: center; color: var(--primary); }
.quiz-cn { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 4px; word-break: break-word; }

.opts { display: grid; gap: 9px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 13px 14px;
  min-height: 50px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: #fff;
  font-size: 15px;
}
.opt:hover { border-color: var(--primary); background: #f8faff; }
.opt .idx {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #eef1f8;
  color: var(--ink-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
}
.opt.correct { border-color: var(--success); background: var(--success-soft); }
.opt.correct .idx { background: var(--success); color: #fff; }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt.wrong .idx { background: var(--danger); color: #fff; }
.opt:disabled { cursor: default; }

.feedback { margin-top: 14px; border-radius: 13px; padding: 13px 14px; font-size: 14px; line-height: 1.65; }
.feedback.ok { background: var(--success-soft); border: 1px solid #bfe8d2; }
.feedback.no { background: var(--danger-soft); border: 1px solid #f3c9cb; }
.feedback b { display: block; margin-bottom: 3px; }

.answer-line { margin-top: 16px; display: flex; gap: 8px; }
.answer-line input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  font-size: 17px;
  outline: none;
  background: #fff;
}
.answer-line input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #eef2ff; }
.answer-line input.ok { border-color: var(--success); background: #f7fffb; }
.answer-line input.no { border-color: var(--danger); background: #fff9f9; }
.answer-line .btn { flex: 0 0 auto; }

.play-row { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.play-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  flex: 0 0 62px;
  box-shadow: 0 8px 20px rgba(79, 110, 247, 0.32);
}
.play-btn:disabled { background: #c6cddc; box-shadow: none; }
.play-left { font-size: 12px; color: var(--ink-3); }

.result-card { text-align: center; padding: 28px 18px; }
.result-score { font-size: 42px; font-weight: 800; letter-spacing: -1px; margin: 6px 0; }
.result-card p { color: var(--ink-2); }

/* ---------------- 工具条 / 词库 ---------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] {
  flex: 1 1 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  outline: none;
  background: #fff;
}
.toolbar input[type="search"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #eef2ff; }
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: #eceff7;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.seg button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}
.seg button.on { background: #fff; color: var(--primary-dark); font-weight: 600; box-shadow: var(--shadow-sm); }

.word-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.word-table th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.word-table td { padding: 12px; border-bottom: 1px solid #f2f5fa; vertical-align: middle; }
.word-table tr:last-child td { border-bottom: 0; }
.word-cell { font-family: var(--font-serif); font-size: 16px; }
.word-cell button { color: var(--primary); margin-left: 6px; font-size: 13px; }

/* ---------------- 统计 ---------------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card { padding: 16px; }
.stat-card small { color: var(--ink-3); font-size: 12px; }
.stat-card b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-top: 4px; }
.stat-note { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-3); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 8px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bar-wrap { width: 100%; max-width: 40px; flex: 1; display: flex; align-items: flex-end; }
.bar { width: 100%; border-radius: 8px 8px 3px 3px; background: #dbe3f8; min-height: 3px; transition: height 0.3s ease; }
.bar.full { background: linear-gradient(180deg, #6fdcb2, var(--success)); }
.bar.part { background: linear-gradient(180deg, #a9bcff, var(--primary)); }
.bar-label { font-size: 10px; color: var(--ink-3); }
.bar-val { font-size: 10px; color: var(--ink-2); min-height: 13px; }

.level-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12.5px; flex-wrap: wrap; }
.level-row .lv-name { width: 96px; flex: 0 0 auto; color: var(--ink-2); }
.level-row .lv-bar { flex: 1 1 120px; height: 8px; border-radius: 5px; background: #eef1f6; overflow: hidden; }
.level-row .lv-bar i { display: block; height: 100%; border-radius: 5px; background: var(--primary); }
.level-row .lv-num { flex: 0 0 auto; color: var(--ink-3); font-size: 11.5px; }

/* ---------------- 设置 ---------------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #f2f5fa;
}
.form-row:last-child { border-bottom: 0; }
.form-row label { flex: 0 0 100%; color: var(--ink-2); font-size: 13px; }
.form-row .hint { color: var(--ink-3); font-size: 12px; flex: 1 1 100%; }
.form-row input[type="number"],
.form-row select {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: #fff;
  outline: none;
  max-width: 100%;
}
.form-row select { flex: 1 1 auto; min-width: 0; }
.form-row input[type="range"] { width: 100%; max-width: 240px; accent-color: var(--primary); }
.form-row .btn { flex: 0 0 auto; }
.danger-zone { border-color: #f6d9da; background: #fffbfb; }

/* ---------------- 弹窗 / 底部抽屉 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 22, 38, 0.44);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  width: 100%;
  max-width: 100%;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-head { padding: 20px 20px 4px; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.2px; }
.modal-head p { margin: 5px 0 0; color: var(--ink-3); font-size: 13px; }
.modal-body { padding: 14px 20px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.modal-foot .btn { width: 100%; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 18px; }
.choice {
  min-height: 48px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  text-align: center;
  font-size: 14px;
}
.choice.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 0 0 3px #eef2ff;
}
.field-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }

/* 底部抽屉（更多菜单） */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 22, 38, 0.4);
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  background: #fff;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet h3 { margin: 0 0 12px; font-size: 15px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}
.sheet-item span:first-child { font-size: 20px; }
.sheet-item:active { background: var(--primary-soft); }

/* ---------------- 作文 ---------------- */
.write-grid { display: grid; gap: 14px; }
.write-area {
  width: 100%;
  min-height: 240px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  line-height: 1.8;
  outline: none;
  resize: vertical;
  font-family: var(--font-serif);
  font-size: 15px;
}
.write-area:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #eef2ff; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef1f8;
  color: var(--ink-2);
  margin: 0 6px 6px 0;
}
.chip.used { background: var(--success-soft); color: #147a4c; }
.chip.miss { background: var(--warn-soft); color: #a76a00; }
.wordcount { font-size: 12px; color: var(--ink-3); }
.wordcount b { color: var(--ink); font-size: 15px; }
.selfeval { display: grid; gap: 10px; }
.selfeval .se-row { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.selfeval .se-row span { flex: 0 0 44px; color: var(--ink-2); }
.selfeval select { min-height: 36px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line-2); }
.model-box {
  background: var(--panel-2);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  padding: 14px;
  line-height: 1.9;
  font-family: var(--font-serif);
  font-size: 14px;
}

/* ---------------- 错题本 ---------------- */
.mk-list { display: flex; flex-direction: column; gap: 10px; }
.mk-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.mk-item.resolved { opacity: 0.68; }
.mk-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mk-title { font-size: 16px; font-family: var(--font-serif); }
.mk-ipa { color: var(--ink-3); font-size: 12.5px; }
.mk-meta { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.mk-q { font-size: 14.5px; margin-top: 8px; line-height: 1.7; }
.mk-answer { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.mk-body { margin-top: 6px; font-size: 14px; }
.mk-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.danger-text { color: var(--danger) !important; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  background: #1d2536;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast.ok { background: #10784f; }
.toast.err { background: #b93a3f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   平板 ≥ 640
   ============================================================ */
@media (min-width: 640px) {
  .view { padding: 20px 24px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .date-chip { display: inline-block; }
  .hero-actions { flex-direction: row; align-items: center; }
  .hero-actions .btn { width: auto; }
  .steps { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .toolbar input[type="search"] { flex: 1 1 240px; }
  .modal-foot { flex-direction: row; justify-content: flex-end; }
  .modal-foot .btn { width: auto; }
  .modal {
    max-width: 560px;
    border-radius: var(--r-xl);
    margin-bottom: 8vh;
  }
  .overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 520px; margin: 0 auto; border-radius: var(--r-xl); margin-bottom: 24px; }
  .write-grid { grid-template-columns: 1fr 300px; align-items: start; }
  .mark-row { grid-template-columns: repeat(3, minmax(0, 220px)); justify-content: center; }
  .mark .kbd { display: inline-block; }
  .toast-root { bottom: 24px; }
}

/* ============================================================
   桌面 ≥ 960：侧边栏 + 无底部栏
   ============================================================ */
@media (min-width: 960px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 20px 14px 16px;
    background: var(--panel);
    border-right: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8ba4ff);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
  }
  .brand-text { display: flex; flex-direction: column; line-height: 1.3; }
  .brand-text strong { font-size: 15px; }
  .brand-text span { font-size: 11px; color: var(--ink-3); }

  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 11px;
    color: var(--ink-2);
    font-size: 14px;
    text-align: left;
  }
  .nav-item:hover { background: #f4f6fc; color: var(--ink); }
  .nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
  .nav-ico { width: 18px; text-align: center; font-size: 14px; }
  .nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-left: auto; }

  .sidebar-foot {
    margin-top: auto;
    display: flex;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .mini-stat { flex: 1; text-align: center; }
  .mini-stat span { display: block; font-size: 19px; font-weight: 800; }
  .mini-stat small { font-size: 11px; color: var(--ink-3); }

  .bottombar { display: none; }
  .topbar { padding: 0 32px; min-height: 72px; }
  .topbar h1 { font-size: 20px; }
  .page-sub { font-size: 12.5px; }
  .view { padding: 26px 32px 48px; max-width: 1040px; }

  .hero { flex-direction: row; align-items: stretch; gap: 14px; }
  .hero-main { flex: 1; padding: 24px 26px; }
  .hero-main h2 { font-size: 23px; }
  .hero-side { flex-direction: column; display: flex; width: 230px; flex: 0 0 230px; gap: 12px; }
  .hero-side .side-card { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .hero-side .side-card b { font-size: 24px; }

  .word-big { font-size: 46px; }
  .word-card { padding: 44px 36px; min-height: 320px; }
  .quiz-q { font-size: 21px; }
  .quiz-cn { font-size: 27px; }
  .steps { gap: 12px; }
  .step { padding: 16px; }
  .step-val { font-size: 21px; }
  .toast-root { left: auto; right: 24px; transform: none; width: auto; max-width: 380px; }
  .form-row { flex-wrap: nowrap; }
  .form-row label { flex: 0 0 132px; }
  .form-row .hint { flex: 1 1 auto; }
  .modal { max-width: 620px; }
  .choice-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   词库表格：窄屏转卡片
   ============================================================ */
@media (max-width: 719px) {
  .answer-line input, .toolbar input[type="search"], .form-row input, .form-row select, .write-area { font-size: 16px; }
  .word-card { min-height: 320px; }
  .btn .kbd, .speak-btn .kbd { display: none; }
  .word-table thead { display: none; }
  .word-table, .word-table tbody, .word-table tr, .word-table td { display: block; width: 100%; }
  .word-table { padding: 6px; }
  .word-table tr {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
  }
  .word-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .word-table td { border: 0; padding: 0; width: auto; flex: 0 0 auto; }
  .word-table td:nth-child(1) { font-size: 17px; }
  .word-table td:nth-child(2) { color: var(--ink-3); font-size: 12px; }
  .word-table td:nth-child(3) { flex: 1 1 100%; font-size: 13px; color: var(--ink-2); }
  .word-table td:nth-child(4), .word-table td:nth-child(5) { margin-top: 6px; }
}

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