/* WordFlow —— 视觉基线：一层柔和的品牌色、克制的阴影、以留白为主 */

:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #8592a6;
  --line: #e8ecf3;
  --brand: #3b6ef5;
  --brand-dark: #2a56d6;
  --brand-soft: #eef3ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffaeb;
  --bad: #dc2626;
  --bad-soft: #fef3f2;
  --radius: 18px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .05), 0 1px 2px rgba(16, 24, 40, .03);
  --shadow-md: 0 12px 28px -8px rgba(16, 24, 40, .12), 0 2px 8px rgba(16, 24, 40, .04);
  --shadow-lg: 0 28px 60px -16px rgba(16, 24, 40, .22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -240px, #e9efff 0%, rgba(233, 239, 255, 0) 70%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 手机端：底部标签栏 + 更紧凑的排版 ---------- */
@media (max-width: 640px) {
  header {
    padding: 10px 14px;
    gap: 10px;
  }
  header .brand { font-size: 15px; }
  header .brand::before { width: 16px; height: 16px; margin-right: 7px; }
  header .who { font-size: 12px; padding: 2px 10px; }

  /* 导航移到屏幕底部，做成小程序那样的大按钮 */
  header nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
  }
  header nav button {
    border-radius: 12px;
    padding: 9px 2px;
    font-size: 13px;
    line-height: 1.2;
  }
  header nav button.active { font-weight: 600; }

  main {
    padding: 16px 12px calc(96px + env(safe-area-inset-bottom));
  }
  .card { padding: 16px; border-radius: 16px; margin-bottom: 12px; }
  .title { font-size: 16px; }
  .big { font-size: 32px; }

  /* 输入框字号 ≥16px，否则 iOS 聚焦时会自动放大页面 */
  input, textarea, .book-select { font-size: 16px; }
  button.primary, button.ghost, button.plain { padding: 14px 18px; font-size: 16px; }

  /* 学习卡片：铺满宽度，按钮做成好点的大块 */
  .study-shell { max-width: 100%; }
  .study-top { margin-bottom: 14px; }
  .word-card {
    padding: 36px 20px 24px;
    border-radius: 22px;
    min-height: 0;
  }
  .wf-word { font-size: 38px; letter-spacing: -1px; }
  .masked .wf-word { font-size: 42px; }
  .wf-head { gap: 10px; }
  .speak { width: 38px; height: 38px; }
  .ask-hint { margin: 20px 0 14px; }
  .ask-actions button, .btn-wide, .btn-known, .btn-unknown { height: 52px; font-size: 16px; }
  .options .option { padding: 15px 16px; font-size: 16px; }
  .reveal { margin-top: 20px; }
  .sense { font-size: 16px; }
  .definition-en { font-size: 14px; padding: 12px 14px; }
  .morph { font-size: 14px; }
  .example-en { font-size: 15px; }
  .finish-card { padding: 36px 20px; border-radius: 22px; }
  .finish-stats span { font-size: 22px; }

  /* 清单表格：手机上 6 列放不下，改成卡片式，只留关键信息 */
  table.report-table thead { display: none; }
  table.report-table, table.report-table tbody, table.report-table tr, table.report-table td {
    display: block;
    width: 100%;
  }
  table.report-table tr {
    border-bottom: 1px solid #f2f5fa;
    padding: 12px 0;
  }
  table.report-table tr:last-child { border-bottom: 0; }
  table.report-table td { border: 0; padding: 2px 0; }
  table.report-table td.rw-word { display: flex; align-items: baseline; gap: 8px; }
  table.report-table td.rw-num,
  table.report-table td.rw-curve { display: inline-block; width: auto; margin-right: 14px; font-size: 13px; }
  table.report-table td:nth-child(6) { display: none; }   /* 词书列在手机上省掉 */
  table.report-table td.rw-num:nth-child(3) { color: var(--bad); }

  /* 导入校对表：改成上下堆叠 */
  table.review thead { display: none; }
  table.review, table.review tbody, table.review tr, table.review td { display: block; width: 100%; }
  table.review tr { border-bottom: 1px solid #f2f5fa; padding: 10px 0; }
  table.review td { padding: 3px 0; }
  table.review input { margin: 0; }
  table.review .actions { display: flex; gap: 8px; margin-top: 6px; }
  .cal-cell { border-radius: 5px; }
}

/* 触屏设备：去掉只对鼠标有意义的悬停位移 */
@media (hover: none) {
  button.primary:hover, .btn-known:hover, .btn-wide:hover, .option:hover { transform: none; }
  .cal-cell:hover { transform: none; }
}

/* ---------- 顶栏 ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  /* 毛玻璃放在伪元素上：如果直接放在 header 上，
     它会成为 fixed 定位子元素的包含块，手机端底部导航就出不来了 */
  background: transparent;
  border-bottom: 1px solid var(--line);
}
header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
header .brand {
  font-weight: 700;
  letter-spacing: -.2px;
  font-size: 16px;
}
header .brand::before {
  content: "";
  display: inline-block;
  width: 18px; height: 18px;
  margin-right: 9px;
  vertical-align: -3px;
  border-radius: 6px;
  background: linear-gradient(140deg, #6f9bff, var(--brand));
  box-shadow: 0 4px 10px -2px rgba(59, 110, 245, .55);
}
header .who {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 3px 12px;
}
header nav { margin-left: auto; display: flex; gap: 4px; }
header nav button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
header nav button:hover { background: #f1f4fa; }
header nav button.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

/* ---------- 布局 ---------- */
main { max-width: 720px; margin: 0 auto; padding: 26px 18px 90px; }

.card {
  background: var(--card);
  border: 1px solid rgba(16, 24, 40, .04);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }
.title { font-size: 17px; font-weight: 650; letter-spacing: -.2px; }
.big { font-size: 40px; font-weight: 700; letter-spacing: -1px; }
h2 { font-size: 13px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: #a9c2fb;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 110, 245, .12);
}

button.primary, button.ghost, button.plain {
  border: 0;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, color .15s;
}
button.primary {
  background: linear-gradient(180deg, #4d7cf7, var(--brand));
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(59, 110, 245, .75);
}
button.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 22px -8px rgba(59, 110, 245, .8); }
button.primary:active { transform: translateY(0); }
button.primary:disabled { background: #cbd5e1; box-shadow: none; cursor: default; transform: none; }
button.ghost { background: #fff; color: var(--brand-dark); border: 1px solid #d7e1fb; }
button.ghost:hover { background: var(--brand-soft); }
button.plain { background: #f1f4fa; color: var(--ink-2); }
button.plain:hover { background: #e8edf7; }

.tag { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 550; }
.tag.new { background: var(--brand-soft); color: var(--brand-dark); }
.tag.review { background: var(--ok-soft); color: var(--ok); }
.tag.mistake { background: var(--bad-soft); color: var(--bad); }
.tag.test { background: #f4f0ff; color: #6d28d9; }

.bar { height: 6px; background: #e9edf3; border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6f9bff, var(--brand)); transition: width .25s; }

.empty { text-align: center; color: var(--muted); padding: 56px 0; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(8px);
  background: rgba(15, 23, 42, .94); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

code { background: #f1f5f9; padding: 2px 7px; border-radius: 6px; font-size: 13px; }

/* ---------- 学习卡片 ---------- */
.study-shell { max-width: 560px; margin: 0 auto; }
.study-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.study-progress { flex: 1; height: 6px; background: #e9edf3; border-radius: 999px; overflow: hidden; }
.study-progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6f9bff, var(--brand)); transition: width .25s; }
.study-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.study-exit { border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.study-exit:hover { color: var(--ink-2); }

.word-card {
  position: relative;
  background: var(--card);
  border-radius: 28px;
  padding: 52px 34px 34px;
  box-shadow: var(--shadow-md);
  min-height: 430px;
  display: flex;
  flex-direction: column;
}
.wf-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.wf-word {
  font-weight: 700;
  letter-spacing: -1.5px;
  text-align: center;
  /* 单词绝不换行：字号由前端按长度算好，宁可小一点也不能断成两行 */
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  line-height: 1.15;
}
.wf-phonetic { text-align: center; color: var(--muted); font-size: 15px; margin-top: 12px; }
.speak {
  border: 0; cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--brand-soft); font-size: 17px; line-height: 1;
  transition: transform .12s, background .15s;
}
.speak:hover { background: #e0e9ff; transform: scale(1.05); }

.ask-hint { text-align: center; color: var(--muted); font-size: 14px; margin: auto 0 18px; }
.ask-actions { display: flex; gap: 12px; }
.ask-actions button { flex: 1; height: 54px; border-radius: 14px; font-size: 16px; font-weight: 550; cursor: pointer; border: 0; font-family: inherit; }
.btn-unknown { background: #fff; color: var(--ink-2); border: 1px solid var(--line) !important; }
.btn-unknown:hover { background: #f8fafc; border-color: #d8e0ec !important; }
.btn-known { background: linear-gradient(180deg, #4d7cf7, var(--brand)); color: #fff; box-shadow: 0 8px 18px -8px rgba(59, 110, 245, .75); }
.btn-known:hover { transform: translateY(-1px); }
.btn-wide {
  width: 100%; height: 54px; border-radius: 14px; border: 0; font-family: inherit;
  background: linear-gradient(180deg, #4d7cf7, var(--brand)); color: #fff; font-size: 16px;
  font-weight: 550; cursor: pointer; margin-top: 18px;
  box-shadow: 0 8px 18px -8px rgba(59, 110, 245, .75);
}
.btn-wide:hover { transform: translateY(-1px); }

.study-shell input { margin: 14px 0 0; text-align: center; font-size: 17px; padding: 14px; }
.switch-row { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.switch { border: 0; background: transparent; color: var(--muted); font-size: 13px;
          cursor: pointer; padding: 7px 12px; border-radius: 999px; font-family: inherit; }
.switch:hover { background: #f1f4fa; color: var(--ink-2); }

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.option {
  border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 17px 18px; font-size: 16px; text-align: left; cursor: pointer; color: var(--ink);
  font-family: inherit; transition: border-color .15s, background .15s, transform .12s;
}
.option:hover { border-color: #a9c2fb; background: #fafcff; transform: translateY(-1px); }

.reveal { margin-top: 28px; text-align: left; }
.senses { display: flex; flex-direction: column; gap: 12px; }
.sense { display: flex; gap: 10px; align-items: baseline; font-size: 17px; line-height: 1.6; }
.sense-pos { flex: none; color: var(--brand-dark); background: var(--brand-soft); border-radius: 7px;
             padding: 1px 8px; font-size: 12px; font-weight: 600; min-width: 26px; text-align: center; }
.sense-pos:empty { display: none; }
.definition-en { margin-top: 18px; padding: 14px 16px; background: #f8fafc;
                 border-radius: 12px; color: var(--ink-2); font-size: 14px; line-height: 1.65; }
.examples { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.morphs { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.morph { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.morph-kind {
  flex: none; font-size: 12px; font-weight: 600; color: #0f766e; background: #ecfdf5;
  border-radius: 7px; padding: 1px 8px; margin-top: 2px;
}
.example { border-left: 3px solid #d7e1fb; padding-left: 14px; }
.example-en { font-size: 15px; line-height: 1.55; }
.example-cn { color: var(--muted); font-size: 13px; margin-top: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pill { font-size: 12px; color: var(--ink-2); background: #f1f4fa; border-radius: 999px; padding: 4px 11px; }
.pill.star { color: var(--warn); background: var(--warn-soft); letter-spacing: 2px; }
.pill.tag { color: var(--brand-dark); background: var(--brand-soft); font-weight: 550; }
.forms { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.confirm-row { margin-top: auto; }
.confirm-hint { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.grade-banner {
  font-size: 16px; font-weight: 600; margin-bottom: 16px;
  padding: 12px 16px; border-radius: 12px; background: #f8fafc;
}
.grade-banner.grade-all-correct { background: var(--ok-soft); color: var(--ok); }
.grade-banner.grade-partial { background: var(--warn-soft); color: var(--warn); }
.grade-banner.grade-wrong { background: var(--bad-soft); color: var(--bad); }

/* ---------- 结算 ---------- */
.finish-card {
  background: var(--card); border-radius: 28px; padding: 52px 34px;
  box-shadow: var(--shadow-md); text-align: center; max-width: 560px; margin: 0 auto;
}
.finish-emoji { font-size: 46px; }
.finish-title { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin-top: 14px; }
.finish-streak { color: var(--warn); background: var(--warn-soft); display: inline-block;
                 padding: 6px 16px; border-radius: 999px; font-size: 14px; margin-top: 16px; }
.finish-stats { display: flex; gap: 8px; margin: 30px 0 6px; }
.finish-stats > div { flex: 1; }
.finish-stats span { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.finish-stats em { font-style: normal; color: var(--muted); font-size: 12px; }

/* ---------- 统计 ---------- */
.stats { display: flex; gap: 8px; margin: 16px 0 4px; }
.stats > div { flex: 1; text-align: center; }
.stats .n { font-size: 28px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-top: 4px; }
.cal-cell { aspect-ratio: 1; border-radius: 7px; background: #eef1f6; transition: transform .12s; }
.cal-cell:hover { transform: scale(1.08); }
.cal-cell.light { background: #bfd4fb; }
.cal-cell.dark { background: var(--brand); }

/* ---------- 同桌 PK ---------- */
table.buddy-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
table.buddy-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; font-size: 13px; }
table.buddy-table td { padding: 10px 6px; border-top: 1px solid #f2f5fa; font-variant-numeric: tabular-nums; }
table.buddy-table td.buddy-me { color: var(--brand-dark); font-weight: 600; }
.weekly-nudge {
  background: #f4f0ff; color: #6d28d9; border-radius: 12px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 12px;
}

/* ---------- 入口页的答题模式 ---------- */
.mode-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.mode {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 7px 16px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.mode:hover { border-color: #c9d7f8; background: #fafcff; }
.mode.on {
  background: var(--brand-soft); border-color: #c2d3fb; color: var(--brand-dark); font-weight: 600;
}

/* ---------- 错词 / 生词清单 ---------- */
.book-select {
  margin: 4px 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
table.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report-table th {
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line);
}
table.report-table td { padding: 12px 6px; border-bottom: 1px solid #f2f5fa; vertical-align: top; }
table.report-table tr:last-child td { border-bottom: 0; }
.rw-head { font-weight: 650; font-size: 15px; white-space: nowrap; }
.rw-sense { line-height: 1.5; }
.rw-sense b { color: var(--brand-dark); font-weight: 600; }
.rw-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rw-curve { white-space: nowrap; font-size: 13px; }

/* ---------- 导入校对表 ---------- */
table.review { width: 100%; border-collapse: collapse; font-size: 14px; }
table.review th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; font-size: 13px; }
table.review td { padding: 5px 6px; vertical-align: middle; }
table.review input { margin: 0; padding: 9px 11px; font-size: 14px; }
table.review tr.rejected { opacity: .4; text-decoration: line-through; }
table.review .actions { white-space: nowrap; }
table.review .actions button { padding: 7px 12px; font-size: 13px; margin-right: 4px; }

.login-card { max-width: 360px; margin: 60px auto; text-align: center; }
.qr-code { display: flex; justify-content: center; align-items: center; min-height: 196px; }
.qr-code img, .qr-code canvas { border-radius: 12px; }
