/* ================= 设计变量 ================= */
:root {
  --bg-1: #eef3fb;
  --bg-2: #e6edfb;
  --card: #ffffff;
  --card-soft: #f7f9fe;
  --primary: #4a7cff;
  --primary-deep: #3a63d8;
  --primary-soft: #eaf0ff;
  --text: #1f2a44;
  --text-2: #5b6780;
  --text-3: #8a97b0;
  --border: #e6ebf5;
  --red: #f5576c;
  --red-soft: #ffecef;
  --green: #2bb673;
  --green-soft: #e7f7ef;
  --amber: #f5a623;
  --amber-soft: #fff4e0;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 32px rgba(76, 108, 190, 0.10);
  --shadow-sm: 0 4px 14px rgba(76, 108, 190, 0.08);
  --sidenav-w: 208px;
  --topbar-h: 60px;
  --dock-h: 66px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ================= 顶部操作栏 ================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(230, 235, 245, 0.8);
}
.topbar-inner {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7fa4ff);
  box-shadow: 0 0 0 4px rgba(74, 124, 255, 0.15);
  flex: none;
}
.brand-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ================= 布局骨架 ================= */
.app {
  padding-top: calc(var(--topbar-h) + 18px);
  padding-bottom: 28px;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
}
/* 桌面端：左侧导航占位 */
@media (min-width: 768px) {
  .app { padding-left: calc(var(--sidenav-w) + 22px); padding-right: 22px; }
}

.page { animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= 导航栏 ================= */
.sidenav {
  position: fixed;
  z-index: 90;
  display: flex;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
/* 桌面端：左侧垂直 */
@media (min-width: 768px) {
  .sidenav {
    left: 14px; top: calc(var(--topbar-h) + 14px); bottom: 14px;
    width: var(--sidenav-w);
    flex-direction: column;
    padding: 12px;
    gap: 6px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-2);
    text-align: left;
    transition: all .18s;
  }
  .nav-item:hover { background: var(--primary-soft); color: var(--primary); }
  .nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(74,124,255,.3); }
  .nav-ico { font-size: 18px; }
}
/* 手机端：底部水平 */
@media (max-width: 767px) {
  .sidenav {
    left: 0; right: 0; bottom: 0;
    height: var(--nav-h);
    flex-direction: row;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-3);
    font-weight: 500;
  }
  .nav-item.active { color: var(--primary); }
  .nav-ico { font-size: 20px; }
  .nav-txt { line-height: 1.2; }
}

/* ================= 通用卡片 / 按钮 ================= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px; font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  transition: all .18s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(74,124,255,.28); }
.btn-primary:hover { background: var(--primary-deep); }
.btn-primary:disabled { background: #b9c6e8; box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: var(--primary-soft); color: var(--primary); }
.btn-ghost:hover { background: #dce6ff; }
.btn-line { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.btn-line:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--card-soft);
  font-size: 15px; transition: all .15s;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }

.input, .textarea, select.input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,124,255,.12);
}
.textarea { resize: vertical; min-height: 130px; line-height: 1.7; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: #c07e00; }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.gray { background: #eef1f7; color: var(--text-3); }

/* ================= 准备页 ================= */
.prep-grid { display: grid; gap: 16px; }
.prep-actions {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex; gap: 10px;
  flex-wrap: wrap;
}
.phrase-card, .grammar-card {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.phrase-card .en { font-weight: 700; font-size: 15px; }
.phrase-card .zh { color: var(--text-2); margin: 2px 0 6px; }
.phrase-meta { font-size: 12.5px; color: var(--text-3); }
.phrase-meta b { color: var(--text-2); font-weight: 600; }
.grammar-card .gname { font-weight: 700; font-size: 15px; color: var(--primary-deep); }
.grammar-card .grule { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: var(--text-2); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin: 8px 0; }
.grammar-card .gzh { font-size: 13px; color: var(--text-2); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.role-item {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; transition: all .15s; background: #fff;
}
.role-item.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(74,124,255,.1); }
.role-item .r-ico { font-size: 22px; display: block; margin-bottom: 4px; }
.role-item .r-name { font-size: 13px; font-weight: 600; }

/* ================= 练习页 ================= */
.practice-layout { display: flex; gap: 16px; align-items: flex-start; }
.convo-col { flex: 0 0 70%; max-width: 70%; }
.correct-col { flex: 0 0 30%; max-width: 30%; position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 30px); overflow: auto; }

