:root {
  --bg: #f3f4fb;
  --bg-accent-1: rgb(99 102 241 / 16%);
  --bg-accent-2: rgb(236 72 153 / 10%);
  --surface: rgb(255 255 255 / 86%);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgb(15 23 42 / 8%);
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef0ff;
  --primary-ink: #ffffff;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%);
  --ok: #059669;
  --ok-bg: #e7f8f1;
  --bad: #e11d48;
  --bad-bg: #fff0f3;
  --info-bg: #eef2ff;
  --warn-bg: #fff7e6;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 8px 24px -12px rgb(15 23 42 / 18%);
  --shadow-lg: 0 20px 40px -18px rgb(79 70 229 / 45%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d1a;
    --bg-accent-1: rgb(99 102 241 / 22%);
    --bg-accent-2: rgb(192 38 211 / 14%);
    --surface: rgb(22 28 46 / 82%);
    --surface-solid: #161c2e;
    --text: #eef2ff;
    --muted: #94a3b8;
    --border: rgb(255 255 255 / 8%);
    --primary: #818cf8;
    --primary-2: #a78bfa;
    --primary-soft: rgb(129 140 248 / 14%);
    --ok: #34d399;
    --ok-bg: rgb(52 211 153 / 12%);
    --bad: #fb7185;
    --bad-bg: rgb(251 113 133 / 12%);
    --info-bg: rgb(129 140 248 / 12%);
    --warn-bg: rgb(251 191 36 / 12%);
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -14px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 500px at -10% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(700px 500px at 110% 10%, var(--bg-accent-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1, h2 { margin: 0; line-height: 1.25; letter-spacing: -.02em; }
h1 { font-size: 1.45rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
a { color: var(--primary); }
.muted { color: var(--muted); font-size: .88rem; }

.ico { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.ico svg, .brand svg { width: 100%; height: 100%; }
.brand { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }

.card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

/* ---------- Home ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 22px 22px;
  border-radius: 28px;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--shadow-lg);
  isolation: isolate;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: -1;
  filter: blur(2px);
}
.hero::before { width: 260px; height: 260px; right: -80px; top: -90px; background: rgb(255 255 255 / 14%); }
.hero::after { width: 180px; height: 180px; left: -60px; bottom: -90px; background: rgb(255 255 255 / 10%); }
.hero-kicker {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
  background: rgb(255 255 255 / 18%);
  margin-bottom: 12px;
}
.hero h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
.hero p { margin: 8px 0 0; opacity: .9; max-width: 34em; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-cta .btn { flex: 1 1 150px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: 16px;
  background: rgb(255 255 255 / 14%);
  border: 1px solid rgb(255 255 255 / 18%);
}
.stat .ico { opacity: .85; width: 1.1em; height: 1.1em; }
.stat strong { font-size: 1.3rem; font-weight: 800; line-height: 1.2; }
.stat span { font-size: .78rem; opacity: .85; }

.section-title { font-size: .95rem; color: var(--muted); font-weight: 600; margin: 4px 4px -6px; }

.modes { display: grid; gap: 12px; }
@media (min-width: 640px) { .modes { grid-template-columns: 1fr 1fr; } }

.mode-card {
  --tone: var(--primary);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  min-height: 82px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.mode-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.mode-card:active { transform: scale(.98); }
.mode-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  color: #fff;
  font-size: 1.35rem;
  background: var(--tone);
  box-shadow: 0 8px 18px -8px var(--tone);
}
.tone-blue { --tone: linear-gradient(135deg, #3b82f6, #6366f1); }
.tone-violet { --tone: linear-gradient(135deg, #8b5cf6, #d946ef); }
.tone-amber { --tone: linear-gradient(135deg, #f59e0b, #f97316); }
.tone-rose { --tone: linear-gradient(135deg, #f43f5e, #ec4899); }
.tone-green { --tone: linear-gradient(135deg, #10b981, #14b8a6); }
.tone-blue .mode-icon, .tone-violet .mode-icon, .tone-amber .mode-icon,
.tone-rose .mode-icon, .tone-green .mode-icon { box-shadow: 0 8px 18px -10px rgb(15 23 42 / 50%); }
.mode-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mode-body strong { font-weight: 700; }
.mode-body span { color: var(--muted); font-size: .88rem; }
.chev { color: var(--muted); display: inline-flex; }

.history { list-style: none; margin: 10px 0 0; padding: 0; }
.history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: .92rem;
}
.score-pill { padding: 3px 10px; border-radius: 99px; font-size: .85rem; }
.score-pill.pass { background: var(--ok-bg); }
.score-pill.fail { background: var(--bad-bg); }
.pass { color: var(--ok); }
.fail { color: var(--bad); }
.footnote { color: var(--muted); font-size: .8rem; margin: 0 4px; text-align: center; }

/* ---------- Install card ---------- */
.install-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed color-mix(in srgb, var(--primary) 45%, transparent);
  box-shadow: var(--shadow);
}
.install-card img { border-radius: 12px; flex: none; }
.install-body { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: .86rem; color: var(--muted); }
.install-body strong { color: var(--text); font-size: .95rem; }
.install-card .btn { flex: none; }

/* ---------- Showcase banner ---------- */
.showcase {
  position: relative;
  padding: 18px 18px 30px;
  border-radius: 24px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgb(249 115 22 / 55%), transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgb(239 68 68 / 35%), transparent 60%),
    linear-gradient(135deg, #0b1220, #1e293b);
  box-shadow: 0 18px 36px -18px rgb(249 115 22 / 55%);
  isolation: isolate;
}
.showcase::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(115deg, transparent 0 22px, rgb(255 255 255 / 3%) 22px 44px);
}
.showcase-track { display: grid; }
.showcase-slide {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(12px);
  transition: opacity .45s ease, transform .45s ease, visibility .45s;
}
.showcase-slide.active { opacity: 1; visibility: visible; transform: none; }
.showcase-slide.text-only .showcase-body { flex: 1; }
.showcase-slide.text-only { justify-content: center; }
.showcase-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.showcase-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: rgb(255 255 255 / 35%);
  cursor: pointer;
  transition: width .3s, background .3s;
}
.showcase-dot[aria-current="true"] { width: 22px; background: #fb923c; }
.showcase-art {
  flex: none;
  width: 120px;
  height: 120px;
  border-radius: 20px;
  overflow: hidden;
  background: #1e293b;
  box-shadow: 0 0 0 2px rgb(251 146 60 / 70%), 0 10px 24px -10px rgb(0 0 0 / 60%);
}
.showcase-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 60% 30%; }
.showcase-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.showcase-name {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fdba74;
}
.showcase-title { font-size: 1.15rem; font-weight: 800; line-height: 1.3; }
.showcase-text { margin: 0; font-size: .88rem; color: rgb(255 255 255 / 75%); }
.showcase-info { display: flex; flex-direction: column; font-size: .9rem; color: rgb(255 255 255 / 85%); }
.showcase-tel { color: #fdba74; font-weight: 700; text-decoration: none; }
.visa-groups { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.visa-row { display: flex; flex-wrap: wrap; gap: 5px; }
.visa {
  padding: 2px 9px;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgb(255 255 255 / 12%);
  border: 1px solid rgb(255 255 255 / 16%);
}
.showcase-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.showcase-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  transition: transform .15s, filter .15s;
}
.showcase-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.showcase-btn.facebook { background: #1877f2; }
.showcase-btn.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); }
.showcase.compact { padding: 14px 14px 26px; border-radius: 20px; }
.showcase.compact .showcase-slide { gap: 12px; }
.showcase.compact .visa-groups { flex-direction: row; flex-wrap: wrap; gap: 4px; }
.showcase.compact .visa-row { display: contents; }
.showcase.compact .showcase-text { font-size: .8rem; }
.showcase.compact .visa { font-size: .72rem; padding: 1px 7px; }
.showcase.compact .showcase-info { font-size: .82rem; }
.showcase.compact .showcase-art { width: 76px; height: 76px; border-radius: 16px; }
.showcase.compact .showcase-title { font-size: .98rem; }
.showcase.compact .showcase-btn { min-height: 36px; padding: 0 12px; font-size: .82rem; }
@media (max-width: 480px) {
  .showcase:not(.compact) .showcase-slide { flex-direction: column; align-items: stretch; }
  .showcase:not(.compact) .showcase-slide.text-only .showcase-body { flex: none; }
  .showcase:not(.compact) .showcase-art { width: 100%; height: 220px; }
}

/* ---------- Study header + toolbar ---------- */
.screen-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.screen-head h1 { flex: 1; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  font-weight: 600;
  font-size: .92rem;
  text-decoration: none;
}
.chip {
  font-size: .8rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
  color: var(--primary);
  background: var(--primary-soft);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar select, .jump {
  font: inherit;
  font-size: .92rem;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}
.toolbar select:focus, .jump:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.toolbar select { flex: 1 1 150px; }
.jump-form { display: flex; gap: 6px; }
.jump { width: 84px; }

.progress { height: 8px; background: var(--primary-soft); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--grad); border-radius: 99px; transition: width .3s ease; }

/* ---------- Question card ---------- */
.question { padding: 20px 18px; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.q-num {
  flex: 1;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge {
  font-size: .74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  color: #b45309;
  background: var(--warn-bg);
}
@media (prefers-color-scheme: dark) { .badge { color: #fbbf24; } }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn.on { color: #f59e0b; background: var(--warn-bg); }
.icon-btn.on svg { fill: currentColor; }
.q-text { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; line-height: 1.45; }
.q-img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}
.conditions {
  margin: 0 0 14px;
  padding: 12px 14px 12px 32px;
  background: var(--info-bg);
  border-radius: 14px;
  font-size: .92rem;
}
.conditions li::marker { color: var(--primary); }
.notice {
  background: var(--warn-bg);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: .9rem;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  font-size: .97rem;
  color: var(--text);
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.option:not(:disabled):hover { border-color: var(--primary); box-shadow: 0 4px 14px -8px var(--primary); }
.option:not(:disabled):active { transform: scale(.985); }
.option:disabled { cursor: default; }
.opt-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--primary-soft);
  transition: background .15s, color .15s;
}
.opt-text { flex: 1; line-height: 1.45; }
.opt-mark { font-weight: 800; font-size: 1.1rem; }
.option.selected { background: var(--primary-soft); border-color: var(--primary); }
.option.selected .opt-num { background: var(--grad); color: #fff; }
.option.correct { background: var(--ok-bg); border-color: var(--ok); }
.option.correct .opt-num { background: var(--ok); color: #fff; }
.option.correct .opt-mark { color: var(--ok); }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); animation: shake .3s; }
.option.wrong .opt-num { background: var(--bad); color: #fff; }
.option.wrong .opt-mark { color: var(--bad); }
.option.dim { opacity: .55; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.feedback {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: .98rem;
  animation: pop .22s ease-out;
}
.feedback.ok { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1.5px var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.feedback.info { background: var(--info-bg); color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* ---------- Buttons ---------- */
.nav-row { display: flex; gap: 10px; }
.nav-row > * { flex: 1; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, filter .15s, box-shadow .15s;
}
.btn:not(:disabled):active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--primary-ink); box-shadow: var(--shadow-lg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; box-shadow: none; border: 1.5px dashed var(--border); color: var(--muted); }
.btn.danger { color: var(--bad); background: transparent; box-shadow: none; border: 1.5px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.block { width: 100%; }
.btn.small { min-height: 42px; font-size: .88rem; }
.btn.active { color: var(--primary); border-color: var(--primary); }
.btn.light { background: #fff; color: #4f46e5; border-color: transparent; }
.btn.glass { background: rgb(255 255 255 / 16%); color: #fff; border: 1px solid rgb(255 255 255 / 30%); box-shadow: none; }

/* ---------- Exam ---------- */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -16px -16px 0;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.exam-bar strong { flex: 1; }
.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 99px;
  color: #fff;
  background: var(--grad);
}
.timer .ico { width: 1.05em; height: 1.05em; }
.timer.urgent { background: var(--bad); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .6; } }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.cell {
  height: 44px;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s;
}
.cell.done { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.cell.current { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- Result ---------- */
.result { text-align: center; display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.result p { margin: 0; color: var(--muted); }
.score-ring {
  --c: var(--ok);
  align-self: center;
  display: grid;
  place-items: center;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--primary-soft) 0);
  animation: pop .5s ease-out;
}
.score-ring.fail { --c: var(--bad); }
.score-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: var(--surface-solid);
}
.score-num { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.score-ring.pass .score-num { color: var(--ok); }
.score-ring.fail .score-num { color: var(--bad); }
.score-unit { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.result-title { font-size: 1.3rem; }
.pass-row { display: grid; gap: 8px; }
@media (min-width: 520px) { .pass-row { grid-template-columns: 1fr 1fr; } }
.pass-badge { padding: 10px; border-radius: 14px; font-weight: 600; font-size: .88rem; }
.pass-badge.pass { background: var(--ok-bg); }
.pass-badge.fail { background: var(--bad-bg); }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
