/* ============================================================
   KET 单词识读 H5 — 样式
   设计目标：PC / iPad 横屏，触控优先，儿童友好但不幼稚
   ============================================================ */
:root {
  --bg1: #eef3ff;
  --bg2: #f7fbff;
  --ink: #1f2a44;
  --ink-soft: #5b6781;
  --line: #e3e9f5;
  --primary: #4f6ef7;
  --primary-d: #3a55d9;
  --green: #22c55e;
  --green-d: #16a34a;
  --orange: #f59e0b;
  --orange-d: #d97706;
  --red: #ef4444;
  --card: #ffffff;
  --prefix: #4f6ef7;
  --base: #22c55e;
  --suffix: #f59e0b;
  --shadow: 0 10px 30px rgba(31, 42, 68, 0.12);
  --radius: 18px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  display: flex;
  flex-direction: column;
  height: 100vh;          /* 回退：老浏览器 */
  height: 100dvh;         /* iOS Safari 动态视口高度，避免地址栏吃掉底部导航 */
  overflow: hidden;
  user-select: none;
  -webkit-touch-callout: none;  /* iPad 长按不弹上下文菜单 */
}

/* ---------- 顶部栏 ---------- */
.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.app-header h1 { font-size: 19px; margin: 0; letter-spacing: 0.5px; }
.app-header .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.header-brand { display: flex; align-items: center; gap: 10px; }
.app-logo { height: 38px; width: auto; display: block; }
.voice-toggle {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.voice-toggle:active { transform: scale(0.96); }

/* ---------- 主内容 ---------- */
.main {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
}
.view { position: absolute; inset: 0; overflow-y: auto; padding: 16px 20px 20px; display: none; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
/* 所有视图隐藏滚动条：触控优先，PC 上通过鼠标滚轮仍可滚动 */
.view::-webkit-scrollbar { display: none; }
.view.active { display: block; }

/* 识读页：单屏固定布局——禁止整页滚动；卡片区内部滚动，按钮/计数器固定不滚 */
#view-cards.active { display: flex; flex-direction: column; overflow: hidden; padding: 12px 20px 14px; }
#view-cards .filterbar { flex-shrink: 0; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  flex: 0 0 auto;
  height: var(--nav-h);
  display: flex;
  border-top: 1px solid var(--line);
  background: #fff;
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
}
.bottom-nav button .dot {
  width: 26px; height: 3px; border-radius: 3px; background: transparent; margin-top: 4px;
}
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active .dot { background: var(--primary); }
.bottom-nav button:active { background: #f2f5ff; }

/* ---------- 通用控件 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* 下拉筛选栏：一行排布，省去横向 chip 占用的纵向空间，避免整页滚动 */
.filterbar { display: flex; gap: 10px; margin-bottom: 10px; }
.filter-field { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.filter-select {
  flex: 1 1 auto; min-width: 0;
  -webkit-appearance: none; appearance: none;
  border: 1px solid var(--line); background-color: #fff;
  border-radius: 10px; padding: 10px 30px 10px 12px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--primary); }
/* 隐藏卡片区滚动条视觉，但保留可滚动能力（内容超长时内部轻滚，不显示条） */
.card-wrap, .flashcard { scrollbar-width: none; }
.card-wrap::-webkit-scrollbar, .flashcard::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip:active { transform: scale(0.96); }

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
}
.btn:active { transform: scale(0.97); }
.btn.green { background: var(--green); }
.btn.orange { background: var(--orange); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
#voiceToggle.uk { background: #2f6fed; color: #fff; border-color: #2f6fed; }
#voiceToggle.us { background: #e0533d; color: #fff; border-color: #e0533d; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   M1 识读卡片
   ============================================================ */
.card-stage { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-progress { flex-shrink: 0; font-size: 13px; color: var(--ink-soft); }
/* 卡区作为唯一可滚动容器，滚动条彻底隐藏；内容超长时顶部仍可滑到（safe center） */
.card-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: safe center; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; padding: 4px 0; }
.card-wrap::-webkit-scrollbar { display: none; }
.flashcard {
  width: min(900px, 94%);
  min-height: 300px;
  overflow: visible;
  margin: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease;
}
.flashcard:active { transform: scale(0.99); }
.fc-head { display: flex; align-items: baseline; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 0 10px; }
.fc-word { font-size: 52px; font-weight: 800; letter-spacing: 1px; line-height: 1.1; }
.fc-pos { font-size: 13px; color: var(--primary); background: #eef1ff; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.fc-head .fc-ipa { display: inline; margin: 0; white-space: nowrap; font-size: 24px; color: var(--ink); letter-spacing: 0.5px; font-family: "Lucida Sans Unicode", "Segoe UI", sans-serif; }
.fc-ipa { display: block; text-align: center; font-size: 24px; color: var(--ink); letter-spacing: 0.5px; margin: 4px 0 6px; font-family: "Lucida Sans Unicode", "Segoe UI", sans-serif; }
.fc-hint { margin-top: 10px; font-size: 12.5px; color: var(--ink-soft); opacity: 0.8; }

.fc-reveal { margin-top: 8px; width: 100%; }
.fc-zh { font-size: 20px; color: var(--ink); margin-bottom: 3px; }
.fc-ex { font-size: 17px; color: var(--ink); margin: 5px 0 2px; line-height: 1.3; text-align: left; }
.fc-ex .ex-tag { display: inline-block; font-size: 12px; color: #fff; background: var(--primary); border-radius: 6px; padding: 1px 8px; margin-right: 8px; vertical-align: middle; }
.fc-exzh { font-size: 14px; color: var(--ink-soft); margin-bottom: 3px; text-align: left; line-height: 1.3; }
.ex-word { color: var(--primary-d); font-weight: 800; }
.syllables { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 5px 0; }
.syl { background: #eef3ff; color: var(--primary-d); border-radius: 10px; padding: 6px 12px; font-size: 20px; font-weight: 700; }
.syl-sep { color: var(--line); align-self: center; font-size: 20px; }

/* 词族积木 */
.family-blocks { display: flex; gap: 8px; justify-content: center; align-items: stretch; margin: 8px 0 2px; flex-wrap: wrap; }
.fb { border-radius: 12px; padding: 9px 13px; color: #fff; min-width: 64px; }
.fb .lbl { font-size: 11px; opacity: 0.85; display: block; margin-bottom: 3px; }
.fb .val { font-size: 22px; font-weight: 800; }
.fb.p { background: var(--prefix); }
.fb.b { background: var(--base); }
.fb.s { background: var(--suffix); }
.fb-note { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.speak-btn {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: #eef1ff; color: var(--primary);
  font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.speak-btn:active { transform: scale(0.92); }

.card-actions { display: flex; gap: 10px; margin-top: 10px; flex-shrink: 0; }
.card-actions .btn { flex: 1; }

/* ============================================================
   M2 词族
   ============================================================ */
.section-title { font-size: 16px; font-weight: 800; margin: 4px 0 12px; }
.fam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fam-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  cursor: pointer; text-align: center;
}
.fam-card .w { font-size: 18px; font-weight: 800; }
.fam-card .dec { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.fam-card .dec b.p { color: var(--prefix); }
.fam-card .dec b.b { color: var(--green-d); }
.fam-card .dec b.s { color: var(--orange-d); }
.fam-detail { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 14px; }
.fam-detail .big { font-size: 34px; font-weight: 800; text-align: center; margin-bottom: 14px; }

/* ============================================================
   M3 练习
   ============================================================ */
.quiz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.quiz-mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.quiz-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.quiz-q { font-size: 15px; color: var(--ink-soft); margin-bottom: 6px; }
.quiz-stim { font-size: 30px; font-weight: 800; text-align: center; margin: 10px 0 18px; min-height: 40px; }
.quiz-stim .ipa { font-size: 30px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  border: 2px solid var(--line); background: #fff; border-radius: 14px;
  padding: 16px; font-size: 18px; font-weight: 700; cursor: pointer; color: var(--ink);
  text-align: center;
}
.opt:active { transform: scale(0.98); }
.opt.correct { border-color: var(--green); background: #eafaf0; color: var(--green-d); }
.opt.wrong { border-color: var(--red); background: #fdecec; color: var(--red); }
.opt:disabled { cursor: default; }
.quiz-feedback { text-align: center; margin-top: 16px; min-height: 22px; font-weight: 700; }
.quiz-feedback.ok { color: var(--green-d); }
.quiz-feedback.no { color: var(--red); }
.mistake-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mistake-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.mistake-item .meta { color: var(--ink-soft); font-size: 12px; }
.empty-tip { text-align: center; color: var(--ink-soft); padding: 40px 0; font-size: 14px; }

/* ============================================================
   M4 进度
   ============================================================ */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: 14px; padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.stat.s1 .n { color: var(--primary); }
.stat.s2 .n { color: var(--green-d); }
.stat.s3 .n { color: var(--orange-d); }
.stat.s4 .n { color: var(--ink); }

.topic-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.topic-row .name { width: 120px; flex: 0 0 120px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-row .bar { flex: 1; height: 14px; background: #eef1ff; border-radius: 999px; overflow: hidden; }
.topic-row .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); }
.topic-row .cnt { width: 56px; flex: 0 0 56px; text-align: right; color: var(--ink-soft); }

/* 两级拆解（拼写/词根 + 读音组合） */
.decomp { margin: 2px 0 6px; }
.decomp-label { font-size: 12px; color: var(--ink-soft); margin: 5px 0 2px; text-align: left; }
.tier { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.tier1 { margin-bottom: 2px; }
.part {
  display: inline-flex; flex-direction: column; align-items: center;
  background: #eef3ff; color: var(--primary-d);
  border-radius: 12px; padding: 5px 11px; font-size: 21px; font-weight: 800;
  cursor: pointer; user-select: none; transition: transform .08s, box-shadow .12s;
  border: 2px solid transparent;
}
.part small { font-size: 10px; font-weight: 600; opacity: 0.7; margin-top: 2px; }
.part:hover { box-shadow: 0 3px 10px rgba(79,110,247,.25); }
.part:active { transform: scale(.94); }
.part.p { background: #e7edff; color: var(--primary-d); border-color: #c7d2fe; }
.part.b { background: #e7f8ee; color: var(--green-d); border-color: #bbf0cf; }
.part.s { background: #fff3e0; color: var(--orange-d); border-color: #fde2b0; }
.part.c { background: #f3e8ff; color: #7c3aed; border-color: #e3d2fb; }
.part.r { background: #eef1f6; color: var(--ink); border-color: #dde3ec; }
.op { font-size: 20px; color: var(--ink-soft); font-weight: 700; }
.chunk {
  display: inline-block; background: #f3f6ff; color: var(--primary-d);
  border-radius: 9px; padding: 4px 10px; font-size: 17px; font-weight: 700;
  cursor: pointer; user-select: none; border: 1px solid #e2e8f7;
}
.chunk:hover { background: #e7edff; }
.chunk:active { transform: scale(.94); }
/* 音标芯片按词块角色着色，与一级拼写块同色对应 */
.chunk.p { background: #e7edff; color: var(--primary-d); border-color: #c7d2fe; }
.chunk.b { background: #e7f8ee; color: var(--green-d); border-color: #bbf0cf; }
.chunk.s { background: #fff3e0; color: var(--orange-d); border-color: #fde2b0; }
.chunk.c { background: #f3e8ff; color: #7c3aed; border-color: #e3d2fb; }
.chunk.r { background: #eef1f6; color: var(--ink); border-color: #dde3ec; }
.dot { font-size: 16px; color: var(--ink-soft); }
.root-note {
  margin: 5px 0 2px; padding: 7px 9px; background: #f6f8ff;
  border-left: 4px solid var(--primary); border-radius: 8px;
  font-size: 13.5px; color: var(--ink); line-height: 1.3;
}

@media (max-width: 560px) {
  .fc-word { font-size: 40px; }
  .options { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .topic-row .name { width: 84px; flex-basis: 84px; }
}

/* iPad 横屏引导：仅竖屏 + 触控设备显示整屏遮罩 */
.rotate-tip { display: none; }
body.portrait-tip .rotate-tip {
  display: flex; position: fixed; inset: 0; z-index: 999;
  background: rgba(31,42,68,0.94); color: #fff;
  align-items: center; justify-content: center; text-align: center;
  font-size: 19px; font-weight: 700; padding: 0 32px; line-height: 1.6;
}

/* 隐私浏览模式：进度不保存的温和提示 */
.store-warn {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 998;
  background: #fff4e5; color: #b45309; border: 1px solid #fde2b0;
  font-size: 12px; padding: 8px 14px; border-radius: 999px; max-width: 92%;
  box-shadow: 0 6px 18px rgba(31,42,68,0.12); text-align: center;
}
