/* Peergene course app.
   Look: a study notebook you swipe like a feed. Ballpoint-blue ink on cool paper,
   highlighter yellow for what matters. The paper tells you the kind of card:
   dotted paper = learn, index card = a word to know, squared paper = try it,
   yellow = quick check, pink = myth or fact, ink = remember. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/atkinson-hyperlegible-next-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #F5F7FC;
  --sheet: #FFFFFF;
  --ink: #1F2A5A;
  --ink-soft: #535D88;
  --rule: #D6DCEC;
  --dot: rgba(31, 42, 90, 0.12);
  --hl: #FFE14D;
  --on-hl: #1F2A5A;
  --mark-bg: #FFE14D;
  --mark-ink: #1F2A5A;
  --quiz: #FFEC85;
  --quiz-ink: #1F2A5A;
  --quiz-opt: #FFFFFF;
  --quiz-mark-bg: rgba(255, 255, 255, 0.75);
  --key: #1F2A5A;
  --key-ink: #F5F7FC;
  --key-label: #FFE14D;
  --key-mark-bg: #FFE14D;
  --key-mark-ink: #1F2A5A;
  --right: #74E3AA;
  --wrong: #FF9DBC;
  --on-answer: #14203F;
  --bar: #1F2A5A;
  --warn: #C98A00;
  --focus: #2F6BFF;
  --grid: rgba(47, 107, 255, 0.12);
  --margin-line: #E5546E;
  --card-line: rgba(47, 107, 255, 0.17);
  --myth: #FFE3EB;
  --myth-ink: #1F2A5A;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141A35;
    --sheet: #1C2347;
    --ink: #E8ECFB;
    --ink-soft: #A7AFD6;
    --rule: #2E3768;
    --dot: rgba(232, 236, 251, 0.07);
    --mark-bg: rgba(255, 225, 77, 0.22);
    --mark-ink: #FFF0A3;
    --quiz: #242E63;
    --quiz-ink: #F3F5FF;
    --quiz-opt: #1A2149;
    --quiz-mark-bg: rgba(255, 225, 77, 0.22);
    --key: #FFE14D;
    --key-ink: #1F2A5A;
    --key-label: #1F2A5A;
    --key-mark-bg: rgba(31, 42, 90, 0.14);
    --key-mark-ink: #1F2A5A;
    --bar: #FFE14D;
    --warn: #FFC94D;
    --focus: #FFE14D;
    --grid: rgba(232, 236, 251, 0.075);
    --margin-line: #FF8098;
    --card-line: rgba(232, 236, 251, 0.1);
    --myth: #362349;
    --myth-ink: #F7F1FF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html.in-lesson, html.in-lesson body { height: 100%; overflow: hidden; overscroll-behavior: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Highlighter marks: **like this** in a course file */
strong { font-weight: 750; }
.txt strong, .q strong, .key-text strong, .sheet h3 strong, .slide h2 strong {
  padding: 0.02em 0.16em;
  margin: 0 -0.04em;
  border-radius: 0.3em 0.12em 0.34em 0.1em;
  background: var(--mark-bg);
  color: var(--mark-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.k-quiz .txt strong, .k-quiz .q strong { background: var(--quiz-mark-bg); color: inherit; }
.k-myth .txt strong, .k-myth .claim strong { background: rgba(255, 255, 255, 0.6); color: inherit; }
.calc-out strong { background: transparent; }
.key-text strong { background: var(--key-mark-bg); color: var(--key-mark-ink); }

/* ---------- Screens: home and course ---------- */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
  background-color: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.15px, transparent 1.5px);
  background-size: 22px 22px;
}
.wrap { max-width: 560px; margin: 0 auto; }
.muted { color: var(--ink-soft); }

.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-bottom: 14px; }
.brand {
  margin: 0 auto 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.035em;
  text-decoration: none;
}
.pill { font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--rule); }
.btn-small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid currentColor;
  background: transparent;
  font-weight: 750;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}

