:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --ink: #1d2623;
  --muted: #66716c;
  --line: #e4ded2;
  --brand: #1f6f5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ec;
  --good: #1d7a46;
  --good-soft: #e2f4e8;
  --bad: #b23b2e;
  --bad-soft: #fbe7e3;
  --warn: #9a6200;
  --warn-soft: #fff3d6;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 14px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --card: #1b2120;
    --ink: #e9eeec;
    --muted: #9aa5a0;
    --line: #2b3331;
    --brand: #4fb39a;
    --brand-ink: #08201a;
    --brand-soft: #1d3530;
    --good: #5fcf8d;
    --good-soft: #17301f;
    --bad: #ff8a7a;
    --bad-soft: #3a1d19;
    --warn: #f0b34a;
    --warn-soft: #382c12;
    --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.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { border-radius: 8px; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 4px 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.pad { padding: 32px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 14px;
}
.card.hero { background: var(--brand); color: var(--brand-ink); border: 0; }
.card.hero .muted { color: inherit; opacity: .85; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  background: var(--brand); color: var(--brand-ink); font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.light { background: var(--card); color: var(--brand); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .9rem; }

label { display: block; font-weight: 600; margin: 0 0 6px; }
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.field + .field { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.switch input { width: 24px; min-height: 24px; height: 24px; accent-color: var(--brand); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 650; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.neutral { background: var(--brand-soft); color: var(--brand); }

.result { border-top: 1px solid var(--line); padding: 12px 0; }
.result:first-of-type { border-top: 0; padding-top: 0; }
.score { font-size: 1.35rem; font-weight: 800; min-width: 64px; }
.score.good { color: var(--good); }
.score.bad { color: var(--bad); }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; margin-top: 6px; }
.wrong { background: var(--bad-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; font-size: .92rem; }
.wrong b { color: var(--good); }
.wrong s { color: var(--bad); }

.code {
  font-size: 2.6rem; font-weight: 800; letter-spacing: .18em; text-align: center;
  font-variant-numeric: tabular-nums; padding: 8px 0; user-select: all;
}

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; min-height: 60px; font-size: .75rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabs .ico { font-size: 1.25rem; line-height: 1; }
.tabs button.on { color: var(--brand); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); z-index: 10; box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}

.steps { counter-reset: s; padding-left: 0; list-style: none; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 36px; margin: 10px 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.notice { background: var(--warn-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.minsel { width: auto; flex: 1; }
a { color: var(--brand); font-weight: 600; }
.given { white-space: pre-wrap; background: var(--card); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
[hidden] { display: none !important; }

/* Hoạt động */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); font-weight: 650; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.visit { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.visit:first-of-type { border-top: 0; }
.visit b { color: var(--brand); min-width: 44px; font-size: .85rem; }
.visit .t { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
