@font-face { font-family: Nunito; src: url(assets/fonts/Nunito.ttf); font-weight: 200 1000; }
:root {
  --bg: #f4efe6; --paper: #fffdf8; --ink: #1f2a30; --muted: #6b7479; --line: #e3dccf;
  --brand: #1f3a44; --accent: #e8743b; --accent-ink: #fff; --soft: #f9e3d4;
  --good: #2e9a5f; --ok: #d29a1d; --poor: #d0503c; --npc: #ffffff; --me: #dff1ea;
  --shadow: 0 2px 10px rgba(31, 42, 48, .08);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12191c; --paper: #1b2428; --ink: #e9eef0; --muted: #9aa6ab; --line: #2b373c;
    --brand: #9fd3dc; --soft: #3a2a20; --npc: #223036; --me: #1d3a31; --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #12191c; --paper: #1b2428; --ink: #e9eef0; --muted: #9aa6ab; --line: #2b373c;
  --brand: #9fd3dc; --soft: #3a2a20; --npc: #223036; --me: #1d3a31; --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.45 Nunito, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
#app { height: 100%; max-width: 560px; margin: 0 auto; position: relative; display: flex; flex-direction: column; }
.boot { margin: auto; font-size: 28px; font-weight: 900; color: var(--brand); }
.page { flex: 1; overflow-y: auto; padding: 0 16px 24px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h2 small, .field small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.empty, .muted { color: var(--muted); }

/* bars & nav */
.bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 12px 0; background: var(--bg); }
.bar h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { width: 36px; height: 36px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); font-size: 18px; }
.tabbar { display: flex; border-top: 1px solid var(--line); background: var(--paper); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; font-size: 18px; color: var(--muted); }
.tabbar span { font-size: 12px; }
.tabbar .on { color: var(--accent); font-weight: 800; }