.tip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: var(--sheet);
  border: 1.5px solid var(--rule);
  font-size: 15.5px;
  line-height: 1.4;
}
.tip p { margin: 0; flex: 1; }

/* The lesson to do next: a highlighter-yellow note */
.hero {
  display: block;
  margin: 4px 0 14px;
  padding: 22px 20px 20px;
  border-radius: 26px 26px 26px 8px;
  background: var(--hl);
  color: var(--on-hl);
  text-decoration: none;
}
.hero-icon { display: block; font-size: 40px; line-height: 1; margin-bottom: 16px; }
.hero-title {
  display: block;
  font-family: var(--display);
  font-weight: 760;
  font-size: clamp(30px, 8.6vw, 40px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.hero-meta { display: block; margin-top: 10px; font-size: 16px; line-height: 1.35; opacity: 0.82; }
.hero-go {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 15px;
  background: var(--on-hl);
  color: var(--hl);
  font-weight: 800;
  font-size: 17.5px;
}
.hero-mins { font-weight: 600; font-size: 15px; opacity: 0.85; }
.hero.is-quiet .hero-title { font-size: 26px; }
.hero:active { transform: scale(0.99); }

.streak { margin: 0 0 24px; padding-left: 2px; font-size: 16px; color: var(--ink-soft); }

.section-title {
  margin: 10px 0 4px;
  font-family: var(--display);
  font-weight: 720;
  font-size: 23px;
  letter-spacing: -0.02em;
}

.course-list, .lessons { list-style: none; margin: 0; padding: 0; }
.course-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 15px;
  align-items: start;
  padding: 18px 0 20px;
  border-top: 1.5px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.course-list li:last-child .course-item { border-bottom: 1.5px solid var(--rule); }
.course-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--sheet);
  border: 1.5px solid var(--rule);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}
.course-name {
  display: block;
  font-family: var(--display);
  font-weight: 720;
  font-size: 21.5px;
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.course-about { display: block; margin-top: 5px; font-size: 15.5px; line-height: 1.4; color: var(--ink-soft); }
.course-item:hover .course-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.course-item.is-broken .course-icon { color: var(--warn); border-color: var(--warn); }

.meter { display: block; height: 6px; margin-top: 13px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--bar); }
.meter.large { height: 8px; margin-top: 4px; }
.course-count { display: block; margin: 7px 0 0; font-size: 14.5px; color: var(--ink-soft); }

.notice {
  margin: 18px 0 24px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--sheet);
  border: 2px solid var(--warn);
  font-size: 15.5px;
  line-height: 1.45;
}
.notice p { margin: 0 0 6px; }
.notice ul { margin: 6px 0; padding-left: 1.1em; }
.notice li { margin-bottom: 6px; }
.notice-title { font-weight: 800; }
.notice-foot { color: var(--ink-soft); }

/* Course page */
.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin: 0 0 8px -8px;
  padding: 0 10px 0 2px;
  font-weight: 750;
  text-decoration: none;
}
.back svg { width: 26px; height: 26px; }
.course-head { margin: 6px 0 30px; }
.course-icon.large { width: 74px; height: 74px; margin-bottom: 18px; border-radius: 22px; font-size: 40px; }
.course-head h1 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 780;
  font-size: clamp(36px, 10vw, 48px);
  line-height: 1;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.about { margin: 0 0 20px; font-size: 18px; line-height: 1.45; color: var(--ink-soft); }
