/* EfficientCoach Learn
   Layout: a calm study desk. Slate rail on the left (bottom tabs on phones), one reading
   spine in the middle, a quiet context rail on wide screens. The lesson view drops the
   rail and keeps only the page being read. Colours and type follow the live
   efficientcoach.com brand: slate, ink, orange call to action with ink text, teal accents,
   cool grey bands; Poppins headings, Inter text, Fraunces for the one welcome line. */
:root {
  --bg: #f4f8fa;
  --surface: #ffffff;
  --panel: #f0f6f7;
  --line: #dbe5e9;
  --line-strong: #788d96;
  --ink: #263f4a;
  --fg: #4a5c65;
  --muted: #5d7079;
  --slate: #3f6477;
  --slate-deep: #2c4d5e;
  --rail: #2c4d5e;
  --rail-fg: #e8f1f4;
  --rail-muted: #b4c9d2;
  --rail-active: #3f6477;
  --cta: #ffa630;
  --cta-hover: #ffb24d;
  --cta-ink: #263f4a;
  --amber: #ed9a24;
  --paint: #ffd07f;
  --teal: #008d98;
  --teal-text: #0a6f78;
  --teal-soft: #e2f3f4;
  --ok: #1f7a6f;
  --ok-soft: #e3f3f0;
  --warn: #8a5a00;
  --warn-soft: #fff3dc;
  --danger: #a13d3d;
  --danger-soft: #fbeaea;
  --focus: #0a6f78;
  --solid: #2c4d5e;
  --solid-hover: #3f6477;
  --solid-fg: #ffffff;
  --toast: #263f4a;
  --toast-fg: #ffffff;
  --shadow: 0 1px 2px rgba(38, 63, 74, .06), 0 6px 18px rgba(38, 63, 74, .07);
  --r-btn: 6px;
  --r-card: 9px;
  --f-head: "Poppins", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-hero: "Fraunces", Georgia, "Times New Roman", serif;
  --scale: 1;
  --lh: 1.65;
  --rail-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13212a;
    --surface: #1a2c36;
    --panel: #213741;
    --line: #2e4651;
    --line-strong: #6d8792;
    --ink: #eef4f6;
    --fg: #c6d4da;
    --muted: #9fb3bc;
    --slate: #8fb4c6;
    --slate-deep: #b9d2de;
    --rail: #0e1a21;
    --rail-fg: #e8f1f4;
    --rail-muted: #9fb3bc;
    --rail-active: #24404d;
    --cta: #ffa630;
    --cta-hover: #ffb955;
    --cta-ink: #1d2f37;
    --amber: #f0a73c;
    --paint: #6b5220;
    --teal: #4cc3cc;
    --teal-text: #6fd3da;
    --teal-soft: #173a40;
    --ok: #6fd0bf;
    --ok-soft: #173a36;
    --warn: #f0c070;
    --warn-soft: #3b2f15;
    --danger: #f0a0a0;
    --danger-soft: #3d2222;
    --focus: #6fd3da;
    --solid: #3f6477;
    --solid-hover: #4d7890;
    --solid-fg: #ffffff;
    --toast: #eef4f6;
    --toast-fg: #13212a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #13212a;
  --surface: #1a2c36;
  --panel: #213741;
  --line: #2e4651;
  --line-strong: #6d8792;
  --ink: #eef4f6;
  --fg: #c6d4da;
  --muted: #9fb3bc;
  --slate: #8fb4c6;
  --slate-deep: #b9d2de;
  --rail: #0e1a21;
  --rail-fg: #e8f1f4;
  --rail-muted: #9fb3bc;
  --rail-active: #24404d;
  --cta: #ffa630;
  --cta-hover: #ffb955;
  --cta-ink: #1d2f37;
  --amber: #f0a73c;
  --paint: #6b5220;
  --teal: #4cc3cc;
  --teal-text: #6fd3da;
  --teal-soft: #173a40;
  --ok: #6fd0bf;
  --ok-soft: #173a36;
  --warn: #f0c070;
  --warn-soft: #3b2f15;
  --danger: #f0a0a0;
  --danger-soft: #3d2222;
  --focus: #6fd3da;
  --solid: #3f6477;
  --solid-hover: #4d7890;
  --solid-fg: #ffffff;
  --toast: #eef4f6;
  --toast-fg: #13212a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
/* stronger contrast, chosen in Account > Reading and display */
:root[data-contrast="more"] { --fg: #22343c; --muted: #36484f; --line: #8fa3ab; --line-strong: #5d7079; --teal-text: #075b62; }
@media (prefers-color-scheme: dark) {
  :root[data-contrast="more"]:not([data-theme="light"]) { --fg: #f1f6f8; --muted: #d3dee3; --line: #6d8792; --line-strong: #9fb3bc; --teal-text: #9be6ec; }
}
:root[data-contrast="more"][data-theme="dark"] { --fg: #f1f6f8; --muted: #d3dee3; --line: #6d8792; --line-strong: #9fb3bc; --teal-text: #9be6ec; }

html { font-size: calc(100% * var(--scale)); height: 100%; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--readerhead, 0px) + 16px); }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font: 400 1rem/var(--lh) var(--f-body);
  font-feature-settings: "cv11", "ss01";
}
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, h4 { font-family: var(--f-head); color: var(--ink); letter-spacing: -.02em; line-height: 1.2; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--teal-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.rail :focus-visible { outline-color: #ffffff; }
[tabindex="-1"]:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--cta); color: var(--cta-ink); padding: 10px 14px; border-radius: var(--r-btn); font-weight: 600; }
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 10px); }
.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.rail {
  background: var(--rail); color: var(--rail-fg);
  position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 14px 16px max(14px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
}
.rail .brand { display: block; padding: 4px 8px 18px; }
.rail .brand img { height: 30px; width: auto; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail .nav-label { font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase; color: var(--rail-muted); padding: 14px 10px 6px; }
.rail a.nav {
  display: flex; align-items: center; gap: 11px; min-height: 44px;
  padding: 8px 10px; border-radius: 7px; color: var(--rail-fg); text-decoration: none; font-weight: 500; font-size: .9375rem;
}
.rail a.nav:hover { background: rgba(255, 255, 255, .08); }
.rail a.nav[aria-current="page"] { background: var(--rail-active); box-shadow: inset 3px 0 0 var(--cta); }
.rail a.nav .count { margin-left: auto; font-size: .75rem; background: rgba(255, 255, 255, .14); padding: 1px 8px; border-radius: 99px; }
.rail .spacer { flex: 1; }
.rail .me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; background: rgba(255, 255, 255, .07); color: var(--rail-fg); text-decoration: none; }
.rail .me:hover { background: rgba(255, 255, 255, .12); }
.rail .me small { display: block; color: var(--rail-muted); font-size: .75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #ffd07f; color: #263f4a; display: grid; place-items: center; font: 700 .875rem var(--f-head); flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: .75rem; }
.avatar.t1 { background: #cfe6e8; } .avatar.t2 { background: #ffd9a8; } .avatar.t3 { background: #d6dff5; } .avatar.t4 { background: #e3d5ee; } .avatar.t5 { background: #d4ebd2; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view {
  flex: 1; width: 100%; max-width: 1120px; margin: 0 auto;
  padding-block: 28px 56px;
  padding-left: max(28px, env(safe-area-inset-left, 0px));
  padding-right: max(28px, env(safe-area-inset-right, 0px));
}
.view:focus { outline: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .app { display: block; }
  .rail { display: none; }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding-block: 10px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .topbar img { height: 26px; width: auto; }
  .topbar .logo-dark { display: none; }
  .topbar .grow { flex: 1; }
  .view { padding-block: 20px calc(env(safe-area-inset-bottom, 0px) + 8.5rem); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; height: auto; padding-block: 6px;
    background: none; border: 0; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 500; cursor: pointer; min-width: 0;
  }
  .tabbar span { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: center; line-height: 1.15; }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--teal-text); font-weight: 700; box-shadow: inset 0 3px 0 var(--teal-text); }
  h1 { font-size: 1.5rem; }
  html { scroll-padding-top: calc(var(--readerhead, 0px) + 76px); }
  html { scroll-padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6rem); }
  html:has(body.reading) { scroll-padding-bottom: 0; }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar .logo-light { display: none; } :root:not([data-theme="light"]) .topbar .logo-dark { display: block; } }
