/* Palette: Utah red rock and desert sky. */
:root {
  --bg: #faf5ee;
  --surface: #ffffff;
  --surface-2: #f3ebe0;
  --ink: #2a211b;
  --muted: #7a6a5d;
  --line: #e6dacb;
  --accent: #c4502b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3d8;
  --sky: #2f6f8f;
  --ok: #1f8a4c;
  --ok-soft: #e1f4e8;
  --no: #c0392b;
  --no-soft: #fbe5e2;
  --mark: #ffe8a3;
  --shadow: 0 1px 2px rgb(60 30 10 / 6%), 0 4px 14px rgb(60 30 10 / 6%);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #221b16;
    --surface-2: #2c231d;
    --ink: #f3e9df;
    --muted: #b3a294;
    --line: #3a2f27;
    --accent: #e3714a;
    --accent-ink: #1a0f0a;
    --accent-soft: #3d2419;
    --sky: #7cb8d6;
    --ok: #4cc584;
    --ok-soft: #173525;
    --no: #ff7a6b;
    --no-soft: #3e1d19;
    --mark: #5b4a1c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--sky); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
[tabindex="-1"]:focus { outline: none; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
mark { background: var(--mark); color: inherit; padding: 0 .15em; border-radius: 4px; }
.muted { color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: .7rem 16px;
}
.brand { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.logo { font-size: 1.2rem; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: .85rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--sky); text-decoration: underline; font: inherit; cursor: pointer; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.section-title { margin: 28px 0 12px; }

/* Home */
.hero {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  border-radius: 22px; padding: 22px; margin-bottom: 16px;
}
.hero p { margin: 0; }
.hero-ring { flex: none; }
@media (max-width: 480px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-ring { align-self: center; }
}

.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s ease; }
.ring-num { font-weight: 800; font-size: 22px; fill: var(--ink); }
.ring-label { font-size: 10px; fill: var(--muted); }

.actions { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
@media (max-width: 520px) { .actions { grid-template-columns: 1fr; } }
.action {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.action:hover { transform: translateY(-1px); border-color: var(--accent); }
.action b { display: block; }
.action small { color: var(--muted); }
.action .ai { font-size: 1.6rem; }
.action.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); grid-column: 1 / -1; }
.action.primary small { color: inherit; opacity: .85; }
.action.warn { border-color: var(--no); }

.topics { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.topic {
  display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.topic:hover { border-color: var(--accent); }
.topic .ti { font-size: 1.5rem; width: 2rem; text-align: center; }
.topic .tb { flex: 1; min-width: 0; }
.topic b { display: block; font-size: .98rem; }
.topic small { color: var(--muted); font-size: .82rem; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 6px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.pass, .fail { font-weight: 800; font-size: .75rem; padding: 2px 8px; border-radius: 99px; margin-right: 6px; }
.pass { background: var(--ok-soft); color: var(--ok); }
.fail { background: var(--no-soft); color: var(--no); }
.tips ul, .notes ul { margin: 0; padding-left: 1.2rem; }
.tips li, .notes li { margin: .35rem 0; }

/* Topic page */
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 600; }
.topic-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.topic-head p { margin: 0; }
.big-icon { font-size: 2.4rem; }
.sticky-cta {
  position: sticky; bottom: 0; display: flex; gap: 10px; flex-wrap: wrap;
  padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent);
  border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; min-height: 48px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 0; padding: 6px 12px; font-size: .85rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Quiz */
.quiz-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.quiz-top .back { margin: 0; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 16px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
.q-topic { margin: 0 0 6px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.q-text { font-size: 1.25rem; margin: 0 0 16px; }
.q-sign { display: flex; justify-content: center; margin: 4px 0 14px; }
.q-sign .sign { width: 150px; height: 150px; }
.q-sign.small .sign { width: 80px; height: 80px; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--surface-2); color: var(--ink); border: 2px solid transparent; border-radius: 12px;
  padding: 12px 14px; font: inherit; cursor: pointer; min-height: 52px;
  transition: border-color .1s ease, background .1s ease;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface); font-weight: 800; font-size: .85rem; color: var(--muted);
}
.opt.chosen { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .key { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--no); background: var(--no-soft); }
.opt.wrong .key { background: var(--no); color: #fff; }
.feedback { margin-top: 16px; padding: 14px; border-radius: 12px; animation: pop .25s ease; }
.feedback.ok { background: var(--ok-soft); }
.feedback.ok b { color: var(--ok); }
.feedback.no { background: var(--no-soft); }
.feedback.no b { color: var(--no); }
.ref { display: block; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.quiz-nav { justify-content: space-between; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Results */
.results { text-align: center; position: relative; overflow: hidden; }
.results .ring { width: 130px; height: 130px; }
.results.passed { border-color: var(--ok); }
.review .q-text { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.review p { margin: 4px 0; }
.review .your { color: var(--no); }
.review .right { color: var(--ok); }
.done { text-align: center; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

/* Flashcards */
.flash {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
  width: 100%; min-height: 240px; margin: 12px 0 16px; padding: 24px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); font: inherit; cursor: pointer; text-align: center;
}
.flash.flipped { border-color: var(--accent); background: var(--accent-soft); }
.flash-topic { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.flash-front { font-size: 1.3rem; font-weight: 700; }
.flash-back { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.cheat { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cheat td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.cheat tr:first-child td { border-top: 0; }
.cheat td:last-child { text-align: right; }

/* Signs */
.sign-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 8px; }
.sign-tile { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px 10px; text-align: center; }
.sign-tile .sign { width: 96px; height: 96px; }
.sign-tile figcaption { font-size: .88rem; font-weight: 600; margin-top: 6px; }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }

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