:root {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #192644;
  background: #f4f6fa;
  font-synthesis: none;
  line-height: 1.55;
  --ink: #192644;
  --muted: #52617b;
  --border: #dce3ed;
  --blue: #244acb;
  --blue-dark: #1a39a7;
  --round: 18px;
  --panel: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.14; letter-spacing: -.04em; }
h1 { font-size: clamp(2.2rem, 5.1vw, 3.8rem); margin-bottom: 0; }
h2 { font-size: clamp(1.34rem, 2.8vw, 1.8rem); margin-bottom: .85rem; }
h3 { font-size: 1.45rem; margin-bottom: .35rem; }
a { color: inherit; }
a:hover { color: var(--blue-dark); }
button { font: inherit; }
:focus-visible { outline: 3px solid #d28022; outline-offset: 4px; }
main:focus { outline: none; }
.container { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }

.site-header { background: #fff; border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-size: 1.14rem; font-weight: 750; letter-spacing: -.035em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--blue); color: white; font-family: Georgia, serif; font-size: 1.43rem; line-height: 1; }
.header-inner nav { display: flex; align-items: stretch; align-self: stretch; gap: clamp(1rem, 3vw, 2.5rem); }
.header-inner nav a { display: flex; align-items: center; padding-block: .9rem; text-decoration: none; font-size: .94rem; font-weight: 650; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.header-inner nav a[aria-current] { color: var(--blue); border-color: var(--blue); }

main { flex: 1; padding-block: 2rem 2.75rem; }
.hero { position: relative; isolation: isolate; overflow: hidden; border-radius: 24px; background: #1b399d; color: #fff; }
.hero-inner { padding: clamp(1.75rem, 4.5vw, 3.35rem); max-width: 60%; }
.hero-kicker { font-size: .9rem; color: #e0e8ff; font-weight: 650; margin-bottom: .85rem; }
.hero h1 { font-size: clamp(3rem, 6.5vw, 5.1rem); line-height: .97; letter-spacing: -.065em; }
.hero-description { max-width: 34ch; margin-block: 1.15rem 1.5rem; color: #e0e8ff; }
#hero-graph { position: absolute; z-index: -1; inset: 0 0 0 auto; width: min(52%, 540px); height: 100%; object-fit: contain; object-position: center; opacity: .95; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem 1.05rem; border: 1px solid transparent; border-radius: 9px; text-decoration: none; cursor: pointer; font-size: .94rem; line-height: 1.25; font-weight: 700; text-align: center; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.light { background: #fff; color: #183789; }
.button.light:hover { background: #e5edff; }
.button.secondary { background: #fff; border-color: #cfd9e8; color: var(--ink); }
.button.secondary:hover { background: #edf2ff; border-color: #b6c6ed; color: var(--blue-dark); }
.button:active { transform: translateY(1px); }

.home-topics { margin-top: 2rem; }
.section-heading { display: flex; gap: .7rem; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: .92rem; white-space: nowrap; }
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel, .topic-card, .lesson, .stat, .overview-strip, .flashcard { border: 1px solid var(--border); border-radius: var(--round); background: var(--panel); }
.topic-card { padding: 1.4rem; display: flex; flex-direction: column; }
.topic-card-heading, .page-topic, .progress-topic-heading { display: flex; align-items: center; gap: .95rem; }
.topic-card-heading p { color: var(--muted); margin-bottom: 0; font-size: .94rem; }
.topic-icon { display: inline-grid; place-items: center; flex: 0 0 50px; width: 50px; height: 50px; border-radius: 13px; }
.matrix-icon { background: #e9eeff; color: #2f52c7; grid-template-columns: repeat(2, 6px); grid-template-rows: repeat(2, 6px); align-content: center; justify-content: center; gap: 4px; }
.matrix-icon i { display: block; width: 6px; height: 6px; border-radius: 1.5px; background: currentColor; }
.vector-icon { background: #e3f5ee; color: #126f55; font-size: 1.7rem; font-weight: 650; }
.topic-progress { margin-top: auto; padding-top: 1.35rem; }
.topic-progress p, .review-meter p { display: flex; justify-content: space-between; color: var(--muted); font-size: .875rem; margin-bottom: .45rem; gap: .75rem; }
.topic-progress strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-track { background: #eaf0f7; border-radius: 9px; overflow: hidden; height: 7px; }
.progress-fill { background: var(--fill, var(--blue)); border-radius: inherit; height: 100%; }
.vectors { --fill: #198367; }
.topic-links { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: 1.2rem; }
.overview-strip { margin-top: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem; }
.overview-strip h2 { font-size: 1.13rem; margin-bottom: .27rem; }
.overview-strip p { margin-bottom: 0; font-size: .92rem; color: var(--muted); }

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--muted); font-size: .92rem; font-weight: 650; text-underline-offset: .21em; }
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.tabs { border-bottom: 1px solid var(--border); display: flex; gap: 1.65rem; margin-bottom: 1.3rem; }
.tabs a { text-decoration: none; font-weight: 700; padding: .65rem .1rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs [aria-current] { color: var(--blue); border-color: var(--blue); }
.reader-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.contents { position: sticky; top: 1rem; padding: .95rem 0; max-height: calc(100vh - 2rem); overflow: auto; }
.contents h2 { font-size: 1.05rem; margin: 0 .55rem .65rem; }
.contents a { display: block; padding: .34rem .55rem; font-size: .9rem; color: var(--muted); text-decoration: none; border-radius: 6px; }
.contents a:hover { color: var(--blue-dark); background: #e8eefd; }
.reader-content { display: grid; gap: .9rem; }
.lesson, .panel { padding: clamp(1rem, 3vw, 1.7rem); min-width: 0; scroll-margin-top: 1rem; }
.lesson h2 { font-size: 1.4rem; }
.lesson p { max-width: 69ch; }
.lesson p, .flashcard p, .lesson .formula, .flashcard .formula { margin-bottom: .75rem; }
.lesson > :last-child, .flashcard-content > :last-child, details > div > :last-child { margin-bottom: 0; }
.formula { background: #f0f4fb; border: 1px solid #e3eaf6; border-radius: 8px; color: #183568; margin-top: 0; padding: .68rem .85rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 500 1rem/1.64 ui-monospace, "DejaVu Sans Mono", monospace; }
.formula:empty { display: none; }
.source-label { color: var(--muted); font-size: .82rem; margin-top: 1rem; }
details { border-top: 1px solid var(--border); padding-top: .65rem; }
details summary { cursor: pointer; color: var(--blue-dark); font-weight: 700; list-style-position: inside; }
details > div { margin-top: .85rem; }

.review-page { width: min(100%, 760px); margin-inline: auto; }
.review-heading { margin-bottom: 1.2rem; }
.review-heading h1 { margin-bottom: .35rem; }
.review-heading p { color: var(--muted); margin-bottom: 0; }
.review-meter { margin-bottom: 1rem; }
.flashcard { min-height: 250px; padding: clamp(1.25rem, 5vw, 2.4rem); box-shadow: 0 5px 18px #1935630b; }
.flashcard.revealed { border-color: #b5c8f3; animation: reveal .18s ease-out; }
.card-side-label { color: var(--blue-dark); font-weight: 750; font-size: .88rem; }
.flashcard h2 { max-width: 30ch; }
.flashcard-content { max-width: 63ch; }
.review-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; margin-top: 1rem; }
.review-actions button { min-width: 142px; }
.review-empty p { color: var(--muted); }
@keyframes reveal { from { transform: perspective(1000px) rotateX(-6deg); opacity: .7; } to { transform: none; opacity: 1; } }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; gap: .35rem; padding: 1.2rem; }
.stat strong { font-size: 2.25rem; line-height: 1; letter-spacing: -.05em; }
.stat span, .progress-topic p { color: var(--muted); }
.known strong { color: #136d52; }
.learning strong { color: #a44b19; }
.due strong { color: var(--blue); }
.progress-topics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.progress-topic-heading h2 { margin: 0; }
.progress-topic p { margin-block: 1rem .4rem; }
.progress-topic details { margin-top: .8rem; }
.progress-topic summary span { margin-left: .45rem; font-size: .85rem; font-weight: 500; color: var(--muted); }
.card-statuses { list-style: none; padding: 0; margin-bottom: .25rem; }
.card-statuses li { display: flex; gap: .7rem; justify-content: space-between; border-bottom: 1px solid #edf0f6; padding: .48rem 0; }
.card-statuses li:last-child { border: 0; padding-bottom: 0; }
.card-statuses a { text-decoration: none; font-size: .94rem; }
.card-statuses a:hover { text-decoration: underline; }
.status { flex-shrink: 0; align-self: flex-start; border-radius: 5px; padding: .13rem .4rem; font-size: .82rem; color: var(--muted); background: #edf1f7; }
.status.known { color: #136046; background: #e7f6ef; }
.status.learning { color: #8c3d10; background: #fff0e4; }

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; padding-block: .95rem 1.25rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .86rem; }
.storage-message { padding: .65rem .75rem; background: #fff0dd; border-radius: 8px; color: #693a0e; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 2; top: .5rem; left: .5rem; background: white; padding: .6rem; color: var(--blue-dark); }

@media (max-width: 680px) {
  .container { width: calc(100% - 2rem); }
  .header-inner { min-height: 61px; gap: .75rem; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 30px; height: 30px; font-size: 1.2rem; }
  .header-inner nav { gap: .8rem; }
  .header-inner nav a { font-size: .87rem; }
  main { padding-block: 1rem 1.7rem; }
  .hero { border-radius: 16px; }
  .hero-inner { max-width: 100%; padding: 1.5rem; }
  .hero h1 { font-size: clamp(2.8rem, 11vw, 4.6rem); }
  #hero-graph { display: none; }
  .topic-grid, .progress-topics, .reader-layout { grid-template-columns: 1fr; }
  .topic-card, .overview-strip { padding: 1rem; }
  .overview-strip { flex-wrap: wrap; }
  .contents { position: static; max-height: none; padding: .6rem .45rem; background: #eaf0f8; border-radius: 10px; }
  .contents a { display: inline-block; padding: .3rem .53rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-actions { justify-content: stretch; }
  .review-actions .button { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
