:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --line: #e6e1d7;
  --text: #22201c;
  --muted: #6d675d;
  --accent: #c7372f;          /* 华为红 */
  --accent-soft: #fbe9e7;
  --teach: #1f6f5c;           /* 讲解：墨绿 */
  --teach-soft: #e5f2ee;
  --book: #3a4a6b;            /* 原文：靛蓝 */
  --book-soft: #e9edf5;
  --ok: #2e7d32;
  --ok-soft: #e7f4e8;
  --bad: #c62828;
  --bad-soft: #fdecea;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .05);
  --radius: 14px;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", system-ui, sans-serif;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --player-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #1f1e1b; --surface-2: #252420; --line: #36342f;
    --text: #ebe7df; --muted: #a29b8f; --accent: #ef6b5f; --accent-soft: #3a2220;
    --teach: #6fcfb2; --teach-soft: #1b302a; --book: #a9b8d8; --book-soft: #232a38;
    --ok: #7bc47f; --ok-soft: #1e2f1f; --bad: #f08080; --bad-soft: #3a1f1f;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #1f1e1b; --surface-2: #252420; --line: #36342f;
  --text: #ebe7df; --muted: #a29b8f; --accent: #ef6b5f; --accent-soft: #3a2220;
  --teach: #6fcfb2; --teach-soft: #1b302a; --book: #a9b8d8; --book-soft: #232a38;
  --ok: #7bc47f; --ok-soft: #1e2f1f; --bad: #f08080; --bad-soft: #3a1f1f;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 16px; line-height: 1.75; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-family: var(--serif); font-size: 19px;
}
.brand-text { font-weight: 700; font-size: 17px; line-height: 1.15; display: flex; flex-direction: column; }
.brand-text small { font-weight: 400; font-size: 12px; color: var(--muted); }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.topnav a:hover { background: var(--surface); color: var(--text); }
.topnav a.active { color: var(--accent); background: var(--accent-soft); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  width: 38px; height: 38px; display: grid; place-items: center; font-size: 16px; line-height: 1;
}
.icon-btn:hover { border-color: var(--muted); }
.only-mobile { display: none; }
.ic { width: 18px; height: 18px; display: block; flex: none; }
.btn .ic { width: 14px; height: 14px; }
.play-btn .ic { width: 24px; height: 24px; }
.play-btn[data-icon="play"] .ic { transform: translateX(1.5px); }
.side-nav { flex-direction: column; gap: 2px; padding: 0 0 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.side-nav a { text-decoration: none; padding: 9px 12px; border-radius: 10px; font-size: 15px; color: var(--text); }
.side-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar {
  position: sticky; top: 60px; height: calc(100vh - 60px - var(--player-h)); overflow-y: auto;
  padding: 18px 12px 24px; border-right: 1px solid var(--line);
}
.main { padding: 28px 40px calc(var(--player-h) + 48px); max-width: 920px; width: 100%; margin: 0 auto; outline: none; min-width: 0; }
.scrim { display: none; }

.side-title { font-size: 12px; letter-spacing: .08em; color: var(--muted); padding: 0 10px 8px; }
.ch-link {
  display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start;
  padding: 9px 10px; border-radius: 10px; text-decoration: none; margin-bottom: 2px;
}
.ch-link:hover { background: var(--surface); }
.ch-link.active { background: var(--surface); box-shadow: var(--shadow); }
.ch-no {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.ch-link.active .ch-no { background: var(--accent); border-color: var(--accent); color: #fff; }
.ch-no.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.ch-name { font-size: 14.5px; line-height: 1.45; }
.ch-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.mini-bar { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; max-width: 110px; }
.mini-bar i { display: block; height: 100%; background: var(--teach); }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px 28px; margin-bottom: 20px;
}
.card h2 { font-size: 21px; margin: 0 0 12px; line-height: 1.4; }
.eyebrow { font-size: 13px; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14.5px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.teach { color: var(--teach); border-color: color-mix(in srgb, var(--teach) 40%, var(--line)); }
.btn.book { color: var(--book); border-color: color-mix(in srgb, var(--book) 40%, var(--line)); }
.btn.sm { padding: 5px 12px; font-size: 13.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- 首页 ---------- */
.hero { padding: 36px 36px 30px; background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 160%); }
.hero h1 { font-family: var(--serif); font-size: 36px; margin: 6px 0 10px; line-height: 1.3; }
.hero p { color: var(--muted); margin: 0 0 20px; max-width: 620px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 22px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ch-card {
  display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: transform .15s;
}
.ch-card:hover { transform: translateY(-2px); border-color: var(--muted); }
.ch-card .eyebrow { font-size: 12px; }
.ch-card h3 { margin: 4px 0 12px; font-size: 16.5px; line-height: 1.45; }
.ch-card .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--teach); border-radius: 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 32px 0 14px; }
.section-head h2 { margin: 0; font-size: 20px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 14.5px; counter-increment: s; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; margin-right: 8px; }

/* ---------- 章节页 ---------- */
.chapter-hero h1 { font-family: var(--serif); font-size: 30px; margin: 6px 0 14px; line-height: 1.35; }
.chapter-hero .bar { margin: 4px 0 6px; max-width: 360px; }
.chapter-hero .progress-text { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.ch-tabs { display: flex; gap: 6px; margin: 22px 0 -1px; border-bottom: 1px solid var(--line); }
.ch-tabs a { padding: 10px 18px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.ch-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.goals { margin: 14px 0 0; padding: 14px 18px; background: var(--surface-2); border-radius: 12px; border: 1px dashed var(--line); }
.goals h3 { margin: 0 0 6px; font-size: 15px; }
.goals ul { margin: 0; padding-left: 20px; }

.sec-card header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 16px; margin-bottom: 8px; }
.sec-card header h2 { margin: 0; flex: 1 1 260px; }
.done-badge { font-size: 12px; color: var(--ok); background: var(--ok-soft); padding: 2px 10px; border-radius: 999px; margin-left: 8px; vertical-align: middle; font-weight: 500; }
.pane-tabs { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 14px; }
.pane-tabs button { border: 0; background: none; padding: 5px 16px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.pane-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.pane-tabs button[data-tab="explain"].active { color: var(--teach); }
.pane-tabs button[data-tab="book"].active { color: var(--book); }

.unit {
  position: relative; margin: 0 -12px 6px; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  transition: background .2s;
}
.unit:hover { background: var(--surface-2); }
.unit.heard::after {
  content: ""; position: absolute; left: 2px; top: 12px; width: 4px; height: 4px; border-radius: 50%; background: var(--teach); opacity: .6;
}
.unit.playing { background: var(--teach-soft); }
.unit.playing::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--teach);
}
.pane-book .unit.playing { background: var(--book-soft); }
.pane-book .unit.playing::before { background: var(--book); }
.pane-explain .unit { font-size: 16.5px; }
.pane-book { font-family: var(--serif); font-size: 16.5px; line-height: 1.95; }
.pane-book .unit.p { text-indent: 2em; }
.pane-book .unit.li { padding-left: 32px; }
.pane-book .unit.li::after {
  content: "•"; position: absolute; left: 16px; top: 6px; width: auto; height: auto; background: none; color: var(--muted); opacity: 1;
}
.pane-book .unit.title { display: none; }
.pane-book .unit.h { font-family: var(--sans); font-weight: 700; font-size: 17px; margin-top: 18px; }
.figure { margin: 14px 0 18px; text-align: center; }
.figure img {
  max-width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: zoom-in;
}
.figure .unit { font-family: var(--sans); font-size: 13.5px; color: var(--muted); text-indent: 0; display: inline-block; margin: 6px 0 0; }
.figure.table-cap .unit { font-weight: 600; color: var(--text); }

/* 英文术语 */
.en-note {
  display: inline-block; font-family: var(--sans); font-size: .7em; line-height: 1.5; font-weight: 500;
  color: var(--teach); background: var(--teach-soft); border-radius: 5px; padding: 0 5px; margin: 0 3px;
  vertical-align: 2px; text-indent: 0; white-space: nowrap;
}
.pane-book .en-note { color: var(--book); background: var(--book-soft); }
body.hide-en .en-note { display: none; }
.en-btn { font-size: 12.5px; font-weight: 700; width: auto; padding: 0 9px; color: var(--muted); }
.en-btn.on { color: var(--teach); border-color: var(--teach); background: var(--teach-soft); }
.en-term { display: block; font-weight: 500; font-size: 13.5px; color: var(--teach); line-height: 1.5; margin-top: 2px; }
.star { color: #d29b0c; margin-right: 4px; }
.say {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; padding: 0;
  background: none; color: var(--teach); cursor: pointer; vertical-align: -6px;
}
.say .ic { width: 16px; height: 16px; }
.say:hover { background: var(--teach-soft); }
.example { margin-top: 6px; padding: 8px 12px; background: var(--surface); border-radius: 8px; font-size: 14px; border: 1px solid var(--line); }
.ex-en { font-style: italic; }
.ex-zh { color: var(--muted); font-size: 13px; margin-top: 2px; }
.gl-tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.gl-tools .search { flex: 1 1 280px; margin: 0; }
.en-quiz-head { margin: 34px 0 14px; padding: 16px 20px; border-radius: var(--radius); background: var(--teach-soft); }
.en-quiz-head h2 { margin: 0 0 4px; font-size: 19px; color: var(--teach); }
.en-quiz-head p { margin: 0; font-size: 14.5px; }
.q-en .q-type { background: var(--teach-soft); color: var(--teach); }

.terms { margin: 18px 0 0; padding: 14px 18px; border-radius: 12px; background: var(--teach-soft); }
.terms h3 { margin: 0 0 8px; font-size: 14.5px; color: var(--teach); }
.terms dl { margin: 0; display: grid; grid-template-columns: minmax(130px, 230px) 1fr; gap: 10px 16px; font-size: 14.5px; }
.terms dt { font-weight: 700; }
.terms dd { margin: 0; color: var(--text); }

.takeaways { border-left: 4px solid var(--accent); }
.takeaways .unit { padding-left: 30px; }
.takeaways .unit .num {
  position: absolute; left: 4px; top: 9px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 700;
}
.cta { text-align: center; padding: 26px; }

/* ---------- 练习 ---------- */
.quiz-summary { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.score-ring { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.score-ring span { position: relative; font-variant-numeric: tabular-nums; }
.q-card { padding: 20px 24px; }
.q-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.q-type { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--book-soft); color: var(--book); white-space: nowrap; }
.q-text { font-weight: 600; font-size: 16.5px; }
.opts { display: grid; gap: 8px; }
.opt-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; background: var(--surface);
}
.opt-item:hover { border-color: var(--muted); }
.opt-item input { margin-top: 6px; accent-color: var(--accent); }
.opt-item.right { border-color: var(--ok); background: var(--ok-soft); }
.opt-item.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-explain { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14.5px; }
.q-explain.ok { background: var(--ok-soft); }
.q-explain.no { background: var(--bad-soft); }
.q-explain b { margin-right: 6px; }
.think .ref { margin-top: 10px; padding: 12px 16px; background: var(--surface-2); border-radius: 10px; font-size: 15px; }
.submit-bar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 10px 0 30px; }

/* ---------- 术语表 ---------- */
.search { width: 100%; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; margin-bottom: 18px; }
.gl-item { display: grid; grid-template-columns: 230px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gl-item:last-child { border-bottom: 0; }
.gl-term { font-weight: 700; }
.gl-src { font-size: 12.5px; color: var(--muted); }
.gl-src a { color: var(--accent); }

.help h3 { margin: 22px 0 8px; font-size: 17px; }
.help code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 14px; }
.help pre { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 14px; }
.notice { padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); font-size: 14.5px; margin-bottom: 18px; }

/* ---------- 播放器 ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; min-height: var(--player-h);
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.player-progress { height: 3px; background: var(--line); }
.player-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.player-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; padding: 10px 20px; }
.player-now { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.tag.e { background: var(--teach-soft); color: var(--teach); border-color: transparent; }
.tag.o { background: var(--book-soft); color: var(--book); border-color: transparent; }
.player-controls { display: flex; align-items: center; gap: 10px; }
.play-btn { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 20px; display: grid; place-items: center; }
.play-btn:hover { filter: brightness(1.08); }
.player-opts { display: flex; align-items: center; gap: 12px; justify-content: flex-end; flex-wrap: wrap; font-size: 13.5px; }
.opt { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.opt select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 6px; color: var(--text); }
.opt.check input { accent-color: var(--accent); }
.player-pos { color: var(--muted); font-variant-numeric: tabular-nums; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 86vh; background: #fff; border-radius: 8px; }
.lightbox p { color: #eee; margin: 12px 0 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .player-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .player-opts { grid-column: 1 / -1; justify-content: flex-start; }
  :root { --player-h: 118px; }
}
@media (max-width: 860px) {
  .only-mobile { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topnav { gap: 0; }
  .btn-row .btn { white-space: normal; }
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 290px; height: auto; z-index: 50; background: var(--bg);
    transform: translateX(-100%); transition: transform .2s; padding-bottom: calc(var(--player-h) + 20px);
  }
  body.drawer .sidebar { transform: none; }
  body.drawer .scrim { display: block; position: fixed; inset: 60px 0 0; background: rgba(0,0,0,.35); z-index: 45; }
  .main { padding: 20px 16px calc(var(--player-h) + 40px); }
  .card { padding: 18px 16px; }
  .hero { padding: 24px 18px; }
  .hero h1 { font-size: 28px; }
  .chapter-hero h1 { font-size: 24px; }
  .topnav { display: none; }
  .side-nav.only-mobile { display: flex; }
  .brand-text small { display: none; }
  .gl-item { grid-template-columns: 1fr; gap: 2px; }
  .terms dl { grid-template-columns: 1fr; gap: 0 0; }
  .terms dd { margin-bottom: 8px; }
  .player-inner { padding: 8px 12px; gap: 8px 12px; }
  .player-pos { display: none; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-text { font-size: 16px; }
}
