:root {
  --navy: #0d3b66;
  --navy-dark: #082b4c;
  --blue: #1670c9;
  --sky: #e9f4ff;
  --paper: #f8fbff;
  --ink: #162536;
  --muted: #657587;
  --line: #d9e3ee;
  --green: #167a51;
  --green-bg: #e7f7ee;
  --red: #ba3f4a;
  --red-bg: #fff0f1;
  --amber: #b27311;
  --shadow: 0 12px 34px rgba(21, 56, 88, 0.11);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef5fb;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eef5fb; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(13px, env(safe-area-inset-top)) clamp(20px, 5vw, 64px) 13px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 2px 10px rgba(7, 40, 70, .14);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #fff; color: var(--navy); font-size: 18px; }
.progress-button { border: 0; border-radius: 999px; background: rgba(255,255,255,.14); color: #fff; padding: 8px 11px; cursor: pointer; font-weight: 700; font-size: 13px; }

main { width: min(100%, 1130px); margin: 0 auto; padding: clamp(24px, 5vw, 54px) clamp(18px, 4vw, 44px); }
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(230px, .75fr); gap: clamp(22px, 5vw, 64px); align-items: center; margin-bottom: 36px; }
.eyebrow { margin: 0 0 9px; color: var(--blue); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; max-width: 720px; color: var(--navy-dark); font-size: clamp(32px, 5vw, 54px); line-height: 1.03; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; color: var(--navy-dark); font-size: clamp(24px, 3vw, 31px); line-height: 1.1; letter-spacing: -.035em; }
h3 { margin-bottom: 6px; font-size: 17px; }
.lead { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: clamp(16px, 2vw, 19px); line-height: 1.55; }
.hero-stat { position: relative; overflow: hidden; padding: 24px; border-radius: 24px; color: white; background: linear-gradient(145deg, #126bbd, #0d3b66); box-shadow: var(--shadow); }
.hero-stat::after { content: ""; position: absolute; width: 170px; height: 170px; border-radius: 50%; right: -61px; bottom: -90px; background: rgba(255,255,255,.12); }
.hero-stat strong { display: block; position: relative; font-size: 46px; line-height: 1; letter-spacing: -.06em; }
.hero-stat span { position: relative; display: block; margin-top: 9px; max-width: 170px; opacity: .9; line-height: 1.35; font-size: 14px; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 32px 0 13px; }
.section-heading p { margin-bottom: 1px; color: var(--muted); font-size: 14px; }
.topic-category + .topic-category { margin-top: 28px; }
.category-heading { margin: 0 0 13px; }
.category-heading h3 { margin-bottom: 3px; color: var(--navy-dark); font-size: 18px; }
.category-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.topic-card, .panel, .question-card, .summary-card, .review-card { background: #fff; border: 1px solid rgba(210, 225, 238, .95); border-radius: 20px; box-shadow: 0 5px 20px rgba(20, 54, 84, .045); }
.topic-card { position: relative; min-height: 176px; display: flex; flex-direction: column; align-items: flex-start; overflow: hidden; padding: 20px; color: inherit; text-align: left; cursor: pointer; }
.topic-card:hover, .topic-card:focus-visible { border-color: #9dc8ee; transform: translateY(-2px); box-shadow: var(--shadow); }
.topic-card:focus-visible, .option:focus-visible, .button:focus-visible, .chip:focus-visible, .nav-item:focus-visible { outline: 3px solid #83c7fa; outline-offset: 2px; }
.topic-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; margin-bottom: 17px; background: var(--sky); color: var(--blue); font-size: 21px; font-weight: 800; }
.topic-card h3 { color: var(--navy-dark); }
.topic-card p { margin-bottom: 11px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.folder-label { margin: -3px 0 8px; color: #688099; font-size: 11px; font-weight: 700; }
.topic-meta { margin-top: auto; color: var(--blue); font-weight: 800; font-size: 13px; }
.topic-card.pending { opacity: .7; cursor: default; background: #f5f8fb; }
.topic-card.pending:hover { transform: none; border-color: rgba(210,225,238,.95); box-shadow: 0 5px 20px rgba(20,54,84,.045); }

.panel { padding: clamp(19px, 4vw, 29px); }
.setup-grid { display: grid; grid-template-columns: 1.4fr .6fr; gap: 26px; }
.field-label { display: block; margin: 0 0 10px; color: var(--navy-dark); font-size: 14px; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { appearance: none; border: 1px solid var(--line); border-radius: 999px; padding: 10px 13px; background: #fff; color: #3e5165; cursor: pointer; font-weight: 700; font-size: 13px; transition: .15s ease; }
.chip.selected { color: #fff; background: var(--navy); border-color: var(--navy); }
.chip:disabled { cursor: not-allowed; opacity: .55; }
.difficulty-chip { display: inline-flex; align-items: center; gap: 7px; }
.difficulty-chip small { color: inherit; opacity: .72; font-size: 11px; font-weight: 700; }
.difficulty-chip.easy:not(.selected) { color: #19734f; border-color: #a5d9bf; background: #f2fbf6; }
.difficulty-chip.medium:not(.selected) { color: #946000; border-color: #f0d08d; background: #fff9ec; }
.difficulty-chip.hard:not(.selected) { color: #8d3943; border-color: #e6b3b9; background: #fff4f5; }
.start-area { display: flex; flex-direction: column; align-items: stretch; justify-content: end; gap: 8px; }
.helper { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.button { appearance: none; display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 14px; padding: 12px 17px; cursor: pointer; color: #fff; background: var(--navy); box-shadow: 0 7px 15px rgba(10, 52, 90, .17); font-weight: 800; text-decoration: none; }
.button:hover { background: #104a7d; }
.button.secondary { color: var(--navy); background: #fff; border-color: #bdd5ea; box-shadow: none; }
.button.secondary:hover { background: var(--sky); }
.button.ghost { color: var(--blue); background: transparent; box-shadow: none; }
.button.danger { color: var(--red); background: var(--red-bg); box-shadow: none; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.bottom-nav { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: clamp(2px, 4vw, 56px); min-height: calc(66px + env(safe-area-inset-bottom)); padding: 7px 12px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid #d9e4ed; background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.nav-item { display: flex; flex: 0 1 88px; flex-direction: column; align-items: center; justify-content: center; min-width: 60px; gap: 3px; border: 0; background: transparent; color: #708094; cursor: pointer; font-size: 11px; font-weight: 700; }
.nav-item span:first-child { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--navy); }

.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 14px; }
.quiz-header .eyebrow { margin-bottom: 4px; }
.quiz-title { margin: 0; color: var(--navy-dark); font-size: 20px; }
.counter { flex: none; color: var(--muted); font-size: 14px; font-weight: 800; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; margin-bottom: 24px; background: #dce8f2; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1c84d7, #0d3b66); transition: width .25s ease; }
.question-card { padding: clamp(21px, 5vw, 42px); }
.question-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.question-source { display: inline-flex; margin-bottom: 16px; padding: 7px 10px; border-radius: 8px; color: #536981; background: #eef5fa; font-size: 12px; font-weight: 800; }
.question-meta .question-source { margin-bottom: 0; }
.difficulty-badge { display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 8px; color: #4c6479; background: #edf3f8; font-size: 12px; font-weight: 900; }
.difficulty-badge.easy { color: #146544; background: var(--green-bg); }
.difficulty-badge.medium { color: #8c5a02; background: #fff4d7; }
.difficulty-badge.hard { color: #9d3440; background: var(--red-bg); }
.question-text { margin-bottom: 25px; color: var(--navy-dark); font-size: clamp(23px, 3.4vw, 34px); line-height: 1.16; letter-spacing: -.035em; }
.options { display: grid; gap: 11px; }
.option { position: relative; width: 100%; min-height: 62px; display: flex; align-items: center; gap: 14px; padding: 12px 15px; border: 1px solid #cfdeea; border-radius: 15px; color: #23384b; background: #fff; text-align: left; cursor: pointer; font-weight: 650; line-height: 1.35; transition: .15s ease; }
.option:not(:disabled):hover { border-color: #71b5e9; background: #f4faff; }
.option:disabled { cursor: default; }
.option-letter { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: #5a6c7e; background: #edf3f8; font-size: 12px; font-weight: 900; }
.option.is-correct { border-color: #7acba7; color: #155d3f; background: var(--green-bg); }
.option.is-correct .option-letter { color: #fff; background: var(--green); }
.option.is-wrong { border-color: #efb6bb; color: #9b303a; background: var(--red-bg); }
.option.is-wrong .option-letter { color: #fff; background: var(--red); }
.feedback { margin-top: 20px; padding: 17px; border-radius: 14px; background: #f2f7fb; border-left: 4px solid var(--blue); }
.feedback.good { border-left-color: var(--green); background: var(--green-bg); }
.feedback.bad { border-left-color: var(--red); background: var(--red-bg); }
.feedback strong { display: block; margin-bottom: 5px; color: var(--navy-dark); }
.feedback p { margin: 0; line-height: 1.45; color: #42566a; }
.quiz-actions { display: flex; justify-content: space-between; gap: 13px; margin-top: 20px; }

.summary { max-width: 680px; margin: 0 auto; text-align: center; }
.summary-card { padding: clamp(28px, 7vw, 50px); }
.score-orb { display: grid; place-items: center; width: 142px; height: 142px; margin: 8px auto 22px; border: 12px solid #dcebf7; border-radius: 50%; color: var(--navy); background: #f8fcff; font-size: 37px; font-weight: 900; letter-spacing: -.06em; }
.summary-card p { color: var(--muted); line-height: 1.5; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.mistakes { margin-top: 21px; text-align: left; }
.mistake { padding: 13px 0; border-top: 1px solid var(--line); color: #4e6276; font-size: 14px; line-height: 1.4; }
.mistake strong { display: block; margin-bottom: 3px; color: var(--navy-dark); }
.continue-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 0 34px; padding: 20px 22px; border: 1px solid #bcd8ef; border-radius: 19px; color: #284357; background: linear-gradient(120deg, #eef8ff, #fff); }
.continue-card .eyebrow { margin-bottom: 5px; }
.continue-card h2 { margin-bottom: 5px; font-size: 21px; }
.continue-card p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 14px; }
.continue-page { max-width: 840px; margin: 0 auto; }
.continue-session { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 19px; margin-top: 25px; padding: clamp(20px, 4vw, 30px); border: 1px solid #bcd8ef; border-radius: 21px; background: #fff; box-shadow: var(--shadow); }
.continue-session .topic-icon { margin: 0; }
.continue-session h2 { margin-bottom: 5px; font-size: 22px; }
.continue-session p { margin: 0; color: var(--muted); line-height: 1.45; }
.continue-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.saved-review { margin-top: 22px; }
.saved-review h2 { font-size: 22px; }
.saved-review p { margin: 0 0 16px; color: var(--muted); line-height: 1.45; }

.review-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.review-card { padding: 20px; }
.review-card .topic-icon { margin-bottom: 13px; }
.fact-list { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; }
.fact-list li { padding-top: 9px; border-top: 1px solid #e6edf3; color: #506376; font-size: 13px; line-height: 1.36; }
.source-list { display: grid; gap: 13px; }
.source-item { display: flex; align-items: flex-start; gap: 13px; padding: 17px; border-radius: 15px; background: #fff; border: 1px solid var(--line); }
.source-item strong { display: block; color: var(--navy-dark); }
.source-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.source-badge { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--sky); color: var(--blue); font-size: 12px; font-weight: 900; }
.notice { margin-top: 22px; padding: 16px 18px; border-radius: 15px; color: #5e4b20; background: #fff6dc; font-size: 14px; line-height: 1.45; }
.progress-panel { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 17px; }
.progress-ring { display: grid; place-items: center; width: 62px; height: 62px; border: 7px solid #dbeaf6; border-radius: 50%; color: var(--navy); font-size: 15px; font-weight: 900; }
.progress-panel h2 { margin-bottom: 4px; font-size: 21px; }.progress-panel p { margin: 0; color: var(--muted); font-size: 14px; }
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); max-width: calc(100vw - 34px); transform: translate(-50%, 20px); padding: 11px 15px; border-radius: 999px; color: white; background: #203b55; box-shadow: 0 8px 22px rgba(0,0,0,.16); opacity: 0; pointer-events: none; font-size: 13px; font-weight: 700; transition: .18s ease; }.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 720px) { .hero, .setup-grid { grid-template-columns: 1fr; }.hero-stat { display: none; }.topic-grid, .review-grid { grid-template-columns: 1fr; }.topic-card { min-height: 145px; }.topic-card p { max-width: 85%; }.start-area { align-items: stretch; }.quiz-actions .button { flex: 1; }.progress-panel { grid-template-columns: auto 1fr; }.progress-panel .button { grid-column: 1 / -1; }.section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }.continue-card, .continue-session { align-items: stretch; grid-template-columns: 1fr; }.continue-card { flex-direction: column; }.continue-session .topic-icon { display: none; }.continue-actions { flex-direction: row; flex-wrap: wrap; }.continue-actions .button { flex: 1 1 180px; } }
@media (min-width: 721px) and (max-width: 950px) { .topic-grid, .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 400px) { .topbar { padding-left: 16px; padding-right: 16px; }.brand { font-size: 14px; }.brand-mark { width: 29px; height: 29px; }.progress-button { padding: 7px 8px; } main { padding-left: 15px; padding-right: 15px; }.chip { padding: 9px 11px; }.question-card { padding: 18px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
