/* Only the active, owned mathematics lesson uses the full-height reader. */
body.yf-lesson-reading {
  --reader-ink: var(--yf-text, #252c29);
  --reader-muted: var(--yf-muted, #59645e);
  --reader-line: var(--yf-border, #d4d9d3);
  --reader-accent: var(--yf-primary, #315e4d);
}
body.yf-lesson-reading[data-yf-soft-route="home"] #home.hero {
  --reader-paper:var(--yf-surface, var(--paper, #faf9f6));
  background:var(--reader-paper) !important;
  padding: 16px clamp(18px, 2.6vw, 42px) max(12px, env(safe-area-inset-bottom)) !important;
}
body.yf-lesson-reading #home > .yf-soft-header:not([hidden]),
body.yf-lesson-reading #home > .hero-stage.is-chat-active {
  width: min(1120px,100%) !important; max-width:100% !important; margin-inline:auto !important;
}
body.yf-lesson-reading #home > .yf-soft-header:not([hidden]) {
  min-height:48px; margin-bottom: 0 !important; padding:0 0 10px;
  border:0; border-bottom:1px solid var(--reader-line);
}
body.yf-lesson-reading #home > .yf-soft-header > .yf-soft-identity { display:none !important; }
#readerLessonTitle { display:flex; align-items:baseline; gap:12px; margin-right:auto; color:var(--reader-ink); }
#readerLessonTitle strong { font-size:1.26rem; font-weight:650; line-height:1.25; }
#readerLessonTitle span { color:var(--reader-muted); font-size:.86rem; }
body.yf-lesson-reading #home > .hero-stage.is-chat-active {
  container: lesson-shell / inline-size; gap:0 !important; padding:0 !important;
}
body.yf-lesson-reading #home #chatArea.chat-area.is-conversation {
  grid-template-columns:minmax(0,1fr) !important; padding:0 0 14px !important;
  border:0 !important; background:transparent !important; box-shadow:none !important;
  scrollbar-gutter:auto; scroll-padding-block:10px; overflow-anchor:none;
}
body.yf-lesson-reading #home #chatArea .chat-turn { width:100%; min-width:0; }
body.yf-lesson-reading #home #chatArea article.reader-lesson {
  width:100%; max-width:none !important; min-width:0; box-sizing:border-box;
  display:block !important; padding:18px 6px 20px !important; border:0 !important; border-radius:0 !important;
  box-shadow:none !important; background:transparent !important; color:var(--reader-ink);
}
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-label,
body.yf-lesson-reading #home #chatArea .reader-lesson > .yf-prototype-copy { display:none !important; }
body.yf-lesson-reading #home #chatArea .reader-lesson:has(.reader-tools[open]) > .yf-prototype-copy {
  display:inline-flex !important; float:right; margin-top:0; position:relative; z-index:1;
}
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body {
  margin:0; padding:0 !important; max-width:none; border:0 !important; box-shadow:none !important;
  background:transparent !important; min-width:0; color:var(--reader-ink);
  font-size:1rem; line-height:1.68;
}
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body > p {
  margin:0 0 .55em !important;
}
.reader-lesson .reader-heading-break { white-space:normal; }
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body h3 {
  margin:1.15em 0 .35em !important; padding:0; color:var(--reader-ink);
  border:0 !important; font-size:1.08em; line-height:1.4; font-weight:650;
}
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body > :first-child h3,
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body > h3:first-child { margin-top:0 !important; }
body.yf-lesson-reading #home #chatArea .reader-lesson h3:focus-visible { outline:2px solid var(--reader-accent); outline-offset:2px; }
body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body .crm-formula-display {
  margin-block:.4em !important; padding-block:.15em;
}
body.yf-lesson-reading #home #chatArea .reader-lesson .chat-other-question { margin:12px 0 6px !important; }
body.yf-lesson-reading #home #chatArea .reader-next-question {
  color:var(--reader-accent); min-height:44px !important; padding:4px 16px !important; border:1px solid var(--reader-line); border-radius:8px;
}
.reader-tools { margin-top:6px; color:var(--reader-muted); }
.reader-tools > summary { cursor:pointer; width:fit-content; padding:10px 0; font-size:.875rem; }
.reader-tools-items { display:flex; flex-wrap:wrap; gap:10px 14px; align-items:baseline; }
.reader-tools-items > .chat-question-source[open], .reader-tools-items > .chat-question-correction:has(textarea) { width:100%; }
.reader-tools-items > .chat-explanation-pdf-status:empty { display:none !important; }
.reader-chapters { display:none; }
@container lesson-shell (min-width: 880px) {
  .reader-chapters {
    display:grid; position:absolute; inset-block-start:28px; inset-inline-end:12px;
    width:170px; border-left:1px solid var(--reader-line); padding-left:20px; z-index:1;
    align-content:start;
  }
  .reader-chapters strong { color:var(--reader-muted); font-size:.82rem; font-weight:550; margin:0 0 8px; }
  .reader-chapters button { text-align:left; padding:6px 8px; min-height:36px; border:0; background:transparent; font:inherit; font-size:.89rem; color:var(--reader-muted); cursor:pointer; }
  .reader-chapters button[aria-current] { color:var(--reader-accent); font-weight:650; }
  .reader-chapters button:hover { text-decoration:underline; }
  .hero-stage:has(.ask-step-panel:not([hidden])) .reader-chapters { display:none; }
  body.yf-lesson-reading #home #chatArea article.reader-lesson:not(:has(.ask-step-panel)) > .chat-message-body,
  body.yf-lesson-reading #home #chatArea article.reader-lesson:not(:has(.ask-step-panel)) > .ask-step-note {
    width: min(790px, calc(100% - 230px));
  }
}
body.yf-lesson-reading #home #searchForm.is-conversation-composer:not(.reader-composer-open) {
  min-height:0 !important; height:auto !important; margin:0 !important; padding:0 !important;
  border:0 !important; border-top:1px solid var(--reader-line) !important; border-radius:0 !important;
  box-shadow:none !important; background:transparent !important;
}
body.yf-lesson-reading #home #searchForm.is-conversation-composer:not(.reader-composer-open) > :not(#readerComposeToggle) { display:none !important; }
body.yf-lesson-reading #readerComposeToggle {
  display:flex; align-items:center; gap:10px; width:100%; min-height:48px; padding:4px 8px;
  border:0; background:transparent; color:var(--reader-ink); border-radius:4px; cursor:pointer;
  font:inherit; font-size:.95rem; text-align:left;
}
body.yf-lesson-reading #readerComposeToggle::before { content:'＋'; font-size:1.25em; color:var(--reader-accent); }
body.yf-lesson-reading #readerComposeToggle[aria-expanded=true] {
  width:fit-content; min-height:32px; margin-inline-start:auto; color:var(--reader-muted); font-size:.82rem;
}
body.yf-lesson-reading #readerComposeToggle[aria-expanded=true]::before { content:'⌄'; }
body.yf-lesson-reading #readerComposeToggle:focus-visible { outline:2px solid var(--reader-accent); outline-offset:-3px; }
body.yf-lesson-reading #searchForm.reader-composer-open { margin-top:6px !important; }
@media (max-width:760px) {
  body.yf-lesson-reading[data-yf-soft-route="home"] #home.hero {
    padding:max(4px,env(safe-area-inset-top)) 14px max(4px,env(safe-area-inset-bottom)) !important;
  }
  body.yf-lesson-reading[data-yf-soft-route="home"] .topbar {
    width:50px !important; height:52px !important; min-height:0 !important; padding:0 4px !important;
    background:transparent !important; border:0 !important; box-shadow:none !important;
  }
  body.yf-lesson-reading[data-yf-soft-route="home"] .topbar > .wordmark { display:none !important; }
  body.yf-lesson-reading[data-yf-soft-route="home"] .topbar #mobileMenuButton { width:42px; min-height:44px; margin:0 !important; }
  body.yf-lesson-reading[data-yf-soft-route="home"] #home > .yf-soft-header:not([hidden]) {
    padding:0 0 0 42px; min-height:48px; gap:6px;
  }
  body.yf-lesson-reading #readerLessonTitle { gap:8px; }
  #readerLessonTitle strong { font-size:1.04rem; }
  #readerLessonTitle span { font-size:.78rem; }
  body.yf-lesson-reading #home #chatArea article.reader-lesson { padding:12px 0 8px !important; }
  body.yf-lesson-reading #home #chatArea .reader-lesson > .chat-message-body { font-size:1rem; line-height:1.6; }
  body.yf-lesson-reading .yf-prototype-header-tools { gap:5px; }
  body.yf-lesson-reading #readerComposeToggle { min-height:44px; padding:2px 4px; }
}

/* The reading area uses the chosen theme's actual paper colour. Avoid a
   translucent card or backdrop behind a page of small math notation. */
body.yf-lesson-reading[data-yf-soft-route="home"] #home.hero > .hero-stage.is-chat-active,
body.yf-lesson-reading[data-yf-soft-route="home"] #home.hero > .yf-soft-header:not([hidden]) {
  background:var(--reader-paper) !important;
}
body.yf-lesson-reading #home .hero-stage.is-chat-active::before,
body.yf-lesson-reading #home .hero-stage.is-chat-active::after { content:none !important; }
body.yf-lesson-reading #home #chatArea .reader-followup {
  margin-inline:0 !important; border-radius:0 !important; box-shadow:none !important;
}
body.yf-lesson-reading #home #chatArea .reader-followup > .chat-message-body {
  max-width:790px; padding:0 !important; min-width:0;
}
