:root {
  color-scheme: light;
  --ink: #202b27;
  --muted: #6e7973;
  --paper: #f5f6f2;
  --surface: #fff;
  --line: #dfe4de;
  --green: #245e49;
  --green-dark: #184735;
  --mint: #e6efe8;
  --coral: #c75c43;
  --gold: #b78228;
  --font-body: "Aptos", "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: var(--font-body); }
button, input { font: inherit; }
.topbar { min-height: 64px; border-bottom: 1px solid var(--line); background: rgb(245 246 242 / 94%); backdrop-filter: blur(12px); }
.topbar > .container-fluid { min-height: 64px; }
.topbar-spacer { flex: 1; }
.brand { color: var(--ink); font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px 9px 9px 2px; color: #fff; background: var(--green); font: 700 1rem var(--font-display); }
.btn-icon { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 1px solid var(--line); background: var(--surface); }
.menu-mark { display: grid; gap: 4px; width: 17px; }
.menu-mark i { display: block; height: 2px; border-radius: 2px; background: var(--ink); }
.menu-mark i:last-child { width: 11px; }
.points-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); font-size: .85rem; }
.points-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.points-label { color: var(--muted); }
.badge-dot { width: 9px; height: 9px; border-radius: 50%; background: #858b8c; }
.badge-bronze.badge-dot, .badge-rank.badge-bronze { --badge-color: #a76239; }
.badge-silver.badge-dot, .badge-rank.badge-silver { --badge-color: #73818b; }
.badge-gold.badge-dot, .badge-rank.badge-gold { --badge-color: #b78228; }
.badge-diamond.badge-dot, .badge-rank.badge-diamond { --badge-color: #31878a; }
.badge-bronze.badge-dot, .badge-silver.badge-dot, .badge-gold.badge-dot, .badge-diamond.badge-dot { background: var(--badge-color); }
.app-main { max-width: 1080px; min-height: calc(100vh - 64px); }
.subject-drawer { --bs-offcanvas-width: min(340px, 88vw); background: var(--paper); }
.offcanvas-header { padding: 1.5rem 1.35rem 1rem; }
.offcanvas-body { display: flex; flex-direction: column; padding: 0 1.15rem 1.25rem; }
.eyebrow { color: var(--green); font-size: .7rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.subject-nav .list-group-item { display: flex; align-items: center; gap: .85rem; padding: .85rem .75rem; border: 0; border-radius: 8px; background: transparent; color: var(--ink); }
.subject-nav .list-group-item.active { color: var(--green-dark); background: var(--mint); }
.subject-nav-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 1.15rem; }
.drawer-profile { border-top: 1px solid var(--line); }
.badge-rank { padding: .22rem .55rem; border-radius: 20px; color: var(--badge-color, #6f7773); background: color-mix(in srgb, var(--badge-color, #858b8c) 13%, white); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.progress { height: 6px; border-radius: 8px; background: #e3e8e3; }
.progress-bar { border-radius: inherit; background: var(--green); transition: width .35s ease; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: .9rem 0 3rem; }
.page-title { font: 700 clamp(1.55rem, 5vw, 2.35rem)/1.15 var(--font-display); }
.heading-icon { color: var(--coral); font-size: 1.45rem; }
.page-description { max-width: 600px; margin: .8rem 0 0 2rem; color: var(--muted); }
.subject-mcq-controls { display: flex; max-width: 460px; align-items: center; gap: .6rem; }
.subject-mcq-controls .form-select { min-width: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0 0 1.15rem; }
.topic-section-heading { margin-top: 0; }
.topic-tile { position: relative; display: flex; min-height: 170px; flex-direction: column; align-items: flex-start; padding: 1rem; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); text-align: left; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.topic-tile:hover, .topic-tile:focus-visible { transform: translateY(-2px); border-color: #97b8a3; box-shadow: 0 8px 22px rgb(32 43 39 / 7%); }
.topic-icon { display: grid; width: 38px; height: 38px; margin-bottom: 1rem; place-items: center; border-radius: 9px; color: var(--green); background: var(--mint); font-size: 1.2rem; }
.topic-title { max-width: 100%; padding-right: .75rem; font-weight: 700; overflow-wrap: anywhere; }
.topic-description { display: -webkit-box; max-width: 100%; margin-top: .35rem; overflow: hidden; color: var(--muted); font-size: .78rem; line-clamp: 2; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.tile-arrow { position: absolute; top: 1rem; right: 1rem; color: #9ba49e; }
.question-list { border-radius: 8px; overflow: hidden; }
.question-row { display: flex; min-height: 72px; align-items: center; gap: .9rem; padding: .85rem 1rem; border-color: var(--line); color: var(--ink); }
.question-status { display: grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; border: 1px solid #cbd3cd; border-radius: 50%; color: #a2aaa4; font-size: 1.15rem; }
.question-status.complete { border-color: var(--green); color: #fff; background: var(--green); font-size: .8rem; }
.row-arrow { color: #8b9790; }
.subnav-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: -.7rem 0 1.75rem; }
.back-link { color: var(--green); font-weight: 650; text-decoration: none; }
.back-link:hover { color: var(--green-dark); }
.empty-inline { padding: 1.25rem; border: 1px dashed #cbd3cd; border-radius: 8px; color: var(--muted); background: rgb(255 255 255 / 55%); }
.empty-state, .state-panel { display: flex; min-height: 40vh; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; text-align: center; }
.empty-state p { max-width: 28rem; color: var(--muted); }
.empty-symbol { display: grid; width: 54px; height: 54px; place-items: center; border: 1px solid #cfdbd1; border-radius: 16px 16px 16px 4px; color: var(--green); background: var(--mint); font-size: 1.5rem; }
.state-panel { min-height: 25vh; flex-direction: row; color: var(--muted); }
.auth-layout { display: grid; min-height: min(680px, calc(100vh - 120px)); align-items: center; gap: 3rem; padding: 2rem 0; }
.auth-intro { position: relative; padding: 2rem 0; }
.auth-intro::before { position: absolute; z-index: -1; top: 5%; left: -5vw; width: min(55vw, 530px); height: 90%; border-radius: 45% 55% 59% 41% / 45% 42% 58% 55%; background: radial-gradient(ellipse at 35% 40%, #e4ede5 0, #e4ede5 54%, transparent 55%); content: ""; }
.auth-intro h1 { font: 700 clamp(2.2rem, 7vw, 4.1rem)/1.06 var(--font-display); }
.auth-intro h1 span { color: var(--green); }
.auth-copy { max-width: 24rem; margin-top: 1rem; color: var(--muted); font-size: 1.05rem; }
.auth-form { width: 100%; max-width: 430px; padding: 1.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 36px rgb(32 43 39 / 5%); }
.form-control { min-height: 46px; border-color: #ccd4ce; border-radius: 6px; }
.btn-primary { --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green); --bs-btn-hover-bg: var(--green-dark); --bs-btn-hover-border-color: var(--green-dark); --bs-btn-active-bg: var(--green-dark); --bs-btn-active-border-color: var(--green-dark); --bs-btn-disabled-bg: #829c8c; --bs-btn-disabled-border-color: #829c8c; }
.btn-outline-primary { --bs-btn-color: var(--green); --bs-btn-border-color: #8eaa98; --bs-btn-hover-bg: var(--green); --bs-btn-hover-border-color: var(--green); --bs-btn-active-bg: var(--green-dark); --bs-btn-active-border-color: var(--green-dark); }
.btn-success-subtle { color: var(--green-dark); background: var(--mint); }
.setup-notice { max-width: 680px; margin: 12vh auto; padding: 2rem; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; background: var(--surface); }
.cache-note { display: flex; align-items: center; gap: .5rem; color: #56645b; font-size: .82rem; }
.cache-note > span { color: var(--gold); }
.tutorial-nav { margin-bottom: 1.2rem; }
.tutorial-header { max-width: 760px; padding: 1.2rem 0 2rem; border-bottom: 1px solid var(--line); }
.tutorial-title, .results-title { max-width: 850px; font: 700 clamp(2rem, 7vw, 3.45rem)/1.08 var(--font-display); overflow-wrap: anywhere; }
.tutorial-summary { max-width: 690px; margin: 1rem 0 0; color: var(--muted); font-size: 1.08rem; }
.tutorial-content { max-width: 760px; padding: 2rem 0 1rem; }
.content-heading { margin: 2rem 0 .75rem; font: 700 1.45rem/1.25 var(--font-display); }
.content-paragraph, .content-list { color: #35423b; font-size: 1rem; line-height: 1.8; }
.content-list { padding-left: 1.25rem; }
.content-list li + li { margin-top: .5rem; }
.code-block { padding: 1rem; overflow-x: auto; border: 1px solid #dce3dc; border-radius: 8px; color: #e7eee8; background: #26352e; font-size: .85rem; line-height: 1.6; }
.tutorial-body h2 { margin: 2rem 0 .75rem; font: 700 1.45rem/1.25 var(--font-display); }
.tutorial-body h3 { margin: 1.6rem 0 .6rem; font: 700 1.2rem/1.3 var(--font-display); }
.tutorial-body p { margin: 0 0 1rem; color: #35423b; font-size: 1rem; line-height: 1.8; }
.tutorial-body ul, .tutorial-body ol { margin: 0 0 1rem; padding-left: 1.25rem; color: #35423b; font-size: 1rem; line-height: 1.8; }
.tutorial-body li + li { margin-top: .5rem; }
.tutorial-body blockquote { margin: 0 0 1rem; padding: .1rem 0 .1rem 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.tutorial-body pre { margin: 0 0 1rem; padding: 1rem; overflow-x: auto; border: 1px solid #dce3dc; border-radius: 8px; background: #26352e; }
.tutorial-body pre code { color: #e7eee8; font-size: .85rem; line-height: 1.6; background: none; }
.tutorial-footer { display: flex; max-width: 760px; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 0 2rem; border-top: 1px solid var(--line); }
.learn-link { color: var(--green); font-size: .9rem; font-weight: 700; text-decoration: none; }
.learn-link:hover { color: var(--green-dark); text-decoration: underline; }
.mcq-view { max-width: 760px; margin: 0 auto; }
.mcq-progress-head { display: flex; justify-content: space-between; margin-bottom: .55rem; }
.mcq-progress { height: 5px; margin-bottom: 2rem; }
.mcq-card { padding: clamp(1.1rem, 4vw, 2rem); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.mcq-question { margin: .6rem 0 1.5rem; font: 700 clamp(1.35rem, 5vw, 2rem)/1.25 var(--font-display); overflow-wrap: anywhere; }
.answer-options { display: grid; gap: .65rem; }
.answer-option { display: flex; min-height: 58px; align-items: center; gap: .8rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; text-align: left; }
.answer-option:enabled:hover { border-color: #9bb5a3; background: #f8fbf8; }
.option-letter { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.answer-option.selected-correct { border-color: #73a889; background: #edf5ef; }
.answer-option.selected-wrong { border-color: #d69a87; background: #fbefeb; }
.answer-option.is-correct .option-letter { border-color: var(--green); color: #fff; background: var(--green); }
.answer-explanation { margin-top: 1rem; padding: .8rem 1rem; border-left: 3px solid var(--green); color: #405047; background: #eff4ef; font-size: .9rem; line-height: 1.6; }
.mcq-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.results-view { max-width: 690px; margin: 5vh auto 0; }
.results-title { font-size: clamp(2.6rem, 8vw, 4.3rem); }
.results-score { margin: 1.5rem 0; color: var(--muted); }
.results-score span { color: var(--green); font: 700 3rem var(--font-display); }
.results-summary { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.results-summary > div { display: flex; flex-direction: column; gap: .35rem; padding: 1rem .8rem 1rem 0; }
.results-summary > div + div { padding-left: .8rem; border-left: 1px solid var(--line); }
.results-summary strong { font: 700 1.35rem var(--font-display); }
.mobile-signout { position: fixed; right: 1rem; bottom: 1rem; z-index: 5; }

@media (min-width: 768px) {
  .auth-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 430px); gap: 4rem; }
  .topic-tile { min-height: 188px; padding: 1.2rem; }
}

@media (max-width: 1024px) {
  .auth-intro { display: none; }
  .auth-layout { grid-template-columns: minmax(0, 430px); justify-content: center; }
}

@media (max-width: 575.98px) {
  .app-main { padding-top: 1.35rem !important; }
  .auth-layout { min-height: 0; padding: .75rem 0 0; }
  .auth-form { padding: 1.1rem; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 2rem; }
  .page-heading > .btn { width: 100%; }
  .page-description { margin-left: 0; }
  .subject-mcq-controls { width: 100%; align-items: stretch; flex-direction: column; }
  .subject-mcq-controls .form-select, .subject-mcq-controls .btn { width: 100%; min-height: 42px; }
  .topic-tile { min-height: 150px; padding: .85rem; }
  .topic-icon { width: 34px; height: 34px; margin-bottom: .75rem; }
  .topic-description { font-size: .73rem; }
  .tutorial-footer { align-items: stretch; flex-direction: column; }
  .tutorial-footer .btn { width: 100%; }
  .results-summary > div { padding-right: .45rem; }
  .results-summary > div + div { padding-left: .45rem; }
  .results-summary .small { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}