.convo-box { display: flex; flex-direction: column; gap: 14px; padding-bottom: 12px; }

.bubble { max-width: 82%; padding: 12px 15px; border-radius: 16px; position: relative; animation: fadeIn .25s ease; }
.bubble.ai {
  align-self: flex-start; background: #fff;
  border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm);
}
.bubble.me {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-actions { display: flex; gap: 6px; margin-top: 8px; }
.ai-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  transition: all .15s;
}
.ai-chip.active { background: var(--primary); color: #fff; }
.ai-chip.speaker { background: #fff; border: 1px solid var(--border); color: var(--text-2); }
.ai-chip.speaker.playing { color: var(--primary); border-color: var(--primary); }
.ai-text, .ai-trans { font-size: 14px; margin-top: 8px; display: none; line-height: 1.7; }
.ai-text.show, .ai-trans.show { display: block; }
.ai-trans { color: var(--text-2); font-size: 13px; }
.me-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.me-undo {
  font-size: 12px; color: rgba(255,255,255,.85); background: rgba(255,255,255,.18);
  padding: 3px 10px; border-radius: 999px;
}

/* 极简纠错卡片（微信划线纠错风格）：红=原句，绿=建议，灰=原因；扁平紧凑保证一屏完整露出 */
/* 多条错误 -> 整页翻页：横向滑动 + scroll-snap 强制吸附，每次精准停在一张完整卡片上 */
.corr-wrap { position: relative; }
.corr-pageinfo {
  /* 页码改为悬浮在红色「原句」框左上角的压线小角标（参考错题库角标），不再独占一行 */
  position: absolute; top: -8px; left: 0; z-index: 2; /* 序号左缘与红框左缘绝对对齐 */
  background: #fff; border: 1.5px solid var(--red); color: var(--red);
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 8px; border-radius: 999px;
}
.corr-pages {
  display: flex;
  overflow-x: auto; overflow-y: hidden; /* 只左右翻页，绝不上下滚动 */
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  margin: 0 -8px; /* 页码已独立占行；滑动区贯通面板、卡片两侧收窄 */
}
.corr-pages::-webkit-scrollbar { display: none; }
.correction-item {
  flex: 0 0 100%; min-width: 100%;
  scroll-snap-align: center; scroll-snap-stop: always; /* 禁止一次滑过多页/停在两页之间 */
  box-sizing: border-box; padding: 0 8px;
}
.corr-orig {
  border: 1.5px solid var(--red); background: #fdf1f3; border-radius: 10px;
  padding: 13px 12px 6px; /* 顶部/左侧加大内边距：给左上角页码角标和「原句」标签留出安全距离 */
  font-size: 12.5px; line-height: 1.45; color: var(--text);
}
.corr-sugg {
  border: 1.5px solid var(--green); background: #eefaf2; border-radius: 10px;
  padding: 5px 10px; font-size: 12.5px; line-height: 1.45; color: var(--green); font-weight: 600;
  margin-top: 8px; /* 删除下箭头后收紧间距 */
}
.corr-label {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: 1px;
  margin: 0 0 1px 10px; opacity: .8;
}
.corr-orig .corr-label { color: var(--red); }
.corr-sugg .corr-label { color: var(--green); }
.corr-reason { color: var(--text-3); font-size: 11.5px; margin-top: 4px; line-height: 1.5; }
.corr-empty { color: var(--text-3); text-align: center; padding: 24px 8px; font-size: 13.5px; }

/* 纠错抽屉/右侧栏卡片：标签与英文同行（限定 correction-item，不影响错题库 err-card） */
.correction-item .corr-orig,
.correction-item .corr-sugg {
  display: flex; align-items: center; /* 标签与英文强制同一行，绝不上下两行 */
  padding: 9px 12px; /* 左侧统一 12px，让「原句：」「建议：」起始位置形成笔直垂直线 */
}
.correction-item .corr-label {
  display: inline; flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: 0;
  margin: 0 6px 0 0; white-space: nowrap; opacity: .9; /* 标签略小加粗，英文紧跟其后 */
}
.correction-item .corr-reason { padding-left: 12px; } /* 灰原因左缘与红/绿框内文字对齐 */

/* 暂停：只禁用输入栏（不遮挡对话内容，可上下滑动查看），「继续」走顶部按钮 */
.practice-dock.paused .dock-inner { opacity: .55; }
.mic-btn:disabled { opacity: .45; cursor: not-allowed; }
.chat-input:disabled { opacity: .5; }

/* ================= 底部输入栏 ================= */
.practice-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.96) 30%);
}
@media (min-width: 768px) {
  .practice-dock { left: calc(var(--sidenav-w) + 14px); }
}
@media (max-width: 767px) {
  .practice-dock { bottom: var(--nav-h); }
}
.dock-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px;
  padding: 6px 8px;
  box-shadow: 0 10px 30px rgba(60, 90, 160, 0.18);
  border: 1px solid var(--border);
}
/* 输入区整体上浮/回落时平滑过渡 */
.practice-dock { transition: bottom .22s ease; }
.mic-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; transition: all .15s;
}
.mic-btn.recording { background: var(--red); color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(245,87,108,.5); } 50% { box-shadow: 0 0 0 9px rgba(245,87,108,0); } }
.chat-input { flex: 1; border: none; outline: none; font-size: 15px; padding: 8px 6px; min-width: 0; background: transparent; color: var(--text); }
.send-btn {
  flex: none; height: 40px; padding: 0 18px; border-radius: 999px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
}
.send-btn:disabled { background: #b9c6e8; }

/* ================= ASR 重新识别提示条（练习页） ================= */
.asr-retry {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--dock-h) + 12px); z-index: 96;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 6px 8px 14px;
  box-shadow: 0 10px 30px rgba(60, 90, 160, 0.18);
  max-width: 92vw;
}
.asr-retry.hidden { display: none; }
.asr-retry-text { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767px) {
  .asr-retry { bottom: calc(var(--nav-h) + var(--dock-h) + 12px); }
}