.course-head .course-count { margin-bottom: 20px; }
.all-done { font-weight: 750; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 22px;
  border-radius: 16px;
  border: 2px solid currentColor;
  background: transparent;
  color: inherit;
  font-weight: 800;
  font-size: 17px;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.wide { display: flex; width: 100%; }
.btn:active { transform: scale(0.985); }

.module { margin-bottom: 28px; }
.module h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 720;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.lesson-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 13px;
  align-items: center;
  min-height: 64px;
  padding: 12px 0;
  border-top: 1.5px solid var(--rule);
  text-decoration: none;
}
.lessons li:last-child .lesson-row { border-bottom: 1.5px solid var(--rule); }
.num {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-weight: 800;
  font-size: 15px;
}
.num svg { width: 19px; height: 19px; }
.is-done .num { background: var(--right); border-color: var(--right); color: var(--on-answer); }
.lesson-title { font-size: 18px; font-weight: 650; line-height: 1.3; }
.is-next .lesson-name {
  padding: 0.02em 0.16em;
  margin: 0 -0.16em;
  border-radius: 0.3em 0.12em 0.34em 0.1em;
  background: var(--mark-bg);
  color: var(--mark-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.mins { font-size: 14.5px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Lesson player: one card per screen, swipe up for the next ---------- */
.player {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  color: var(--ink);
}
.player-top {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 6px;
  pointer-events: none;
  transition: color 0.2s;
}
.player-top > * { pointer-events: auto; }
.player[data-kind="quiz"] .player-top { color: var(--quiz-ink); }
.player[data-kind="key"] .player-top { color: var(--key-ink); }
.player[data-kind="myth"] .player-top { color: var(--myth-ink); }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.bar {
  flex: 1;
  height: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.25);
  background: color-mix(in srgb, currentColor 16%, transparent);
}
.bar > span { display: block; width: 0; height: 100%; border-radius: 6px; background: currentColor; transition: width 0.3s ease; }
.pos { min-width: 3em; text-align: right; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; }

.feed {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.feed:focus { outline: none; }
.slide {
  position: relative;
  display: flex;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.slide-inner {
  width: 100%;
  max-width: 620px;
  max-height: 100%;
  margin: auto;
  overflow-y: auto;
  padding: calc(74px + env(safe-area-inset-top)) 24px calc(108px + env(safe-area-inset-bottom));
}
.k-card, .k-done {
  background-color: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.15px, transparent 1.5px);
  background-size: 22px 22px;
}
.k-quiz { background: var(--quiz); color: var(--quiz-ink); }
.k-key { background: var(--key); color: var(--key-ink); }

.emoji { margin: 0 0 20px; font-size: 62px; line-height: 1; }
.slide h2 {
  margin: 0 0 20px;
  font-family: var(--display);
  font-weight: 760;
  font-size: clamp(31px, 8.6vw, 42px);
  line-height: 1.03;
  letter-spacing: -0.032em;
  text-wrap: balance;
}
.txt p, .txt ul, .txt ol { margin: 0 0 14px; font-size: 19.5px; line-height: 1.5; max-width: 32em; }
.txt ul, .txt ol { padding-left: 1.15em; }
.txt ol { padding-left: 1.4em; }
.txt ol li::marker { font-weight: 800; }
.txt li { margin-bottom: 6px; }
.txt a { font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.more-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 6px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  background: transparent;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}
.more-btn svg { width: 20px; height: 20px; }

.media { margin: 0 0 20px; border-radius: 18px; overflow: hidden; background: var(--rule); }
.media img { display: block; width: 100%; height: auto; max-height: 42vh; object-fit: cover; }
.media.video { aspect-ratio: 16 / 9; }
.media.video iframe { display: block; width: 100%; height: 100%; border: 0; }

.label { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.k-key .label { color: var(--key-label); }
.k-quiz .q { font-size: clamp(27px, 7.4vw, 36px); }
.setup, .after { margin: 0 0 14px; font-size: 19px; line-height: 1.45; max-width: 32em; }
.setup { font-weight: 500; }
.slide h2.is-long { font-size: clamp(24px, 6.4vw, 29px); line-height: 1.12; letter-spacing: -0.02em; }
.k-quiz .txt p { font-size: 18.5px; }

.options { display: grid; gap: 11px; margin: 24px 0 6px; }
.opt {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 14px 16px 14px 18px;
  border-radius: 17px;
  border: 2px solid currentColor;
  background: var(--quiz-opt);
  color: var(--quiz-ink);
  font-weight: 650;
  font-size: 18px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
/* The highlighter swipe when you answer */
.opt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.opt.is-right::before { background: var(--right); transform: scaleX(1); }
.opt.is-wrong::before { background: var(--wrong); transform: scaleX(1); }
.opt.is-right, .opt.is-wrong { color: var(--on-answer); border-color: var(--on-answer); }
.opt.is-dim { opacity: 0.5; }
.opt:disabled { cursor: default; }
.opt:not(:disabled):active { transform: scale(0.985); }
.opt-text { flex: 1; }
.opt-mark { flex: none; width: 24px; height: 24px; }
.opt-mark svg { width: 24px; height: 24px; }

.feedback { margin-top: 16px; }
.is-answered .feedback { animation: appear 0.35s ease both; }
.verdict { margin: 0 0 6px; font-family: var(--display); font-weight: 780; font-size: 26px; letter-spacing: -0.02em; }
.feedback .txt p { font-size: 18px; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

.key-text p {
  margin: 0 0 14px;
  font-family: var(--display);
  font-weight: 740;
  font-size: clamp(32px, 9vw, 46px);
  line-height: 1.07;
  letter-spacing: -0.032em;
  text-wrap: balance;
}
.key-text ul { font-size: 22px; padding-left: 1.1em; }

.done-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 50%;
  background: var(--right);
  color: var(--on-answer);
}
.done-mark svg { width: 40px; height: 40px; }
.is-finished .done-mark { animation: pop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: none; opacity: 1; } }
.k-done h2 { margin-bottom: 6px; }
.done-lesson { margin: 0 0 18px; font-size: 19px; font-weight: 700; }
.done-stats p { margin: 0 0 6px; font-size: 18px; color: var(--ink-soft); }
.done-actions { display: grid; gap: 11px; margin-top: 28px; }

.next {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  margin-left: -29px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.next svg { width: 28px; height: 28px; }
.next:active { transform: scale(0.94); }
.player[data-kind="quiz"] .next { background: var(--quiz-ink); color: var(--quiz); }
.player[data-kind="key"] .next { background: var(--key-ink); color: var(--key); }

.hint {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: calc(92px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  pointer-events: none;
  animation: nudge 1.4s ease-in-out 0.6s 3;
}
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* "Tell me more" panel */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(12, 17, 40, 0.5); opacity: 0; transition: opacity 0.22s; }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 640px;
  max-height: 80vh;
  max-height: 80dvh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 6px 22px calc(30px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--sheet);
  color: var(--ink);
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet.is-open .sheet-panel { transform: none; }
.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px 6px 0;
  padding-top: 12px;
  background: var(--sheet);
}
.sheet-head h3 {
  flex: 1;
  margin: 0;
  font-family: var(--display);
  font-weight: 760;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.sheet-body p, .sheet-body li { font-size: 18.5px; }





/* ---------- Bottom tabs: Learn, Glossary, Notes ---------- */
.screen.has-tabs { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.tabs {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1.5px solid var(--rule);
}
.tab {
  flex: 1;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 56px;
  padding: 5px 4px 4px;
  border-radius: 14px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 750;
  text-decoration: none;
}
.tab-ico { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .tab-ico { background: var(--mark-bg); color: var(--mark-ink); }

/* Level label and the course notice */
.level {
  display: inline-block;
  vertical-align: 0.18em;
  margin-left: 4px;
  padding: 2px 9px 3px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  font-family: var(--text);
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: nowrap;
}
.level-line { margin: 0 0 10px; }
.level-line .level { margin-left: 0; font-size: 14px; padding: 3px 11px 4px; }
.course-notice {
  margin: 0 0 20px;
  padding: 11px 14px;
  border-left: 4px solid var(--hl);
  border-radius: 3px 14px 14px 3px;
  background: var(--sheet);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* ---------- Card types: word to know, try it, calculator, myth ---------- */
.k-term {
  background-color: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.15px, transparent 1.5px);
  background-size: 22px 22px;
}
.index-card {
  margin: 0 0 22px;
  padding: 0 20px 8px;
  border: 1.5px solid var(--rule);
  border-radius: 5px 5px 22px 5px;
  background: var(--sheet);
}
.index-card .term {
  margin: 0;
  padding: 20px 0 12px;
  border-bottom: 2.5px solid var(--margin-line);
}
.index-card .txt {
  padding-top: 8px;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--card-line) 31px, var(--card-line) 32px);
  background-position: 0 8px;
}
.index-card .txt p { margin: 0; font-size: 19.5px; line-height: 32px; }
.index-card .txt p + p { margin-top: 0; }

.eg { margin: 0 0 20px; padding: 2px 0 2px 16px; border-left: 3px solid var(--margin-line); }
.eg-label { margin: 0 0 4px; font-size: 15px; font-weight: 800; }
.eg .txt p, .eg .txt ul { margin-bottom: 8px; font-size: 18px; }

.k-try, .k-calc {
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}
.k-try .q, .k-calc h2 { font-size: clamp(26px, 7.2vw, 34px); }
.try-input, .note-input {
  display: block;
  width: 100%;
  min-height: 116px;
  margin: 18px 0 6px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 17.5px;
  line-height: 1.45;
  resize: vertical;
}
.try-input::placeholder, .note-input::placeholder, .search input::placeholder { color: var(--ink-soft); opacity: 1; }
.save-state { min-height: 1.4em; margin: 0 0 10px; font-size: 14.5px; font-weight: 700; color: var(--ink-soft); }
.try-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-small.solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.reveal { margin-top: 16px; padding: 14px 16px 4px; border-radius: 16px 16px 16px 5px; animation: appear 0.3s ease both; }
.try-hint { background: var(--sheet); border: 1.5px solid var(--rule); }
.try-answer { background: var(--quiz); color: var(--quiz-ink); }
.reveal .txt p, .reveal .txt ul { font-size: 18px; }
.try-answer .txt strong { background: var(--quiz-mark-bg); color: inherit; }

.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 12px; align-items: end; margin: 18px 0 16px; }
.calc-box { display: grid; gap: 6px; }
.calc-label { font-size: 15px; font-weight: 750; line-height: 1.3; }
.calc-box input {
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calc-group { margin: 14px 0 0; padding: 0; border: 0; min-width: 0; }
.calc-group legend { padding: 0; font-family: var(--display); font-size: 21px; font-weight: 760; letter-spacing: -0.015em; }
.calc-group .calc-grid { margin: 8px 0 4px; }
.calc-out {
  margin-top: 4px;
  padding: 15px 18px 16px;
  border-radius: 20px 20px 20px 6px;
  background: var(--hl);
  color: var(--on-hl);
}
.calc-out.is-waiting { background: var(--sheet); color: var(--ink); border: 2px dashed var(--rule); }
.calc-name { margin: 0; font-size: 15px; font-weight: 800; }
.calc-big {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.calc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-line { margin: 0; font-size: 16px; line-height: 1.45; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-line sup { font-size: 0.7em; }
.calc-note { margin: 8px 0 0; font-size: 16.5px; line-height: 1.4; font-weight: 650; }
.calc-msg { margin: 0; font-weight: 700; }

.k-myth { background: var(--myth); color: var(--myth-ink); }
.k-myth .claim { transition: color 0.3s; }
.k-myth.is-revealed .claim {
  text-decoration: line-through;
  text-decoration-color: var(--margin-line);
  text-decoration-thickness: 0.08em;
}
.myth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 26px 0 6px; }
.myth-btn {
  min-height: 60px;
  padding: 12px;
  border-radius: 17px;
  border: 2px solid currentColor;
  background: var(--sheet);
  color: var(--ink);
  font-weight: 750;
  font-size: 18px;
  cursor: pointer;
}
.myth-btn:disabled { cursor: default; opacity: 0.55; }
.myth-btn.is-chosen { opacity: 1; background: var(--myth-ink); color: var(--myth); border-color: var(--myth-ink); }
.myth-btn:not(:disabled):active { transform: scale(0.985); }
.myth-fact { margin-top: 18px; }
.myth-fact:empty { display: none; }
.myth-fact .verdict, .myth-reply { animation: appear 0.35s ease both; }
.myth-reply { margin: 0 0 10px; font-size: 18px; font-weight: 700; }

/* Save a Remember card to your notes */
.save-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-top: 14px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  background: transparent;
  color: inherit;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}
.save-key svg { width: 21px; height: 21px; }
.save-key[aria-pressed="true"] { background: var(--key-label); border-color: var(--key-label); color: var(--key); }
.save-key:active { transform: scale(0.97); }

.mark-btn[aria-pressed="true"] { color: inherit; }

/* Sources, under the facts they back up */
.sources { margin-top: 20px; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.sources p, .sources ul { margin: 0 0 4px; }
.sources ul { padding-left: 1.1em; }
.sources li { margin-bottom: 4px; }
.sources a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.src-label { font-weight: 800; }
.k-quiz .sources, .k-key .sources, .k-myth .sources, .reveal .sources { color: inherit; opacity: 0.85; }

.done-stats a { font-weight: 750; color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- Glossary and notes pages ---------- */
.page-title {
  margin: 4px 0 8px;
  font-family: var(--display);
  font-weight: 780;
  font-size: clamp(36px, 10vw, 48px);
  line-height: 1;
  letter-spacing: -0.035em;
}
.page-sub { margin: 0 0 18px; font-size: 17px; line-height: 1.45; color: var(--ink-soft); }
.empty { margin: 4px 0 0; font-size: 16px; line-height: 1.45; color: var(--ink-soft); }

.search { position: sticky; top: 0; z-index: 2; margin: 0 -20px 6px; padding: 8px 20px 10px; background: var(--paper); }
.search svg { position: absolute; left: 35px; top: 50%; width: 22px; height: 22px; margin-top: -11px; color: var(--ink-soft); pointer-events: none; }
.search input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px 0 46px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.gl-letter { margin: 22px 0 2px; font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1; }
.gl-entry { padding: 14px 0 16px; border-top: 1.5px solid var(--rule); }
.gl-group .gl-entry:first-of-type { border-top: 0; }
.gl-term { margin: 0 0 6px; font-family: var(--display); font-size: 23px; font-weight: 760; line-height: 1.15; letter-spacing: -0.015em; }
.gl-entry .txt p { margin: 0 0 8px; font-size: 17px; }
.gl-eg { margin: 6px 0 10px; padding-left: 13px; border-left: 3px solid var(--margin-line); }
.gl-eg .txt p { font-size: 16px; color: var(--ink-soft); }
.gl-from { display: inline-block; margin-top: 2px; font-size: 14.5px; font-weight: 700; color: var(--ink-soft); text-underline-offset: 3px; }

.note-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 26px; }
.note-actions .btn-small { display: inline-flex; align-items: center; gap: 7px; }
.btn-small svg { width: 19px; height: 19px; }
.notes-section { margin: 0 0 28px; }
.notes-section .section-title { margin-bottom: 6px; }
.note-input { margin-top: 8px; }
.note-list { list-style: none; margin: 0; padding: 0; }
.note-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: start; padding: 14px 0; border-top: 1.5px solid var(--rule); }
.note-list li:last-child { border-bottom: 1.5px solid var(--rule); }
.note-q { margin: 0 0 4px; font-weight: 750; line-height: 1.35; }
.note-text { margin: 0 0 6px; line-height: 1.45; white-space: pre-wrap; }
.note-from { margin: 0; font-size: 14.5px; }
.note-from a { font-weight: 700; color: var(--ink-soft); text-underline-offset: 3px; }
.note-item .icon-btn { margin: -6px -10px 0 0; color: var(--ink-soft); }
.btn-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 11px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 750;
  font-size: 15.5px;
  transform: translateX(-50%);
  animation: appear 0.2s ease both;
}

@media (min-width: 760px) {
  .slide-inner { padding-left: 40px; padding-right: 40px; }
  .brand { font-size: 34px; }
}

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