:root[data-theme="dark"] .topbar .logo-light { display: none; }
:root[data-theme="dark"] .topbar .logo-dark { display: block; }

/* ---------- building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.lg { gap: 28px; }
.stack.sm { gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
@media (max-width: 1080px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.eyebrow { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lead { font-size: 1.0625rem; color: var(--fg); max-width: 62ch; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.xs { font-size: .8125rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; min-width: 0; }
.card.rule { border-top: 3px solid var(--slate); }
.card.rule.amber { border-top-color: var(--amber); }
.card.rule.teal { border-top-color: var(--teal); }
.card.flush { padding: 0; overflow: hidden; }
.card h2 + p, .card h3 + p { margin-top: 6px; }
.band { background: var(--panel); border-radius: var(--r-card); padding: 18px 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border-radius: var(--r-btn); border: 1px solid transparent;
  font-weight: 600; font-size: .9375rem; text-decoration: none; cursor: pointer; line-height: 1.2; text-align: center;
  transition: background-color .18s, border-color .18s;
}
.btn.primary { background: var(--cta); color: var(--cta-ink); }
.btn.primary:hover { background: var(--cta-hover); }
.btn.solid { background: var(--solid); color: var(--solid-fg); }
.btn.solid:hover { background: var(--solid-hover); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--panel); }
.btn.quiet { background: transparent; color: var(--teal-text); padding-inline: 8px; }
.btn.quiet:hover { background: var(--teal-soft); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; }
.iconbtn:hover { background: var(--panel); }
.iconbtn .icon { width: 22px; height: 22px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--panel); color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.new { background: var(--warn-soft); color: var(--warn); }
.chip.teal { background: var(--teal-soft); color: var(--teal-text); }
.chip.line { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.chip .icon { width: 14px; height: 14px; }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; transition: width .3s; }
.progress.thin { height: 5px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 500; font-size: .875rem; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; color: var(--ink); font-size: .9375rem; }
.field .hint { font-size: .8125rem; color: var(--muted); }
.field .err { font-size: .8125rem; color: var(--danger); font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-btn);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: max(16px, 1rem);
}
textarea.input { min-height: 104px; resize: vertical; line-height: 1.55; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch:first-child { border-top: 0; }
.switch.wrap { flex-wrap: wrap; }
@media (max-width: 620px) {
  .switch.wrap .seg { display: flex; width: 100%; }
  .switch.wrap .seg button { flex: 1 1 0; min-width: 0; padding-inline: 6px; }
}
.switch input { width: 22px; height: 22px; accent-color: var(--teal); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-btn); overflow: hidden; }
.seg button { min-height: 40px; min-width: 44px; padding: 6px 12px; border: 0; background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; font-size: .875rem; border-left: 1px solid var(--line-strong); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal-text); font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.rowlink { display: flex; align-items: center; gap: 14px; padding: 14px 4px; text-decoration: none; color: inherit; min-height: 56px; }
.rowlink:hover { background: var(--panel); }
.rowlink .t { font-weight: 600; color: var(--ink); }
.rowlink .chev { margin-left: auto; color: var(--muted); }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: var(--teal-soft); color: var(--ink); font-size: .9375rem; }
.notice.warn { background: var(--warn-soft); }
.notice .icon { color: var(--teal-text); margin-top: 2px; }

/* ---------- welcome (arrival after buying) ---------- */
.welcome { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 36px; align-items: center; }
.welcome h1 { font: 500 2.5rem/1.1 var(--f-hero); letter-spacing: -.02em; }
.welcome .art { border-radius: 14px; overflow: hidden; aspect-ratio: 1; max-width: 100%; background: var(--panel); position: relative; }
.welcome .art img, .cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; max-width: none; }
.cover { position: relative; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .tick { width: 24px; height: 24px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; flex: none; margin-top: 1px; }
.steps .tick .icon { width: 14px; height: 14px; stroke-width: 2.6; }
@media (max-width: 860px) { .welcome { grid-template-columns: minmax(0, 1fr); gap: 22px; } .welcome h1 { font-size: 2rem; } .welcome .art { max-width: 260px; } }

/* ---------- course cards ---------- */
.course { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: center; text-decoration: none; color: inherit; }
.course .cover { width: 112px; height: 112px; border-radius: 8px; overflow: hidden; background: var(--panel); }
.course .cover img { width: 100%; height: 100%; object-fit: cover; }
.course h3 { font-size: 1.0625rem; }
.course:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.continue { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0; }
.continue .cover { background: var(--panel); min-height: 200px; }
.continue .cover img { width: 100%; height: 100%; object-fit: cover; }
.continue .body { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 620px) {
  .continue { grid-template-columns: minmax(0, 1fr); }
  .continue .cover { min-height: 0; aspect-ratio: 16 / 9; }
  .course { grid-template-columns: 84px minmax(0, 1fr); gap: 12px; }
  .course .cover { width: 84px; height: 84px; }
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font: 700 1.5rem/1.1 var(--f-head); color: var(--ink); }
.stat span { font-size: .8125rem; color: var(--muted); }

/* ---------- course outline ---------- */
.hero-course { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 22px; align-items: center; }
.hero-course .cover { width: 168px; height: 168px; border-radius: 10px; overflow: hidden; background: var(--panel); }
.hero-course .cover img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 620px) { .hero-course { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; } .hero-course .cover { width: 96px; height: 96px; } }
.module { border-top: 1px solid var(--line); }
.module:first-child { border-top: 0; }
.module > summary, .module > .head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; list-style: none; min-height: 60px; }
.module > summary::-webkit-details-marker { display: none; }
.module > summary:hover { background: var(--panel); }
.module .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); color: var(--ink); font: 700 .875rem var(--f-head); flex: none; }
.module .n.done { background: var(--ok-soft); color: var(--ok); }
.module .n.now { background: var(--cta); color: var(--cta-ink); }
.module .n .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.module .title { font-weight: 600; color: var(--ink); }
.module .meta { font-size: .8125rem; color: var(--muted); }
.module .caret { margin-left: auto; color: var(--muted); transition: transform .18s; }
.module[open] .caret { transform: rotate(90deg); }
.module .parts { padding: 0 18px 16px 66px; display: grid; gap: 8px; }
.part { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); min-height: 48px; background: var(--surface); }
.part:hover { border-color: var(--line-strong); background: var(--panel); }
.part .state { margin-left: auto; font-size: .8125rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.part .state.ok { color: var(--ok); font-weight: 600; }
.part.locked { color: var(--muted); background: var(--panel); border-style: dashed; }
@media (max-width: 620px) { .module .parts { padding-left: 18px; } }

/* ---------- reader ---------- */
body.reading .rail, body.reading .tabbar, body.reading .topbar { display: none; }
body.reading .app { display: block; }
body.reading .view { max-width: none; padding: 0; }
.readerhead { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.readerbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.readerbar .where { min-width: 0; flex: 1; }
.readerbar .where b { display: block; color: var(--ink); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readerbar .where span { display: block; font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readerprog { height: 3px; background: var(--line); }
.readerprog i { display: block; height: 100%; background: var(--teal); transition: width .3s; }
.reader { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 0; align-items: start; }
.reader .outline { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--readerhead, 64px)); max-height: calc(100vh - var(--readerhead, 64px)); max-height: calc(100dvh - var(--readerhead, 64px) - env(safe-area-inset-top, 0px)); overflow-y: auto; padding: 22px 14px 22px max(18px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); }
.reader .outline ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.reader .outline a { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 7px; text-decoration: none; color: var(--fg); font-size: .875rem; line-height: 1.35; min-height: 40px; }
.reader .outline a:hover { background: var(--panel); }
.reader .outline a[aria-current="true"] { background: var(--teal-soft); color: var(--ink); font-weight: 600; }
.reader .outline .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; margin-top: 1px; display: grid; place-items: center; }
.reader .outline .dot.done { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.reader .outline .dot .icon { width: 10px; height: 10px; stroke-width: 3.4; }
.page { max-width: 46rem; margin: 0 auto; padding-block: 36px 96px; padding-left: max(22px, env(safe-area-inset-left, 0px)); padding-right: max(22px, env(safe-area-inset-right, 0px)); }
.page .kicker { font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-text); font-weight: 700; }
.page h1 { font-size: 2rem; margin-top: 6px; }
.prose { margin-top: 22px; display: flow-root; font-size: 1.0625rem; color: var(--fg); }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { font-size: 1.25rem; margin-top: 1.9em; }
.prose ul, .prose ol { margin-bottom: 0; padding-left: 1.3em; display: grid; gap: .5em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose .insight { border-left: 4px solid var(--amber); background: var(--warn-soft); padding: 14px 16px; border-radius: 0 8px 8px 0; color: var(--ink); }
.prose .insight b { display: block; font: 700 .8125rem var(--f-head); letter-spacing: .06em; text-transform: uppercase; color: var(--warn); margin-bottom: 4px; }
.prose .exercise { border: 1px solid var(--line-strong); border-radius: var(--r-card); padding: 18px; background: var(--surface); display: grid; gap: 12px; }
.prose .exercise .tag { font: 700 .8125rem var(--f-head); letter-spacing: .06em; text-transform: uppercase; color: var(--teal-text); }
.prose .exercise .saved { font-size: .8125rem; color: var(--ok); font-weight: 600; min-height: 1.2em; }
.prose .exercise details { border-top: 1px solid var(--line); padding-top: 10px; }
.prose .exercise summary { cursor: pointer; font-weight: 600; color: var(--teal-text); min-height: 40px; padding-block: 8px; }
.prose .exercise details p { margin-top: 8px; font-size: .9375rem; }
.pagenav { display: flex; gap: 12px; justify-content: space-between; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.listen { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin-top: 18px; }
.listen .bar { flex: 1; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 40px; }
.listen .bar i { display: block; height: 100%; width: 0; background: var(--slate); }
.listen .time { font-size: .8125rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 620px) { .listen > .xs { flex-basis: 100%; } }
.notes { margin-top: 28px; }
@media (max-width: 980px) {
  .reader { grid-template-columns: minmax(0, 1fr); }
  .reader .outline { display: none; }
  .reader .outline.open { display: block; position: fixed; inset: 0; z-index: 40; max-height: none; background: var(--surface); border: 0; padding-top: calc(env(safe-area-inset-top, 0px) + 18px); }
  .page { padding-block: 24px 96px; }
  .page h1 { font-size: 1.625rem; }
}
.outline-close, #btn-outline { display: none; }
@media (max-width: 980px) { .reader .outline.open .outline-close, #btn-outline { display: inline-grid; } }

/* ---------- tests and exam ---------- */
.q { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); padding: 18px; display: grid; gap: 12px; }
.q .qn { font: 700 .8125rem var(--f-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
fieldset.q { display: block; min-width: 0; margin: 0; }
fieldset.q legend { float: left; width: 100%; padding: 0; margin-bottom: 12px; display: grid; gap: 8px; }
fieldset.q legend .qt { display: block; }
fieldset.q .opts { clear: both; }
.q .qt { font-weight: 600; color: var(--ink); font-size: 1.0625rem; line-height: 1.45; }
.model { background: var(--panel); border-radius: 8px; padding: 12px 14px; font-size: .9375rem; }
.model b { display: block; font-size: .8125rem; color: var(--teal-text); margin-bottom: 2px; }
.opts { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; background: var(--surface); line-height: 1.5; }
.opt:hover { background: var(--panel); }
.opt input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--teal); flex: none; }
.opt:has(input:checked) { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); background: var(--teal-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.result { text-align: center; padding: 32px 20px; }
.result h1 { display: grid; gap: 8px; justify-items: center; }
.result .score { display: block; font: 700 3rem/1 var(--f-head); color: var(--ink); letter-spacing: -.02em; }

/* ---------- certificate ---------- */
.certwrap { overflow-x: auto; }
@media (max-width: 620px) { .certwrap .cert { min-width: 520px; } }
.cert {
  background: #fff; color: #263f4a; border: 1px solid #dbe5e9; border-radius: 6px; padding: 7% 8%;
  aspect-ratio: 1.414 / 1; width: 100%; max-width: 760px; margin: 0 auto; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1.4%;
  box-shadow: var(--shadow); container-type: inline-size;
}
.cert::before { content: ""; position: absolute; inset: 2.4%; border: 2px solid #3f6477; border-radius: 3px; pointer-events: none; }
.cert::after { content: ""; position: absolute; inset: 3.4%; border: 1px solid #ed9a24; pointer-events: none; }
.cert img.lg { height: 5.2cqw; width: auto; }
.cert .c-small { font: 600 1.55cqw var(--f-body); letter-spacing: .22em; text-transform: uppercase; color: #5d7079; }
.cert .c-name { font: 500 5.6cqw/1.1 var(--f-hero); color: #263f4a; }
.cert .c-course { font: 700 3cqw/1.2 var(--f-head); color: #2c4d5e; }
.cert .c-line { font: 400 1.75cqw/1.5 var(--f-body); color: #4a5c65; max-width: 80%; }
.cert .c-foot { position: absolute; left: 8%; right: 8%; bottom: 7.5%; display: flex; justify-content: space-between; align-items: flex-end; font: 400 1.45cqw/1.4 var(--f-body); color: #4a5c65; text-align: left; }
.cert .c-foot b { display: block; color: #263f4a; font-weight: 600; }
.cert .qr { width: 9cqw; height: 9cqw; display: grid; grid-template-columns: repeat(9, 1fr); gap: 0; background: #fff; padding: .4cqw; border: 1px solid #dbe5e9; }
.cert .qr i { background: #263f4a; }
.cert .qr i.o { background: transparent; }

/* ---------- community ---------- */
.thread { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 16px 18px; text-decoration: none; color: inherit; }
.thread:hover { background: var(--panel); }
.thread h3 { font-size: 1rem; line-height: 1.35; }
.thread .ex { color: var(--fg); font-size: .9375rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; }
.thread .meta, .post .meta { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: .8125rem; color: var(--muted); margin-top: 8px; }
.school { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel); color: var(--ink); }
.school.efc { background: var(--teal-soft); color: var(--teal-text); }
.post { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 18px 0; border-top: 1px solid var(--line); }
.post:first-of-type { border-top: 0; }
.post .who { font-weight: 600; color: var(--ink); }
.post .body { margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; }
.like { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-size: .8125rem; font-weight: 600; }
.like[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-text); }

/* ---------- live ---------- */
.live { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 18px; }
.date { width: 76px; text-align: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.date b { display: block; font: 700 1.5rem/1.3 var(--f-head); color: var(--ink); }
.date span { display: block; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; background: var(--solid-hover); color: var(--solid-fg); padding: 3px 0; font-weight: 600; }
@media (max-width: 620px) { .live { grid-template-columns: 64px minmax(0, 1fr); } .live .act { grid-column: 1 / -1; } .date { width: 64px; } }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; border-radius: 12px; background: var(--surface); color: var(--fg); width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 760px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(20, 34, 41, .55); }
dialog .dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
dialog .dbody { padding: 18px 20px 22px; display: grid; gap: 16px; }

.toast { position: fixed; left: 16px; right: 16px; margin-inline: auto; width: max-content; max-width: min(560px, calc(100vw - 32px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); z-index: 60; background: var(--toast); color: var(--toast-fg); padding: 12px 18px; border-radius: 8px; font-weight: 500; font-size: .9375rem; box-shadow: var(--shadow); pointer-events: none; }
@media (max-width: 860px) { .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 124px); } body.reading .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 68px); } }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
:root[data-motion="less"] *, :root[data-motion="less"] *::before, :root[data-motion="less"] *::after { transition: none !important; animation: none !important; }


/* ---------- pages outside the signed-in shell: sign-in, sign-in link, certificate check ---------- */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.bare .box { width: 100%; max-width: 440px; display: grid; gap: 22px; }
.bare .box.wide { max-width: 760px; }
.bare .logo { height: 32px; width: auto; justify-self: start; }
.bare .logo-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bare .logo-light { display: none; } :root:not([data-theme="light"]) .bare .logo-dark { display: block; } }
:root[data-theme="dark"] .bare .logo-light { display: none; }
:root[data-theme="dark"] .bare .logo-dark { display: block; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8125rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- messages from the server ---------- */
.flash { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: var(--teal-soft); color: var(--ink); font-size: .9375rem; margin-bottom: 18px; }
.flash.ok { background: var(--ok-soft); }
.flash.warn { background: var(--warn-soft); }
.flash.bad { background: var(--danger-soft); }
.flash .icon { margin-top: 2px; color: var(--teal-text); }
.flash.ok .icon { color: var(--ok); }
.flash.bad .icon { color: var(--danger); }
.banner { background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--line); padding-block: 10px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); font-size: .9375rem; display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; }
.banner.admin { background: var(--danger-soft); }
form.inline { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--teal-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
audio { width: 100%; margin-top: 18px; }

/* A control that needs scripts is shipped with the hidden attribute; nothing in the stylesheet may show it again. */
[hidden] { display: none !important; }
/* Stand-alone links on the sign-in and error pages are easy to hit with a thumb. */
.bare p.small > a { display: inline-block; padding-block: 10px; }

/* A picture inside a lesson */
.lesson-figure { margin: 22px 0; }
.lesson-figure img { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.lesson-figure figcaption { margin-top: 8px; font-size: .875rem; color: var(--muted); }
.listen { margin: 0 0 20px; padding: 12px 14px; border-radius: 10px; background: var(--panel); }
.listen p { margin: 0 0 8px; font-weight: 600; color: var(--ink); }

/* The accredited certificate design: a picture of the sheet, with the student's details set on it.
   Sizes are in cqw (hundredths of the sheet's width), so it looks the same at any size and in print. */
.certphoto { position: relative; container-type: inline-size; aspect-ratio: 1375 / 1062; max-width: 980px; margin-inline: auto; color: #1d2540; }
.certphoto .bg { display: block; width: 100%; height: 100%; }
.certphoto .cp { position: absolute; left: 13%; right: 13%; transform: translateY(-50%); text-align: center; line-height: 1.15; font-family: "Cormorant Garamond", "Fraunces", Georgia, "Times New Roman", serif; }
.certphoto .cp-title { top: 24.3%; font-size: 3.1cqw; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.certphoto .cp-name { top: 35.1%; font-size: 3.5cqw; font-weight: 500; letter-spacing: .03em; text-transform: uppercase; color: #48689b; }
.certphoto .cp-line { top: 44.8%; font-size: 1.5cqw; letter-spacing: .05em; text-transform: uppercase; }
.certphoto .cp-line b { font-weight: 500; color: #48689b; }
.certphoto .cp-date { top: 52.1%; font-size: 1.25cqw; font-style: italic; }
.certphoto .cp-num { top: 54.5%; font-size: 1.25cqw; font-style: italic; }
.certphoto .cp-check { top: 88.6%; font-size: .95cqw; color: #4a5c65; letter-spacing: .02em; font-family: var(--f-body); }
@media (max-width: 620px) { .certwrap .certphoto { min-width: 520px; } }
