:root {
  --bg: #FFFDF8; --card: #FFFFFF; --ink: #16130A; --muted: #6E675B; --line: #EFE8DA; --soft: #F7F2E8;
  --yellow: #FFD43B; --yellow-ink: #16130A; --mark: #FFE88A; --deep: #C98B00; --blue: #3D7BFF;
  --ok: #1E9E5A; --ok-soft: #E3F5EA; --bad: #E0484E; --bad-soft: #FCE8E8;
  --shadow: 0 1px 2px rgba(22, 19, 10, .06), 0 10px 30px rgba(22, 19, 10, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0F12; --card: #1B1D23; --ink: #F4F1EA; --muted: #A39C8E; --line: #2A2D35; --soft: #24262D;
    --mark: #5C4A0A; --deep: #FFCF3F; --ok: #3DD68C; --ok-soft: #12301F; --bad: #FF6B70; --bad-soft: #3A1A1C;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E0F12; --card: #1B1D23; --ink: #F4F1EA; --muted: #A39C8E; --line: #2A2D35; --soft: #24262D;
  --mark: #5C4A0A; --deep: #FFCF3F; --ok: #3DD68C; --ok-soft: #12301F; --bad: #FF6B70; --bad-soft: #3A1A1C;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
[lang="en"] { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; }
svg { display: block; }
h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: var(--yellow); color: var(--yellow-ink); font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.line-btn svg { margin-right: 6px; }
.play svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.play.on { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* pinned footer: Douyin account + ICP number on every page */
.credits {
  display: flex; flex-wrap: wrap; justify-content: center; margin: 0;
  padding: 6px 16px;
  padding-bottom: max(6px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 11px; line-height: 1.5;
  background: var(--bg);
}
.credits > * { margin: 0 7px; }
.credits a:hover { text-decoration: underline; }
.credits b { color: var(--deep); font-weight: 700; }

/* ---------- home ---------- */
.home-page { min-height: 100vh; min-height: calc(var(--vh, 1vh) * 100); min-height: 100dvh; display: flex; flex-direction: column; }
.home-page .credits { position: -webkit-sticky; position: sticky; bottom: 0; border-top: 1px solid var(--line); }
.top, .home { width: 100%; max-width: 560px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.home { flex: 1 0 auto; padding-bottom: 20px; }
.top { padding-top: 14px; padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; font-weight: 700; font-size: 15px; }
.avatar { display: block; width: 34px; height: 34px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--yellow); }
.hero { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; padding: 6px 0 14px; }
.hero h1 { margin: 0 12px 0 0; font-size: 26px; line-height: 1.25; letter-spacing: -.01em; white-space: nowrap; }
.hero .mark { padding: 0 2px; background: linear-gradient(transparent 58%, var(--mark) 58%); }
.hero .rest { font-weight: 500; color: var(--muted); }
.hero-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.sub { margin: 0; color: var(--muted); }
.top + .home .grid:first-child { margin-top: 14px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 14px; }
.brand .avatar { flex: none; margin-right: 10px; }
.brand-text { display: flex; flex-wrap: wrap; align-items: baseline; min-width: 0; }
.brand-text b { margin-right: 8px; font-size: 15px; }
.tagline { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.tile { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.cover { position: relative; }
.cover img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; background: var(--line); }
.tile-video {
  /* bottom-right of the cover, just above the cover's own caption line so it never covers text */
  position: absolute; right: 8px; bottom: 9%; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #16130A;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
/* the triangle's path is drawn around its centroid, so the icon sits optically centred without nudging */
.tile-video svg { width: 18px; height: 18px; fill: currentColor; }
.tile .meta { display: flex; align-items: center; min-width: 0; padding: 10px 12px 8px; }
.tile .meta b { min-width: 0; margin-left: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; }
.tile .meta .chip { flex: none; }
.words-btn {
  display: flex; align-items: center; justify-content: center; margin: 0 10px 10px; height: 36px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--soft); color: var(--ink); font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.words-btn svg { flex: none; width: 15px; height: 15px; margin-right: 5px; color: var(--muted); fill: currentColor; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.doc h1 { margin: 10px 0 8px; font-size: 22px; }
.doc p, .doc li { font-size: 15px; line-height: 1.7; }
.doc ul { padding-left: 20px; }
.doc-back { color: var(--deep); font-weight: 600; }

/* add to home screen: header button + guide sheet */
.top { display: flex; align-items: center; }
.top .brand { flex: 1; min-width: 0; }
.a2hs-btn {
  flex: none; margin-left: 10px; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.a2hs-btn[hidden] { display: none; }
.a2hs { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; }
.a2-mask { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(14, 15, 18, .45); animation: a2-fade .2s ease; }
.a2-sheet {
  position: absolute; left: 10px; right: 10px; bottom: 46px; max-width: 520px; margin: 0 auto; padding: 18px 18px 14px;
  border-radius: 22px; background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1);
}
@keyframes a2-fade { from { opacity: 0; } }
.a2-head { display: flex; align-items: center; }
.a2-head img { flex: none; width: 52px; height: 52px; border-radius: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.a2-head div { margin-left: 12px; }
.a2-head b { display: block; font-size: 17px; line-height: 1.35; }
.a2-head span { color: var(--muted); font-size: 13px; }
.a2-note { margin: 12px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--soft); font-size: 13px; }
.a2-steps { margin: 12px 0 0; padding: 0; list-style: none; }
.a2-steps li { display: flex; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; line-height: 1.4; }
.a2-steps li:first-child { border-top: 0; }
.a2-steps li > b {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-right: 10px; border-radius: 50%;
  background: var(--yellow); color: var(--yellow-ink); font-size: 12px;
}
.a2-steps .a2-t { flex: 1; }
.a2-ic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin-left: 8px; border-radius: 10px; background: var(--soft); color: #0A84FF; }
.a2-ic svg { width: 22px; height: 22px; }
.a2-ic svg[viewBox="0 0 34 20"] { width: 28px; height: 17px; }
.a2-actions { display: grid; grid-template-columns: 1fr 2fr; grid-gap: 10px; margin-top: 14px; }
.a2-actions button { height: 44px; border: 0; border-radius: 12px; font-weight: 700; }
.a2-later { background: var(--soft); }
.a2-ok, .a2-go { background: var(--yellow); color: var(--yellow-ink); }
/* the arrow points at the browser's own button: bottom-right (Safari 26 "···"), bottom-centre (older Safari share),
   top-right (in-app "···", Chrome's share / menu) */
.a2-arrow {
  position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--yellow);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); animation: a2-bob 1s ease-in-out infinite;
}
.a2-arrow::after {
  content: ""; position: absolute; left: 11px; top: 8px; width: 10px; height: 10px;
  border-right: 3px solid #16130A; border-bottom: 3px solid #16130A; transform: rotate(45deg);
}
.a2-br { right: 22px; bottom: 6px; }
.a2-bc { left: 50%; bottom: 6px; margin-left: -17px; }
.a2-tr { right: 14px; top: 10px; top: max(10px, env(safe-area-inset-top)); }
.a2-tr::after { top: 13px; transform: rotate(-135deg); }
@keyframes a2-bob { 50% { transform: translateY(5px); } }
.a2-tr { animation-name: a2-bob-up; }
@keyframes a2-bob-up { 50% { transform: translateY(-5px); } }

/* word list (score screen and home pop-up) */
.words { margin: 0; padding: 0; list-style: none; counter-reset: w; overflow-y: auto; }
.words li { counter-increment: w; border-top: 1px solid var(--line); }
.words li:first-child { border-top: 0; }
.words a { display: grid; grid-template-columns: 24px 1fr auto 20px; grid-column-gap: 8px; padding: 8px 0; align-items: baseline; }
.words a::before { content: counter(w); color: var(--muted); font-size: 13px; }
.words .ipa { grid-column: 2; font-size: 13px; color: var(--muted); }
.words .cn { grid-row: 1; grid-column: 3; color: var(--muted); font-size: 14px; }
.words a::after { content: ""; grid-row: 1; grid-column: 4; font-weight: 800; text-align: right; }
.words li.ok a::after { content: "✓"; color: var(--ok); }
.words li.bad a::after { content: "✗"; color: var(--bad); }

/* home pop-up: bottom sheet */
.sheet-dialog {
  position: fixed; top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-width: 560px; max-height: 82vh; max-height: 82dvh;
  margin: 0 auto; padding: 16px 18px;
  padding-bottom: max(16px, env(safe-area-inset-bottom)); border: 0; border-radius: 22px 22px 0 0;
  background: var(--card); color: var(--ink); box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
}
.sheet-dialog[open] { display: block; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
.sheet-dialog::backdrop { background: rgba(14, 15, 18, .45); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.dlg-head { display: flex; align-items: center; margin-bottom: 8px; }
.dlg-head p { flex: 1; display: flex; align-items: center; margin: 0; font-size: 18px; }
.dlg-head p b { margin-left: 8px; }
.dlg-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--soft); font-size: 22px; line-height: 1; }
/* the list sizes itself: older WebKit gives a flex: 1 child of an auto-height (max-height only) column 0 px */
.sheet-dialog .words { max-height: 56vh; max-height: calc(82vh - 160px); max-height: calc(82dvh - 160px); -webkit-overflow-scrolling: touch; }
.dlg-go {
  display: grid; place-items: center; height: 46px; margin-top: 12px; border-radius: 13px;
  background: var(--yellow); color: var(--yellow-ink); font-weight: 700;
}

/* ---------- episode: one question per screen ---------- */
.deck-page { height: 100vh; height: calc(var(--vh, 1vh) * 100); height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.bar { flex: none; display: flex; align-items: center; padding: 8px 12px 6px; padding-top: max(8px, env(safe-area-inset-top)); }
.bar > * + * { margin-left: 8px; }
.back { display: grid; place-items: center; width: 36px; height: 36px; margin-left: -4px; border-radius: 50%; }
.back svg, .edge svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ttl { flex: 1; min-width: 0; display: flex; align-items: center; margin: 0; }
.ttl b { margin-left: 8px; }
.ttl b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 17px; }
.count { margin: 0 0 0 12px !important; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.count b { color: var(--ink); }
.progress { flex: none; display: flex; padding: 0 16px 10px; }
.progress i + i { margin-left: 4px; }
.progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background .25s; }
.progress i.last { flex: .35; }
.progress i.cur { background: var(--deep); }
.progress i.ok { background: var(--ok); }
.progress i.bad { background: var(--bad); }

.deck {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; min-width: 0; display: flex; scroll-snap-align: center; scroll-snap-stop: always; padding: 0 16px 8px; }
.q, .sheet {
  flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 22px; overflow: hidden; background: var(--card); box-shadow: var(--shadow);
  transform-origin: 50% 60%; will-change: transform, opacity;
}

.shot { position: relative; flex: 1 1 0%; min-height: 120px; overflow: hidden; background: var(--line); transition: flex .4s cubic-bezier(.2, .8, .2, 1); }
.shot img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.12); will-change: transform; }
.hint {
  position: absolute; left: 12px; bottom: 12px; padding: 4px 12px; border-radius: 10px;
  background: var(--yellow); color: var(--yellow-ink); font-weight: 700; font-size: 15px;
}
.hint::after { content: " · 用英语怎么说？"; font-weight: 500; }
.answered .hint { display: none; }

/* swipe affordance: arrows on the card edges */
.edge {
  position: absolute; top: 50%; z-index: 1; display: grid; place-items: center; width: 34px; height: 34px; margin-top: -17px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .82); color: #16130A;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.edge svg { width: 18px; height: 18px; }
.edge.prev { left: 10px; }
.edge.next { right: 10px; }
.slide:first-child .edge.prev { display: none; }
.nudge .slide:first-child .edge.next { animation: nudge 1.2s ease-in-out 3; }
@keyframes nudge { 50% { transform: translateX(5px); } }

.body { flex: 0 0 auto; padding: 14px 16px 16px; overflow-y: auto; overscroll-behavior: contain; transition: flex .4s cubic-bezier(.2, .8, .2, 1); }
/* answered: the teaching takes the whole card */
.answered .shot { display: none; }
/* answered: the result fills the card and its buttons stay at the bottom, where the thumb already is */
.answered .body { flex: 1 1 0%; display: flex; flex-direction: column; padding-top: 18px; padding-bottom: 0; }
.ask-line { display: flex; align-items: flex-start; }
.ask-line .listen { margin-left: 10px; }
.line { flex: 1; margin: 0; font-size: 21px; line-height: 1.45; font-weight: 600; }
.listen {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin-top: 2px;
  border: 0; border-radius: 50%; background: var(--soft);
}
.answered .listen { display: none; }
.blank {
  display: inline-block; min-width: var(--w); margin: 0 .1em; text-align: center;
  border-bottom: 3px solid var(--deep); line-height: 1.2;
}
.blank span { opacity: 0; transition: opacity .25s; }
.answered .blank span { opacity: 1; }
.answered .blank { background: var(--mark); border-radius: 4px 4px 0 0; }

.opts { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 10px; margin-top: 14px; }
.opt {
  min-height: 50px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--soft);
  font-size: 17px; font-weight: 600; line-height: 1.25; transition: background .2s, border-color .2s, transform .1s;
}
.opt:active { transform: scale(.97); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.picked .opt:not(.right):not(.wrong) { opacity: .45; }
.answered .opts { display: none; }

.result { display: none; }
.answered .result { display: flex; flex-direction: column; flex: 1 0 auto; animation: rise .35s ease both; }
.answered .ask-line { flex: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.verdict { display: block; width: -webkit-fit-content; width: fit-content; max-width: 100%; margin: 10px 0 6px; padding: 4px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; line-height: 1.5; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.no { background: var(--bad-soft); color: var(--bad); }
.verdict.no b { font-weight: 800; }
.kw { display: flex; align-items: center; }
.kw .ipa { margin-left: 10px; }
.kw b { font-size: 24px; line-height: 1.25; }
.ipa { color: var(--muted); font-size: 15px; }
.kw .play {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; margin-left: auto;
  border: 0; border-radius: 50%; background: var(--yellow); color: var(--yellow-ink);
}
.zh { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.tip { margin: 10px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--soft); font-size: 14px; line-height: 1.5; }
.tag {
  display: inline-block; margin-right: 8px; padding: 0 7px; border-radius: 6px;
  background: var(--yellow); color: var(--yellow-ink); font-size: 12px; font-weight: 800; line-height: 20px;
}
.tag.us { background: var(--blue); color: #fff; }
.ex { margin: 0; padding: 0; list-style: none; }
.ex li + li { border-top: 1px solid var(--line); }
.ex-row {
  display: flex; align-items: flex-start; width: 100%; margin: 0; padding: 7px 0; border: 0; background: none;
  text-align: left; border-radius: 10px;
}
.ex-row:active { background: var(--soft); }
.ex-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--soft); }
.ex-ic svg { width: 17px; height: 17px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ex-row.on .ex-ic { animation: pulse 1s ease-in-out infinite; }
.ex-row.on .en { color: var(--deep); }
.ex-text { display: block; margin-left: 10px; }
.ex-text .en { display: block; font-size: 16px; line-height: 1.4; font-weight: 500; }
.ex-text .zh { display: block; margin: 0; font-size: 14px; }
.rel { display: flex; flex-wrap: wrap; margin: 0 0 0 -8px; padding: 0; list-style: none; }
.rel li { margin: 0 0 8px 8px; }
.rel li { padding: 4px 10px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.rel b { margin-right: 6px; }
.result-actions {
  position: -webkit-sticky; position: sticky; bottom: 0; display: grid; grid-template-columns: auto 1fr; grid-gap: 10px; margin: auto -16px 0; padding: 10px 16px 14px;
  background: linear-gradient(to bottom, transparent, var(--card) 14px);
}
.result-actions button { height: 46px; border: 0; border-radius: 13px; font-weight: 700; }
.line-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; background: var(--soft); }
.go-next { background: var(--yellow); color: var(--yellow-ink); }

/* score screen */
.sheet { padding: 22px 18px 16px; }
.score { margin: 0; font-size: 20px; color: var(--muted); }
.score b { margin-right: 6px; font-size: 56px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.score-note { margin: 6px 0 12px; color: var(--muted); font-size: 15px; }
.sheet .words { flex: 1 1 auto; min-height: 0; }
.end-actions { flex: none; display: grid; grid-template-columns: 1fr 1fr; grid-gap: 10px; margin-top: 14px; }
.end-actions > * { display: grid; place-items: center; height: 46px; border-radius: 13px; border: 0; font-weight: 700; }
.again { background: var(--yellow); color: var(--yellow-ink); }
.end-actions a { background: var(--soft); }

.swipe-hint {
  position: fixed; left: 50%; top: 32%; z-index: 3; white-space: nowrap; margin: 0; padding: 8px 16px; border-radius: 999px;
  background: rgba(14, 15, 18, .78); color: #fff; font-size: 14px; transform: translateX(-50%);
  opacity: 0; pointer-events: none; transition: opacity .4s;
}
.swipe-hint.show { opacity: 1; }

/* narrow phones (320–360 px wide): keep "EP.02 冲热可可" on one line */
@media (max-width: 360px) {
  .hero h1 { font-size: 22px; }
  .tile .meta { padding: 9px 9px 7px; }
  .tile .meta .chip { padding: 0 6px; font-size: 11px; }
  .tile .meta b { margin-left: 5px; font-size: 14px; }
  .words-btn { margin: 0 8px 8px; font-size: 12px; }
}

/* short phones (iPhone SE etc.) */
@media (max-height: 700px) {
  .line { font-size: 19px; }
  .opt { min-height: 44px; font-size: 16px; }
  .kw b { font-size: 21px; }
  .body { padding: 12px 14px 14px; }
  .result-actions { margin: auto -14px 0; padding: 8px 14px 12px; }
  .result-actions button, .end-actions > * { height: 42px; }
  .score b { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
