/* =========================================================
   百倚英语学习器 · 样式表
   设计基调：暖色调（浅橙 / 米白）、圆角卡片、留白充足、字大易读
   适配：手机竖屏（默认）+ 电脑浏览器（居中定宽）
   ========================================================= */

:root {
  /* 主题色（设置里可改，由 JS 注入 --primary） */
  --primary: #E8943A;
  --primary-soft: #FBE9D3;
  --primary-deep: #C9762A;
  --bg: #FBF6EF;
  --card: #FFFFFF;
  --ink: #3A3330;
  --ink-soft: #8A807A;
  --line: #ECE3D8;

  /* 分级色 */
  --lv-a: #3FA76A;   /* A 级 绿 */
  --lv-b: #E8943A;   /* B 级 橙 */
  --lv-c: #E0604F;   /* C 级 红 */

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(180, 140, 90, 0.12);
  --shadow-lg: 0 10px 30px rgba(180, 140, 90, 0.20);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- 布局容器 ---------- */
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 76px; /* 给底部导航留位 */
}

.app-header {
  padding: 18px 18px 12px;
  background: linear-gradient(180deg, var(--primary-soft), var(--bg));
}
.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary-deep);
}
.subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.slogan {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-deep);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.view {
  flex: 1;
  padding: 14px 14px 24px;
}

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: center;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
  z-index: 50;
}
.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 8px 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  color: var(--ink-soft);
  font-size: 11px;
}
.nav-btn .ico { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--primary-deep); font-weight: 700; }
.nav-btn.active .ico { transform: translateY(-1px); }
.nav-add {
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  margin: 6px 4px;
  flex: 0 0 56px;
  justify-content: center;
}
.nav-add .ico { font-size: 24px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

/* 等级徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}
.badge-A { background: var(--lv-a); }
.badge-B { background: var(--lv-b); }
.badge-C { background: var(--lv-c); }
.badge-L { background: var(--ink-soft); }

/* 顶部信息行 */
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.card-title {
  font-size: 19px;
  font-weight: 800;
  flex: 1;
  word-break: break-word;
}
.tag {
  display: inline-block;
  font-size: 12px;
  color: var(--primary-deep);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 2px 10px;
}
.tag-soft { color: var(--ink-soft); background: #F1ECE5; }
.tag-due { color: #fff; background: var(--lv-c); }
.tag-soon { color: #fff; background: var(--lv-b); }
.tag-master { color: #fff; background: var(--lv-a); }

/* 字段行 */
.field { margin: 6px 0; }
.field .k {
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 6px;
}
.field .v { font-size: 16px; }
.homophonic { color: var(--primary-deep); font-weight: 600; }
.example { color: var(--ink-soft); font-size: 14px; font-style: italic; }

/* 元信息（日期 / 次数） */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-deep);
  width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: #FBE3DF; color: var(--lv-c); }
.btn-sm { padding: 8px 12px; font-size: 14px; width: auto; }
.btn:active { transform: scale(0.98); }

.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- 首页统计条 ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
}
.hero .big { font-size: 40px; font-weight: 900; line-height: 1; }
.hero .label { font-size: 13px; opacity: 0.9; }
.hero .sub { margin-top: 10px; font-size: 13px; opacity: 0.95; }
.hero-empty { background: var(--card); border: 1px dashed var(--primary); color: var(--ink); }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.form-group .hint { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
input[type="text"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 64px; }

/* ---------- 筛选条 ---------- */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-bar select { flex: 1; min-width: 120px; }

/* ---------- 统计页 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.stat-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-box .n { font-size: 28px; font-weight: 900; color: var(--primary-deep); }
.stat-box .t { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap .legend { font-size: 14px; }
.ring-wrap .legend div { margin: 4px 0; }

/* 分级进度条 */
.lvl-bar {
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
  margin: 10px 0;
}
.lvl-bar span { display: block; height: 100%; }
.lvl-bar .a { background: var(--lv-a); }
.lvl-bar .b { background: var(--lv-b); }
.lvl-bar .c { background: var(--lv-c); }

/* ---------- 自测（全屏专注） ---------- */
.review-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 28px;
  max-width: 520px;
  margin: 0 auto;
}
.review-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--ink-soft); margin-bottom: 8px;
}
.review-card {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.review-chinese {
  font-size: 38px;
  font-weight: 900;
  color: var(--ink);
  word-break: break-word;
}
.review-homo {
  margin-top: 12px;
  font-size: 20px;
  color: var(--primary-deep);
  font-weight: 700;
}
.cover {
  margin-top: 28px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 22px;
  color: var(--ink-soft);
  font-size: 15px;
}
.reveal-block { margin-top: 22px; text-align: left; }
.reveal-block .en {
  font-size: 26px; font-weight: 800; color: var(--primary-deep);
}
.reveal-block .ph { font-size: 16px; color: var(--ink-soft); margin-left: 8px; }
.reveal-block .ex { font-size: 14px; color: var(--ink-soft); margin-top: 8px; font-style: italic; }
.review-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }

/* 分级弹窗 */
.popup-mask {
  position: fixed; inset: 0; background: rgba(40,30,20,0.45);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
}
.popup {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 20px 18px 26px;
  box-shadow: var(--shadow-lg);
}
.popup h3 { margin: 0 0 4px; font-size: 18px; }
.popup p { margin: 0 0 14px; font-size: 13px; color: var(--ink-soft); }
.grade-grid { display: flex; gap: 10px; }
.grade-grid .btn { flex: 1; }
.grade-A { background: var(--lv-a); color: #fff; }
.grade-B { background: var(--lv-b); color: #fff; }
.grade-C { background: var(--lv-c); color: #fff; }

/* ---------- 模态（表单 / 备份） ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40,30,20,0.45);
  z-index: 150; display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 18px 18px 26px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-close { border: none; background: #F1ECE5; border-radius: 999px; width: 32px; height: 32px; font-size: 18px; color: var(--ink-soft); }

/* 提示 toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(40,30,20,0.9); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 14px; z-index: 300; max-width: 90%;
  text-align: center;
}

/* 空状态 */
.empty {
  text-align: center; color: var(--ink-soft); padding: 40px 20px;
  font-size: 15px;
}
.empty .emoji { font-size: 46px; display: block; margin-bottom: 10px; }

/* 设置项 */
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-row .name { font-weight: 700; }
.set-row .desc { font-size: 12px; color: var(--ink-soft); }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.switch { position: relative; width: 50px; height: 28px; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; background: #ddd; border-radius: 999px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--lv-a); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.section-title {
  font-size: 15px; font-weight: 800; color: var(--primary-deep);
  margin: 18px 4px 6px;
}

/* ---------- 四行学习卡（英 / 中 / 音 / 谐） ---------- */
.study-card {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 14px 14px;
  margin-bottom: 4px;
}
.study-card .sl {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(180,140,90,0.18);
}
.study-card .sl:last-child { border-bottom: none; }
.study-card .sl-k {
  flex: 0 0 22px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
  border-radius: 6px;
  text-align: center;
  align-self: center;
  padding: 1px 0;
}
.study-card .sl-v { flex: 1; word-break: break-word; }
.study-card .en { font-size: 22px; font-weight: 800; color: var(--primary-deep); }
.study-card .zh { font-size: 17px; font-weight: 600; }
.study-card .ph { font-size: 15px; color: var(--ink-soft); }
.study-card .ho { font-size: 16px; color: var(--primary-deep); font-weight: 600; }
.study-card .sl-speak { flex: 0 0 auto; width: auto; padding: 4px 10px; }

/* ---------- 首页快捷入口 ---------- */
.home-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

/* ---------- 悬浮添加按钮 ---------- */
.fab {
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 60;
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 30px; line-height: 1;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(0.94); }

/* 单词拆解小标签 */
.word-tag {
  display: inline-block; font-size: 12px; color: var(--primary-deep);
  background: #fff; border-radius: 999px; padding: 2px 10px; margin-bottom: 8px;
}

/* 自由学习：翻译来源徽标 */
.src-badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; margin-bottom: 8px;
}
.src-badge.local { color: #9a6a1e; background: #fbe9cf; }
.src-badge.online { color: #2f7d4f; background: #d9f0e0; }

/* ---------- 首页课程分类卡片 ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.cat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.cat-card:active { transform: scale(0.97); }
.cat-card.locked { opacity: 0.7; }
.cat-ico { font-size: 26px; line-height: 1; }
.cat-name { font-size: 14px; font-weight: 800; margin-top: 6px; color: var(--ink); }
.cat-sub { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

/* 课程广场分类 chips */
.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 课程条目紧凑行 */
.study-mini {
  display: flex; align-items: stretch; gap: 8px; margin-top: 8px;
}
.study-mini .study-card { flex: 1; margin-bottom: 0; padding: 8px 10px; }
.mini-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; align-self: center; }
.mini-add { width: 44px; padding: 8px 0; }
.mini-fav { width: 44px; padding: 8px 0; }

/* 锁定卡片 */
.locked-card {
  text-align: center; color: var(--ink-soft); font-size: 14px;
  border: 1px dashed var(--lv-c);
}

/* 自由学习结果区 */
#free-result .study-card { margin-top: 10px; }

/* 使用码框 */
.code-box {
  background: var(--primary-soft); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: monospace; font-size: 15px; font-weight: 700;
  color: var(--primary-deep); word-break: break-all; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin-bottom: 10px;
}

/* 微信登录按钮（a 标签样式对齐） */
a.btn { text-decoration: none; }

/* 登录区 */
.account-tag { font-size: 11px; }

/* ---------- 收藏夹：搜索 / 标签 / 导出 ---------- */
.fav-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.fav-toolbar .form-group { margin-bottom: 0; }
.fav-tag-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fav-tag {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700;
}
.fav-tag.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.fav-card { position: relative; }
.fav-tag-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--primary-deep);
  background: var(--primary-soft); border-radius: 999px; padding: 1px 10px; margin-bottom: 8px;
}
.fav-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- 语音：跟读打分 ---------- */
.study-card .sl-mic { flex: 0 0 auto; width: auto; padding: 4px 10px; }
.mic-btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  width: 100%; margin-top: 12px;
  background: var(--primary); color: #fff; border: none;
  border-radius: 999px; padding: 12px 0; font-size: 16px; font-weight: 800;
}
.mic-btn.recording { animation: pulse 1s infinite; background: var(--lv-c); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224,96,79,0.5); } 70% { box-shadow: 0 0 0 14px rgba(224,96,79,0); } 100% { box-shadow: 0 0 0 0 rgba(224,96,79,0); } }
#promo-result { margin-top: 12px; }
.score-wrap { text-align: center; padding: 6px 0; }
.score-ring { display: inline-block; }
.score-num { font-size: 30px; font-weight: 900; }
.score-fb { font-size: 16px; font-weight: 800; margin-top: 6px; }
.score-fb.good { color: var(--lv-a); }
.score-fb.mid { color: var(--lv-b); }
.score-fb.weak { color: var(--lv-c); }
.score-heard { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.score-err { font-size: 14px; color: var(--lv-c); text-align: center; padding: 10px 0; }
.mic-hint { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 8px; }

/* ---------- 学习说明书（图文并茂） ---------- */
.manual-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.manual-hero h1 { margin: 0; font-size: 20px; font-weight: 900; }
.manual-hero p { margin: 6px 0 0; font-size: 13px; opacity: 0.95; }
.manual-hero .back-link {
  display: inline-block; margin-bottom: 10px; font-size: 13px; font-weight: 700;
  color: #fff; background: rgba(255,255,255,0.18); border-radius: 999px; padding: 4px 12px;
  border: none;
}
.manual-section { margin-bottom: 14px; }
.manual-illu {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  border: 1px solid var(--line);
}
.manual-illu svg { width: 100%; max-width: 300px; height: auto; }
.manual-body { padding: 12px 4px 2px; }
.manual-body h3 {
  margin: 0 0 6px; font-size: 17px; font-weight: 800; color: var(--primary-deep);
  display: flex; align-items: center; gap: 8px;
}
.manual-body p { margin: 6px 0; font-size: 14px; color: var(--ink); }
.manual-body .lead { color: var(--ink-soft); font-size: 13px; }
.manual-steps { list-style: none; padding: 0; margin: 8px 0; counter-reset: ms; }
.manual-steps li {
  position: relative; padding: 6px 8px 6px 34px; margin-bottom: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px;
}
.manual-steps li::before {
  counter-increment: ms; content: counter(ms);
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; background: var(--primary); color: #fff;
  border-radius: 50%; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.manual-tip {
  margin-top: 8px; font-size: 13px; color: var(--primary-deep);
  background: var(--primary-soft); border-radius: var(--radius-sm); padding: 8px 12px;
}
.manual-grade {
  display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap;
}
.manual-grade .g {
  flex: 1; min-width: 90px; text-align: center; border-radius: var(--radius-sm);
  padding: 10px 6px; color: #fff; font-weight: 800;
}
.manual-grade .g small { display: block; font-weight: 500; font-size: 11px; opacity: 0.95; margin-top: 4px; }
.manual-foot { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 8px 0 20px; }

/* ===== 语音功能环境引导 ===== */
.mic-warn { font-size: 13px; color: #8a5a00; background: #FFF6E5; border: 1px solid #F0D9A8; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; text-align: left; }
.mic-guide { font-size: 13px; color: var(--ink); background: #F7F1E8; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; text-align: left; line-height: 1.7; }
.mic-guide ol { margin: 6px 0 0; padding-left: 18px; }
.mic-copy { display: block; width: 100%; margin-top: 4px; }
