:root {
  --yellow: #ffd400;
  --yellow-soft: #fff4a6;
  --ink: #191919;
  --ink-2: #303030;
  --muted: #737373;
  --line: #dedede;
  --panel: #f4f4f1;
  --paper: #ffffff;
  --danger: #b52a2a;
  --sidebar-width: 310px;
  --topbar-height: 76px;
  --radius: 16px;
  --shadow: 0 16px 46px rgba(0,0,0,.11);
}

/* Academy Stars 1 — course overrides */
.ef-brand-mark { width: 38px; font-size: 11px; letter-spacing: -.02em; }
.academy-brand-mark { width: 42px; color: #fff; background: #ef4050; font-size: 12px; letter-spacing: -.02em; border-radius: 10px; }
.sidebar-scroll-area { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.reference-nav { position: relative; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.13); }
.reference-nav .nav-section-label { position: sticky; top: 0; z-index: 2; display: block; padding: 8px 4px; background: #181818; }
.supplement-link .lesson-code { color: var(--yellow); }
.audio-dock.is-muted { opacity: .72; }
.spread-view.single-page { grid-template-columns: minmax(0, 760px); justify-content: center; }
.spread-view[hidden] { display: none !important; }
.course-empty-state { min-height: 440px; margin: 20px; border: 1px dashed #c9c8c2; border-radius: 18px; background: #f4f3ef; display: grid; place-content: center; gap: 8px; text-align: center; color: #696862; }
.course-empty-state[hidden] { display: none; }
.course-empty-state strong { color: #222; font-size: 18px; }
.page-card[hidden], .spread-divider[hidden] { display: none !important; }
.modal-toolbar-workspace { grid-template-columns: max-content minmax(350px, 1fr) max-content max-content; gap: 8px; padding: 7px 10px; flex-wrap: nowrap; }
.modal-page-meta { min-width: max-content; }
.modal-page-meta strong { white-space: nowrap; }
.modal-audio { min-width: 0; flex-wrap: nowrap; }
.modal-audio[hidden] { display: none !important; }
.modal-audio-select { min-width: 130px; max-width: 210px; }
.modal-page-nav, .modal-actions { flex-wrap: nowrap; white-space: nowrap; }
.modal-actions .soft-button, .modal-page-nav .soft-button { min-height: 32px; padding-inline: 9px; }

@media (max-width: 1180px) {
  .modal-toolbar-workspace { grid-template-columns: max-content minmax(260px, 1fr) max-content; }
  .modal-page-nav { grid-column: 2; grid-row: 2; justify-self: center; }
  .modal-actions { grid-column: 3; grid-row: 1 / span 2; }
}

@media (max-width: 860px) {
  .sidebar { overflow: hidden; }
  .spread-view.single-page { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions .soft-button#fullscreenButton { display: none; }
  .modal-toolbar-workspace { display: flex; overflow-x: auto; align-items: center; }
  .modal-page-nav { order: 3; }
  .modal-actions { order: 4; }
}

@media (orientation: landscape) and (max-height: 620px) {
  .main-area { overflow-y: auto; }
  .topbar { min-height: 58px; padding-block: 6px; }
  .audio-dock { padding-block: 6px; }
  .view-toolbar { min-height: 46px; padding-block: 5px; }
  .lesson-footer { display: none; }
}

/* Remembered one-password access gate. */
html:not(.access-granted) .app-shell { visibility: hidden; pointer-events: none; }
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(244,64,118,.48), transparent 36%),
    radial-gradient(circle at 85% 82%, rgba(245,101,49,.25), transparent 38%),
    linear-gradient(145deg, #651c57 0%, #35162f 52%, #16151b 100%);
  color: #202024;
}
html.access-granted .access-gate { display: none; }
.access-card {
  width: min(100%, 410px);
  padding: 32px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}
.access-logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 18px;
  border-radius: 13px;
  background: linear-gradient(135deg, #7a1f63, #ef3e71);
  color: #fff;
  font-weight: 900;
  letter-spacing: -.03em;
}
.access-course { color: #77777d; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.access-card h1 { margin: 7px 0 8px; font-size: clamp(26px, 7vw, 34px); line-height: 1.05; }
.access-card p { margin: 0 0 24px; color: #66666d; font-size: 14px; line-height: 1.5; }
.access-field { display: grid; gap: 8px; font-size: 13px; font-weight: 750; }
.access-input-row { display: grid; grid-template-columns: 1fr auto; overflow: hidden; border: 1px solid #cfcfd5; border-radius: 11px; background: #fff; }
.access-input-row:focus-within { border-color: #8d286c; box-shadow: 0 0 0 3px rgba(141,40,108,.14); }
.access-input-row input { min-width: 0; height: 48px; padding: 0 14px; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; }
.access-input-row button { padding: 0 13px; border: 0; background: transparent; color: #55555c; font-weight: 700; cursor: pointer; }
.access-error { min-height: 21px; padding-top: 6px; color: #c92336; font-size: 13px; }
.access-submit { width: 100%; min-height: 48px; border: 0; border-radius: 11px; background: linear-gradient(135deg, #7a1f63, #ef3e71); color: #fff; font: inherit; font-weight: 850; cursor: pointer; }
.access-submit:hover { filter: brightness(.94); }
.access-submit:focus-visible { outline: 3px solid rgba(141,40,108,.28); outline-offset: 2px; }
@media (max-width: 480px) {
  .access-gate { place-items: center; padding: 14px; }
  .access-card { padding: 25px 20px; border-radius: 18px; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #e9e9e6;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: #e9e9e6;
}

.sidebar {
  position: relative;
  z-index: 30;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #171717;
  border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand {
  min-height: 82px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: #111;
  font-size: 24px;
  font-weight: 900;
  border-radius: 10px 2px 10px 2px;
}
.sidebar-brand strong { display: block; font-size: 15px; letter-spacing: .09em; }
.sidebar-brand span { display: block; margin-top: 3px; color: #aaa; font-size: 12px; }
.sidebar-tools { padding: 14px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.09); }
.search-box {
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #292929;
  border: 1px solid #3c3c3c;
  border-radius: 10px;
}
.search-box span { color: #aaa; font-size: 19px; }
.search-box input { width: 100%; border: 0; outline: 0; color: #fff; background: transparent; }
.search-box input::placeholder { color: #888; }
.progress-summary {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #aaa;
  font-size: 12px;
}
.progress-summary strong { display: block; margin-top: 2px; color: #fff; font-size: 14px; }
.progress-ring {
  --progress: 0deg;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--yellow) var(--progress), #3b3b3b 0);
  border-radius: 50%;
  position: relative;
}
.progress-ring::before { content: ""; position: absolute; inset: 5px; background: #1b1b1b; border-radius: 50%; }
.progress-ring span { position: relative; color: #fff; font-size: 10px; font-weight: 700; }

.lesson-nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 8px 18px;
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}
.unit-group { margin-bottom: 4px; }
.unit-heading {
  width: 100%;
  padding: 10px 9px;
  display: grid;
  grid-template-columns: 30px minmax(0,1fr) 18px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  color: #f4f4f4;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.unit-heading:hover { background: #252525; }
.unit-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #555;
  border-radius: 7px;
  color: var(--yellow);
  font-weight: 800;
}
.unit-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.unit-chevron { color: #777; transform: rotate(-90deg); transition: transform .2s; }
.unit-group.open .unit-chevron { transform: rotate(0); }
.unit-lessons { display: none; padding: 0 0 6px 38px; }
.unit-group.open .unit-lessons { display: block; }
.lesson-link {
  width: 100%;
  min-height: 42px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: minmax(0,1fr) 18px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 9px 9px 0;
  color: #bababa;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.lesson-link:hover { color: #fff; background: #242424; }
.lesson-link.active { color: #fff; background: #303030; border-left-color: var(--yellow); }
.lesson-link .lesson-code { display: block; color: #777; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.lesson-link .lesson-name { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.lesson-check { width: 8px; height: 8px; justify-self: center; border: 1px solid #666; border-radius: 50%; }
.lesson-link.completed .lesson-check { border-color: var(--yellow); background: var(--yellow); box-shadow: 0 0 0 3px rgba(255,212,0,.1); }
.supplement-link { margin: 4px 0 0; }
.supplement-link .lesson-code { color: #bdad50; }

.reference-nav { padding: 10px 8px 14px; border-top: 1px solid rgba(255,255,255,.1); background: #1c1c1c; }
.nav-section-label { display: block; padding: 0 8px 7px; color: #777; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.reference-link {
  width: 100%;
  padding: 7px 9px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  color: #bbb;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}
.reference-link:hover, .reference-link.active { color: #fff; background: #2c2c2c; }
.reference-link span:last-child { color: #6f6f6f; font-size: 10px; }

.main-area {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0,1fr) auto;
  overflow: hidden;
}
.topbar {
  min-height: var(--topbar-height);
  padding: 10px 18px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lesson-heading { min-width: 0; }
.lesson-heading span { display: block; color: #777; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.lesson-heading h1 { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 23px; line-height: 1.15; }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}
.icon-button:hover { background: #f4f4f4; }
.soft-button {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #333;
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}
.soft-button:hover { background: #f5f5f5; }
.complete-toggle {
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d7d7d7;
  border-radius: 9px;
  background: #fafafa;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.complete-toggle input { width: 16px; height: 16px; accent-color: #111; }

.audio-dock {
  min-height: 72px;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(480px, 1.6fr);
  align-items: center;
  gap: 18px;
  color: #fff;
  background: #202020;
  border-bottom: 4px solid var(--yellow);
}
.audio-track-info { display: flex; align-items: center; gap: 11px; min-width: 0; }
.audio-label { padding: 6px 7px; color: #111; background: var(--yellow); border-radius: 5px; font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.audio-track-info div { min-width: 0; }
.audio-track-info strong, .audio-track-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-track-info strong { font-size: 13px; }
.audio-track-info span { margin-top: 3px; color: #979797; font-size: 11px; }
.audio-controls { display: flex; align-items: center; gap: 8px; min-width: 0; }
.audio-button, .play-button {
  flex: 0 0 auto;
  border: 1px solid #4c4c4c;
  color: #fff;
  background: #2f2f2f;
  cursor: pointer;
}
.audio-button { width: 38px; height: 32px; border-radius: 8px; font-size: 11px; }
.play-button { width: 42px; height: 42px; border-radius: 50%; background: var(--yellow); border-color: var(--yellow); color: #111; font-size: 16px; }
.audio-button:disabled, .play-button:disabled { opacity: .35; cursor: default; }
.time-readout { flex: 0 0 auto; display: flex; gap: 4px; color: #aaa; font-size: 11px; font-variant-numeric: tabular-nums; }
.audio-range { min-width: 80px; flex: 1 1 140px; accent-color: var(--yellow); }
.compact-select, .track-select { height: 32px; border: 1px solid #4b4b4b; border-radius: 8px; color: #ddd; background: #2b2b2b; outline: 0; font-size: 11px; }
.compact-select { width: 64px; padding: 0 5px; }
.track-select { min-width: 140px; max-width: 220px; padding: 0 8px; }

.view-toolbar {
  min-height: 54px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f7f7f5;
  border-bottom: 1px solid #d8d8d5;
}
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid #d7d7d3; border-radius: 10px; background: #ebebe7; }
.segmented-control button { min-height: 32px; padding: 0 13px; border: 0; border-radius: 7px; color: #666; background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.segmented-control button.active { color: #111; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.1); }
.segmented-control button:disabled { opacity: .38; cursor: default; }
.page-navigation { display: flex; align-items: center; gap: 10px; }
.page-navigation span { min-width: 86px; color: #777; text-align: center; font-size: 11px; }
.nav-button { min-height: 34px; padding: 0 11px; border: 1px solid #d7d7d3; border-radius: 8px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 700; }
.nav-button:hover { border-color: #aaa; }
.nav-button:disabled { opacity: .4; cursor: default; }

.viewer { min-height: 0; overflow: hidden; background: #dededb; }
.spread-view {
  height: 100%;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0,1fr) 12px minmax(0,1fr);
  gap: 0;
  overflow: auto;
}
.spread-divider { position: relative; }
.spread-divider::before { content: ""; position: absolute; inset: 44px 5px 14px; border-radius: 99px; background: linear-gradient(90deg,rgba(0,0,0,.07),rgba(255,255,255,.7),rgba(0,0,0,.07)); }
.page-card {
  min-width: 0;
  height: max-content;
  overflow: hidden;
  border: 1px solid #cfcfcb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
}
.page-card-header {
  height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #e4e4e1;
  color: #777;
  background: #fafafa;
  font-size: 11px;
  font-weight: 700;
}
.page-action { border: 0; color: #555; background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }
.page-action:hover { color: #000; }
.page-image-wrap { position: relative; width: 100%; aspect-ratio: 595 / 842; overflow: hidden; background: #f1f1ef; cursor: zoom-in; }
.page-image-wrap img { position: relative; z-index: 2; display: block; width: 100%; height: auto; opacity: 0; transition: opacity .18s; }
.page-image-wrap img.loaded { opacity: 1; }
.page-skeleton { position: absolute; inset: 0; background: linear-gradient(100deg,#eee 25%,#f8f8f8 45%,#eee 65%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.page-image-wrap img.loaded + .page-skeleton, .page-image-wrap:has(img.loaded) .page-skeleton { display: none; }
@keyframes shimmer { to { background-position-x: -200%; } }

.teacher-view { height: 100%; padding: 14px 18px 18px; }
.teacher-notice { height: 48px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #d0d0cc; border-bottom: 0; border-radius: 10px 10px 0 0; background: #fff; }
.teacher-notice strong, .teacher-notice span { display: block; }
.teacher-notice strong { font-size: 12px; }
.teacher-notice span { margin-top: 2px; color: #777; font-size: 10px; }
.teacher-view iframe { width: 100%; height: calc(100% - 48px); border: 1px solid #d0d0cc; border-radius: 0 0 10px 10px; background: #fff; }

.lesson-footer {
  min-height: 48px;
  padding: 7px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid #d5d5d1;
  background: #f8f8f6;
}
.footer-label { display: block; color: #999; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lesson-footer strong { display: block; margin-top: 2px; font-size: 11px; }
.footer-hint { color: #888; font-size: 10px; text-align: right; }

.notes-panel {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  width: min(390px, 94vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  box-shadow: -16px 0 45px rgba(0,0,0,.2);
  transform: translateX(105%);
  transition: transform .25s ease;
}
.notes-panel.open { transform: translateX(0); }
.notes-header { padding: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.notes-header span, .notes-header strong { display: block; }
.notes-header span { color: #888; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.notes-header strong { margin-top: 3px; font-size: 14px; }
.notes-panel textarea { width: 100%; height: 100%; padding: 18px; resize: none; border: 0; outline: 0; line-height: 1.55; }
.notes-footer { padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: #888; font-size: 10px; }
.danger-link { border: 0; color: var(--danger); background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  background: rgba(24,24,24,.97);
}
.modal[hidden] { display: none; }
.modal-toolbar { min-height: 66px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #fff; border-bottom: 1px solid #414141; background: #202020; }
.modal-toolbar strong, .modal-toolbar span { display: block; }
.modal-toolbar strong { font-size: 14px; }
.modal-toolbar > div:first-child span { margin-top: 2px; color: #999; font-size: 10px; }
.modal-actions { display: flex; align-items: center; gap: 8px; }
.modal-actions .soft-button, .modal-close { color: #fff; border-color: #4b4b4b; background: #2d2d2d; }
#zoomValue { min-width: 50px; text-align: center; font-size: 11px; }
.modal-canvas { min-height: 0; overflow: auto; padding: 24px; text-align: center; }
.modal-canvas img { width: min(100%, 1050px); max-width: none; height: auto; transform-origin: top center; box-shadow: 0 18px 65px rgba(0,0,0,.45); user-select: none; }

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 22px;
  max-width: min(520px,90vw);
  padding: 10px 14px;
  border-radius: 9px;
  color: #111;
  background: var(--yellow);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .2s;
  font-size: 12px;
  font-weight: 700;
}
.toast.show { opacity: 1; transform: translate(-50%,0); }
.sidebar-scrim { display: none; }
.mobile-only { display: none; }

body.presentation-mode .sidebar,
body.presentation-mode .topbar,
body.presentation-mode .audio-dock,
body.presentation-mode .view-toolbar,
body.presentation-mode .lesson-footer { display: none; }
body.presentation-mode .app-shell { display: block; }
body.presentation-mode .main-area { height: 100%; display: block; }
body.presentation-mode .viewer { height: 100%; }
body.presentation-mode .spread-view { padding: 10px; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 280px; }
  .audio-dock { grid-template-columns: 1fr; gap: 8px; }
  .audio-controls { width: 100%; }
  .track-select { max-width: 180px; }
  .topbar-actions .soft-button { display: none; }
}

@media (max-width: 860px) {
  body { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 25; inset: 0; display: block; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.open + .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .mobile-only { display: grid; }
  .sidebar-brand .mobile-only { margin-right: 2px; color: #fff; border-color: #444; background: #242424; }
  .main-area { height: 100%; }
  .topbar { min-height: 66px; }
  .lesson-heading h1 { font-size: 18px; }
  .topbar-actions { gap: 5px; }
  .complete-toggle span { display: none; }
  .complete-toggle { width: 38px; padding: 0; justify-content: center; }
  .audio-dock { min-height: 116px; padding: 8px 12px; }
  .audio-track-info { display: none; }
  .audio-controls { flex-wrap: wrap; }
  .audio-range { order: 10; flex-basis: calc(100% - 110px); }
  .track-select { order: 11; max-width: none; flex: 1; }
  .view-toolbar { align-items: stretch; flex-direction: column; gap: 7px; }
  .segmented-control { width: 100%; }
  .segmented-control button { flex: 1; padding: 0 5px; }
  .page-navigation { justify-content: space-between; }
  .page-navigation span { flex: 1; }
  .spread-view { grid-template-columns: 1fr; gap: 14px; padding: 12px; }
  .spread-divider { display: none; }
  .page-card { width: 100%; }
  .lesson-footer { display: none; }
  .teacher-view { padding: 10px; }
  .footer-hint { display: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 8px 10px; }
  .lesson-heading span { font-size: 9px; }
  .lesson-heading h1 { font-size: 16px; }
  .topbar-actions .complete-toggle { display: none; }
  .audio-button { width: 34px; }
  .time-readout { display: none; }
  .compact-select { width: 58px; }
  .view-toolbar { padding: 7px 9px; }
  .nav-button { padding: 0 8px; font-size: 10px; }
  .page-navigation span { min-width: 56px; font-size: 10px; }
  .spread-view { padding: 8px; }
  .modal-toolbar { align-items: flex-start; }
  .modal-toolbar > div:first-child span { display: none; }
  .modal-actions { flex-wrap: wrap; justify-content: flex-end; }
  .modal-canvas { padding: 12px; }
}

.repeat-button.active,
.repeat-button[aria-pressed="true"] {
  color: #111;
  border-color: var(--yellow);
  background: var(--yellow);
}
.script-pdf-link {
  min-height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #444;
  background: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}
.script-pdf-link:hover { background: #f4f4f4; }

/* Contextual worksheet library */
.resources-trigger {
  min-height: 38px;
  padding: 0 8px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d6d6d2;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.resources-trigger:hover,
.resources-trigger[aria-expanded="true"] { border-color: #999; background: #f7f7f4; }
.resources-trigger.has-resources { border-color: #d7bd00; }
.resources-trigger b {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #111;
  background: var(--yellow);
  font-size: 10px;
}
.resources-trigger b[hidden] { display: none; }

.resources-scrim {
  position: fixed;
  z-index: 52;
  inset: 0;
  background: rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.resources-scrim.open { opacity: 1; pointer-events: auto; }
.resources-panel {
  position: fixed;
  z-index: 54;
  top: 0;
  right: 0;
  width: min(440px, 95vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  color: #1a1a1a;
  background: #f5f5f2;
  box-shadow: -20px 0 55px rgba(0,0,0,.22);
  transform: translateX(105%);
  transition: transform .25s ease;
}
.resources-panel.open { transform: translateX(0); }
.resources-header {
  min-height: 74px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d9d9d5;
  background: #fff;
}
.resources-header span,
.resources-header strong { display: block; }
.resources-header span {
  color: #888;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.resources-header strong { margin-top: 4px; font-size: 14px; }
.resources-content {
  min-height: 0;
  padding: 15px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #bbb transparent;
}
.resource-section { margin-bottom: 18px; }
.resource-section-heading {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #686868;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.resource-section-heading b,
.resource-details summary b {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #555;
  background: #e5e5e1;
  font-size: 9px;
}
.resource-list { display: grid; gap: 8px; }
.resource-card {
  min-width: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr);
  gap: 11px;
  border: 1px solid #d9d9d5;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.035);
}
.resource-card:hover { border-color: #bdbdb8; }
.resource-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px 3px 10px 3px;
  color: #111;
  background: var(--yellow);
  font-size: 13px;
  font-weight: 900;
}
.resource-reading .resource-icon { background: #dbe9ff; }
.resource-vocabulary .resource-icon { color: #083743; background: #bfeaf1; }
.resource-communicative .resource-icon { background: #ffe16a; }
.resource-grammar .resource-icon { background: #e7e7e4; }
.resource-language .resource-icon { background: #e3dcff; }
.resource-mediation .resource-icon { background: #dff3e6; }
.resource-review .resource-icon { background: #ffd400; }
.resource-teacher .resource-icon { color: #fff; background: #232323; }
.resource-learner .resource-icon { background: #f0e1bc; }
.resource-card-body { min-width: 0; }
.resource-kind {
  display: block;
  margin-bottom: 3px;
  color: #999;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .09em;
}
.resource-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1d1d1d;
  font-size: 12px;
  line-height: 1.3;
}
.resource-card p {
  margin: 4px 0 0;
  color: #777;
  font-size: 10px;
  line-height: 1.4;
}
.resource-actions {
  margin-top: 9px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.resource-primary,
.resource-secondary {
  min-height: 29px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  font-size: 9px;
  font-weight: 850;
}
.resource-primary { border: 1px solid #202020; color: #fff; background: #202020; }
.resource-primary:hover { background: #383838; }
.resource-secondary { border: 1px solid #d6d6d2; color: #555; background: #fff; }
.resource-secondary:hover { color: #111; border-color: #aaa; }
.resource-details {
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid #d9d9d5;
  border-radius: 12px;
  background: #ecece8;
}
.resource-details summary {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: #555;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.resource-details summary::-webkit-details-marker { display: none; }
.resource-details[open] summary { border-bottom: 1px solid #d4d4cf; background: #e5e5e1; }
.resource-details .resource-list { padding: 9px; }
.teacher-resources { border-color: #c8c8c3; }
.teacher-resources summary { color: #222; }
.resource-empty {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px dashed #c8c8c3;
  border-radius: 12px;
  color: #777;
  background: rgba(255,255,255,.55);
}
.resource-empty strong,
.resource-empty span { display: block; }
.resource-empty strong { color: #333; font-size: 12px; }
.resource-empty span { margin-top: 5px; font-size: 10px; line-height: 1.5; }
.resources-footnote {
  padding: 8px 4px 2px;
  color: #9a9a95;
  font-size: 9px;
  line-height: 1.45;
  text-align: center;
}

.resource-modal {
  position: fixed;
  z-index: 112;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(18,18,18,.91);
}
.resource-modal[hidden] { display: none; }
.resource-modal-card {
  width: min(1180px, 100%);
  height: min(920px, 100%);
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  overflow: hidden;
  border: 1px solid #484848;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0,0,0,.5);
}
.resource-modal-toolbar {
  min-height: 66px;
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  background: #202020;
}
.resource-modal-toolbar strong,
.resource-modal-toolbar span { display: block; }
.resource-modal-toolbar strong { font-size: 13px; }
.resource-modal-toolbar span { margin-top: 3px; color: #a7a7a7; font-size: 9px; }
.resource-modal-actions { display: flex; align-items: center; gap: 8px; }
.resource-modal-actions .soft-button,
.resource-modal-actions .icon-button { color: #fff; border-color: #484848; background: #2d2d2d; text-decoration: none; }
.resource-modal iframe { width: 100%; height: 100%; border: 0; background: #e5e5e2; }
body.resource-modal-open { overflow: hidden; }

body.presentation-mode .resources-trigger,
body.presentation-mode .resources-panel,
body.presentation-mode .resources-scrim { display: none; }

@media (max-width: 1180px) {
  .resources-trigger span { display: none; }
  .resources-trigger { padding: 0 7px; }
}

@media (max-width: 860px) {
  .resources-trigger span { display: inline; }
  .resources-trigger { min-height: 36px; padding: 0 7px 0 10px; }
  .resources-panel { width: min(420px, 96vw); }
  .resource-modal { padding: 0; }
  .resource-modal-card { width: 100%; height: 100%; border: 0; border-radius: 0; }
}

@media (max-width: 520px) {
  .resources-trigger span { display: none; }
  .resources-trigger { padding: 0 6px; }
  .resources-panel { width: 100vw; }
  .resources-content { padding: 11px; }
  .resource-modal-toolbar { align-items: flex-start; }
  .resource-modal-toolbar > div:first-child span { display: none; }
  .resource-modal-actions .soft-button { padding: 0 8px; font-size: 9px; }
}

/* v4.3 — touch-friendly PDF material viewer */
.resource-modal-card {
  grid-template-rows: auto minmax(0, 1fr);
}
.resource-modal-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.resource-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.resource-zoom-controls[hidden] { display: none; }
.resource-zoom-controls .icon-button {
  min-width: 34px;
  width: 34px;
  height: 34px;
  font-size: 18px;
}
.resource-zoom-value {
  min-width: 76px;
  justify-content: center;
  white-space: nowrap;
}
.resource-page-status {
  min-width: 42px;
  color: #c8c8c8 !important;
  font-size: 10px !important;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.resource-viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: none;
  cursor: grab;
  background:
    linear-gradient(45deg, rgba(0,0,0,.025) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.025) 75%),
    linear-gradient(45deg, rgba(0,0,0,.025) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.025) 75%),
    #d9d9d6;
  background-position: 0 0, 14px 14px;
  background-size: 28px 28px;
  outline: none;
}
.resource-viewer.is-dragging { cursor: grabbing; }
.resource-viewer[hidden] { display: none; }
.resource-pdf-document {
  box-sizing: border-box;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.resource-pdf-page {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
  box-shadow: 0 12px 34px rgba(0,0,0,.22);
}
.resource-pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
}
.resource-page-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #777;
  background: #f7f7f5;
  font-size: 11px;
  text-align: center;
}
.resource-page-loading[hidden] { display: none; }
.resource-page-loading.error { color: #9d2222; }
.resource-viewer-message {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #555;
  background: #e5e5e2;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
.resource-viewer-message[hidden] { display: none; }
.resource-viewer-message.error { color: #8d1d1d; }
.resource-frame-fallback {
  width: 100%;
  height: 100%;
  border: 0;
  background: #e5e5e2;
}
.resource-frame-fallback[hidden] { display: none; }

@media (max-width: 860px) {
  .resource-modal-toolbar {
    min-height: 58px;
    padding: max(7px, env(safe-area-inset-top)) 8px 7px 11px;
  }
  .resource-modal-toolbar > div:first-child {
    min-width: 0;
    flex: 1 1 150px;
  }
  .resource-modal-toolbar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .resource-modal-actions {
    flex: 1 1 auto;
    gap: 5px;
  }
  .resource-modal-actions > .soft-button#resourceOpenSeparate {
    min-height: 34px;
    padding: 0 9px;
  }
  .resource-pdf-document {
    padding: 10px 9px max(14px, env(safe-area-inset-bottom));
    gap: 12px;
  }
}

@media (max-width: 520px) {
  .resource-modal-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
  }
  .resource-modal-toolbar > div:first-child {
    grid-column: 1;
    grid-row: 1;
  }
  .resource-modal-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    justify-content: stretch;
    width: 100%;
  }
  .resource-zoom-controls {
    grid-column: 1;
  }
  .resource-page-status {
    grid-column: 2;
    align-self: center;
  }
  .resource-modal-actions > .soft-button#resourceOpenSeparate {
    grid-column: 3;
    justify-self: end;
  }
  #closeResourceModal {
    grid-column: 4;
  }
  .resource-zoom-controls .icon-button {
    min-width: 32px;
    width: 32px;
    height: 32px;
  }
  .resource-zoom-value {
    min-width: 66px;
    padding: 0 7px !important;
    font-size: 9px !important;
  }
  .resource-pdf-document {
    padding-left: 8px;
    padding-right: 8px;
  }
}


/* v4.4 — reliable touch viewer in portrait and landscape */
.resource-modal {
  width: var(--resource-viewport-width, 100vw);
  height: var(--resource-viewport-height, 100dvh);
  max-width: 100vw;
  max-height: 100dvh;
}
.resource-modal-card,
.resource-viewer,
.resource-frame-fallback {
  min-height: 0;
}
.resource-viewer {
  width: 100%;
  height: 100%;
  contain: layout paint;
}
.resource-pdf-document,
.resource-pdf-page,
.resource-pdf-page canvas {
  touch-action: none;
}

@media (hover: none) and (pointer: coarse) {
  .resource-modal {
    padding: 0;
    place-items: stretch;
  }
  .resource-modal-card {
    width: var(--resource-viewport-width, 100vw);
    height: var(--resource-viewport-height, 100dvh);
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .resource-modal-toolbar {
    min-height: 46px;
    max-height: 64px;
    padding: max(4px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) 4px max(9px, env(safe-area-inset-left));
    flex-wrap: nowrap;
    gap: 7px;
    overflow: hidden;
  }
  .resource-modal-toolbar > div:first-child {
    min-width: 0;
    flex: 1 1 120px;
  }
  .resource-modal-toolbar > div:first-child span {
    display: none;
  }
  .resource-modal-toolbar strong {
    font-size: 11px;
  }
  .resource-modal-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .resource-zoom-controls .icon-button {
    min-width: 30px;
    width: 30px;
    height: 30px;
  }
  .resource-zoom-value {
    min-width: 60px;
    min-height: 30px;
    padding: 0 6px !important;
    font-size: 8px !important;
  }
  .resource-page-status {
    min-width: 34px;
  }
  .resource-modal-actions > .soft-button#resourceOpenSeparate {
    min-height: 30px;
    max-width: 104px;
    padding: 0 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
  }
  #closeResourceModal {
    min-width: 30px;
    width: 30px;
    height: 30px;
  }
  .resource-pdf-document {
    padding: 7px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 9px;
  }
}

/* v4.5 — mobile pull-to-refresh for the fixed-layout course shell */
.pull-refresh-indicator {
  position: fixed;
  z-index: 260;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  min-height: 38px;
  max-width: min(88vw, 330px);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: #fff;
  background: rgba(25,25,25,.94);
  box-shadow: 0 10px 28px rgba(0,0,0,.25);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 22px)) scale(.96);
  transition: opacity .16s ease, transform .18s ease, background .16s ease, color .16s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.pull-refresh-indicator::before {
  content: "↓";
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #111;
  background: var(--yellow);
  font-size: 15px;
  font-weight: 900;
  transition: transform .18s ease;
}
.pull-refresh-indicator.visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.pull-refresh-indicator.ready {
  color: #111;
  background: var(--yellow);
  border-color: rgba(0,0,0,.08);
}
.pull-refresh-indicator.ready::before {
  color: #fff;
  background: #191919;
  transform: rotate(180deg);
}
.pull-refresh-indicator.refreshing::before {
  content: "↻";
  animation: pull-refresh-spin .7s linear infinite;
}
body.pull-refresh-active {
  -webkit-user-select: none;
  user-select: none;
}
@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }
@media (hover: hover) and (pointer: fine) {
  .pull-refresh-indicator { display: none; }
}


/* v4.6 — make the main course page scrollable on short landscape phone screens */
@media (max-width: 1000px) and (orientation: landscape) and (max-height: 700px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    display: block;
    overflow: visible;
  }

  .main-area {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .topbar,
  .audio-dock,
  .view-toolbar,
  .lesson-footer {
    flex: 0 0 auto;
  }

  .viewer {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .spread-view {
    height: auto;
    min-height: 0;
    overflow: visible;
    -webkit-overflow-scrolling: auto;
  }

  .teacher-view {
    height: max(430px, 82dvh);
    min-height: 430px;
  }

  .teacher-view iframe {
    min-height: 370px;
  }

  /* Keep overlays fixed and self-contained even though the page itself can scroll. */
  body.resource-modal-open,
  body:has(.modal:not([hidden])) {
    height: 100%;
    overflow: hidden;
  }
}


/* v8.1 — enlarged page workspace: compact navigation + synchronized lesson audio */
.modal-toolbar-workspace {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) auto minmax(360px, 1.6fr) auto;
  align-items: center;
  gap: 12px;
}
.modal-page-meta { min-width: 0; }
.modal-page-nav { display: flex; gap: 6px; align-items: center; }
.modal-page-nav .soft-button { white-space: nowrap; }
.modal-audio {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px 32px 32px auto minmax(120px,1fr) minmax(130px,200px);
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #414141;
  border-radius: 10px;
  background: #171717;
}
.modal-audio button,
.modal-audio select,
.modal-audio input { font: inherit; }
.modal-audio-play {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  color: #111; background: var(--yellow, #ffd500); font-weight: 900; cursor: pointer;
}
.modal-audio-skip {
  min-width: 30px; height: 28px; padding: 0 5px;
  border: 1px solid #4b4b4b; border-radius: 7px;
  color: #fff; background: #2d2d2d; cursor: pointer;
}
.modal-audio-time { white-space: nowrap; color: #aaa !important; font-size: 9px !important; }
.modal-audio-seek { width: 100%; accent-color: var(--yellow, #ffd500); }
.modal-audio-select {
  width: 100%; min-width: 0; height: 30px; padding: 0 24px 0 8px;
  border: 1px solid #4b4b4b; border-radius: 7px;
  color: #fff; background: #2d2d2d;
  font-size: 9px;
}
.modal-audio.is-disabled { opacity: .45; }
.modal-page-nav button:disabled,
.modal-audio button:disabled,
.modal-audio select:disabled,
.modal-audio input:disabled { cursor: default; opacity: .45; }

@media (max-width: 1180px) {
  .modal-toolbar-workspace {
    grid-template-columns: minmax(110px,.7fr) auto minmax(320px,1.4fr) auto;
    gap: 8px;
  }
  .modal-page-nav .soft-button { padding: 0 8px; font-size: 9px; }
  .modal-audio { grid-template-columns: 32px 30px 30px auto minmax(90px,1fr) minmax(110px,160px); }
}

@media (max-width: 900px) {
  .modal-toolbar-workspace {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .modal-page-meta { grid-column: 1; grid-row: 1; }
  .modal-actions { grid-column: 2; grid-row: 1; }
  .modal-page-nav { grid-column: 1 / -1; grid-row: 2; }
  .modal-audio { grid-column: 1 / -1; grid-row: 3; grid-template-columns: 34px 30px 30px auto 1fr minmax(110px,180px); }
  .modal-toolbar { padding-bottom: 9px; }
}

@media (max-width: 620px) {
  .modal-page-nav { justify-content: space-between; }
  .modal-page-nav .soft-button { flex: 1; }
  .modal-audio { grid-template-columns: 34px 30px 30px auto 1fr; }
  .modal-audio-select { grid-column: 1 / -1; }
  .modal-actions #zoomValue { min-width: 38px; text-align: center; }
}

/* Academy Stars final overrides: keep after the inherited viewer rules. */
.ef-brand-mark { width: 38px; font-size: 11px; letter-spacing: -.02em; }
.academy-brand-mark { width: 42px; color: #fff; background: #ef4050; font-size: 12px; letter-spacing: -.02em; border-radius: 10px; }
.academy-brand-mark,
.unit-number,
.play-button { background: #ef4050 !important; color: #fff !important; }
.audio-dock { border-bottom-color: #ef4050; }
.audio-label { background: #ef4050; color: #fff; }
.lesson-link.active { border-left-color: #ef4050; }
.lesson-link.active .lesson-code,
.supplement-link .lesson-code { color: #ff6672; }
.progress-ring { background: conic-gradient(#ef4050 var(--progress), #3b3b3b 0); }
.audio-range,
.modal-audio-seek { accent-color: #ef4050; }
.sidebar-scroll-area { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.reference-nav { position: relative; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.13); }
.reference-nav .nav-section-label { position: sticky; top: 0; z-index: 2; display: block; padding: 8px 4px; background: #181818; }
.supplement-link .lesson-code { color: var(--yellow); }
.audio-dock.is-muted { opacity: .72; }
.spread-view.single-page { grid-template-columns: minmax(0, 760px); justify-content: center; }
.course-empty-state { min-height: 440px; margin: 20px; border: 1px dashed #c9c8c2; border-radius: 18px; background: #f4f3ef; display: grid; place-content: center; gap: 8px; text-align: center; color: #696862; }
.course-empty-state[hidden] { display: none; }
.course-empty-state strong { color: #222; font-size: 18px; }
.page-card[hidden], .spread-divider[hidden] { display: none !important; }
.modal-toolbar-workspace { display: flex !important; flex-wrap: nowrap !important; align-items: center !important; gap: 8px !important; padding: 7px 10px !important; overflow-x: auto; }
.modal-page-meta { flex: 0 0 auto; min-width: max-content; }
.modal-page-meta strong { white-space: nowrap; }
.modal-audio { flex: 1 1 420px; min-width: 350px; flex-wrap: nowrap; }
.modal-audio[hidden] { display: none !important; }
.modal-audio-select { min-width: 120px; max-width: 190px; }
.modal-page-nav, .modal-actions { flex: 0 0 auto; flex-wrap: nowrap; white-space: nowrap; }
.modal-actions .soft-button, .modal-page-nav .soft-button { min-height: 32px; padding-inline: 9px; }

@media (max-width: 860px) {
  .sidebar { overflow: hidden; }
  .spread-view.single-page { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions .soft-button#fullscreenButton { display: none; }
  .modal-toolbar-workspace { align-items: center !important; }
  .modal-audio { min-width: 330px; }
}

@media (orientation: landscape) and (max-height: 620px) {
  .main-area { overflow-y: auto; }
  .topbar { min-height: 58px; padding-block: 6px; }
  .audio-dock { padding-block: 6px; }
  .view-toolbar { min-height: 46px; padding-block: 5px; }
.lesson-footer { display: none; }
}

/* Gateway B2 palette, based on the book cover and unit bands. */
.gateway-brand-mark { width: 44px; color: #fff; background: linear-gradient(135deg, #7a1f63, #ef3e71); font-size: 11px; letter-spacing: -.03em; border-radius: 10px; }
.gateway-brand-mark,
.unit-number,
.play-button { background: linear-gradient(135deg, #7a1f63, #ef3e71) !important; color: #fff !important; }
.audio-dock { border-bottom-color: #ef3e71; background: #3c1835; }
.audio-label { background: #ef3e71; color: #fff; }
.lesson-link.active { border-left-color: #ef3e71; }
.lesson-link.active .lesson-code,
.supplement-link .lesson-code { color: #ff6f9a; }
.progress-ring { background: conic-gradient(#ef3e71 var(--progress), #3b3b3b 0); }
.audio-range,
.modal-audio-seek { accent-color: #ef3e71; }
.sidebar-brand { background: linear-gradient(145deg, rgba(122,31,99,.34), transparent 58%); }
.view-toolbar { border-bottom-color: rgba(122,31,99,.18); }