/* ================= 纠错底部上拉面板（手机） ================= */
.correction-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  background: #fff; border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(30,50,100,.18);
  display: none; /* 收起时彻底隐藏：不占空间、绝不可见（不用 transform 位移，避免幽灵残留） */
  max-height: 35vh; /* 面板高度约 35% 屏幕：紧凑不遮挡上方对话 */
  flex-direction: column;
  padding-bottom: calc(env(safe-area-inset-bottom) + 6px);
}
.correction-sheet.open {
  display: flex;
  animation: sheetUp .26s cubic-bezier(.2,.8,.3,1);
}
@keyframes sheetUp { from { transform: translateY(55%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: var(--border); margin: 4px auto 2px; } /* 顶部空白压缩：只留拖拽横条的极小空间 */
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 1px 18px 0; } /* 标题上移：压缩标题上方间距 */
.sheet-title { font-weight: 700; font-size: 15px; }
.sheet-body { overflow-y: auto; padding: 5px 18px 2px; } /* 内容随标题顺延上移 */
.sheet-mask {
  position: fixed; inset: 0; z-index: 115; background: rgba(20,30,60,.12); /* 极淡聚焦：对话内容保持完全可读，可边看对话边看纠错 */
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.sheet-mask.open { opacity: 1; pointer-events: none; }

/* 顶部「纠错」按钮展开态：主色填充，与收起态明确区分 */
#actCorrection.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ================= 复习页 ================= */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: #fff; color: var(--text-2); border: 1px solid var(--border);
  transition: all .15s;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.material-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 12px; }
.material-card .m-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.material-card .m-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-card .m-meta { font-size: 12.5px; color: var(--text-3); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
/* 素材卡操作栏：编辑/删除/操作独立成行，放在日期信息行正下方 */
.material-card .m-actions { display: flex; gap: 6px; margin-top: 10px; }
.collapse-head { display: flex; flex-direction: column; align-items: stretch; gap: 2px; cursor: pointer; padding: 12px 0; border-bottom: 1px solid var(--border); }
.collapse-head .c-title { font-weight: 700; font-size: 15px; min-width: 0; }
.collapse-body { padding: 10px 0; }
.vocab-card, .err-card { background: var(--card-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 10px; position: relative; }
/* 词汇库：顶部两端对齐（左=英文+中文同行，右=状态标签）；序号为绝对定位角标，不挤占文档流 */
.vocab-card .vocab-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 26px; }
.vocab-card .vocab-main { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0 8px; min-width: 0; flex: 1 1 auto; }
.vocab-card .v-word { font-weight: 700; font-size: 15px; flex: none; word-break: break-word; }
.vocab-card .v-zh { color: var(--text-2); font-size: 13px; flex: 1 1 auto; min-width: 0; margin: 0; } /* 中文稍小淡色，紧跟英文同行，过长自动换行且首行与英文对齐 */
.vocab-card .vocab-top .tag-mini { flex: none; font-size: 10.5px; padding: 0 8px; line-height: 1.6; }
.vocab-card .vocab-body { margin-top: 2px; }
.vocab-card .v-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.del-btn { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.del-btn:hover { background: var(--red-soft); color: var(--red); }

/* 复习列表：序号（当前/总数）+ 迷你状态标签 + 分组日期一行显示 */
.item-no {
  flex: none; font-size: 11px; font-weight: 600; color: var(--text-3);
  white-space: nowrap; margin-right: 6px;
}
.tag-mini { font-size: 10.5px; padding: 2px 8px; font-weight: 600; }
/* 词汇库序号角标：骑在卡片左上角边框上，不占用左侧空间，中文/搭配/例句顶格左对齐 */
.vocab-card .item-no {
  position: absolute; top: -9px; left: 10px; margin: 0;
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  background: #f1f4fa; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 6px; line-height: 1.6; white-space: nowrap; z-index: 2;
}
/* 错题卡片：原句框顶部 Flex 两端对齐（左：序号+原句；右：弱化状态角标），英文另起一行占满宽 */
.err-card { position: relative; }
.err-orig-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.err-orig-row .corr-orig { flex: 1; min-width: 0; }
/* 红框：内容垂直居中、min-height 一行高；序号/标签已移到灰容器角标，红框自身不再作为定位上下文 */
.err-card .corr-orig { width: 100%; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; min-height: 36px; padding: 6px 10px 6px 6px; }
.err-card .corr-top { margin: 0; padding: 0; } /* 空容器：序号/标签均为绝对定位角标，脱离文档流 */
/* 原句行：标签「原句：」与红色英文同行，垂直居中；英文换行后与首字母对齐、绝不缩进到标签下 */
.err-card .corr-orig-line { display: flex; align-items: center; gap: 6px; }
.err-card .corr-orig-line .corr-label { flex: none; font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--red); line-height: 1.7; }
/* 序号：移到最外层灰容器左上角，作为压线角标 */
.err-card .corr-top .item-no {
  position: absolute; top: -8px; left: 10px; margin: 0;
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  background: #f1f4fa; border: 1px solid var(--border); border-radius: 999px;
  padding: 0 6px; height: 17px; line-height: 15px;
  white-space: nowrap; z-index: 2;
}
/* 状态角标：紧贴灰容器右边缘（微调 top 避开删除按钮），字号进一步缩小 */
.err-card .corr-top .tag-mini {
  position: absolute; top: -8px; right: 6px; margin: 0;
  font-size: 9.5px; padding: 0 6px; line-height: 1.6; font-weight: 600;
  background: #eaf6ef; color: var(--green);
  border: 1px solid rgba(43, 182, 115, .35); border-radius: 999px;
  white-space: nowrap; z-index: 2;
}
/* 英文句子占满剩余空间、可换行，不被挤压 */
.err-card .corr-orig-text { flex: 1; min-width: 0; word-break: break-word; white-space: normal; }
.err-card .corr-sugg { width: 100%; box-sizing: border-box; white-space: normal; word-break: break-word; display: flex; align-items: center; gap: 6px; min-height: 36px; } /* 建议行：标签与英文同行，垂直居中，min-height 一行高 */
.err-card .corr-sugg .corr-label { flex: none; font-size: 10px; font-weight: 700; letter-spacing: 1px; line-height: 1.7; }
.err-card .corr-sugg-text { flex: 1; min-width: 0; }
/* 错题卡片：原句/建议英文字号放大加粗；红/绿框左缘与原因文字左缘强制同一条垂直线 */
.err-card .corr-orig { font-size: 13.5px; font-weight: 600; margin-left: 0; }
.err-card .corr-sugg { font-size: 13.5px; font-weight: 700; margin-top: 6px; margin-left: 0; padding: 6px 10px 6px 6px; }
.err-card .corr-reason { margin-top: 6px; margin-left: 6px; padding-left: 2px; } /* 原因文字右移对齐「序号框斜杠」基准线 */
/* 外层白底大卡片：底部内边距压到极小，消灭原因说明下方的大块白边 */
.err-card { padding-bottom: 6px; }
/* 分组标题行：日期固定在右侧、绝不换行；标题过长时收缩 */
/* 分组标题行：两行排布（上标题 / 下 数字+日期+箭头 靠右小字），绝不换行错位 */
.collapse-head .head-meta { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
/* 数字圆圈后置：这一行从左到右 = 日历图标 -> 日期 -> 数字圆圈，右侧垃圾桶/箭头不变 */
.collapse-head .head-meta .group-date { order: -1; }
.collapse-head .head-meta .tag { font-size: 11px; padding: 1px 8px; }
.collapse-head .group-date { font-size: 11px; color: var(--text-3); font-weight: 400; white-space: nowrap; }
.collapse-arrow { font-size: 15px; color: var(--text-3); line-height: 1; }
/* 分组级删除按钮：推到标题行最右侧，悬停变红 */
.group-del-btn {
  margin-left: auto; flex: none;
  background: transparent; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-3); padding: 2px 4px; line-height: 1;
}
.group-del-btn:hover { color: var(--red); }

/* 复习弹窗顶部：进度 + 暂停/退出按钮 */
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.quiz-progress { font-size: 12.5px; color: var(--text-3); font-weight: 600; }

/* 复习弹窗：语音输入麦克风按钮 + 输入行（错题回答 / 造句共用） */
.quiz-mic {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  transition: all .15s;
}
.quiz-mic.recording { background: var(--red); color: #fff; }
.err-answer-row, .sentence-answer-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.err-answer-row .input, .sentence-answer-row .input { flex: 1; min-width: 0; }

.search-box { position: relative; margin-bottom: 14px; }
.search-box input { padding-left: 40px; }
.search-box .s-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
mark { background: #ffe58a; border-radius: 3px; padding: 0 1px; }

/* 复习模式弹层 */
.review-modal {
  position: fixed; inset: 0; z-index: 130; background: rgba(20,30,60,.5);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.review-modal .rm-card { background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px; padding: 22px; max-height: 88vh; overflow: auto; }

/* 结束评分弹窗：标题+CEFR+按钮固定在顶部，评分卡片与建议在下方独立滚动 */
.score-modal { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.score-top { flex: none; padding: 18px 22px 12px; background: #fff; border-bottom: 1px solid var(--border); box-shadow: 0 6px 14px -10px rgba(31, 42, 68, .28); z-index: 2; }
.score-actions { display: flex; gap: 10px; }
.score-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 20px; -webkit-overflow-scrolling: touch; }

/* ================= 报告页 ================= */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 6px 12px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.stat-card .s-num { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card .s-unit { font-size: 10px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.stat-card .s-label { font-size: 10px; color: var(--text-3); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* 手机端：学习日历与四维评分上下两行堆叠，各自占满 100% 宽度，释放展示空间 */
@media (max-width: 767px) { .report-grid { grid-template-columns: 1fr; gap: 14px; } .report-grid .card { width: 100%; } }
/* 页面顶部留白压缩：页面标题与第一张卡片间距压到约 14px（只动外层容器 margin，不动卡片内部排版）。
   手机端顶栏在无操作按钮页（开练/复习/报告/配置）只有一行标题，实际高约 46px，
   而 .app 预留 100px（按练习页两行顶栏计算），故上移 40px 归还空隙；桌面端上移 4px（18px→14px）。 */
.report-page, .prep-page, .review-page, .config-page { margin-top: -4px; }
@media (max-width: 767px) {
  .report-page, .prep-page, .review-page, .config-page { margin-top: -40px; }
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; background: #f1f4fa; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3); position: relative; cursor: pointer; }
.cal-cell.has-data { background: var(--primary); color: #fff; font-weight: 700; }
.cal-cell.selected { background: #1f2a44; color: #fff; font-weight: 800; outline: 2px solid #4a7cff; outline-offset: -2px; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--amber); }
.cal-cell .cal-min { font-size: 8.5px; opacity: .92; line-height: 1.1; letter-spacing: -.2px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--text-3); margin-bottom: 2px; }
/* 日历头部：年月显眼显示 + 左右切换按钮 */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head .cal-ym { font-size: 15px; font-weight: 800; color: var(--text); }
.cal-nav {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  font-size: 17px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-nav:active { background: var(--primary-soft); color: var(--primary); }
.banner-warn {
  background: linear-gradient(90deg, #fff7e6, #fff1d6);
  border: 1px solid #f5d9a0; color: #9a6b00;
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 14px;
  font-size: 13.5px; display: flex; gap: 8px; align-items: center;
}
.advice-priority { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-bottom: 8px; }
.advice-priority.p1 { background: var(--red-soft); color: var(--red); }
.advice-priority.p2 { background: var(--amber-soft); color: #c07e00; }
/* 复习页专项过滤横幅 */
.filter-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(90deg, #eaf0ff, #f0f5ff);
  border: 1px solid #c9d9ff; color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px;
  font-size: 13.5px;
}
.filter-banner b { color: var(--primary); font-weight: 800; }


/* ================= 配置中心 ================= */
.config-group { margin-bottom: 20px; }
.config-group .cg-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.key-input-wrap { position: relative; }
.key-input-wrap .toggle-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 16px; }
.test-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.test-result { margin-top: 10px; font-size: 13px; line-height: 1.6; word-break: break-word; min-height: 18px; }
.test-result.ok { color: var(--green); }
.test-result.err { color: var(--red); }
.test-result.pending { color: var(--text-3); }
.prompt-preview { margin-top: 8px; background: var(--card-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text); max-height: 280px; overflow: auto; white-space: pre-wrap; }

/* ================= 查词浮窗 ================= */
.dict-pop {
  position: fixed; z-index: 140; max-width: 300px; min-width: 200px;
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(30,50,100,.25);
  padding: 14px 16px; font-size: 13.5px;
}
.dict-pop .d-word { font-weight: 800; font-size: 16px; }
.dict-pop .d-phon { color: var(--text-3); font-family: ui-monospace, monospace; font-size: 13px; margin: 2px 0; }
.dict-pop .d-pos { color: var(--primary); font-weight: 600; font-size: 12.5px; }
.dict-pop .d-def { color: var(--text-2); margin-top: 6px; line-height: 1.6; }

/* ================= toast / loading ================= */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: rgba(31,42,68,.94); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: all .25s;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: rgba(245,87,108,.96); }
.loading-mask {
  position: fixed; inset: 0; z-index: 300; background: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 滚动条美化 ================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4dbec; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 手机端练习页 ================= */
@media (max-width: 767px) {
  .practice-layout { display: block; }
  .convo-col, .correct-col { flex: none; max-width: 100%; }
  /* 纠错区在手机端收进底部抽屉，绝不混入聊天流 */
  .correct-col { display: none; }
  .app { padding-left: 12px; padding-right: 12px; }
  /* 顶部操作栏手机端两行排布：标题独占第一行，操作按钮独占第二行，二者完全错开绝不互相遮挡 */
  .topbar { height: auto; }
  .topbar-inner { flex-wrap: wrap; padding: 8px 10px; row-gap: 4px; }
  .topbar-left, .topbar-right { flex: 0 0 100%; }
  /* 操作按钮压缩：缩小左右 padding 与字号，保证最右侧「结束」按钮完整露出不裁切 */
  .topbar-right { gap: 4px; flex-wrap: nowrap; }
  .topbar-right .btn { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
  /* 主体内容下推，给两行顶栏让位，绝不被遮挡 */
  .app { padding-top: calc(var(--topbar-h) + 40px); }
  .stats-row { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .stat-card { padding: 10px 4px; gap: 4px; }
  .stat-card .s-num { font-size: 16px; }
  .stat-card .s-unit { font-size: 9px; }
  .stat-card .s-label { font-size: 9.5px; }
  /* 报告页：学习日历与四维评分手机端上下堆叠、各占满宽（电脑端仍左右并排） */
  .report-grid { grid-template-columns: 1fr; gap: 14px; }
  .report-grid .card { width: 100%; }
  .card { padding: 16px; }
  /* 练习页底部留出输入栏 + 导航空间 */
  .practice-page { padding-bottom: calc(var(--dock-h) + var(--nav-h) + 24px); }
  /* 抽屉打开：对话区小幅让位（面板约 35% 屏幕） */
  body.sheet-open .practice-page { padding-bottom: calc(var(--dock-h) + var(--nav-h) + 35vh); }
  /* 面板从底部（导航栏上方）弹出并盖住输入栏区域，输入栏整体上浮到面板正上方 */
  .correction-sheet { bottom: var(--nav-h); max-height: 35vh; }
  /* 输入区整体上浮：悬浮在纠错面板正上方，随时可见可点击 */
  body.sheet-open .practice-dock { bottom: calc(var(--nav-h) + var(--corr-sheet-h, 35vh)); }
  /* 遮罩低于输入栏层级，输入框/麦克风在抽屉展开时仍可点击 */
  .sheet-mask { z-index: 94; }
}
@media (min-width: 768px) {
  .practice-page { padding-bottom: calc(var(--dock-h) + 16px); }
}
/* 桌面端：纠错在右侧 30% 边栏常驻，隐藏顶部「纠错」按钮 */
@media (min-width: 768px) {
  #actCorrection { display: none; }
}

/* 手机端：内容底部给固定导航留空间，操作栏悬在导航上方 */
@media (max-width: 767px) {
  .app { padding-bottom: calc(var(--nav-h) + 28px); }
  .prep-actions { bottom: var(--nav-h); }
}

/* ================= 合并版新增：短语卡片 / 四维评分 / 建议 ================= */
.phrase-card .ph-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.phrase-card .ph-word { font-weight: 700; font-size: 16px; color: var(--text); }
.phrase-card .ph-meaning { color: var(--text-2); font-size: 14px; }

.dim-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.dim-row { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: #fbfdff; }
.dim-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dim-name { font-size: 13px; font-weight: 600; color: var(--text-2); }
.dim-score { font-size: 15px; font-weight: 800; color: var(--primary); }
.dim-track { height: 8px; background: #eef2f8; border-radius: 5px; overflow: hidden; }
.dim-fill { height: 100%; background: linear-gradient(90deg, #7fa4ff, #4a7cff); border-radius: 5px; transition: width .4s ease; }
.dim-reason { font-size: 12px; color: var(--text-3); margin-top: 8px; line-height: 1.6; }

.score-suggestions { margin-top: 16px; }
.sugg-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.sugg-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--card-soft); border-radius: 12px; margin-bottom: 8px; }
.sugg-prio { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sugg-item.p2 .sugg-prio { background: var(--green); }
.sugg-text { font-size: 13px; line-height: 1.7; color: var(--text); }

/* ================= PWA 安全区适配 ================= */
/* 顶部：刘海屏下顶栏内容避开刘海，仍保持 fixed 冻结（桌面/安卓 safe-area-top=0 无影响）。
   手机端顶栏本就是 height:auto 自适应，padding-top 会自然撑高；同步给 .app 加同等偏移防遮挡。 */
@media (max-width: 767px) {
  .topbar { padding-top: env(safe-area-inset-top); }
  .app { padding-top: calc(var(--topbar-h) + 40px + env(safe-area-inset-top)); }
}
