/* 英语小课堂 · 样式 */
:root {
  --paper: #faf7f1;
  --paper-2: #f2ece1;
  --ink: #2b2b2b;
  --muted: #7a7266;
  --line: #e3dbcc;
  --accent: #d9643e;
  --accent-2: #3f6f9e;
  --green: #4f8a6b;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(60, 45, 30, .06), 0 8px 24px rgba(60, 45, 30, .06);
  --radius: 14px;
  --serif: Georgia, "Songti SC", "SimSun", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* 顶部导航 */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 247, 241, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 22px; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-family: var(--serif);
}
.nav-links { display: flex; gap: 18px; margin-left: auto; font-size: 14px; color: var(--muted); }
.nav-links a:hover { color: var(--accent); }
.nav-links a.active { color: var(--ink); font-weight: 600; }
@media (max-width: 720px) { .nav-links { gap: 12px; font-size: 13px; } .brand span { display: none; } }

/* 首页 hero */
.hero { padding-top: 66px; padding-bottom: 40px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.2;
  margin: 0 0 14px;
  letter-spacing: .5px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); max-width: 620px; font-size: 17px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 11px 22px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: .18s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); background: #c9562f; }
.btn-ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.stats { display: flex; gap: 34px; margin-top: 44px; flex-wrap: wrap; }
.stat b { font-size: 28px; font-family: var(--serif); }
.stat span { display: block; color: var(--muted); font-size: 13px; }

