:root {
  color-scheme: light;
  --navy: #173252;
  --navy-soft: #27486c;
  --paper: #fffaf2;
  --paper-deep: #f6eddf;
  --white: #ffffff;
  --ink: #1b2b3b;
  --muted: #657485;
  --line: #d8e0e2;
  --mint: #93d5c5;
  --mint-dark: #23775f;
  --sky: #a8d4ec;
  --sky-dark: #22668f;
  --coral: #f28b74;
  --coral-dark: #9e3f31;
  --gold: #f2bf4d;
  --gold-dark: #8a6212;
  --violet: #b8a4d8;
  --violet-dark: #594184;
  --green: #4d9b72;
  --red: #b94638;
  --shadow: 0 18px 54px rgba(23, 50, 82, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --content: 1180px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
img, svg { max-width: 100%; }

.skip-link { position: fixed; z-index: 999; top: 8px; left: 8px; transform: translateY(-140%); padding: 10px 14px; border-radius: 10px; background: var(--navy); color: white; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 6px; color: var(--coral-dark); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.lede { color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.fine-print { color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.muted { color: var(--muted); }
.success-text { color: var(--mint-dark); }
.danger-text { color: var(--red); }

.login-page { background: radial-gradient(circle at 16% 8%, rgba(147, 213, 197, .28), transparent 27rem), radial-gradient(circle at 88% 88%, rgba(242, 191, 77, .22), transparent 25rem), var(--paper); }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 28px 18px; }
.login-card { width: min(100%, 490px); padding: clamp(28px, 6vw, 52px); border: 1px solid rgba(23, 50, 82, .09); border-radius: 34px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.login-card h1 { margin: 32px 0 12px; color: var(--navy); font-size: clamp(2.25rem, 7vw, 3.8rem); line-height: .98; letter-spacing: -.045em; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.button-reset { padding: 0; border: 0; appearance: none; background: transparent; color: inherit; text-align: left; }
.brand-lockup img { width: 58px; height: 58px; }
.brand-name { margin: 0; color: var(--navy); font-size: 1.12rem; font-weight: 850; }
.form-stack { display: grid; gap: 18px; margin-top: 28px; }
.form-stack label { display: grid; gap: 8px; color: var(--navy); font-weight: 750; }
input, select, textarea { width: 100%; border: 1.5px solid #cfd7da; border-radius: 14px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 52px; padding: 0 15px; }
textarea { min-height: 130px; padding: 14px 15px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--sky-dark); box-shadow: 0 0 0 4px rgba(168, 212, 236, .34); }
.form-message { min-height: 1.35em; margin: 0; color: var(--red); font-weight: 700; }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 9px; padding: 11px 18px; border: 0; border-radius: 999px; font-weight: 800; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, .nav-button:focus-visible, .choice:focus-visible, .grade-card:focus-visible { outline: 3px solid rgba(34, 102, 143, .45); outline-offset: 3px; }
.button-primary { background: var(--navy); color: white; box-shadow: 0 9px 20px rgba(23, 50, 82, .2); }
.button-primary:hover { background: #0d2949; }
.button-secondary { border: 1px solid #cdd7dc; background: white; color: var(--navy); }
.button-soft { background: var(--paper-deep); color: var(--navy); }
.button-danger { background: #fff0ed; color: var(--red); }
.button-wide { width: 100%; }
.button-small { min-height: 38px; padding: 8px 14px; font-size: .88rem; }
.icon-button { display: inline-grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--navy); font-weight: 900; }

.loading-screen { display: grid; min-height: 100vh; place-items: center; align-content: center; gap: 15px; color: var(--navy); font-weight: 750; }
.loading-screen img { animation: float 1.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-7px); } }

.app-shell { min-height: 100vh; padding-bottom: 94px; background: radial-gradient(circle at top right, rgba(168, 212, 236, .18), transparent 32rem), var(--paper); }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; height: 76px; align-items: center; justify-content: space-between; gap: 18px; padding: 10px max(18px, calc((100vw - var(--content)) / 2)); border-bottom: 1px solid rgba(23,50,82,.08); background: rgba(255,250,242,.94); backdrop-filter: blur(14px); }
.topbar .brand-lockup img { width: 46px; height: 46px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.profile-chip { display: flex; align-items: center; gap: 9px; padding: 7px 12px 7px 8px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--navy); font-weight: 750; }
.avatar { display: inline-grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--gold); color: var(--navy); }
.content { width: min(calc(100% - 32px), var(--content)); margin: 0 auto; padding: 36px 0 54px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head h1 { margin-bottom: 7px; color: var(--navy); font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.02; letter-spacing: -.04em; }
.page-head p { margin-bottom: 0; color: var(--muted); }

.bottom-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: flex; min-height: 76px; justify-content: center; gap: 8px; padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(23,50,82,.1); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.nav-button { display: grid; min-width: 120px; place-items: center; gap: 3px; padding: 7px 16px; border: 0; border-radius: 16px; background: transparent; color: var(--muted); font-size: .74rem; font-weight: 750; }
.nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-button.active { background: #edf5f8; color: var(--navy); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { border: 1px solid rgba(23,50,82,.09); border-radius: var(--radius-lg); background: rgba(255,255,255,.95); box-shadow: 0 9px 26px rgba(23,50,82,.07); }
.card-body { padding: clamp(20px, 4vw, 30px); }
.card h2, .card h3 { color: var(--navy); }
.hero-card { display: grid; min-height: 340px; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); overflow: hidden; background: linear-gradient(130deg, #f8fff9, #fff9eb); }
.hero-copy { display: grid; align-content: center; padding: clamp(28px, 5vw, 58px); }
.hero-copy h1 { max-width: 730px; margin-bottom: 18px; color: var(--navy); font-size: clamp(2.5rem, 6vw, 5rem); line-height: .94; letter-spacing: -.055em; }
.hero-copy .lede { max-width: 630px; }
.study-illustration { position: relative; min-height: 310px; overflow: hidden; background: linear-gradient(150deg, rgba(147,213,197,.65), rgba(168,212,236,.4) 44%, rgba(242,191,77,.34)); }
.study-illustration::before { position: absolute; width: 220px; height: 160px; right: 10%; bottom: 13%; border: 10px solid #5e9f98; border-radius: 22px; background: repeating-linear-gradient(0deg, transparent 0 22px, rgba(23,50,82,.08) 23px 24px), #fffdf7; box-shadow: 0 18px 38px rgba(23,50,82,.18); content: ""; transform: rotate(-5deg); }
.study-illustration::after { position: absolute; width: 78px; height: 78px; top: 16%; right: 17%; border-radius: 28% 50% 40% 45%; background: var(--gold); box-shadow: -72px 138px 0 -15px var(--coral), 68px 142px 0 -13px var(--sky-dark), 0 0 0 7px rgba(255,255,255,.7); content: "★"; color: var(--navy); font-size: 39px; line-height: 78px; text-align: center; transform: rotate(8deg); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric { padding: 20px; border: 1px solid rgba(23,50,82,.08); border-radius: 18px; background: white; }
.metric-label { margin: 0 0 8px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-value { margin: 0; color: var(--navy); font-size: 1.75rem; font-weight: 900; letter-spacing: -.04em; }
.progress-track { width: 100%; height: 11px; overflow: hidden; border-radius: 999px; background: #e7ecec; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint-dark), var(--sky-dark)); transition: width .35s ease; }

.action-card { display: flex; min-height: 200px; flex-direction: column; justify-content: space-between; padding: 26px; border: 0; text-align: left; }
.action-card.mint { background: linear-gradient(145deg, #ecfff7, #cfeee4); }
.action-card.sky { background: linear-gradient(145deg, #f2faff, #d7edf8); }
.action-card.gold { background: linear-gradient(145deg, #fffdf4, #fae9b9); }
.action-card.coral { background: linear-gradient(145deg, #fff6f2, #f7d1c7); }
.action-card h2 { margin-bottom: 7px; font-size: 1.55rem; }
.action-card p { margin-bottom: 0; color: #435668; line-height: 1.55; }
.card-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; background: rgba(255,255,255,.78); color: var(--navy); font-size: 1.35rem; }
.card-arrow { align-self: end; color: var(--navy); font-weight: 900; }

.setup-shell { min-height: 100vh; padding: 28px 18px; background: radial-gradient(circle at 75% 12%, rgba(147,213,197,.32), transparent 28rem), var(--paper); }
.setup-card { width: min(100%, 920px); margin: 0 auto; padding: clamp(25px, 6vw, 56px); }
.setup-card h1 { margin-bottom: 13px; color: var(--navy); font-size: clamp(2.3rem, 7vw, 4.4rem); line-height: .98; letter-spacing: -.05em; }
.setup-progress { display: flex; gap: 8px; margin-bottom: 38px; }
.setup-progress span { width: 52px; height: 6px; border-radius: 99px; background: #dfe6e7; }
.setup-progress span.active { background: var(--navy); }
.grade-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 24px 0; }
.grade-card { min-height: 110px; padding: 16px; border: 1.5px solid var(--line); border-radius: 18px; background: white; color: var(--navy); font-weight: 850; text-align: left; }
.grade-card span { display: block; margin-top: 8px; color: var(--muted); font-size: .75rem; font-weight: 650; }
.grade-card.available { border-color: var(--mint-dark); background: #f0fff8; box-shadow: 0 0 0 3px rgba(147,213,197,.32); }
.avatar-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 28px; }
.avatar-option { display: grid; width: 58px; height: 58px; place-items: center; border: 2px solid transparent; border-radius: 18px; background: var(--paper-deep); font-size: 1.4rem; }
.avatar-option.selected { border-color: var(--navy); background: white; }

.diagnostic-shell, .practice-shell { width: min(100%, 920px); margin: 0 auto; }
.question-card { padding: clamp(22px, 5vw, 42px); }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 25px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; background: #eef3f5; color: var(--navy); font-size: .78rem; font-weight: 800; }
.question-card h1 { margin-bottom: 25px; color: var(--navy); font-size: clamp(1.65rem, 5vw, 2.75rem); line-height: 1.18; letter-spacing: -.025em; }
.choices { display: grid; gap: 11px; }
.choice { min-height: 58px; padding: 14px 18px; border: 1.5px solid var(--line); border-radius: 16px; background: white; color: var(--ink); font-weight: 750; text-align: left; }
.choice:hover { border-color: var(--sky-dark); background: #f8fcff; }
.choice.selected { border-color: var(--navy); background: #edf5f8; box-shadow: 0 0 0 3px rgba(168,212,236,.35); }
.choice.correct { border-color: var(--mint-dark); background: #eafff3; }
.choice.incorrect { border-color: var(--red); background: #fff0ed; }
.question-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 22px; }
.teach-panel { margin-top: 18px; padding: 22px; border: 1px solid #b8d8e8; border-radius: 18px; background: #f1faff; }
.teach-panel h2 { margin-bottom: 12px; color: var(--navy); }
.teach-panel ol { margin: 0; padding-left: 23px; color: #354d61; line-height: 1.65; }
.scratchpad { margin-top: 18px; }
.scratchpad summary { color: var(--navy); cursor: pointer; font-weight: 800; }
.scratchpad textarea { margin-top: 12px; background: repeating-linear-gradient(0deg, white 0 31px, #dce6eb 32px 33px); line-height: 32px; }
.feedback { margin-top: 20px; padding: 18px; border-radius: 16px; font-weight: 700; line-height: 1.55; }
.feedback.correct { background: #eafff3; color: #155f46; }
.feedback.incorrect { background: #fff0ed; color: #8f3227; }

.topic-list { display: grid; gap: 12px; }
.topic-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) 2fr auto; align-items: center; gap: 18px; padding: 17px 0; border-bottom: 1px solid #e5e9e9; }
.topic-row:last-child { border-bottom: 0; }
.topic-title { color: var(--navy); font-weight: 800; }
.topic-code { display: block; margin-top: 4px; color: var(--muted); font-size: .75rem; }
.accuracy { min-width: 58px; color: var(--navy); font-weight: 850; text-align: right; }
.bar-mini { height: 8px; overflow: hidden; border-radius: 99px; background: #e8eded; }
.bar-mini span { display: block; height: 100%; border-radius: inherit; background: var(--mint-dark); }

.facts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.fact-card { min-height: 150px; padding: 21px; }
.fact-card h3 { margin-bottom: 8px; }
.fact-card p { color: var(--muted); line-height: 1.55; }
.fact-equation { margin-top: 13px; color: var(--navy); font-size: 1.35rem; font-weight: 900; }

.section-stack { display: grid; gap: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.section-title h2 { margin-bottom: 0; }
.check-list { display: grid; gap: 11px; padding: 0; list-style: none; }
.check-list li { display: flex; gap: 11px; line-height: 1.55; }
.check { display: inline-grid; width: 24px; height: 24px; flex: 0 0 24px; place-items: center; border-radius: 50%; background: #dff7ec; color: var(--mint-dark); font-weight: 900; }
.plan-step { display: grid; grid-template-columns: 42px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid #e5e9e9; }
.plan-step:last-child { border-bottom: 0; }
.plan-number { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; background: var(--navy); color: white; font-weight: 900; }
.plan-step h3 { margin-bottom: 6px; }
.plan-step p { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.settings-grid { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(0, 1.2fr); gap: 20px; }
.settings-list { display: grid; gap: 10px; }
.settings-row { display: grid; gap: 7px; padding: 16px 0; border-bottom: 1px solid #e5e9e9; }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { color: var(--navy); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--navy); font-size: .82rem; font-weight: 750; }
.chip.selected { border-color: var(--mint-dark); background: #eafff3; color: #155f46; }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15,31,49,.55); }
.modal { width: min(100%, 650px); max-height: min(88vh, 780px); overflow: auto; padding: clamp(22px, 5vw, 38px); border-radius: 26px; background: white; box-shadow: 0 28px 80px rgba(9,22,38,.3); }
.modal h2 { color: var(--navy); font-size: 2rem; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.toast { position: fixed; z-index: 90; right: 20px; bottom: 96px; max-width: 360px; padding: 14px 18px; border-radius: 14px; background: var(--navy); color: white; box-shadow: var(--shadow); font-weight: 700; }

@media (max-width: 900px) {
  .hero-card { grid-template-columns: 1fr; }
  .study-illustration { min-height: 240px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .topic-row { grid-template-columns: 1fr auto; }
  .topic-row .bar-mini { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .topbar { height: 68px; padding-inline: 13px; }
  .topbar .brand-name { display: none; }
  .topbar .eyebrow { margin: 0; }
  .profile-chip span:last-child { display: none; }
  .content { width: min(calc(100% - 22px), var(--content)); padding-top: 22px; }
  .page-head { align-items: start; flex-direction: column; }
  .grid-2, .grid-3, .facts-grid, .metric-grid { grid-template-columns: 1fr; }
  .grade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { justify-content: space-around; gap: 3px; }
  .nav-button { min-width: 0; flex: 1; padding-inline: 4px; }
  .question-actions .button { width: 100%; }
  .hero-copy { padding: 28px 22px; }
  .hero-copy h1 { font-size: 2.65rem; }
  .study-illustration { min-height: 220px; }
  .study-illustration::before { right: 9%; bottom: 11%; transform: scale(.78) rotate(-5deg); transform-origin: right bottom; }
  .study-illustration::after { transform: scale(.78) rotate(8deg); transform-origin: right top; }
}

@media print {
  .topbar, .bottom-nav, .button, .no-print { display: none !important; }
  .app-shell { padding: 0; background: white; }
  .content { width: 100%; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: white; }
}

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