/* PEP 3A 同步学习工作台 · App 级样式 */
:root {
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --ink: #262B38;
  --sub: #7B8398;
  --line: rgba(38, 43, 56, .08);
  --brand: #FF8A3D;
  --brand-soft: #FFF1E5;
  --blue: #4AA3E8;
  --blue-soft: #EAF4FD;
  --green: #34B378;
  --green-soft: #E9F8F0;
  --red: #E5484D;
  --red-soft: #FDECEC;
  --amber: #F5A623;
  --r-lg: 22px;
  --r-md: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 80, .04), 0 10px 30px rgba(30, 40, 80, .07);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.55;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: rgba(244, 246, 251, .82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top .back {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-size: 18px; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.top .back:active { transform: scale(.9); }
.top .tt { flex: 1; min-width: 0; }
.top .tt h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .tt small { color: var(--sub); font-size: 12px; }

/* ---------- 通用卡 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 14px 16px 30px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
  animation: rise .45s cubic-bezier(.2, .8, .3, 1) both;
}
.card:nth-child(2) { animation-delay: .04s; }
.card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .12s; }
.card:nth-child(5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--sub);
  background: var(--bg); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.tag {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.tag.a { background: var(--blue-soft); color: #2B7CC2; }
.tag.b { background: var(--green-soft); color: #1F8A5D; }
.tag.r { background: var(--brand-soft); color: #D96A1A; }

/* ---------- 点读元素 ---------- */
[data-a] {
  cursor: pointer;
  transition: transform .16s cubic-bezier(.2, .8, .3, 1), background .2s, box-shadow .2s;
}
[data-a]:active { transform: scale(.97); }
.speaking {
  background: var(--brand-soft) !important;
  box-shadow: inset 0 0 0 2px var(--brand);
  border-radius: 10px;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px #FFB77E; } }

/* ---------- 卡拉 OK 逐词高亮（像字幕一样跟着读） ---------- */
.kw {
  border-radius: 6px;
  padding: 0 1px;
  transition: background .13s ease, color .13s ease, box-shadow .13s ease;
}
.kw.on {
  background: #FFC44D;
  color: #6B3200;
  box-shadow: 0 1px 0 rgba(150, 90, 0, .22);
  border-radius: 6px;
}
/* 已经读过的词留一层淡底色，读完整句就像看完一行字幕 */
.kw.done { background: rgba(255, 196, 77, .2); border-radius: 6px; }
/* 有逐词字幕时，整句的呼吸动画会让词看不清，改为静态淡色底 */
.speaking.karaoke {
  background: var(--brand-soft) !important;
  box-shadow: none !important;
  animation: none !important;
}

.sen { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; border-radius: 12px; }
.sen .en { font-size: 17px; font-weight: 500; }
.sen .zh { color: var(--sub); font-size: 13px; }
.sen .no { color: var(--sub); font-size: 12px; min-width: 18px; }
body.nozh .zh { display: none; }

/* ---------- 对话气泡 ---------- */
.dia { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-end; }
.dia.right { flex-direction: row-reverse; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #FFB77E, #FF8A3D);
  box-shadow: 0 3px 8px rgba(255, 138, 61, .35);
}
.dia.right .avatar { background: linear-gradient(135deg, #7CC4F4, #4AA3E8); box-shadow: 0 3px 8px rgba(74, 163, 232, .35); }
.avatar .avimg {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  background: #BFE3E6;   /* 透明抠图头像的衬底，取课本拱形青 */
}
.dia.right .avatar .avimg { background: #DCEEF9; }
.bub {
  max-width: 76%; background: var(--card);
  border: 1px solid var(--line); border-radius: 4px 18px 18px 18px;
  padding: 10px 14px; position: relative;
}
.dia.right .bub { background: var(--blue-soft); border-color: transparent; border-radius: 18px 4px 18px 18px; }
.bub .rn { font-size: 11px; color: var(--sub); margin-bottom: 2px; }
.bub .en { font-size: 17px; font-weight: 500; }
.bub .zh { font-size: 13px; color: var(--sub); margin-top: 3px; }

/* ---------- 词卡网格 ---------- */
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 10px; text-align: center; position: relative;
  transition: transform .16s;
}
.wcard:active { transform: scale(.95); }
.wcard .tile { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.wcard .en { font-weight: 600; font-size: 17px; }
.wcard .zh { font-size: 12px; color: var(--sub); margin-top: 2px; }
.wcard .ipa { font-size: 11px; color: var(--blue); margin-top: 1px; }
.wcard .pg { position: absolute; top: 7px; right: 9px; font-size: 10px; color: #B6BCCB; }

/* ---------- 字母卡 ---------- */
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.lcard {
  border: 1px solid var(--line); border-radius: 18px; padding: 12px; text-align: center;
  background: linear-gradient(180deg, #fff, #FBFCFF);
}
.lcard .big { font-size: 40px; font-weight: 700; color: var(--blue); line-height: 1.1; }
.lcard .ws { font-size: 13px; color: var(--ink); margin-top: 4px; }

/* ---------- 节标题 ---------- */
.sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h3 { font-size: 18px; flex: 1; min-width: 0; }
.playall {
  border: none; background: var(--brand-soft); color: #D96A1A;
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: transform .15s;
}
.playall:active { transform: scale(.93); }
.playall.on { background: var(--brand); color: #fff; }

/* ---------- 播放器工具条 ---------- */
.toolbar {
  position: sticky; top: 60px; z-index: 40;
  display: flex; gap: 8px; align-items: center;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 8px 10px; margin-bottom: 14px;
  overflow-x: auto; scrollbar-width: none;
  box-shadow: var(--shadow);
}
.toolbar::-webkit-scrollbar { display: none; }
.tbtn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 999px;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.tbtn:active { transform: scale(.93); }
.tbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tbtn.brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
a.tbtn { text-decoration: none; display: inline-flex; align-items: center; }
.cover.rev { background: linear-gradient(135deg, #4CC98C, #2FA86F 55%, #1F8A5D); box-shadow: 0 14px 34px rgba(47, 168, 111, .28); }

/* ---------- 单元页 ---------- */
.cover {
  border-radius: var(--r-lg); padding: 26px 22px; color: #fff;
  background: linear-gradient(135deg, #FF9D5C, #FF7A2F 55%, #F56A00);
  box-shadow: 0 14px 34px rgba(245, 106, 0, .28);
  margin-bottom: 14px; position: relative; overflow: hidden;
}
.cover::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.cover small { opacity: .85; font-size: 13px; letter-spacing: .1em; }
.cover h1 { font-size: 26px; margin: 6px 0 10px; }
.cover .bq {
  display: inline-block; background: rgba(255, 255, 255, .2);
  padding: 8px 14px; border-radius: 14px; font-size: 15px; font-weight: 500;
}
.cover .zh { opacity: .9; font-size: 13px; margin-top: 8px; }

/* chips 导航 */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: #fff;
  font-size: 12px; font-weight: 500; color: var(--ink);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.chip:active { transform: scale(.93); }
.chip.seen { background: var(--green-soft); border-color: transparent; color: #1F8A5D; }

/* ---------- 首页单元网格 ---------- */
.hero {
  border-radius: var(--r-lg); color: #fff; padding: 30px 24px 26px;
  background: linear-gradient(140deg, #4AA3E8, #2F7FD0 60%, #1E5FA8);
  box-shadow: 0 14px 34px rgba(47, 127, 208, .3);
  position: relative; overflow: hidden; margin-bottom: 16px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -50px;
  width: 190px; height: 190px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero small { opacity: .85; letter-spacing: .14em; font-size: 12px; }
.hero h1 { font-size: 25px; margin: 6px 0 8px; }
.hero p { font-size: 13px; opacity: .92; }
.ugrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ucard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 15px; box-shadow: var(--shadow); cursor: pointer;
  text-decoration: none; color: var(--ink); display: block;
  transition: transform .18s cubic-bezier(.2, .8, .3, 1), box-shadow .18s;
  animation: rise .5s cubic-bezier(.2, .8, .3, 1) both;
}
.ucard:nth-child(2) { animation-delay: .05s; }
.ucard:nth-child(3) { animation-delay: .1s; }
.ucard:nth-child(4) { animation-delay: .15s; }
.ucard:nth-child(5) { animation-delay: .2s; }
.ucard:nth-child(6) { animation-delay: .25s; }
.ucard:active { transform: scale(.96); }
.ucard .un { font-size: 11px; font-weight: 700; color: var(--blue); letter-spacing: .08em; }
.ucard h3 { font-size: 16px; margin: 4px 0 3px; }
.ucard .zh { font-size: 12px; color: var(--sub); }
.ucard .st { margin-top: 8px; font-size: 12px; color: var(--amber); letter-spacing: 2px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--sub); text-decoration: none;
  padding: 4px 14px; border-radius: 12px; transition: color .15s, transform .15s;
}
.tab:active { transform: scale(.9); }
.tab .ic { font-size: 21px; }
.tab.on { color: var(--brand); font-weight: 600; }

/* ---------- 故事 ---------- */
.panel { margin-bottom: 16px; }
.panel img {
  width: 100%; border-radius: 16px; border: 1px solid var(--line);
  display: block;
}
.plines { margin-top: 8px; }

/* ---------- 讲解卡 ---------- */
.excard { border-left: 4px solid var(--brand); }
.excard .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.excard .head .ic { font-size: 22px; }
.excard .head h4 { font-size: 15px; flex: 1; }
.excard .zh { font-size: 14px; color: var(--ink); line-height: 1.7; }
.excard .exs { margin-top: 10px; display: grid; gap: 6px; }
.excard .exs .sen { background: var(--bg); border: 1px solid var(--line); }

/* ---------- 测验 ---------- */
.opts { display: grid; gap: 10px; margin-top: 12px; }
.opt {
  border: 1.5px solid var(--line); background: #fff; border-radius: 16px;
  padding: 13px 16px; font-size: 16px; text-align: left; cursor: pointer;
  transition: all .15s;
}
.opt:active { transform: scale(.97); }
.opt.ok { border-color: var(--green); background: var(--green-soft); }
.opt.bad { border-color: var(--red); background: var(--red-soft); }
.bigtile { font-size: 64px; text-align: center; padding: 20px 0 6px; }

/* ---------- 弹层 ---------- */
.ovl {
  position: fixed; inset: 0; z-index: 90; display: none;
  align-items: flex-end; justify-content: center;
  background: rgba(20, 26, 40, .45);
}
.ovl.show { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; background: #fff;
  border-radius: 26px 26px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  text-align: center; animation: up .3s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(60px); opacity: .5; } }
.stars { font-size: 40px; letter-spacing: 8px; margin: 10px 0; }
.stars i { font-style: normal; opacity: .25; }
.stars i.on { opacity: 1; }
.btn {
  border: none; background: var(--brand); color: #fff; font-size: 16px; font-weight: 600;
  padding: 12px 34px; border-radius: 999px; cursor: pointer; transition: transform .15s;
}
.btn:active { transform: scale(.94); }
.btn.blue { background: var(--blue); }

/* ---------- 工具 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--sub); font-size: 13px; }
.center { text-align: center; }
.bigplay {
  width: 72px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #FFB77E, #FF8A3D); color: #fff; font-size: 28px;
  box-shadow: 0 10px 24px rgba(255, 138, 61, .4);
  transition: transform .15s;
}
.bigplay:active { transform: scale(.92); }
.bigplay.rec { background: linear-gradient(135deg, #FF7B7B, #E5484D); box-shadow: 0 10px 24px rgba(229, 72, 77, .4); animation: pulse2 1s infinite; }
@keyframes pulse2 { 50% { transform: scale(1.06); } }

/* ---------- 练习 ---------- */
.qbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.qbar .bar { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.qbar .bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #FFB77E, #FF8A3D); transition: width .35s cubic-bezier(.2, .8, .3, 1); }
.qtip { font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.qask { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
.qask .hl { color: var(--brand); }
.wopts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.wopt {
  border: 1.5px solid var(--line); background: #fff; border-radius: 18px;
  padding: 14px 10px; text-align: center; cursor: pointer; transition: all .15s;
}
.wopt:active { transform: scale(.95); }
.wopt .en { font-size: 19px; font-weight: 600; }
.wopt .zh { font-size: 12px; color: var(--sub); }
.wopt.ok { border-color: var(--green); background: var(--green-soft); }
.wopt.bad { border-color: var(--red); background: var(--red-soft); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.wordbank { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; min-height: 54px; }
.wb {
  border: 1.5px dashed var(--line); background: #fff; border-radius: 12px;
  padding: 8px 14px; font-size: 17px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.wb:active { transform: scale(.93); }
.wb.used { opacity: .28; pointer-events: none; }
.sortline {
  min-height: 58px; border-radius: 16px; background: var(--bg);
  border: 1px solid var(--line); padding: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.sortline .wb { border-style: solid; border-color: var(--brand); background: var(--brand-soft); }
.qfoot { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.qfoot .btn { padding: 11px 24px; font-size: 15px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.resultbig { text-align: center; padding: 18px 0 4px; }
.resultbig .sc { font-size: 46px; font-weight: 700; color: var(--brand); }

/* ---------- 跟读 ---------- */
.recwave { border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 10px; margin-top: 12px; }
.recwave .lb { font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.recwave canvas { width: 100%; height: 58px; display: block; }
.recrow { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--sub); }
.mic {
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #7CC4F4, #4AA3E8); color: #fff; font-size: 24px;
  box-shadow: 0 8px 20px rgba(74, 163, 232, .38); transition: transform .15s;
}
.mic:active { transform: scale(.92); }
.mic.rec { background: linear-gradient(135deg, #FF7B7B, #E5484D); box-shadow: 0 8px 20px rgba(229, 72, 77, .38); animation: pulse2 1s infinite; }
.scorepick { display: flex; gap: 8px; }
.scorepick button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; transition: all .15s;
}
.scorepick button.on { background: var(--green-soft); border-color: var(--green); color: #1F8A5D; font-weight: 600; }

/* ---------- 错题本 ---------- */
.mcard { border-left: 4px solid var(--red); }
.mcard .mhead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mcard .mhead h4 { flex: 1; font-size: 15px; }
.mcard .mya { font-size: 13px; color: var(--red); }
.mcard .mok { font-size: 13px; color: var(--green); }
.pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--sub); border: 1px solid var(--line); }
.pill.hot { background: var(--red-soft); color: var(--red); border-color: transparent; }

/* ---------- 家长报告 ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--sub); }
.ubar { display: grid; gap: 10px; margin-top: 6px; }
.ubarrow { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.ubarrow .nm { width: 96px; color: var(--ink); font-weight: 500; }
.ubarrow .bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ubarrow .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4AA3E8, #2FA86F); }
.dict { columns: 2; column-gap: 18px; }
.dict div { break-inside: avoid; padding: 5px 0; font-size: 14px; border-bottom: 1px dashed var(--line); }
@media print {
  .top, .tabbar, .toolbar, .noprint { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; }
}

@media (min-width: 720px) {
  .ugrid { grid-template-columns: repeat(3, 1fr); }
  .sheet { border-radius: 26px; margin-bottom: 40px; }
}