.section { padding-top: 46px; padding-bottom: 46px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.section-head h2 { font-family: var(--serif); font-size: 26px; margin: 0; }
.section-head .more { margin-left: auto; color: var(--muted); font-size: 13px; }
.section-head .more:hover { color: var(--accent); }

/* 等级 / 功能卡片 */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: #d6c9b4; }
.card h3 { margin: 10px 0 4px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.card .level-tag { font-size: 12px; color: var(--accent); font-weight: 700; letter-spacing: 1px; }
.cover {
  height: 88px; border-radius: 10px; display: grid; place-items: center;
  font-size: 38px; background: var(--paper-2); margin-bottom: 12px;
}

/* 筛选 chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 22px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* 阅读页 */
.reader-top { padding: 34px 0 6px; }
.kicker { color: var(--accent); font-size: 13px; letter-spacing: 1.5px; font-weight: 700; }
.reader-title { font-family: var(--serif); font-size: clamp(28px, 4vw, 40px); margin: 8px 0 6px; }
.reader-zh { color: var(--muted); margin: 0 0 16px; }
.reader-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0 22px; }
.reader-tools .btn { padding: 8px 16px; font-size: 13.5px; }

.progress { height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; margin-bottom: 26px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.text-body { font-family: var(--serif); font-size: 20px; line-height: 2; max-width: 760px; }
.text-body p { margin: 0 0 22px; }

/* 自然段编号：方便按“第几段”定位 */
.text-body { counter-reset: ec-para; }
.text-body > p {
  counter-increment: ec-para;
  padding-left: 2.6em;
}
.text-body > p::before {
  content: counter(ec-para);
  float: left;
  width: 2em;
  margin-left: -2.6em;
  margin-right: .6em;
  font-family: var(--serif);
  font-size: .66em;
  line-height: 3.05;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: .78;
  user-select: none;
  -webkit-user-select: none;
}
.text-body .w {
  cursor: pointer; border-radius: 4px; padding: 0 1px;
  transition: background .12s;
}
.text-body .w:hover { background: #f6e3d7; }
.text-body .w.marked { background: #e6efe8; box-shadow: inset 0 -2px 0 var(--green); }
.text-body .w.known { color: #9a9184; }

/* 生词弹层 */
.pop {
  position: fixed; z-index: 100; width: 268px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(50, 35, 20, .18); padding: 16px;
  display: none;
}
.pop.show { display: block; }
.pop .word { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.pop .ip { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.pop .zh { font-size: 15px; margin-bottom: 4px; }
.pop .pos { color: var(--accent); font-size: 12px; margin-right: 6px; }
.pop-actions { display: flex; gap: 8px; margin-top: 12px; }
.pop-actions button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 7px 8px; font-size: 12.5px; cursor: pointer;
}
.pop-actions button:hover { border-color: var(--accent); color: var(--accent); }
.pop-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 生词本 */
.vocab-stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 24px; }
.vocab-stats .box {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 20px; min-width: 120px;
}
.vocab-stats .box b { font-size: 24px; font-family: var(--serif); display: block; }
.vocab-stats .box span { color: var(--muted); font-size: 12.5px; }

.flashcard {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  min-height: 240px; display: grid; place-items: center; text-align: center;
  padding: 30px; box-shadow: var(--shadow); cursor: pointer;
}
.flashcard .front { font-family: var(--serif); font-size: 40px; }
.flashcard .back .zh { font-size: 24px; margin: 6px 0; }
.flashcard .hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
.flashcard .ex { font-family: var(--serif); font-size: 15px; margin-top: 12px; padding: 0 10px; line-height: 1.5; }
.flash-actions { display: flex; gap: 10px; margin-top: 14px; }
.flash-actions .btn { flex: 1; justify-content: center; }

.word-list { display: grid; gap: 10px; }
.word-row {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.word-row .w { font-family: var(--serif); font-size: 18px; font-weight: 700; min-width: 130px; }
.word-row .m { color: var(--muted); font-size: 14px; }
.word-row .tag { margin-left: auto; font-size: 11px; color: var(--accent); border: 1px solid #f0d0c2; padding: 2px 8px; border-radius: 99px; }

/* 词汇详情：短语与例句 */
.word-item { flex-wrap: wrap; cursor: pointer; }
.word-item .more { flex: 1 1 100%; font-size: 11px; color: var(--muted); margin-top: 4px; }
.word-item.open .more { display: none; }
.word-extra { display: none; flex: 1 1 100%; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.word-item.open .word-extra { display: block; }
.word-extra .ph { font-size: 13px; color: var(--muted); margin: 2px 0; }
.word-extra .ex { font-family: var(--serif); font-size: 14px; margin-top: 6px; line-height: 1.6; }
.word-extra .ex .muted { font-size: 12.5px; }
html[data-theme="dark"] .word-extra { border-color: #3b342c; }

/* 练习 */
.practice-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); }
.practice-card h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 22px; }
.practice-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.sentence { font-family: var(--serif); font-size: 20px; line-height: 1.9; margin: 10px 0 16px; }
.blank {
  display: inline-block; min-width: 110px; border-bottom: 2px solid var(--line);
  margin: 0 3px; text-align: center; color: var(--accent); font-weight: 700;
}
input[type="text"], select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); outline: none;
  max-width: 100%;
}
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); }
#text-select { flex: 1 1 100%; width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.text-body p, .sentence, .word-row .m, .practice-card .sub { overflow-wrap: anywhere; }
.feedback { margin-top: 14px; font-size: 14px; min-height: 22px; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: #c0392b; }

/* 护眼 / 夜间模式 */
.theme-btn {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 14px; cursor: pointer; display: grid; place-items: center; padding: 0;
  margin-left: 10px;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }

html[data-theme="dark"] {
  --paper: #1b1815;
  --paper-2: #2a2520;
  --ink: #ece3d5;
  --muted: #a89d8d;
  --line: #3b342c;
  --card: #241f1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .4);
}
html[data-theme="dark"] .nav { background: rgba(27, 24, 21, .9); }
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .pop,
html[data-theme="dark"] .flashcard,
html[data-theme="dark"] .practice-card,
html[data-theme="dark"] .card,
html[data-theme="dark"] .vocab-stats .box,
html[data-theme="dark"] .theme-btn,
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .pop-actions button,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background-color: #241f1a !important; color: var(--ink); }
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] input::placeholder { color: #7d7365; }
html[data-theme="dark"] .chip.active { background: var(--accent) !important; border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .cover { filter: brightness(.88) saturate(.9); }
html[data-theme="dark"] .word-row { background: #241f1a; }
html[data-theme="dark"] .word-row .tag { background: #2a2520 !important; color: #c9bfae; border-color: #4a4036; }
html[data-theme="dark"] .text-body .w:hover { background: #3a2f26; }
html[data-theme="dark"] .text-body .w.marked { background: #2c3a30; }
html[data-theme="dark"] .footer { border-color: var(--line); }

/* 页脚 */
.footer { border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 0 40px; color: var(--muted); font-size: 13px; }
.footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* 手机端 */
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .nav-inner { height: 52px; gap: 10px; }
  .brand { font-size: 14px; gap: 6px; }
  .brand .dot { width: 22px; height: 22px; font-size: 11px; }
  .nav-links { gap: 8px; font-size: 11.5px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { white-space: nowrap; padding: 2px 0; }
  .hero { padding-top: 30px; padding-bottom: 18px; }
  .hero h1 { font-size: 30px; line-height: 1.22; }
  .hero p { font-size: 14px; margin-bottom: 18px; }
  .hero-actions .btn { padding: 10px 18px; font-size: 14px; }
  .stats { gap: 20px; margin-top: 26px; }
  .stat b { font-size: 22px; }
  .section { padding-top: 30px; padding-bottom: 30px; }
  .section-head h2 { font-size: 21px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; border-radius: 12px; }
  .card h3 { font-size: 14.5px; }
  .card p { font-size: 12px; }
  .cover { height: 62px; font-size: 28px; margin-bottom: 8px; }
  .text-body { font-size: 17px; line-height: 1.85; }
  .text-body > p { padding-left: 2.2em; }
  .text-body > p::before { width: 1.6em; margin-left: -2.2em; line-height: 2.9; }
  .reader-title { font-size: 24px; }
  .reader-zh { font-size: 14px; }
  .reader-tools .btn { padding: 7px 13px; font-size: 12.5px; }
  .vocab-stats { gap: 8px; }
  .vocab-stats .box { flex: 1 1 40%; min-width: 0; padding: 10px 12px; }
  .flashcard { min-height: 200px; padding: 22px; }
  .flashcard .front { font-size: 30px; }
  .flash-actions .btn { padding: 9px 8px; font-size: 13px; }
  .word-row { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .word-row .w { min-width: 100%; font-size: 16px; }
  .pop { width: 236px; }
  .text-body .w { padding: 1px 0; }
  .practice-card { padding: 18px; }
  .sentence { font-size: 17px; }
  * { -webkit-tap-highlight-color: transparent; }
}

/* 杂项 */
.back-btn {
  flex: 0 0 auto; width: 32px; height: 32px; margin-right: 2px;
  border: 1px solid var(--line); border-radius: 50%; background: #fff;
  color: var(--muted); font-size: 15px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.hidden { display: none !important; }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  max-width: min(80vw, 320px);
  padding: 9px 16px; border-radius: 999px;
  background: rgba(43, 43, 43, .92); color: #fff;
  font-size: 13px; line-height: 1.4; text-align: center;
  opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
html[data-theme="dark"] .toast { background: rgba(245, 240, 232, .95); color: #1b1815; }

/* 分页条 */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 6px;
}
.pager .btn {
  min-width: 38px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 999px;
}
.pager .btn:disabled { opacity: .45; cursor: default; }
.pager-note { text-align: center; margin: 10px 0 0; }

.pager .btn-primary:disabled { opacity: 1; }

/* 关闭连字，避免 ffl / fi 等字母粘连 */
body, .front, .zh, .w, .word-row, .word-item, h1, h2, h3 {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "dlig" 0;
}

/* 空态段落不显示段号 */
.text-body > p.no-num { padding-left: 0; counter-increment: none; }
.text-body > p.no-num::before { content: none; }

/* 左右滑动切页的过场 */
body.swipe-next, body.swipe-prev { animation: ec-swipe-out .12s ease-in forwards; }
body.swipe-next { --ec-shift: -14px; }
body.swipe-prev { --ec-shift: 14px; }
@keyframes ec-swipe-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: .35; transform: translateX(var(--ec-shift, -14px)); }
}
@media (prefers-reduced-motion: reduce) {
  body.swipe-next, body.swipe-prev { animation: none; }
}

/* 版本更新提示条 */
.update-bar{background:var(--accent);color:#fff;font-size:13.5px;padding:9px 16px;display:flex;gap:10px;align-items:center;justify-content:center;flex-wrap:wrap}
.update-bar a{color:#fff;text-decoration:underline}
.update-bar button{background:transparent;border:0;color:#fff;font-size:18px;line-height:1;cursor:pointer;padding:0 2px}
