/* G8Code Student Learning UI v1 — Home-matched headers, cards & five-tab mobile navigation.
   Standalone guest access is preserved. No changes to lesson PDFs, activities, quiz
   overlays, project editors, saved data, or teacher settings. */
:is(#lessonViewerScreen,#givenActivitiesScreen){
  --ls-bg:#f5f7fc;--ls-ink:#17253c;--ls-muted:#60718b;--ls-card:#fff;
  --ls-border:#e3e9f2;--ls-accent:#275ac8;--ls-soft:#ecf2ff;
  --ls-radius:18px;--ls-shadow:0 12px 40px rgba(29,53,96,.055);
  box-sizing:border-box;max-width:100vw;overflow-x:hidden;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) *,
:is(#lessonViewerScreen,#givenActivitiesScreen) *::before,
:is(#lessonViewerScreen,#givenActivitiesScreen) *::after{box-sizing:border-box}
html[data-theme="dark"] :is(#lessonViewerScreen,#givenActivitiesScreen){
  --ls-bg:#0f1727;--ls-ink:#eef3ff;--ls-muted:#b1c0d8;--ls-card:#17243a;
  --ls-border:#34415b;--ls-accent:#8bb5ff;--ls-soft:#23395c;
  --ls-shadow:0 10px 36px rgba(0,0,0,.13);
}
body[data-student-app-theme]:not([data-student-app-theme="original"]) :is(#lessonViewerScreen,#givenActivitiesScreen){
  --ls-bg:var(--sat-bg,#f5f7fc);--ls-ink:var(--sat-text,#17253c);
  --ls-muted:var(--sat-muted,#60718b);--ls-card:var(--sat-card,#fff);
  --ls-border:var(--sat-border,#e3e9f2);--ls-accent:var(--sat-primary,#275ac8);
  --ls-soft:var(--sat-soft,#ecf2ff);--ls-radius:var(--sat-radius,18px);
}
/* Keep independently themed guest lessons untouched; student pages follow Home. */
body #lessonViewerScreen.is-learning-student,
body #givenActivitiesScreen.is-learning-student{
  background:var(--sat-decor,none),var(--ls-bg)!important;
  color:var(--ls-ink)!important;
}
/* Header: same structure, logo, scale, controls and maximum width as Student Home. */
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header{
  position:relative!important;top:auto!important;z-index:25;
  flex:0 0 auto;display:block!important;width:100%;min-height:0!important;
  padding:0 clamp(16px,3vw,34px)!important;
  background:transparent!important;border:0!important;box-shadow:none!important;
  backdrop-filter:none!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header-inner{
  max-width:1240px;margin-inline:auto;min-height:94px;padding:12px 0;
  display:flex;justify-content:space-between;align-items:center;gap:12px;
  border-bottom:1px solid var(--ls-border);
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand{
  display:flex;align-items:center;gap:13px;min-width:0;flex:1 1 auto;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-logo{
  width:48px;height:48px;flex:0 0 48px;position:relative;display:grid;place-items:center;
  border-radius:15px;border:1px solid rgba(240,214,130,.2);
  background:linear-gradient(145deg,#172a46,#223e67);color:#ffdc63;
  box-shadow:0 8px 20px rgba(14,27,53,.13);
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-logo-indicator{
  position:absolute;bottom:7px;right:7px;width:5px;height:5px;border-radius:50%;
  background:#69dbab;box-shadow:0 0 0 3px rgba(105,219,171,.12);
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-copy{
  min-width:0;display:flex;flex-direction:column;gap:2px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-eyebrow{
  font-size:10px;letter-spacing:1.7px;line-height:1.25;font-weight:850;
  color:var(--ls-muted);
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-copy strong{
  font-size:19px;line-height:1.22;letter-spacing:-.5px;font-weight:850;
  color:var(--ls-ink)!important;white-space:nowrap;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-subtitle{
  font-size:11px;line-height:1.4;color:var(--ls-muted)!important;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:min(44vw,440px);
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header-tools{
  display:flex!important;flex:0 0 auto;align-items:center;justify-content:flex-end;
  flex-wrap:nowrap!important;width:auto!important;gap:8px!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-term-pill{
  display:inline-flex;align-items:center;justify-content:center;min-height:38px;
  padding:0 13px;border-radius:999px;white-space:nowrap;
  border:1px solid var(--ls-border)!important;background:var(--ls-card)!important;
  color:var(--ls-muted)!important;font-size:12px;font-weight:750;
  width:auto!important;order:0;grid-column:auto;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) :is(.learning-round-btn,.learning-back-btn){
  display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
  margin:0;min-height:40px!important;height:40px;min-width:40px;
  padding:0 9px!important;border:1px solid var(--ls-border)!important;border-radius:12px!important;
  background:var(--ls-card)!important;color:var(--ls-ink)!important;
  box-shadow:none!important;font-size:19px!important;font-weight:700;
  cursor:pointer;line-height:1;white-space:nowrap;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) :is(.learning-round-btn,.learning-back-btn):hover{
  background:var(--ls-soft)!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-round-btn svg{display:block;flex:none}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-back-btn{
  gap:6px;padding:0 12px!important;font-size:12px!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-back-btn span{font-size:12px}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-theme-btn{
  font-size:0!important;position:relative;overflow:hidden!important;text-indent:-9999px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-theme-btn::after{
  content:'◐';font-size:23px;line-height:1;position:absolute;inset:0;display:grid;place-items:center;text-indent:0;color:var(--ls-ink);
}
html[data-theme="dark"] :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-theme-btn::after,
body[data-student-app-appearance="dark"] :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-theme-btn::after{content:'☀'}
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-round-btn.hidden{display:none!important}
:is(#lessonViewerScreen,#givenActivitiesScreen):not(.is-learning-student) .learning-student-only{display:none!important}
/* Cards, hero and controls follow the Student Home design, preserving content/actions. */
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-main,.given-activities-main){
  min-width:0;
}
#lessonViewerScreen.is-learning-student .lesson-library-main{
  max-width:1240px;width:calc(100% - clamp(32px,6vw,68px));
  padding:14px 0 60px;
}
#givenActivitiesScreen.is-learning-student .given-activities-main{
  padding:14px clamp(16px,3vw,34px) 60px;min-width:0;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome){
  position:relative;isolation:isolate;overflow:hidden;
  min-height:170px;padding:24px clamp(20px,2.5vw,30px)!important;
  background:linear-gradient(115deg,#132847 0%,#173b71 70%,#2458a1 100%)!important;
  color:#fff!important;border:0!important;border-radius:18px!important;
  box-shadow:0 9px 27px rgba(12,35,77,.13)!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome)::before{
  content:'';position:absolute;inset:0;z-index:-1;pointer-events:none;
  background:radial-gradient(circle at 85% 25%,rgba(94,178,255,.2),transparent 38%),
  radial-gradient(circle at 16% 100%,rgba(248,196,55,.11),transparent 37%);
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) :is(h2,p,span){
  color:#fff!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) h2{
  font-size:clamp(22px,2.3vw,28px)!important;letter-spacing:-.55px;
  line-height:1.2;margin:7px 0 8px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) p{
  max-width:680px;font-size:12px!important;line-height:1.55;opacity:.88;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-eyebrow,.given-activities-eyebrow){
  color:var(--ls-accent)!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) :is(.lesson-library-eyebrow,.given-activities-eyebrow){
  font-size:10px!important;letter-spacing:1.3px;color:#c2d9fa!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-stat,.given-activities-stat){
  background:rgba(255,255,255,.12)!important;border:1px solid rgba(255,255,255,.16)!important;
  color:#fff!important;border-radius:17px!important;min-height:94px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-stat,.given-activities-stat) :is(strong,span){
  color:#fff!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-controls,.given-activities-controls,.lesson-continue-card,.lesson-library-card,.given-activity-card){
  background:var(--ls-card)!important;border:1px solid var(--ls-border)!important;
  border-radius:var(--ls-radius)!important;
  box-shadow:var(--ls-shadow)!important;color:var(--ls-ink)!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-controls,.given-activities-controls){
  margin-top:16px;padding:14px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-continue-card,.lesson-library-card,.given-activity-card){
  transition:border-color .2s ease,transform .2s ease,box-shadow .2s ease;
}
@media(hover:hover) and (pointer:fine){
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-card,.given-activity-card):hover{
    transform:translateY(-3px);border-color:var(--ls-accent)!important;
    box-shadow:0 16px 35px rgba(32,69,128,.13)!important;
  }
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-grid,.given-activities-grid){
  gap:13px;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-term-tab{
  min-width:0;border-radius:12px;font-size:12px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-term-tab.active{
  background:var(--ls-accent)!important;border-color:var(--ls-accent)!important;color:#fff!important;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-search,.lesson-library-filter-row select,.given-activities-filter-row select){
  border-color:var(--ls-border)!important;color:var(--ls-ink)!important;border-radius:12px;
}
:is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-search input,.given-activities-filter-row input){
  color:var(--ls-ink)!important;
}
/* Student Home uses exactly these 5 labels/icons; expose same mobile navigation. */
:is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-nav{display:none}
@media(max-width:760px){
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header{
    padding:0 12px!important;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header-inner{
    min-height:67px;padding:9px 0;gap:7px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand{gap:9px}
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-logo{
    width:38px;height:38px;flex-basis:38px;border-radius:12px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-eyebrow{
    font-size:8px;letter-spacing:.85px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-copy strong{
    font-size:15px;line-height:1.2;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-subtitle{
    font-size:9px;max-width:130px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header-tools{gap:5px!important}
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-term-pill{display:none!important}
  :is(#lessonViewerScreen,#givenActivitiesScreen) :is(.learning-round-btn,.learning-back-btn){
    width:36px;min-width:36px;min-height:36px!important;height:36px;
    border-radius:12px!important;padding:0 5px!important;
    font-size:18px!important;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-back-btn{width:auto;gap:2px;font-size:12px!important}
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .learning-back-btn{display:none!important}
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .learning-header-tools :is(#lessonLibraryRefreshBtn,#givenActivitiesRefreshBtn){display:none!important}
  #lessonViewerScreen.is-learning-student .lesson-library-main{
    width:calc(100% - 24px);padding:12px 0 calc(103px + env(safe-area-inset-bottom));
  }
  #givenActivitiesScreen.is-learning-student .given-activities-main{
    padding:12px 12px calc(103px + env(safe-area-inset-bottom));
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome){
    min-height:0;padding:17px!important;border-radius:16px!important;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) h2{
    font-size:21px!important;line-height:1.2;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-welcome-card,.given-activities-welcome) p{
    font-size:11px!important;line-height:1.45;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-stat,.given-activities-stat){
    min-height:60px;padding:10px;flex-basis:auto;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-controls,.given-activities-controls){
    padding:11px;margin-top:12px;border-radius:15px!important;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-grid,.given-activities-grid){
    grid-template-columns:minmax(0,1fr)!important;gap:10px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-term-tabs{gap:6px}
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-term-tab{
    min-height:39px;padding:6px 4px;font-size:11px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-term-tab span{
    min-width:18px;height:18px;font-size:10px;margin-left:2px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-library-filter-row,
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .given-activities-filter-row{
    display:flex;flex-direction:column;gap:8px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-library-search{
    flex:0 0 auto;width:100%;min-height:42px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-library-search input{
    font-size:13px!important;font-weight:500!important;min-height:40px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .lesson-library-search input::placeholder{
    font-size:13px!important;font-weight:500!important;opacity:1;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student :is(.lesson-library-filter-row select,.given-activities-filter-row select){
    width:100%;min-height:42px;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen).is-learning-student .learning-bottom-nav{
    display:grid;grid-template-columns:repeat(5,minmax(0,1fr));
    position:fixed;bottom:0;left:0;right:0;z-index:40;
    padding:8px max(10px,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom));
    background:var(--ls-card);border-top:1px solid var(--ls-border);
    box-shadow:0 -7px 25px rgba(18,42,83,.05);
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab{
    min-width:0;min-height:49px;display:flex;flex-direction:column;
    align-items:center;justify-content:center;gap:3px;
    background:transparent;border:0;border-radius:12px;
    color:var(--ls-muted);font:inherit;cursor:pointer;
    -webkit-tap-highlight-color:transparent;
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab span{font-size:20px;line-height:1}
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab small{font-size:10px;font-weight:750}
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab.is-active{
    background:var(--ls-soft);color:var(--ls-accent);
  }
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab:focus-visible{
    outline:2px solid var(--ls-accent);outline-offset:-2px;
  }
  /* Any full-screen PDF/activity (including a protected quiz) owns the screen. */
  :is(#lessonViewerScreen,#givenActivitiesScreen).learning-modal-open .learning-bottom-nav{display:none!important}
}
@media(max-width:380px){
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-brand .sh-brand-subtitle{display:none}
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-header-tools{gap:4px!important}
  :is(#lessonViewerScreen,#givenActivitiesScreen) :is(.learning-round-btn,.learning-back-btn){width:34px;min-width:34px;height:35px;min-height:35px!important}
}
@media(prefers-reduced-motion:reduce){
  :is(#lessonViewerScreen,#givenActivitiesScreen) .learning-bottom-tab{transition:none!important}
}
/* Keep Home's navy welcome artwork above the older global student card rules,
   which otherwise force a light surface and dark text on these two heroes. */
body.student-session-active #givenActivitiesScreen.is-learning-student .given-activities-header.learning-header,
body.student-session-active #lessonViewerScreen.is-learning-student .lesson-library-header.learning-header{
  background:transparent!important;
  box-shadow:none!important;
  border:0!important;
}
body.student-session-active #givenActivitiesScreen.is-learning-student .given-activities-welcome,
body.student-session-active #lessonViewerScreen.is-learning-student .lesson-library-welcome-card{
  background:linear-gradient(115deg,#132847 0%,#173b71 70%,#2458a1 100%)!important;
  color:#fff!important;
}
body.student-session-active #givenActivitiesScreen.is-learning-student .given-activities-welcome :is(h2,h3,p,span,strong),
body.student-session-active #lessonViewerScreen.is-learning-student .lesson-library-welcome-card :is(h2,h3,p,span,strong){
  color:#fff!important;
}
body.student-session-active #givenActivitiesScreen.is-learning-student .given-activities-filter-row input,
body.student-session-active #lessonViewerScreen.is-learning-student .lesson-library-filter-row input{
  font-size:13px!important;font-weight:500!important;
}
body.student-session-active #givenActivitiesScreen.is-learning-student .given-activities-filter-row input::placeholder,
body.student-session-active #lessonViewerScreen.is-learning-student .lesson-library-filter-row input::placeholder{
  font-size:13px!important;font-weight:500!important;
}


/* V2.37: Guest Lessons respects the reader's OWN appearance. The global
   app appearance may be teacher-locked, and the guest reader does not change
   it; consequently html[data-theme] must not decide guest header colors.
   Keep the logged-in Lessons/Activities palette unchanged. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="light"] {
  --ls-bg:#eef3fa;--ls-ink:#1b2f49;--ls-muted:#52657e;
  --ls-card:#fff;--ls-border:#c7d7e9;--ls-accent:#1959b3;
  --ls-soft:#f1f6fc;--ls-shadow:0 12px 30px rgba(19,48,91,.07);
  color-scheme:light;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="dark"] {
  --ls-bg:#0d1726;--ls-ink:#f1f6ff;--ls-muted:#bdccdf;
  --ls-card:#1a2a41;--ls-border:#3b526f;--ls-accent:#9ec7ff;
  --ls-soft:#24364e;--ls-shadow:0 12px 30px rgba(0,0,0,.18);
  color-scheme:dark;
}
/* The switch icon must represent the active reader mode, not a potentially
   unrelated Login or published App mode. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="dark"] .learning-theme-btn::after {
  content:'☀' !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="light"] .learning-theme-btn::after {
  content:'☾' !important;
}


/* V2.38 — PUBLIC / GUEST LESSONS: authoritative page-specific palette.
   The older immersive student themes set the hero background and all child
   text to white even when the public reader is in LIGHT mode. Here we scope
   the override to the non-student lesson screen, so authenticated pages keep
   their teacher-published style. These selectors must win over both generic
   student-theme styles and the old lesson-reader !important declarations. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="light"] {
  --lv-page:#eef3fa !important; --lv-header:#fff !important;
  --lv-panel:#fff !important; --lv-raised:#f1f6fc !important;
  --lv-control:#f5f8fc !important; --lv-ink:#1b2f49 !important;
  --lv-muted:#52657e !important; --lv-border:#c7d7e9 !important;
  --lv-accent:#1959b3 !important; --ls-bg:#eef3fa !important;
  --ls-card:#fff !important; --ls-ink:#1b2f49 !important;
  --ls-muted:#52657e !important; --ls-border:#c7d7e9 !important;
  --ls-soft:#f1f6fc !important;
  --guest-hero:#fff; --guest-hero-ink:#233449;
  --guest-hero-muted:#52657e; --guest-hero-kicker:#b21e70;
  --guest-control:#f5f8fc;
  color-scheme:light !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="dark"] {
  --lv-page:#0d1726 !important; --lv-header:#142238 !important;
  --lv-panel:#1a2a41 !important; --lv-raised:#24364e !important;
  --lv-control:#101e31 !important; --lv-ink:#f1f6ff !important;
  --lv-muted:#bdccdf !important; --lv-border:#3b526f !important;
  --lv-accent:#9ec7ff !important; --ls-bg:#0d1726 !important;
  --ls-card:#1a2a41 !important; --ls-ink:#f1f6ff !important;
  --ls-muted:#bdccdf !important; --ls-border:#3b526f !important;
  --ls-soft:#24364e !important;
  --guest-hero:#172a43; --guest-hero-ink:#f1f6ff;
  --guest-hero-muted:#c2d3eb; --guest-hero-kicker:#e4b7e0;
  --guest-control:#101e31;
  color-scheme:dark !important;
}
/* Important: the published themes use background-image separately; reset it
   explicitly so a bright/dark admin hero never sticks on the guest reader. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] {
  background:var(--lv-page) !important;
  background-image:none !important;
  background-color:var(--lv-page) !important;
  color:var(--lv-ink) !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card {
  background:var(--guest-hero) !important;
  background-image:none !important;
  background-color:var(--guest-hero) !important;
  border:1px solid var(--lv-border) !important;
  box-shadow:var(--lv-shadow) !important;
  color:var(--guest-hero-ink) !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card :is(h1,h2,h3,strong) {
  color:var(--guest-hero-ink) !important; opacity:1 !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card p {
  color:var(--guest-hero-muted) !important; opacity:1 !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card .lesson-library-eyebrow {
  color:var(--guest-hero-kicker) !important; opacity:1 !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-library-header,.lesson-library-controls,.lesson-continue-card,
  .lesson-library-card,.lesson-library-empty,.lesson-pdf-card
) {
  background:var(--lv-panel) !important;
  background-image:none !important;
  color:var(--lv-ink) !important;
  border-color:var(--lv-border) !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-library-header,.learning-header
) {background:transparent !important; background-image:none !important;}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-continue-content p,.lesson-card-content p,.lesson-card-meta,
  .lesson-card-progress > span,.lesson-library-empty p,.lesson-library-status
) {color:var(--lv-muted) !important;}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-library-search,.lesson-library-search input,.lesson-library-filter-row select
) {
  color:var(--lv-ink) !important;
  background:var(--guest-control) !important;
  border-color:var(--lv-border) !important;
  -webkit-text-fill-color:var(--lv-ink) !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-search input::placeholder {
  color:var(--lv-muted) !important;
  -webkit-text-fill-color:var(--lv-muted) !important;
  opacity:1 !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .learning-theme-btn {
  background:var(--lv-panel) !important; color:var(--lv-ink) !important;
  border-color:var(--lv-border) !important;
}
/* Some immersive designs fill inactive term buttons with a dark/gray color
   while leaving pale labels. Guest reading tabs must stay legible. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-term-tab:not(.active) {
  color:var(--lv-ink) !important;
  background:var(--lv-raised) !important;
  background-image:none !important;
  border-color:var(--lv-border) !important;
  opacity:1 !important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-stat,
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-stat :is(strong,span) {
  color:#fff !important;
}


/* V2.39 — Lessons contrast/appearance fix shared by public + signed-in pages.
   A V2.37/V2.38 CSS-only fix could not work consistently because the admin
   appearance gate still hid the *public* toggle. The JS gate is now corrected.
   Limit these to Lessons: Activities, Dashboard and teacher theme controls
   continue to use their own published theme rules. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .learning-theme-btn,
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .learning-theme-btn.hidden {
  display:inline-flex!important;
  visibility:visible!important;
  opacity:1!important;
  pointer-events:auto!important;
}
/* Give Guest Lessons one consistent surface/foreground for the hero, even
   when a published immersive design puts WHITE text on a LIGHT background. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card {
  background:var(--guest-hero)!important;
  background-image:none!important;
  color:var(--guest-hero-ink)!important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card :is(h2,p,span,strong) {
  color:var(--guest-hero-ink)!important;
  opacity:1!important;
  -webkit-text-fill-color:currentColor!important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card p {
  color:var(--guest-hero-muted)!important;
  -webkit-text-fill-color:var(--guest-hero-muted)!important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-welcome-card .lesson-library-eyebrow {
  color:var(--guest-hero-kicker)!important;
  -webkit-text-fill-color:var(--guest-hero-kicker)!important;
}
/* The count badge is deliberately BLUE, so its number and LESSONS caption
   must stay white in either theme. The former selector missed themes that
   apply text colors directly to badge children. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-stat {
  background:linear-gradient(145deg,#2563eb,#0e8ecd)!important;
  background-image:linear-gradient(145deg,#2563eb,#0e8ecd)!important;
  border:1px solid rgba(255,255,255,.25)!important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] .lesson-library-stat :is(strong,span) {
  color:#ffffff!important;
  -webkit-text-fill-color:#ffffff!important;
  opacity:1!important;
}
/* Ensure small count badges, PDF lesson descriptors and secondary labels
   use the SAME contrast tokens as the rest of the reader. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-term-tab:not(.active),.lesson-term-tab:not(.active) span,
  .lesson-card-content p,.lesson-card-meta,.lesson-continue-content p,
  .lesson-library-status,.lesson-library-filter-row label
) {color:var(--lv-muted)!important;-webkit-text-fill-color:var(--lv-muted)!important;opacity:1!important;}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance] :is(
  .lesson-library-card h3,.lesson-continue-card h3,.lesson-library-controls,
  .lesson-library-card,.lesson-continue-card
) {color:var(--lv-ink)!important;-webkit-text-fill-color:var(--lv-ink)!important;}
/* Signed-in Lessons: keep the Home-inspired hero but guarantee readable text.
   The light palette uses a light hero with DARK copy; dark uses a navy hero
   with WHITE copy. Teacher-selected whole-app light/dark wins over the root
   switch when it is published. */
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student {
  --lesson-hero-surface:#f8fbff;
  --lesson-hero-ink:#1c3049;
  --lesson-hero-muted:#465b77;
  --lesson-hero-kicker:#9b206f;
  --lesson-stat-surface:linear-gradient(145deg,#2563eb,#0284c7);
}
html[data-theme="dark"] body:not([data-student-app-appearance="light"]) #lessonViewerScreen.lesson-viewer-screen.is-learning-student,
html body[data-student-app-appearance="dark"] #lessonViewerScreen.lesson-viewer-screen.is-learning-student {
  --lesson-hero-surface:#152941;
  --lesson-hero-ink:#f1f6ff;
  --lesson-hero-muted:#c1d2ea;
  --lesson-hero-kicker:#f0bfe4;
  --lesson-stat-surface:linear-gradient(145deg,#2563eb,#0369a1);
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-welcome-card {
  background:var(--lesson-hero-surface)!important;
  background-image:none!important;
  background-color:var(--lesson-hero-surface)!important;
  border:1px solid var(--ls-border)!important;
  color:var(--lesson-hero-ink)!important;
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-welcome-card :is(h2,h3,strong) {
  color:var(--lesson-hero-ink)!important;
  -webkit-text-fill-color:var(--lesson-hero-ink)!important;
  opacity:1!important;
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-welcome-card p {
  color:var(--lesson-hero-muted)!important;
  -webkit-text-fill-color:var(--lesson-hero-muted)!important;
  opacity:1!important;
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-welcome-card .lesson-library-eyebrow {
  color:var(--lesson-hero-kicker)!important;
  -webkit-text-fill-color:var(--lesson-hero-kicker)!important;
  opacity:1!important;
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-stat {
  background:var(--lesson-stat-surface)!important;
  background-image:var(--lesson-stat-surface)!important;
  border:1px solid rgba(255,255,255,.25)!important;
  color:#fff!important;
}
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-library-stat :is(strong,span){
  color:#fff!important;-webkit-text-fill-color:#fff!important;opacity:1!important;
}
/* Count chips, titles, PDF labels and controls in the published light theme. */
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student :is(
  .lesson-term-tab:not(.active),.lesson-term-tab:not(.active) span,
  .lesson-card-content p,.lesson-card-meta,.lesson-continue-content p,
  .lesson-library-status
){ color:var(--lv-muted)!important;-webkit-text-fill-color:var(--lv-muted)!important;opacity:1!important; }
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student :is(
  .lesson-library-card h3,.lesson-continue-card h3,.lesson-library-card,
  .lesson-continue-card,.lesson-library-controls
){color:var(--lv-ink)!important;}

/* V2.39 — explicit contrast for term controls and PDF cover numbers.
   Existing older appearance variants used a light chip in Dark Mode, and
   applied text fill independently of `color`. Never combine a pale chip
   with pale text, or a blue cover with dark PDF/lesson-number lettering. */
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="light"] .lesson-term-tab:not(.active),
html body #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-term-tab:not(.active) {
  background:#e8eff8!important;
  background-image:none!important;
  border-color:#bfcedf!important;
  color:#344a67!important;
  -webkit-text-fill-color:#344a67!important;
}
html body #lessonViewerScreen.lesson-viewer-screen:not(.is-learning-student)[data-lesson-appearance="dark"] .lesson-term-tab:not(.active),
html[data-theme="dark"] body:not([data-student-app-appearance="light"]) #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-term-tab:not(.active),
html body[data-student-app-appearance="dark"] #lessonViewerScreen.lesson-viewer-screen.is-learning-student .lesson-term-tab:not(.active) {
  background:#263b56!important;
  background-image:none!important;
  border-color:#4c6481!important;
  color:#ebf2ff!important;
  -webkit-text-fill-color:#ebf2ff!important;
}
html body #lessonViewerScreen.lesson-viewer-screen .lesson-term-tab:not(.active) span {
  background:rgba(67,95,132,.14)!important;
  color:inherit!important;
  -webkit-text-fill-color:currentColor!important;
  opacity:1!important;
}
html body #lessonViewerScreen.lesson-viewer-screen .lesson-term-tab.active {
  background:#1769cb!important;
  background-image:none!important;
  border-color:#1769cb!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
html body #lessonViewerScreen.lesson-viewer-screen .lesson-term-tab.active span {
  background:rgba(1,27,67,.28)!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
html body #lessonViewerScreen.lesson-viewer-screen .lesson-card-cover {
  background:linear-gradient(160deg,#2059bd,#123b8a 65%,#1164a3)!important;
  color:#fff!important;
}
html body #lessonViewerScreen.lesson-viewer-screen .lesson-card-cover :is(.lesson-card-number,.lesson-card-pdf,.lesson-card-book){
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
  opacity:1!important;
}
/* Prevent a pale-on-pale intermediate frame during rapid Light/Dark toggles. */
html body #lessonViewerScreen.lesson-viewer-screen .lesson-term-tab,
html body #lessonViewerScreen.lesson-viewer-screen .lesson-term-tab span{
  transition:none!important;
}
