:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #13202e;
  --muted: #5b6b7d;
  --border: #dde3ea;
  --brand: #0f2a44;
  --accent: #0e8a7e;
  --accent-soft: #e1f3f0;
  --warn: #b4501f;
  --warn-soft: #fbece4;
  --gold: #c48a12;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 42, 68, .06), 0 4px 14px rgba(15, 42, 68, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141c;
    --surface: #152030;
    --surface-2: #1b2a3d;
    --text: #e7edf3;
    --muted: #9aaabb;
    --border: #26364a;
    --brand: #0a1d30;
    --accent: #3cc1b2;
    --accent-soft: #143430;
    --warn: #f0935f;
    --warn-soft: #3a2217;
    --gold: #e7b84a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.logo {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 800;
}
.brand-name { font-size: 18px; }
.unlock-btn {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.unlock-btn[hidden] { display: none; }

.view { max-width: 720px; margin: 0 auto; padding: 16px; outline: none; }
h1 { font-size: 24px; line-height: 1.25; margin: 4px 0 6px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.search {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; margin-bottom: 12px;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 14px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.list { display: grid; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card-main { flex: 1; min-width: 0; }
.card-q { font-weight: 600; }
.card-cat { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge { flex: none; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.free { background: var(--accent-soft); color: var(--accent); }
.badge.lock { background: var(--surface-2); color: var(--muted); }
.star-mark { color: var(--gold); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.back { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; margin-bottom: 8px; }
.detail-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.fav-btn {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 14px;
}
.fav-btn.on { color: var(--gold); border-color: var(--gold); }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; box-shadow: var(--shadow); }
.section h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.section ul { margin: 0; padding-left: 20px; }
.section li { margin: 4px 0; }
.section.good h2 { color: var(--accent); }
.section.bad h2 { color: var(--warn); }
.section.example { background: var(--accent-soft); border-color: transparent; }
.section.example p { margin: 0; }
.notes {
  width: 100%; min-height: 110px; resize: vertical; padding: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.saved-hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

.locked-box { text-align: center; padding: 28px 16px; }
.locked-box p { color: var(--muted); }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.outline { background: var(--surface); border: 1px solid var(--border); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.practice-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px 18px; box-shadow: var(--shadow); text-align: center; }
.practice-q { font-size: 22px; font-weight: 700; line-height: 1.3; margin: 8px 0 18px; }
.timer { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0; }
.timer.low { color: var(--warn); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.practice-actions { display: grid; gap: 10px; margin-top: 14px; }
.reveal { text-align: left; }

.guide-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.guide-card ul { margin: 0; padding-left: 20px; }
.guide-card li { margin: 5px 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { border: 0; background: none; padding: 8px 4px 10px; font-size: 12px; color: var(--muted); display: grid; justify-items: center; gap: 2px; }
.tab-icon { font-size: 18px; line-height: 1.2; }
.tab.active { color: var(--accent); font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(5, 12, 20, .55); display: grid; place-items: end center; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px; padding: 22px 20px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
@media (min-width: 600px) { .modal-backdrop { place-items: center; } }
.modal h2 { font-size: 22px; }
.modal-lead { color: var(--muted); margin: 0 0 12px; }
.modal-list { padding-left: 20px; margin: 0 0 16px; }
.modal-list li { margin: 5px 0; }
.price { margin: 0 0 14px; }
.price-amount { font-size: 30px; font-weight: 800; }
.price-note { color: var(--muted); }
.demo-note { font-size: 12px; color: var(--muted); margin: 10px 0 2px; text-align: center; }
