:root {
  --bg: #f5f7f7;
  --card: #ffffff;
  --text: #1c2526;
  --muted: #5f6b6d;
  --line: #dde3e4;
  --brand: #0f6e6e;
  --brand-soft: #e1f0ef;
  --good: #1f7a3a;
  --good-soft: #e3f3e7;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --warn: #8a5a00;
  --radius: 14px;
  --on-brand: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111617;
    --card: #1b2223;
    --text: #e6eced;
    --muted: #9aa7a9;
    --line: #2c3637;
    --brand: #4fb8b3;
    --brand-soft: #1d3332;
    --good: #6cc785;
    --good-soft: #1b3123;
    --bad: #f08a80;
    --bad-soft: #3a1f1c;
    --warn: #e2b55a;
    --on-brand: #062b2a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, select, input { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #0f6e6e; color: #fff;
}
.top h1 { font-size: 1.1rem; margin: 0; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: inherit; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; border: 0; padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; font-size: .78rem; color: var(--muted);
}
.tabs button span { font-size: 1.3rem; line-height: 1.2; }
.tabs button.active { color: var(--brand); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { flex: 1 1 220px; min-width: 0; }
select, input[type=text] {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: .9rem;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.item .en { font-size: 1.08rem; font-weight: 600; }
.item .ipa, .ipa { font-family: "Segoe UI", "Lucida Sans Unicode", "Arial Unicode MS", sans-serif; color: var(--brand); }
.item .vi { color: var(--muted); }
.item .vi.hidden { filter: blur(5px); cursor: pointer; user-select: none; }
.item .head { display: flex; gap: 8px; align-items: baseline; }
.num { color: var(--muted); font-size: .8rem; min-width: 2.2em; }
.actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  background: var(--brand); color: var(--on-brand); font-weight: 600;
}
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.rec { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.result { margin-top: 8px; font-size: .95rem; }
.result .w-ok { color: var(--good); }
.result .w-bad { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 3px; }
.score { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.score.good { background: var(--good-soft); color: var(--good); }
.score.bad { background: var(--bad-soft); color: var(--bad); }
.heard { color: var(--muted); font-size: .85rem; }
.badge { font-size: .75rem; color: var(--muted); margin-left: auto; white-space: nowrap; }

.big { text-align: center; padding: 22px 14px; }
.big .en { font-size: 1.35rem; font-weight: 700; }
.big .vi { font-size: 1.1rem; }
.big .actions { justify-content: center; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 12px; }
.progress > div { height: 100%; background: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
h2 { font-size: 1.1rem; margin: 6px 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 8px; }

.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-bottom: 14px; }
.sym {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 0;
  font-size: 1.25rem; cursor: pointer; text-align: center;
}
.sym.active { border-color: var(--brand); background: var(--brand-soft); }
.sym small { display: block; font-size: .7rem; color: var(--muted); }
.ex-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ex-row:first-of-type { border-top: 0; }
.ex-row .w { font-weight: 600; min-width: 5.5em; }
.tip { background: var(--brand-soft); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.tip.warn { background: var(--bad-soft); }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }
.choice {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 8px;
  font-size: 1.1rem; cursor: pointer;
}
.choice.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.6rem; color: var(--brand); }

dialog { border: 0; border-radius: var(--radius); background: var(--card); color: var(--text); width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
dialog label.row { flex-direction: row; }
.search-box { width: 100%; font-size: 1.05rem; margin-bottom: 10px; }
.sec-label { font-size: .75rem; color: var(--muted); }
mark { background: #ffe58a; color: #1c2526; border-radius: 3px; padding: 0 1px; }
.notice { background: var(--bad-soft); color: var(--bad); padding: 8px 10px; border-radius: 10px; margin-bottom: 10px; font-size: .9rem; }
