:root {
  color-scheme: light dark;
  --bg: #f6f5f1; --card: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e3e1da;
  --accent: #0f7b6c; --accent-soft: #e2f3ef;
  --good: #2b8a3e; --good-soft: #e6f4ea; --bad: #c92a2a; --bad-soft: #fdecec; --warn: #b7791f; --warn-soft: #fdf3e1;
  --shadow: 0 8px 24px rgba(20, 20, 30, .10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --card: #1e1e22; --ink: #ececef; --muted: #9a9aa2; --line: #2e2e34;
    --accent: #4fc7b3; --accent-soft: #1b3330;
    --good: #5cc97a; --good-soft: #1b3123; --bad: #ff7b7b; --bad-soft: #3a1f21; --warn: #f0b75a; --warn-soft: #3a2f1c;
    --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; min-height: 100dvh; }
.wrap { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.btn { font: inherit; font-weight: 600; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #08201c; } }
.btn.ghost { background: none; }
.btn.icon { min-height: 40px; min-width: 40px; padding: 0 12px; font-weight: 500; }
.btn:disabled { opacity: .45; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }

.hero { text-align: center; padding: 28px 18px; }
.hero .big { font-size: 44px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero .lbl { color: var(--muted); margin: 4px 0 20px; }

.cat { margin: 10px 0; }
.cat .top { display: flex; justify-content: space-between; font-size: 14px; }
.track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 5px; position: relative; }
.track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 99px; }
.track i.deck { background: var(--accent-soft); }

#bar { position: fixed; left: 0; right: 0; top: 0; height: 3px; background: transparent; z-index: 5; }
#barfill { display: block; height: 100%; width: 0; background: var(--accent); opacity: .55; transition: width 1s linear; }

.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2px 10px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.gray { background: var(--line); color: var(--muted); }
.en { font-size: 26px; font-weight: 600; line-height: 1.25; }
.vi { font-size: 34px; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.resp { font-size: 22px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.resp .t { color: var(--accent); font-weight: 700; }
.note { margin-top: 14px; background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.flagnew { margin-top: 10px; font-size: 12px; color: var(--warn); }
.prompt { color: var(--muted); font-size: 15px; margin-top: 12px; }
.audio { display: flex; gap: 8px; margin-top: 16px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate .btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; font-size: 15px; padding: 6px 4px; }
.rate .btn small { font-weight: 500; color: var(--muted); font-size: 12px; }
.rate .again { color: var(--bad); } .rate .good { color: var(--good); }

.setting { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.setting:last-child { border-bottom: 0; }
.setting select, .setting input[type=number] { font: inherit; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; border: 0; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 9; }
.card.flip { min-height: 240px; display: flex; flex-direction: column; justify-content: center; cursor: pointer; user-select: none; }
.rate.why { grid-template-columns: repeat(3, 1fr); }