/* buttons */
.cta { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 12px 22px; font-weight: 800; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.cta.wide, .ghost.wide { width: 100%; }
.ghost { border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 18px; background: var(--paper); font-weight: 700; }
.link { color: var(--accent); text-decoration: underline; margin-left: 8px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row .cta { flex: 1; }
.row.end { margin: 24px 0; }
.faved { color: var(--accent) !important; }
.cta.faved { background: var(--soft); color: var(--accent) !important; }

/* home */
.hero { padding: 26px 4px 16px; }
.hero h1 { font-size: 32px; font-weight: 900; color: var(--brand); letter-spacing: -.5px; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.home > .cta { width: 100%; display: flex; flex-direction: column; align-items: flex-start; padding: 18px 22px; border-radius: var(--radius); font-size: 20px; text-align: left; }
.home > .cta small { font-weight: 600; font-size: 13px; opacity: .9; }
.scene-list { display: grid; gap: 10px; }
.scene-card { position: relative; display: flex; gap: 12px; align-items: center; background: var(--paper); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); text-align: left; width: 100%; }
.scene-card .thumb { width: 74px; height: 74px; flex: none; border-radius: 12px; background: var(--soft) center/cover; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.scene-card .thumb img { width: 58px; height: 58px; border-radius: 50%; border: 2px solid #fff; margin-bottom: 6px; }
.scene-card .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.scene-card small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.tags em { font-style: normal; font-size: 12px; background: var(--bg); border-radius: 6px; padding: 1px 7px; color: var(--muted); }
.del { position: absolute; top: 6px; right: 10px; color: var(--muted); padding: 4px; }
.stars i { font-style: normal; color: var(--line); }
.stars i.on { color: #f2b51c; }

/* forms */
.field { display: block; margin: 16px 0; }
.field > span { display: block; font-weight: 800; margin-bottom: 8px; }
textarea, input { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; background: var(--paper); color: var(--ink); resize: none; }
textarea:focus, input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.seg { display: flex; background: var(--paper); border-radius: 12px; padding: 4px; gap: 4px; box-shadow: var(--shadow); }
.seg button { flex: 1; border-radius: 9px; padding: 8px 4px; font-weight: 700; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.seg button small { font-size: 11px; font-weight: 500; color: var(--muted); margin: 2px 0 0; }
.seg .on { background: var(--brand); color: var(--bg); }
.seg .on small { color: inherit; opacity: .8; }
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.cast button { display: flex; flex-direction: column; align-items: center; border-radius: 12px; padding: 4px; border: 2px solid transparent; }
.cast img, .cast .auto { width: 48px; height: 48px; border-radius: 50%; }
.cast .auto { display: grid; place-items: center; background: var(--brand); color: var(--bg); font-weight: 900; }
.cast small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cast .on { border-color: var(--accent); background: var(--soft); }
.status { color: var(--muted); font-size: 14px; }
.status.warn { color: var(--poor); }
.status a { color: var(--accent); text-decoration: underline; cursor: pointer; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(1turn); } }

/* play */
.play { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.play .bar { padding: 10px 16px 6px; }
.score { background: var(--brand); color: var(--bg); border-radius: 999px; padding: 2px 12px; font-weight: 900; min-width: 48px; text-align: center; }
.progress { height: 4px; background: var(--line); margin: 0 16px; border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.stage { position: relative; height: 26vh; min-height: 150px; max-height: 240px; margin: 8px 16px 0; border-radius: var(--radius); background: center 40% / cover; overflow: hidden; flex: none; }
.stage.nobg { background: linear-gradient(135deg, #2c5260, #1f3a44 60%, #e8743b 160%); }
.stage .npc { position: absolute; left: 50%; transform: translateX(-50%); top: 6%; height: 190%; transform-origin: 50% 20%; transition: transform .2s; filter: drop-shadow(0 6px 8px rgba(0,0,0,.25)); }
.stage .npc.talking { animation: talk .5s ease-in-out infinite alternate; }
@keyframes talk { from { transform: translateX(-50%) translateY(0) rotate(-.6deg); } to { transform: translateX(-50%) translateY(-3px) rotate(.6deg); } }
.nametag { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.92); color: #1f2a30; border-radius: 10px; padding: 4px 10px; display: flex; flex-direction: column; line-height: 1.2; }
.nametag small { color: #6b7479; font-size: 11px; }
.place { position: absolute; top: 10px; left: 12px; color: #fff; font-weight: 900; opacity: .85; }
.combo { position: absolute; right: 10px; top: 10px; background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px; font-weight: 900; opacity: 0; transform: scale(.6); transition: .25s; }
.combo.show { opacity: 1; transform: scale(1); }
.log { flex: 1; overflow-y: auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
.setting { font-size: 13px; color: var(--muted); background: var(--paper); border-radius: 10px; padding: 8px 12px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; animation: pop .25s ease-out; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.msg .av { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.bub { background: var(--npc); border-radius: 16px 16px 16px 4px; padding: 8px 12px 4px; box-shadow: var(--shadow); position: relative; }
.me .bub { background: var(--me); border-radius: 16px 16px 4px 16px; }
.en { margin: 0; font-size: 17px; }
.zh { margin: 2px 0 0; font-size: 14px; color: var(--muted); display: none; }
.zh.show, .feedback .zh, .card .zh { display: block; }
.w { cursor: pointer; border-radius: 4px; }
.w:active, .w:hover { background: var(--soft); }
.tools { display: flex; gap: 2px; justify-content: flex-end; margin-top: 2px; }
.tools button { font-size: 14px; padding: 2px 7px; color: var(--muted); border-radius: 8px; }
.acc { position: absolute; top: -10px; left: -8px; font-size: 12px; font-weight: 900; color: #fff; border-radius: 999px; padding: 0 7px; }
.acc.good { background: var(--good); } .acc.ok { background: var(--ok); } .acc.poor { background: var(--poor); }

.dock { flex: none; max-height: 58vh; overflow-y: auto; background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.08); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.waiting { color: var(--muted); text-align: center; padding: 10px; }
.task { position: relative; background: var(--soft); border-radius: 14px; padding: 10px 12px; }
.task .lbl, .say .lbl { font-size: 12px; font-weight: 800; color: var(--accent); }
.task p { margin: 2px 0 6px; font-size: 17px; font-weight: 800; }
.hint { font-size: 13px; color: var(--muted); background: var(--paper); border-radius: 999px; padding: 2px 10px; }
.hint.on { color: var(--accent); font-weight: 800; }
.modes { display: flex; gap: 6px; margin: 10px 0; }
.modes button { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 2px; font-size: 14px; font-weight: 700; line-height: 1.2; }
.modes small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.modes .on { border-color: var(--brand); background: var(--brand); color: var(--bg); }
.modes .on small { color: inherit; }
.options { display: grid; gap: 8px; }
.opt { text-align: left; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 16px; background: var(--paper); }
.opt.on { border-color: var(--accent); background: var(--soft); }
.tray { min-height: 52px; border: 2px dashed var(--line); border-radius: 12px; padding: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tray .ph { color: var(--muted); font-size: 14px; padding: 0 6px; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tile { background: var(--paper); border: 1.5px solid var(--line); border-bottom-width: 3px; border-radius: 10px; padding: 6px 11px; font-size: 16px; font-weight: 700; }
.tile.in { background: var(--me); }
.tile.used { visibility: hidden; }
.typebox textarea { font-size: 17px; }

.feedback .verdict { display: flex; align-items: baseline; gap: 10px; }
.feedback .big { font-size: 26px; font-weight: 900; }
.feedback.good .big { color: var(--good); } .feedback.ok .big { color: var(--ok); } .feedback.poor .big { color: var(--poor); }
.feedback .pts { margin-left: auto; font-weight: 900; color: var(--accent); }
.feedback .pts small { color: var(--muted); font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.bars i { display: block; height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent) var(--v), var(--line) var(--v)); margin: 2px 0; }
.note { margin: 6px 0; }
.diff { background: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 16px; }
.d-missing { color: var(--good); font-weight: 800; text-decoration: underline; }
.d-extra { color: var(--poor); text-decoration: line-through; }
.err { margin: 4px 0; font-size: 14px; }
.err s { color: var(--poor); } .err small { color: var(--muted); }
.say { border-left: 3px solid var(--accent); padding: 4px 10px; margin: 10px 0; }
.also { font-size: 14px; color: var(--muted); }
.also span { color: var(--ink); }
.feedback .cta { margin-top: 8px; }

/* result */
.summary { display: flex; flex-direction: column; align-items: center; background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.summary img { width: 72px; height: 72px; border-radius: 50%; }
.summary .stars { font-size: 34px; }
.summary b { font-size: 28px; }
.summary small { color: var(--muted); }
.review { display: grid; gap: 8px; }
.rv { background: var(--paper); border-radius: 12px; padding: 10px 12px; border-left: 4px solid var(--line); }
.rv.good { border-color: var(--good); } .rv.ok { border-color: var(--ok); } .rv.poor { border-color: var(--poor); }
.rv .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.rv p { margin: 4px 0 0; }
.rv .mine small { color: var(--muted); font-size: 12px; }
.rv .best { color: var(--good); }
.mini { font-size: 13px; }
.vocab { display: grid; gap: 8px; }
.vc, .item { display: flex; align-items: center; gap: 4px; background: var(--paper); border-radius: 12px; padding: 10px 12px; }
.vc > div, .item > div { flex: 1; display: flex; flex-direction: column; min-width: 0; cursor: pointer; }
.vc span, .item small { color: var(--muted); font-size: 14px; }
.vc small, .item em { color: var(--muted); font-size: 12px; font-style: normal; }
.vc button, .item button { padding: 6px 8px; font-size: 16px; color: var(--muted); }
.ipa { color: var(--muted); font-weight: 400; font-size: 14px; }
.book .tabs { margin-bottom: 12px; }
.items { display: grid; gap: 8px; }

/* sheet & toast */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.sheet-wrap.in { opacity: 1; }
.sheet { width: 100%; max-width: 560px; background: var(--paper); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(30px); transition: transform .2s; }
.sheet-wrap.in .sheet { transform: none; }
.card h3 { margin: 0 0 6px; font-size: 26px; }
.card p { margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--brand); color: var(--bg); padding: 8px 16px; border-radius: 999px; z-index: 30; font-size: 14px; max-width: 90vw; transition: opacity .3s; }
.toast.out { opacity: 0; }

/* account, credits, progress (v0.2) */
.small { font-size: 12px; }
.cta.small, .ghost.small { padding: 6px 14px; font-size: 14px; }
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.me-chip { display: flex; flex-direction: column; align-items: flex-end; background: var(--paper); border-radius: 14px; padding: 6px 12px; box-shadow: var(--shadow); line-height: 1.3; flex: none; max-width: 46%; }
.me-chip b { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip span { font-size: 12px; color: var(--muted); }
.panel { background: var(--paper); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.panel.account { display: flex; align-items: center; gap: 10px; }
.who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.who b { font-size: 18px; }
.who small { color: var(--muted); }
.big-num { display: flex; align-items: baseline; justify-content: space-between; }
.big-num span { color: var(--muted); font-weight: 700; }
.big-num b { font-size: 34px; font-weight: 900; color: var(--accent); }
.exchange p { margin: 6px 0; font-size: 14px; color: var(--muted); }
.exchange .row { margin-top: 6px; flex-wrap: wrap; }
details { margin-top: 10px; font-size: 14px; }
summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.rules { width: 100%; border-collapse: collapse; margin-top: 6px; }
.rules td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.rules td:last-child { text-align: right; font-weight: 800; white-space: nowrap; padding-left: 10px; }
.ledger p { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; }
.ledger span { flex: 1; }
.ledger small { color: var(--muted); }
.plus { color: var(--good); } .minus { color: var(--poor); }
.lv { display: flex; align-items: baseline; gap: 8px; }
.lv b { font-size: 24px; font-weight: 900; color: var(--brand); }
.lv span { font-weight: 800; }
.lv small { margin-left: auto; color: var(--muted); }
.bar-track { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin: 8px 0; }
.bar-track i { display: block; height: 100%; background: var(--accent); }
.stats { display: flex; justify-content: space-between; gap: 6px; font-size: 14px; flex-wrap: wrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badges span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); filter: grayscale(1); opacity: .6; }
.badges span.got { background: var(--soft); color: var(--accent); filter: none; opacity: 1; font-weight: 800; }
.item .pts { font-weight: 900; color: var(--accent); margin-left: 6px; }
.item.local { border-left: 3px dashed var(--line); }
.item.cloud { border-left: 3px solid var(--brand); }
.banner { background: var(--soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.banner a { color: var(--accent); text-decoration: underline; cursor: pointer; }
.levelup { margin: 6px 0 0; font-weight: 800; color: var(--accent); }
.login input { margin: 6px 0; }
.login .row .cta, .login .row .ghost { flex: 1; }
.fav-wide { flex: 1; }
.photo-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -6px 0 10px; }
.photo-row small { color: var(--muted); }
.photo-card { display: flex; gap: 12px; background: var(--paper); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); margin-bottom: 12px; }
.photo-card img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; flex: none; }
.photo-card > div { flex: 1; min-width: 0; }
.photo-card p { margin: 2px 0; }
.photo-card .lbl { font-size: 12px; font-weight: 800; color: var(--accent); margin-top: 6px; }
.idea { display: block; width: 100%; text-align: left; border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 6px 0; font-size: 14px; }
.idea small { display: block; color: var(--muted); font-size: 12px; }
.idea.on { border-color: var(--accent); background: var(--soft); }
.objects { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.objects .w { color: var(--ink); font-weight: 700; }

/* v0.3 spoken answers */
.speakbox { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0 4px; text-align: center; }
.speakbox .mic { width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 30px; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.speakbox .mic.on { background: var(--poor); animation: micpulse 1.2s ease-in-out infinite; font-size: 24px; }
.speakbox .mic:disabled { opacity: .7; }
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(208, 80, 60, .45); } 50% { box-shadow: 0 0 0 14px rgba(208, 80, 60, 0); } }
@media (prefers-reduced-motion: reduce) { .speakbox .mic.on { animation: none; } }
