:root {
  --bg: #f6f3ee; --card: #ffffff; --fg: #1d1b19; --muted: #6f6a63; --line: #e5ded3;
  --accent: #c8102e; --accent-soft: #fbe3e6; --ok: #2f8a4e; --bad: #c8102e; --greek: #0d5eaf; --greek-soft: #e3eefb;
  --t1: #d2452e; --t2: #2e8b57; --t3: #2f6fd6; --t4: #8a3fd1; --t0: #8a8580;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --card: #221f1d; --fg: #f1ece6; --muted: #a59d93; --line: #39342f;
    --accent: #ff5a6e; --accent-soft: #3a1d22; --greek: #6aa8ff; --greek-soft: #17263b;
    --t1: #ff7a5c; --t2: #4fd38a; --t3: #6aa0ff; --t4: #c08bff;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", sans-serif; padding-bottom: env(safe-area-inset-bottom); }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--accent); color: #fff; }
.top h1 { flex: 1; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { font-size: 30px; line-height: 1; width: 34px; }
.top .icon { font-size: 20px; width: 40px; height: 34px; border-radius: 17px; opacity: .55; }
.top .icon.on { opacity: 1; background: rgba(255,255,255,.22); }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 60px; }
h2 { font-size: 20px; margin: 22px 0 8px; }
h3 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 10px 0; }
.note { color: var(--muted); font-size: 14px; }

/* 首页 */
.hero { padding: 6px 2px 4px; }
.hero .big { font-size: 15px; color: var(--muted); }
.tile { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; }
.tile .em { font-size: 30px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); flex: none; }
.tile .t { flex: 1; min-width: 0; }
.tile .t b { display: block; font-size: 17px; }
.tile .t span { color: var(--muted); font-size: 14px; }
.tile .chev { color: var(--muted); font-size: 22px; }
.lesson-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.lesson-row:last-child { border-bottom: 0; }
.lesson-row .no { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: none; }
.lesson-row.done .no { background: var(--ok); color: #fff; }
.lesson-row .t { flex: 1; }
.lesson-row .t span { display: block; color: var(--muted); font-size: 13px; }

/* 课文 */
.goal { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.md p { margin: 8px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--bg); }
.md ul, .md ol { padding-left: 22px; margin: 6px 0; }
.greek { background: var(--greek-soft); border-left: 4px solid var(--greek); border-radius: 10px; padding: 8px 14px; margin: 12px 0; }
.greek::before { content: "🇬🇷"; float: right; font-size: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.snd { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px 8px; text-align: center; position: relative; }
.snd .hz { font-size: 34px; line-height: 1.2; font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.snd .py { font-size: 18px; font-weight: 600; }
.snd .en { font-size: 12px; color: var(--muted); min-height: 18px; }
.snd .acts { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.snd .acts button { width: 38px; height: 34px; border-radius: 10px; background: var(--bg); font-size: 15px; }
.snd.playing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tone1 { color: var(--t1); } .tone2 { color: var(--t2); } .tone3 { color: var(--t3); } .tone4 { color: var(--t4); } .tone0 { color: var(--t0); }

.tones-svg { width: 100%; max-width: 520px; display: block; margin: 6px auto; }
.tone-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.tone-keys button { padding: 10px 4px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.tone-keys b { display: block; font-size: 22px; }
.tone-keys span { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 22px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: var(--card); color: var(--fg); border: 1px solid var(--line); }
.btn.big { padding: 14px 24px; font-size: 18px; }
.btn.rec { background: #d93025; }
.btn:disabled { opacity: .4; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }

/* 练习 */
.quiz-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.quiz-play { display: grid; place-items: center; margin: 24px 0; }
.quiz-play button { width: 110px; height: 110px; border-radius: 55px; background: var(--accent); color: #fff; font-size: 42px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opts button { padding: 16px 8px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); font-size: 22px; font-weight: 600; }
.opts button.ok { border-color: var(--ok); background: #e6f4ea; color: var(--ok); }
.opts button.bad { border-color: var(--bad); background: var(--accent-soft); color: var(--bad); }
.quiz-fb { min-height: 52px; text-align: center; margin: 12px 0; font-size: 16px; }

/* 医院 */
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font-size: 16px; }
.phr { display: flex; gap: 10px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.phr:last-child { border-bottom: 0; }
.phr .m { flex: 1; min-width: 0; }
.phr .hz { font-size: 22px; font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.phr .py { color: var(--accent); font-size: 15px; }
.phr .en { color: var(--muted); font-size: 14px; }
.phr .b { display: flex; flex-direction: column; gap: 6px; }
.phr .b button { width: 44px; height: 36px; border-radius: 10px; background: var(--bg); font-size: 16px; }
.doctor-tag { display: inline-block; font-size: 12px; background: var(--greek-soft); color: var(--greek); border-radius: 8px; padding: 1px 8px; margin-left: 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.chips button { flex: none; padding: 7px 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.show { position: fixed; inset: 0; z-index: 30; background: #fff; color: #111; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.show-hz { font-size: min(18vw, 120px); line-height: 1.25; font-weight: 700; font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; word-break: break-all; }
.show-py { font-size: 26px; color: #c8102e; margin-top: 18px; }
.show-en { font-size: 20px; color: #555; margin-top: 8px; }
.show-btns { display: flex; gap: 12px; margin-top: 34px; }

.sheet { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { background: var(--card); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); text-align: center; }
.rec-hz { font-size: 44px; font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.rec-py { font-size: 20px; font-weight: 600; }
#recCanvas { width: 100%; height: auto; background: var(--bg); border-radius: 12px; margin-top: 8px; }
.rec-legend { display: flex; justify-content: center; gap: 16px; font-size: 13px; margin-top: 4px; }
.lg.ref { color: var(--muted); } .lg.me { color: var(--accent); }
.rec-msg { min-height: 24px; color: var(--muted); margin: 6px 0; font-size: 14px; }
.rec-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; background: rgba(20,20,20,.9); color: #fff; padding: 9px 16px; border-radius: 18px; font-size: 14px; max-width: 90vw; text-align: center; }
/* 大字页面始终是白底，按钮颜色固定，不随深色模式变 */
.show .btn.ghost { background: #eeeeee; color: #111111; border-color: #dddddd; }

/* 偏旁、笔画：显示名称，不发音 */
.snd.part .pname { font-size: 18px; font-weight: 700; color: var(--accent); font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.snd.part .py { font-size: 14px; font-weight: 500; color: var(--muted); }
