:root {
  color-scheme: light dark;
  --bg: #fbf6ec; --surface: #ffffff; --surface-2: #f4ecdd; --ink: #1d2733; --muted: #5d6773;
  --line: #e4d8c3; --accent: #c8691c; --accent-ink: #ffffff; --blue: #2f5d8a; --blue-soft: #e3eef7;
  --good: #2e7d4f; --good-soft: #e1f3e7; --bad: #b3372e; --bad-soft: #fbe4e1; --warn: #8a6100; --warn-soft: #fbf0d0;
  --radius: 14px; --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a20; --surface: #1f252d; --surface-2: #262d36; --ink: #ece6da; --muted: #a6adb6;
    --line: #36404b; --accent: #f0954a; --accent-ink: #1a1208; --blue: #8fbce6; --blue-soft: #22303e;
    --good: #7fd19c; --good-soft: #1d3326; --bad: #f09a90; --bad-soft: #3a2220; --warn: #f2cd6b; --warn-soft: #3a3118;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  padding: env(safe-area-inset-top) 0 calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
}
[lang="zh-CN"], .zh { font-family: "PingFang SC", "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .75rem 16px .5rem; max-width: 760px; margin: 0 auto; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-zh { font-size: 1.5rem; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.brand-en { font-size: .82rem; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { min-height: 36px; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: .85rem; }
.chip[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); font-weight: 600; }
#lab-offline-status:empty { display: none; }
#lab-offline-status, .notice { max-width: 760px; margin: .25rem auto; padding: .55rem .8rem; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-size: .9rem; width: calc(100% - 32px); }

main { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h2 .zh { color: var(--accent); margin-right: .35rem; }
p.lead { color: var(--muted); margin: .25rem 0 .75rem; font-size: .95rem; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { min-height: var(--nav-h); border: 0; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); gap: 1px; }
.tabs button span { font-size: 1.15rem; font-weight: 600; }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] span { color: var(--accent); }

/* Buttons */
.btn { min-height: 44px; padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.blue { background: var(--blue); color: var(--bg); border-color: var(--blue); }
.btn.small { min-height: 38px; padding: .35rem .7rem; font-size: .9rem; }
.btn.listening { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.spread { justify-content: space-between; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--blue-soft); color: var(--blue);
  display: inline-grid; place-items: center; flex: none; }
.play svg { width: 20px; height: 20px; fill: currentColor; }

/* Word cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem;
  display: grid; grid-template-columns: 52px 1fr; gap: .1rem .6rem; align-items: center; text-align: left; min-height: 76px; }
.card .ico { grid-row: span 3; width: 52px; height: 52px; }
.card .h { font-size: 1.45rem; font-weight: 600; line-height: 1.1; }
.card .p { color: var(--blue); font-size: .95rem; }
.card .e { color: var(--muted); font-size: .82rem; }
.card.on { outline: 3px solid var(--accent); }
.card .tick { color: var(--good); font-size: .8rem; }
.ico { width: 48px; height: 48px; }
body.no-pinyin .py { visibility: hidden; }
body.no-english .en-t { visibility: hidden; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.mode { text-align: left; padding: .75rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); min-height: 64px; }
.mode b { display: block; }
.mode small { color: var(--muted); }

/* Quiz */
.quiz-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }
.prompt { text-align: center; margin: .5rem 0 1rem; }
.prompt .big { font-size: 2.6rem; font-weight: 600; line-height: 1.2; }
.prompt .ico { width: 92px; height: 92px; }
.prompt .en-big { font-size: 1.25rem; font-weight: 600; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.choice { min-height: 72px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); padding: .5rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; font-weight: 600; }
.choice .ico { width: 40px; height: 40px; }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin: .75rem 0 .25rem; padding: .65rem .8rem; border-radius: 10px; }
.feedback:empty { display: none; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback.close { background: var(--warn-soft); color: var(--warn); }
.feedback .ans { color: var(--ink); margin-top: .3rem; }
.type-row { display: flex; gap: .4rem; margin-top: .6rem; }
.type-row input { flex: 1; min-width: 0; min-height: 44px; padding: .4rem .7rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 1.05rem; }
.method { display: flex; gap: .35rem; margin: .5rem 0; }
.method button { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: .9rem; }
.method button[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); font-weight: 600; }

/* Sentences */
.sent .zh-line { font-size: 1.35rem; font-weight: 500; }
.sent .py { color: var(--blue); }
.sent .en-t { color: var(--muted); font-size: .92rem; }
.tok { display: inline-block; }
.mark-hit { color: var(--good); }
.mark-miss { color: var(--bad); text-decoration: underline dotted; }

/* Tiles */
.tiles { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 52px; padding: .4rem; border-radius: 10px; }
.tiles.target { border: 2px dashed var(--line); background: var(--bg); }
.tile { min-height: 44px; min-width: 44px; padding: .3rem .65rem; border-radius: 10px; border: 1px solid var(--blue);
  background: var(--blue-soft); font-size: 1.25rem; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.tile small { font-size: .7rem; color: var(--blue); }
.tile:disabled { opacity: .25; }

/* Scene */
.scene-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #f3e6d0; }
.scene { display: block; width: 100%; height: auto; }
.scene .obj { cursor: pointer; transition: filter .2s; }
.scene .obj:focus { outline: none; }
.scene .obj.hl, .scene .obj:focus-visible { filter: drop-shadow(0 0 4px #d9822b) drop-shadow(0 0 3px #d9822b); }
.bubble { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(255,255,255,.95); color: #1d2733;
  border-radius: 12px; padding: .5rem .7rem; box-shadow: 0 2px 10px rgba(0,0,0,.15); display: flex; gap: .6rem; align-items: center; }
.bubble .py { color: #2f5d8a; }
.bubble .en-t { color: #5d6773; }

/* Homework */
.hw-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.hw-chip { min-height: 44px; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.hw-chip[aria-pressed="true"] { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.hw-row { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.hw-row select { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 .4rem; max-width: 100%; }
.hw-row .x { margin-left: auto; }
.sent-list { display: grid; gap: .6rem; }
.sent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.sent .tools { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
body.rehearse .sent:not(.revealed) .zh-line, body.rehearse .sent:not(.revealed) .py { display: none; }
body.rehearse .sent .en-t { visibility: visible; color: var(--ink); font-size: 1.05rem; }
.empty { color: var(--muted); font-style: italic; }

dialog { max-width: min(28rem, 90vw); border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
dialog button { min-height: 44px; padding: .5rem 1rem; margin-right: .5rem; }
@media (min-width: 700px) {
  .scene-wrap { max-width: 620px; margin: 0 auto; }
}
