/* Courses */
.nav nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--trace); }

.courses-hero { background: radial-gradient(900px 480px at 85% 0%, rgba(94, 234, 212, 0.13), transparent 60%), radial-gradient(700px 420px at 0% 100%, rgba(11, 79, 179, 0.26), transparent 65%), var(--night); color: var(--on-night); padding: var(--hero-top) var(--gutter) 110px; }
.courses-hero .eyebrow { color: var(--trace); }
.courses-hero h1 { font-size: var(--h1); max-width: 15em; }
.courses-hero h1 em { font-style: italic; color: var(--trace); }
.courses-hero .lede { max-width: 40em; }

.courses-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 var(--gutter); margin-top: -60px; position: relative; }
.courses-how article { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 16px 36px rgba(16, 29, 46, 0.09); }
.courses-step { font-family: var(--mono); font-weight: 700; color: var(--blue); font-size: 14px; }
.courses-how h2 { font-size: 24px; margin: 8px 0 6px; }
.courses-how p { color: var(--muted); font-size: 16px; }

.courses-soon { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; padding: var(--section-y) var(--gutter); }
.courses-soon h2 { font-size: var(--h2); }
.courses-soon > div > p:not(.eyebrow) { color: var(--muted); margin-top: 14px; font-size: 18px; }
.courses-soon > div > .courses-free { margin-top: 24px; }
.courses-free { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.courses-free a { display: grid; gap: 2px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 16px; background: #fff; text-decoration: none; transition: border-color 0.15s ease, transform 0.15s ease; }
.courses-free a:hover { border-color: var(--blue); transform: translateY(-2px); }
.courses-free b { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.courses-free span { color: var(--muted); font-size: 15px; }

@media (max-width: 980px) {
  .courses-how, .courses-soon { grid-template-columns: minmax(0, 1fr); }
  .courses-soon { gap: 28px; padding-top: 72px; padding-bottom: 72px; }
}
@media (prefers-reduced-motion: reduce) { .courses-free a { transition: none; } .courses-free a:hover { transform: none; } }

/* --- Learner side: shared --------------------------------------------------- */
[hidden] { display: none !important; }
.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; }
.nav .nav-account { color: var(--trace); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn .icon { margin: 0 8px 0 -4px; }
.btn span + .icon { margin: 0 -4px 0 8px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-deep); }
.btn-line { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-line:hover { border-color: var(--blue); }
.btn-small { min-height: 40px; padding: 0 16px; font-size: 14.5px; }
.btn-done { background: #dff6f1; color: #0a6b5e; border-color: #9fdccd; }
button.btn { font: inherit; font-weight: 650; cursor: pointer; }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: var(--paper-2); color: var(--muted); white-space: nowrap; }
.pill-free { background: #dff6f1; color: #0a6b5e; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; text-decoration: none; color: inherit; opacity: 0.85; padding: 6px 0; }
.crumb:hover { opacity: 1; text-decoration: underline; }
.crumb .icon { width: 16px; height: 16px; }

/* Accents: one colour per course, used for the card stripe and detail band. */
.accent-teal { --accent: #0f9d8a; --accent-glow: rgba(94, 234, 212, 0.16); }
.accent-blue { --accent: #2563eb; --accent-glow: rgba(59, 130, 246, 0.2); }
.accent-rose { --accent: #e11d48; --accent-glow: rgba(244, 63, 94, 0.16); }
.accent-amber { --accent: #d97706; --accent-glow: rgba(245, 158, 11, 0.16); }
.accent-violet { --accent: #7c3aed; --accent-glow: rgba(139, 92, 246, 0.18); }

.course-banner { margin: 0; padding: 14px var(--gutter); font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--line); }
.course-banner.is-ok { background: #dff6f1; color: #064e44; border-color: #9fdccd; }
.course-banner.is-info { background: #fff6e0; color: #6b4a00; border-color: #f0d9a0; }
.course-banner a { color: inherit; font-weight: 700; }

.course-loading { display: flex; align-items: center; gap: 14px; padding: 80px var(--gutter); color: var(--muted); }
.player-body .course-loading { padding: 24px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.course-empty { padding: 90px var(--gutter); max-width: 760px; }
.course-empty h1 { font-size: clamp(30px, 4vw, 44px); }
.course-empty p { color: var(--muted); margin-top: 14px; font-size: 18px; }

/* --- Catalog --------------------------------------------------------------- */
.catalog { padding: var(--section-y) var(--gutter); }
.catalog-head h2 { font-size: var(--h2); }
.catalog-grid { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; }
.course-card { position: relative; display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 26px 24px 22px; border: 1px solid var(--line); border-radius: 20px; background: #fff; text-decoration: none; overflow: hidden; box-shadow: 0 14px 34px rgba(16, 29, 46, 0.07); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.course-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: var(--accent); }
.course-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 22px 44px rgba(16, 29, 46, 0.13); }
.course-card-top { display: flex; flex-wrap: wrap; gap: 8px; }
.course-card h3 { font-size: 27px; }
.course-card-sub { color: var(--muted); font-size: 16px; flex: 1; }
.course-card-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--mono); font-size: 13.5px; color: var(--muted); }
.course-card-facts li + li::before { content: "·"; margin-right: 16px; margin-left: -10px; }
.course-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.course-price { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.course-go { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--blue); font-size: 15.5px; }

/* --- Course detail -------------------------------------------------------------- */
.course-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 48px; align-items: end; color: var(--on-night); padding: 40px var(--gutter) 56px; background: radial-gradient(900px 480px at 85% 0%, var(--accent-glow), transparent 60%), radial-gradient(700px 420px at 0% 100%, rgba(11, 79, 179, 0.24), transparent 65%), var(--night); border-top: 5px solid var(--accent); }
.course-top .crumb { color: var(--on-night-muted); margin-bottom: 18px; }
.course-top .eyebrow { color: var(--trace); }
.course-top h1 { font-size: clamp(36px, 4.6vw, 60px); }
.course-top .lede { max-width: 36em; }
.course-facts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 0; margin: 28px 0 0; color: var(--on-night-muted); font-size: 15px; }
.course-facts b { font-family: var(--mono); color: #fff; font-size: 17px; margin-right: 2px; }
.buy { display: grid; gap: 12px; padding: 24px; border: 1px solid var(--night-line); border-radius: 20px; background: rgba(11, 26, 46, 0.82); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3); }
.buy-price { font-family: var(--serif); font-size: 36px; font-weight: 600; color: #fff; line-height: 1.1; }
.buy-note { font-size: 14px; color: var(--on-night-muted); }
.buy-status { font-size: 14.5px; color: var(--trace); min-height: 0; }
.buy-status:empty { display: none; }

.course-progress { display: grid; gap: 8px; }
.course-progress-bar { height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.course-progress-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #3b82f6, #0f9d8a); transition: width 0.4s ease; }
.course-progress p { font-family: var(--mono); font-size: 13.5px; color: var(--muted); }
.course-progress.on-night .course-progress-bar { background: var(--night-2); border: 1px solid var(--night-line); }
.course-progress.on-night .course-progress-bar i { background: linear-gradient(90deg, #3b82f6, var(--trace)); }
.course-progress.on-night p { color: var(--on-night-muted); }
.course-progress .btn-cert { justify-self: start; margin-top: 4px; }
.buy .course-progress .btn-cert { justify-self: stretch; min-height: 44px; }

.course-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 48px; align-items: start; padding: 56px var(--gutter) 96px; }
.curriculum h2 { font-size: 30px; margin-bottom: 18px; }
.module { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.module + .module { margin-top: 14px; }
.module-num { font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--blue); }
.module-head h3 { font-size: 22px; margin-top: 4px; }
.module-sum { color: var(--muted); font-size: 15px; margin-top: 4px; }
.module-lessons { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.lesson-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); text-decoration: none; transition: border-color 0.15s ease; }
.lesson-row:hover { border-color: var(--blue); }
.lesson-row.is-done { background: #eefaf6; border-color: #bfe8dd; }
.lesson-row.is-locked { color: var(--muted); }
.lesson-row.is-current { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); background: #fff; }
.lesson-row-text { display: grid; min-width: 0; }
.lesson-row-title { font-weight: 600; font-size: 15.5px; }
.lesson-row-meta { font-size: 13px; color: var(--muted); }
.kind { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--paper-2); color: var(--muted); }
.kind-lab { background: #dff6f1; color: #0a6b5e; }
.kind-video { background: #e6eefc; color: var(--blue); }
.kind-quiz { background: #fdf0dc; color: #8a5a00; }
.lesson-state { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
.lesson-state.done { background: #0f9d8a; color: #fff; }
.lesson-state.locked { color: var(--muted); }
.lesson-state .icon { width: 16px; height: 16px; }

/* Markdown text */
.md { font-size: 17.5px; line-height: 1.65; overflow-wrap: anywhere; }
.md > * + * { margin-top: 14px; }
.md h2 { font-size: 28px; margin-top: 30px; }
.md h3 { font-size: 22px; margin-top: 26px; }
.md h4, .md h5, .md h6 { font-family: var(--serif); font-size: 19px; margin-top: 22px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 6px; }
.md a { color: var(--blue); text-underline-offset: 2px; }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.md pre { background: var(--night); color: var(--on-night); border-radius: 12px; padding: 16px 18px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; color: inherit; }
.md blockquote { margin: 18px 0 0; padding: 12px 18px; border-left: 4px solid var(--trace); background: #fff; border-radius: 0 12px 12px 0; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.course-about { color: var(--ink); }
.course-about > :first-child { margin-top: 0; }

/* --- Lesson player ----------------------------------------------------------------- */
.player { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 40px; align-items: start; padding: 40px var(--gutter) 96px; }
.player-main { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 34px 40px; }
.player-main h1 { font-size: clamp(32px, 3.6vw, 46px); }
.player-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; margin: 14px 0 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.player-meta .kind { width: 30px; height: 30px; }
.player-nav { position: sticky; top: 86px; display: grid; gap: 14px; max-height: calc(100vh - 110px); overflow-y: auto; padding: 4px 4px 12px; }
.player-nav .crumb { color: var(--blue); }
.player-course { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.2; }
.player-module .module-lessons { margin-top: 8px; }
.player-module .lesson-row { padding: 8px 10px; gap: 10px; }
.player-module .kind { width: 28px; height: 28px; }
.player-module .kind .icon { width: 16px; height: 16px; }
.callout { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 20px 22px; border-radius: 16px; margin-bottom: 24px; }
.callout-lab { background: linear-gradient(120deg, #06101f, #0b2440); color: var(--on-night); border: 1px solid var(--night-line); }
.callout-lab .btn-blue { background: var(--trace); color: #04231f; }
.callout-lab .btn-blue:hover { background: #8df3e2; }
.callout-video { background: #eef3fd; border: 1px solid #cddcf7; }
.callout-title { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.callout p:not(.callout-title) { font-size: 15px; opacity: 0.85; }
.callout-lab p:not(.callout-title) { color: var(--on-night-muted); opacity: 1; }
.locked-card { display: grid; justify-items: start; gap: 10px; padding: 28px; border: 1px dashed #c9c1b1; border-radius: 16px; background: var(--paper); }
.locked-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--night); color: var(--trace); }
.locked-icon .icon { width: 24px; height: 24px; }
.locked-card h2 { font-size: 26px; }
.locked-card p { color: var(--muted); }
.locked-card .hero-actions { margin-top: 8px; }
.player-actions { display: grid; gap: 18px; margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.complete { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.complete-status { color: var(--muted); font-size: 15px; }
.player-steps { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.player-steps .btn { max-width: 100%; }
.player-steps .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 980px) {
  .course-top, .course-body { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .course-top { align-items: start; }
  .player { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 24px; }
  .player-nav { position: static; max-height: none; overflow: visible; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
}
@media (max-width: 640px) {
  .catalog { padding-top: 64px; }
  .course-top { padding-top: 24px; padding-bottom: 40px; }
  .buy { padding: 20px; }
  .course-body { padding-top: 40px; padding-bottom: 64px; }
  .module { padding: 16px 14px; }
  .player { padding-left: 12px; padding-right: 12px; }
  .player-main { padding: 22px 18px; border-radius: 16px; }
  .md { font-size: 16.5px; }
  .callout { padding: 18px; }
  .callout .btn { width: 100%; }
  .player-steps .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .course-card, .lesson-row, .course-progress-bar i { transition: none; }
  .course-card:hover { transform: none; }
  .spinner { animation-duration: 3s; }
}

/* --- Handouts --------------------------------------------------------------------- */
.course-intro { display: grid; gap: 40px; min-width: 0; }
.handouts-section h2 { font-size: 26px; }
.handouts-sub { color: var(--muted); font-size: 15px; margin: 4px 0 14px; }
.handouts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.handout { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.handout.is-locked { background: var(--paper); }
.handout.is-locked .handout-title { color: var(--muted); }
.handout-text { display: grid; gap: 2px; min-width: 0; }
.handout-title { font-weight: 650; font-size: 15.5px; overflow-wrap: anywhere; }
.handout-desc { color: var(--muted); font-size: 14.5px; }
.handout-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.handout-meta .pill { font-family: var(--sans); font-size: 11px; padding: 2px 8px; }
.handout-note { font-size: 13px; color: var(--blue-deep); }
.handout-note:empty { display: none; }
.file-tile { position: relative; display: grid; place-items: end center; width: 40px; height: 48px; padding-bottom: 7px; border-radius: 6px 14px 6px 6px; background: #eef1f5; color: #3b4a5e; font-family: var(--mono); font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; border: 1px solid rgba(16, 29, 46, 0.08); }
.file-tile::before { content: ""; position: absolute; top: 9px; left: 9px; right: 13px; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.35; box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor; }
.file-pdf { background: #fdeceb; color: #b42318; }
.file-img { background: #eaf6ef; color: #17803d; }
.file-slides { background: #fdf0dc; color: #a15c07; }
.file-sheet { background: #e6f5ec; color: #0f7a3f; }
.file-doc { background: #e8effc; color: var(--blue); }
.handouts.is-compact .handout { padding: 8px 10px; gap: 10px; background: var(--paper); }
.handouts.is-compact .file-tile { width: 32px; height: 38px; font-size: 8px; padding-bottom: 5px; }
.handouts.is-compact .file-tile::before { top: 7px; left: 7px; right: 10px; box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor; }
.handout-get { min-height: 38px; padding: 0 14px; }
.module-handouts { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.module-sub { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.module-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.module-study { flex: none; min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.player-module .module-study { margin-top: 10px; }
.btn-study { color: var(--on-night); }
.btn-study:hover { border-color: var(--trace); color: var(--trace); }

/* --- Flashcards ------------------------------------------------------------------- */
.study-top { color: var(--on-night); padding: 32px var(--gutter) 96px; background: radial-gradient(900px 480px at 85% 0%, var(--accent-glow), transparent 60%), radial-gradient(700px 420px at 0% 100%, rgba(11, 79, 179, 0.24), transparent 65%), var(--night); border-top: 5px solid var(--accent); }
.study-top .crumb { color: var(--on-night-muted); margin-bottom: 16px; }
.study-top .eyebrow { color: var(--trace); margin-bottom: 10px; }
.study-top h1 { font-size: clamp(32px, 4vw, 50px); }
.study-counts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 22px 0 0; }
.study-counts li { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--night-line); background: rgba(11, 26, 46, 0.7); font-size: 14.5px; color: var(--on-night-muted); }
.study-counts b { font-family: var(--mono); font-size: 17px; color: #fff; }
.study-counts .count-due b { color: #fbbf24; }
.study-counts .count-new b { color: #93c5fd; }
.study-counts .count-learned b { color: var(--trace); }

.study-stage { max-width: 760px; margin: -64px auto 0; padding: 0 20px 96px; position: relative; }
.study-stage > .course-loading { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 40px; }
.study-session { display: grid; gap: 18px; }
.study-progress { display: grid; gap: 8px; }
.study-progress .course-progress-bar { background: var(--night-2); border: 1px solid var(--night-line); height: 9px; }
.study-progress .course-progress-bar i { background: linear-gradient(90deg, #3b82f6, var(--trace)); }
.study-progress-text { font-family: var(--mono); font-size: 13.5px; color: var(--on-night-muted); }

.flashcard { perspective: 1600px; cursor: pointer; border-radius: 24px; outline-offset: 6px; }
.flashcard-inner { position: relative; display: grid; min-height: 300px; transform-style: preserve-3d; transition: transform 0.65s cubic-bezier(0.2, 0.75, 0.25, 1.15); }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard.no-anim .flashcard-inner { transition: none; }
.face { position: relative; grid-area: 1 / 1; display: flex; flex-direction: column; gap: 14px; padding: 34px 38px; border-radius: 24px; background: #fff; border: 1px solid var(--line); box-shadow: 0 24px 50px rgba(16, 29, 46, 0.14); -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.face-back { transform: rotateY(180deg); background: linear-gradient(160deg, #fff, #f2fbf8); border-color: #bfe8dd; }
.face::after { content: ""; position: absolute; inset: auto 38px 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--blue); opacity: 0.85; }
.face-back::after { background: #0f9d8a; }
.face-label { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); }
.face-back .face-label { color: #0a6b5e; }
.face-body { flex: 1; display: grid; align-content: center; font-family: var(--serif); font-size: clamp(22px, 2.6vw, 28px); line-height: 1.35; }
.face-body > * + * { margin-top: 10px; }
.face-body code { font-size: 0.75em; }
.flashcard:hover .face { border-color: #c9d6ea; }

.study-controls { min-height: 74px; display: grid; }
.btn-reveal { justify-self: center; min-width: 220px; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.grade { position: relative; display: grid; justify-items: center; gap: 2px; padding: 12px 8px 10px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; font: inherit; color: var(--ink); cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease; }
.grade:hover { transform: translateY(-2px); }
.grade:disabled { opacity: 0.6; cursor: wait; transform: none; }
.grade-name { font-weight: 700; font-size: 16px; }
.grade-next { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.grade-key { position: absolute; top: 6px; left: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); opacity: 0.7; }
.grade-again { border-color: #f3c3bd; } .grade-again:hover { background: #fdecea; border-color: #c2410c; } .grade-again .grade-name { color: #b42318; }
.grade-hard { border-color: #f0d9a0; } .grade-hard:hover { background: #fff6e0; border-color: #b45309; } .grade-hard .grade-name { color: #8a5a00; }
.grade-good { border-color: #9fdccd; } .grade-good:hover { background: #dff6f1; border-color: #0f9d8a; } .grade-good .grade-name { color: #0a6b5e; }
.grade-easy { border-color: #c4d4f5; } .grade-easy:hover { background: #e8effc; border-color: var(--blue); } .grade-easy .grade-name { color: var(--blue); }
.study-message { color: #8a1c0c; font-size: 15px; text-align: center; }
.study-message:empty { display: none; }
.study-keys { text-align: center; color: var(--muted); font-size: 13.5px; }
kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: #fff; color: var(--ink); }

.study-done, .study-locked { background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 36px; box-shadow: 0 24px 50px rgba(16, 29, 46, 0.1); display: grid; justify-items: start; gap: 12px; }
.study-locked { border-style: solid; }
.study-done h2 { font-size: 32px; }
.study-done p { color: var(--muted); }
.done-badge { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #0f9d8a; color: #fff; }
.done-badge .icon { width: 26px; height: 26px; stroke-width: 2.6; }
.study-summary { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; padding: 0; margin: 6px 0 0; }
.study-summary li { display: grid; justify-items: center; padding: 12px 6px; border-radius: 12px; background: var(--paper); font-size: 14px; color: var(--muted); }
.study-summary b { font-family: var(--mono); font-size: 22px; color: var(--ink); }
.study-done .hero-actions { margin-top: 8px; }

@media (max-width: 640px) {
  .module-head { flex-direction: column; }
  .handout { grid-template-columns: auto minmax(0, 1fr); }
  .handout > .btn, .handout > .lesson-state { grid-column: 2; justify-self: start; }
  .study-top { padding-top: 22px; padding-bottom: 88px; }
  .study-stage { padding: 0 12px 64px; }
  .face { padding: 26px 22px 30px; }
  .flashcard-inner { min-height: 260px; }
  .grades { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn-reveal { justify-self: stretch; }
  .study-done, .study-locked { padding: 24px 20px; }
  .study-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  /* No 3D turn: cross-fade the faces instead. */
  .flashcard-inner, .flashcard.is-flipped .flashcard-inner { transform: none; transition: none; }
  .face-back { transform: none; opacity: 0; visibility: hidden; }
  .flashcard.is-flipped .face-front { opacity: 0; visibility: hidden; }
  .flashcard.is-flipped .face-back { opacity: 1; visibility: visible; }
  .face { transition: opacity 0.15s linear; }
  .grade { transition: none; }
  .grade:hover { transform: none; }
}
/* Headings receive focus programmatically on view changes; no ring needed. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

@media (hover: none) and (pointer: coarse) { .study-keys { display: none; } }

/* Course hero: .swap keeps both wordings of a note or button in one grid cell
   (the unused one invisible), so swapping them once the catalog loads does not
   resize the hero. Without scripting the hidden wording stays out. */
@media (scripting: enabled) {
  .swap { display: inline-grid; }
  .swap > * { grid-area: 1 / 1; }
  .swap > [hidden] { display: inline !important; visibility: hidden; }
  .hero-actions .swap { justify-items: center; }
}

/* While a course, lesson or study view is still loading, keep the footer out of
   sight: it would flash up under the spinner and then drop away. */
@media (scripting: enabled) {
  body:has(.course-loading) .foot, body:has(.course-view:not([hidden]):empty) .foot { visibility: hidden; }
}
