:root {
  --bg: #0b0d14;
  --card: #141824;
  --text: #f2f3f7;
  --mute: #9aa3b5;
  --accent: #6c5ce7;
  --accent2: #00b894;
  --danger: #d63031;
  --line: #232838;
  --radius: 18px;
  --top-h: 56px;
  --drawer-w-open: min(260px, 72vw);
  font-family: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}
.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(108, 92, 231, 0.25), transparent),
    radial-gradient(700px 400px at 90% 0%, rgba(0, 184, 148, 0.12), transparent);
  pointer-events: none;
  z-index: 0;
}
.top, main, .foot { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  min-height: var(--top-h);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  background: rgba(11, 13, 20, 0.95);
  z-index: 60;
}
.top .brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.top .brand .title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}
.top .brand .sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}
.top .hub-top-tabs { margin-left: auto; flex-shrink: 0; }

/* Hamburger — three real spans (reliable on iOS Safari) */
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #0f172a; color: #f2f3f7; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 1rem; padding: 0;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 18px;
  height: 14px;
}
.icon-bars span {
  display: block;
  height: 2px;
  width: 100%;
  background: #f2f3f7;
  border-radius: 1px;
}

/* Left nav drawer */
.nav-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 55;
  width: var(--drawer-w-open);
  max-width: 86vw;
  background: #0e1628;
  border-right: 1px solid var(--line);
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  padding: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 0.5rem) 0.9rem 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
}
body.nav-open .nav-drawer { transform: translateX(0); }
.hub-main { transition: padding-left 0.22s ease; min-width: 0; }

/* Desktop / tablet: push content when open */
@media (min-width: 900px) {
  body.nav-open .hub-main,
  body.nav-open .foot {
    padding-left: var(--drawer-w-open);
  }
  .nav-drawer {
    top: var(--top-h);
    padding-top: 0.85rem;
    height: calc(100dvh - var(--top-h));
  }
}

/* Mobile: overlay only — never squeeze library content to a sliver */
@media (max-width: 899px) {
  body.nav-open .hub-main,
  body.nav-open .foot {
    padding-left: 0 !important;
  }
  body.nav-open {
    overflow: hidden;
  }
  /* Soft scrim so menu is clearly on top, content still full-width underneath */
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
  }
  .top .brand .sub { display: none; }
  .hub-top-tabs {
    display: none; /* Library/Tutor/Coach live in the drawer on phone */
  }
  .top {
    flex-wrap: nowrap;
  }
  .top .brand .title { max-width: min(55vw, 12rem); }
}

.nav-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; margin-bottom: 1rem; padding-bottom: 0.65rem; border-bottom: 1px solid var(--line);
  color: #f2f3f7;
}
.nav-section { margin-bottom: 1.25rem; }
.nav-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: #9aa3b5;
  margin: 0 0 0.45rem;
}
/* Force block links — avoid browser-default blue inline scramble */
.nav-drawer a.nav-link,
#navDrawer .nav-link {
  display: block !important;
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  color: #f2f3f7 !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0 0 0.25rem;
  border: 1px solid transparent;
  background: transparent;
  line-height: 1.3;
}
.nav-drawer a.nav-link:hover,
.nav-drawer a.nav-link:focus-visible,
.nav-drawer a.nav-link:visited {
  color: #f2f3f7 !important;
  background: #121a2f;
  border-color: var(--line);
  outline: none;
}
.track-tabs-col {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  gap: 0.25rem;
}
.track-tabs-col .track-tab,
#navDrawer a.track-tab {
  display: block !important;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  text-decoration: none !important;
  border: 1px solid var(--line);
  background: #101522;
  color: #f2f3f7 !important;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  margin: 0;
}
.track-tabs-col .track-tab.active,
.track-tabs-col .track-tab:hover,
#navDrawer a.track-tab:visited {
  background: rgba(108, 92, 231, 0.25);
  border-color: var(--accent);
  color: #f2f3f7 !important;
}

@media (max-width: 700px) {
  main, .hub-main { padding: 1rem 0.85rem 2.5rem; }
  h1 { font-size: clamp(1.5rem, 6vw, 2.2rem); }
  .player-layout { grid-template-columns: 1fr; }
  .video { max-height: 50vh; }
  .play-tabs { gap: 0.35rem; }
  .play-tabs button { font-size: 0.82rem; padding: 0.35rem 0.7rem; }
  .grid { grid-template-columns: 1fr; }
  .tutor-layout { grid-template-columns: 1fr; }
}

/* Live tutor (Option B) — Phase 1: single column, modes in main */
.tutor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
.tutor-main { min-width: 0; }
.unit-nav {
  margin: 0.35rem 0 0.15rem;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.unit-nav-label {
  font-size: 0.9rem;
  color: var(--mute);
  min-width: 8rem;
  text-align: center;
}
.session-controls .mode-toggle.is-active,
.session-controls .mode-toggle[aria-pressed="true"] {
  background: rgba(0, 184, 148, 0.18);
  border-color: rgba(0, 184, 148, 0.55);
  color: #e8fff8;
}
.main-mode-panel {
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 0.9rem 1rem;
}
.main-mode-panel.hidden { display: none !important; }
.main-mode-panel textarea {
  width: 100%;
  margin: 0.5rem 0;
  background: #0f1320;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 0.7rem;
  font-family: inherit;
}
.lede-inline {
  margin: 0.5rem 0 0.75rem;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
}
.practice-strip.hidden { display: none !important; }
.tutor-chrome-legacy.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0 0.35rem;
}
.session-controls {
  margin: 0.35rem 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: 14px;
  background: rgba(108, 92, 231, 0.08);
  align-items: center;
}
.session-controls #btnPlaySession.is-busy {
  opacity: 0.92;
  pointer-events: none;
}
.session-controls #btnPlaySession.is-busy .btn-label { display: none; }
.session-controls #btnPlaySession.is-busy .btn-busy { display: inline; }
.session-controls .btn-busy.hidden { display: none; }
.session-controls .btn-busy:not(.hidden) { display: inline; }
.session-controls.is-interrupted {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.1);
}
.session-controls.is-interrupted #sessionPlayStatus {
  color: #fde68a;
  font-weight: 600;
}
.session-interrupt-banner {
  flex-basis: 100%;
  margin: 0.25rem 0 0;
  color: #fde68a;
  font-size: 0.88rem;
  line-height: 1.35;
}

.session-interrupt-banner.hidden { display: none; }

/* Conversational Ask UX P0+P1 */
.ask-primary-row { margin-top: 0.75rem; }
.ask-primary-row .btn.primary { min-height: 2.6rem; font-weight: 600; }
.ask-secondary-row { margin-top: 0.45rem; opacity: 0.92; }
.ask-https-banner {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  font-size: 0.9rem;
  line-height: 1.4;
}
.ask-https-banner a { color: #fbbf24; font-weight: 600; text-decoration: underline; }
.ask-https-banner.hidden { display: none; }
.ask-heard-line {
  margin: 0.4rem 0 0;
  color: #a5f3fc;
  font-weight: 600;
  font-size: 0.92rem;
}
.ask-heard-line.hidden { display: none; }
.ask-status {
  min-height: 1.35rem;
  margin-top: 0.55rem;
  color: #c4b5fd;
  font-weight: 500;
}
#askPanel .coach-reply {
  margin-top: 0.65rem;
  white-space: pre-wrap;
}

#sessionPlayStatus { font-size: 0.85rem; color: #c4b5fd; }
.spoken-panel {
  margin: 0.65rem 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c101a;
  overflow: hidden;
}
.spoken-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.spoken-scroll {
  max-height: min(42vh, 360px);
  overflow-y: auto;
  padding: 0.75rem 0.9rem 1rem;
  scroll-behavior: smooth;
}
.spoken-transcript {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #e8eaf0;
  white-space: pre-wrap;
}
.spoken-transcript .spoken-chunk {
  display: inline;
}
.spoken-transcript .spoken-chunk.is-active {
  background: rgba(0, 184, 148, 0.22);
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.examples-on-demand { margin: 0.5rem 0; }
.examples-on-demand .unit-examples.hidden { display: none !important; }
.chapter-tabs .track-tab {
  border: 1px solid var(--line);
  background: #101522;
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.chapter-tabs .track-tab.active {
  background: var(--accent);
  border-color: var(--accent);
}
.unit-card {
  margin: 0.5rem 0 1rem;
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #101522;
}
.unit-bullets {
  margin: 0.75rem 0;
  padding-left: 1.2rem;
  line-height: 1.45;
}
.unit-bullets li { margin-bottom: 0.35rem; }
/* Minimal chalkboard — short labels; voice explains off-slide (Mayer redundancy) */
.unit-bullets.chalkboard {
  list-style: none;
  padding: 0.65rem 0.75rem;
  margin: 0.75rem 0;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(160deg, #0f172a 0%, #111827 55%, #0b1220 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.chalkboard-cell {
  margin: 0.35rem 0;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.35;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chalkboard-cell .board-label {
  display: block;
}
.chalkboard-cell.is-active {
  color: #f8fafc;
  background: rgba(129, 140, 248, 0.16);
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.15);
}
.unit-synthesis {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
  color: var(--mute);
  line-height: 1.5;
}
.unit-examples h4 { margin: 0.8rem 0 0.35rem; font-size: 0.9rem; }
.example-line { color: var(--mute); font-size: 0.9rem; margin: 0.25rem 0; }
.practice-strip { margin-top: 0.5rem; }
.practice-strip textarea {
  width: 100%;
  margin: 0.5rem 0;
  background: #0f1320;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 0.7rem;
  font-family: inherit;
}
.scene-list li.done-unit { color: var(--accent2); }
.scene-list li.skipped-unit { color: #fdcb6e; }
.unit-actions { margin-top: 0.75rem; flex-wrap: wrap; }
.highlight-list {
  list-style: none;
  margin: 0.35rem 0 0.75rem;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  font-size: 0.85rem;
}
.highlight-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.35rem;
  background: #101522;
  color: var(--mute);
}
.highlight-list li strong { color: var(--text); display: block; font-size: 0.8rem; }
.synth-heading { margin-top: 1rem; font-size: 1rem; }
.synth-actions { margin-top: 0.55rem; align-items: center; }
.synth-body[contenteditable="true"] {
  outline: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.35rem;
  min-height: 4rem;
}
.coach-persona {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.coach-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(108, 92, 231, 0.45);
  flex-shrink: 0;
  display: block;
}
.avatar-stage {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}
.avatar-stage-sm {
  width: 28px;
  height: 28px;
}
.avatar-stage-md {
  width: 48px;
  height: 48px;
}
.avatar-stage-sm .coach-avatar,
.avatar-stage-sm img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(108, 92, 231, 0.4);
}
.avatar-stage-md .coach-avatar,
.avatar-stage-md img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(108, 92, 231, 0.55);
  background: #1a1f2e;
  display: block;
}
.tutor-coach-chip.elena-visible,
.player-elena-chip.elena-visible {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(0, 184, 148, 0.06));
}
.elena-name {
  color: #c4b5fd;
  font-weight: 600;
}
/* Lesson video stage + Elena picture-in-picture (visible while listening) */
.video-stage {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.video-stage .video {
  width: 100%;
  display: block;
  max-height: min(70vh, 720px);
  background: #000;
}
.elena-pip {
  position: absolute;
  right: 0.85rem;
  bottom: 3.5rem; /* above native video controls */
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.7rem 0.45rem 0.45rem;
  border-radius: 999px;
  background: rgba(11, 13, 20, 0.92);
  border: 2px solid rgba(108, 92, 231, 0.7);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(196, 181, 253, 0.15);
  pointer-events: none; /* don't block video controls */
  max-width: min(260px, 70%);
}
.avatar-stage-lg {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  position: relative;
}
.avatar-stage-lg .coach-avatar,
.avatar-stage-lg img,
.elena-pip-video {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(0, 184, 148, 0.75);
  display: block;
  background: #1a1f2e;
}
.elena-pip-video {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.elena-pip-video.hidden {
  display: none !important;
}
.avatar-stage-lg .avatar-mouth {
  z-index: 2;
}
.elena-pip-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.78rem;
  line-height: 1.2;
  color: #e8eaf0;
}
.elena-pip-label strong {
  color: #c4b5fd;
  font-size: 0.85rem;
}
.elena-pip-label span {
  color: #9aa3b5;
  font-size: 0.72rem;
}
.video-stage.is-playing .elena-pip {
  border-color: rgba(0, 184, 148, 0.85);
}
@media (max-width: 600px) {
  .elena-pip {
    right: 0.5rem;
    bottom: 2.85rem;
    padding: 0.35rem 0.45rem 0.35rem 0.35rem;
  }
  .elena-pip-label { display: none; }
  .avatar-stage-lg,
  .avatar-stage-lg img,
  .elena-pip-video {
    width: 72px;
    height: 72px;
  }
}
.avatar-stage.speaking {
  animation: avatar-speak-pulse 1.1s ease-in-out infinite;
}
.avatar-stage.speaking .coach-avatar,
.avatar-stage.speaking img {
  border-color: rgba(0, 184, 148, 0.85);
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.25);
}
.avatar-mouth {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 18%;
  height: 6%;
  margin-left: -9%;
  border-radius: 40%;
  background: rgba(40, 20, 20, 0.35);
  opacity: 0;
  pointer-events: none;
}
.avatar-stage.speaking .avatar-mouth {
  opacity: 0.55;
  animation: mouth-talk 0.28s ease-in-out infinite alternate;
}
.avatar-stage-sm .avatar-mouth {
  bottom: 16%;
  height: 8%;
}
@keyframes avatar-speak-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
@keyframes mouth-talk {
  from { transform: scaleY(0.6); }
  to { transform: scaleY(1.35); }
}
.card-inset {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1320;
}
.card-inset h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.mem-consent {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--mute);
  margin: 0.5rem 0;
  cursor: pointer;
}
.elena-lecture-video {
  max-width: 100%;
  width: min(360px, 100%);
  border-radius: 12px;
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  background: #0a0c12;
}
.elena-live-avatar h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
#memScopeLabel { font-size: 0.78rem; opacity: 0.9; }
.player-elena-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1320;
}
.player-elena-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.88rem;
}
.player-elena-copy strong { color: #c4b5fd; font-weight: 600; }
.mem-list {
  list-style: none;
  margin: 0.4rem 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
  font-size: 0.82rem;
}
.mem-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}
.mem-list button {
  flex-shrink: 0;
  font-size: 0.75rem;
  border: none;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
}
.mem-offer {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed rgba(108, 92, 231, 0.45);
  border-radius: 12px;
  background: rgba(108, 92, 231, 0.08);
}
.coach-tagline { margin: 0.15rem 0 0; font-size: 0.88rem; }
.tutor-coach-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.65rem 0 0.25rem;
  padding: 0.65rem 0.85rem 0.65rem 0.65rem;
  font-size: 0.88rem;
  color: var(--mute);
  border: 1px solid rgba(108, 92, 231, 0.4);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(0, 184, 148, 0.06));
}
/* Force brand face size — override legacy 28px rule */
.tutor-coach-chip .avatar-stage-lg,
.tutor-coach-chip .avatar-stage-lg .coach-avatar,
.tutor-coach-chip .avatar-stage-lg img,
.tutor-coach-chip #tutorElenaVideo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
}
.tutor-coach-chip img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(0, 184, 148, 0.75);
  display: block;
  background: #1a1f2e;
}
.tutor-elena-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.tutor-elena-copy .elena-name {
  font-size: 1.05rem;
}
#tutorElenaStatus {
  font-size: 0.86rem;
  line-height: 1.35;
  color: #c5c9d6;
}
.synth-report {
  margin-top: 0.4rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1320;
  max-height: 280px;
  overflow: auto;
  font-size: 0.85rem;
}
.synth-report[data-state="preparing"] { border-color: rgba(108, 92, 231, 0.5); }
.synth-report[data-state="ready"] { border-color: rgba(0, 184, 148, 0.45); }
.synth-body h4 { margin: 0.6rem 0 0.25rem; font-size: 0.88rem; }
.synth-body .synth-unit { margin-bottom: 0.75rem; padding-bottom: 0.55rem; border-bottom: 1px dashed var(--line); }
.synth-body .synth-quotes { color: #fdcb6e; font-style: italic; margin: 0.25rem 0; padding-left: 0.6rem; }
.hl-popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.65);
  padding: 1rem;
}
.hl-popup.hidden { display: none; }
.hl-popup-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.hl-popup-card h3 { margin: 0 0 0.5rem; }
.hl-popup-card #hlPopupPreview {
  max-height: 6rem;
  overflow: auto;
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.65rem;
  background: #0f1320;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.focus-cards { display: grid; gap: 0.85rem; margin-top: 1rem; }
.focus-cards .unit-card { margin: 0; }
.mark-hl {
  background: rgba(253, 203, 110, 0.25);
  border-bottom: 1px solid #fdcb6e;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.track-tab {
  /* used in library cards too */
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #0984e3);
  font-weight: 700;
}
.title { font-weight: 700; }
.sub { color: var(--mute); font-size: 0.85rem; }
.nav { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.nav a {
  color: var(--mute);
  text-decoration: none;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}
.nav a.active, .nav a:hover {
  color: var(--text);
  background: var(--card);
}
.nav a.nav-classroom {
  border: 1px solid var(--line);
  color: var(--text);
  margin-left: 0.25rem;
}
.nav a.nav-classroom:hover {
  border-color: var(--accent2);
  background: transparent;
}
.empty-state {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  color: var(--mute);
  max-width: 42ch;
}
.book-card {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.book-card-clickable {
  cursor: pointer;
}
.book-card-clickable:hover,
.book-card-clickable:focus-visible {
  border-color: rgba(108, 92, 231, 0.55);
  box-shadow: 0 8px 28px rgba(108, 92, 231, 0.18);
  transform: translateY(-1px);
  outline: none;
}
.book-card-clickable:active {
  transform: scale(0.99);
}
.book-card .tile-hint {
  margin: auto 0 0;
  min-height: 0;
  padding-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}
.book-card .domain {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent2);
  margin: 0 0 0.35rem;
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.view.hidden { display: none; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent2);
  font-size: 0.75rem;
  font-weight: 700;
}
h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  margin: 0.4rem 0 0.8rem;
}
.lede { color: var(--mute); max-width: 52ch; line-height: 1.55; }
.muted { color: var(--mute); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.book-card h3 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.book-card p { color: var(--mute); font-size: 0.92rem; line-height: 1.45; min-height: 3.6em; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.7rem 0; }
.tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #1c2233;
  color: var(--mute);
}
.tag.ok { color: var(--accent2); border: 1px solid rgba(0,184,148,0.35); }
.tag.warn { color: #fdcb6e; border: 1px solid rgba(253,203,110,0.4); }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn.primary { background: var(--accent); color: white; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.cta-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }

.player-layout {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .player-layout { grid-template-columns: 1fr; }
}
.video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 14px;
  margin-top: 0.8rem;
}
.play-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; align-items: center; }
.play-tabs button {
  border: 1px solid var(--line);
  background: #101522;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.play-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
}
.play-tabs .play-sep {
  margin-left: 0.35rem;
  margin-right: 0.15rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.scene-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  max-height: 45vh;
  overflow: auto;
}
.scene-list li {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.9rem;
}
.scene-list li:hover, .scene-list li.active { color: var(--accent2); }
.progress {
  height: 8px;
  background: #101522;
  border-radius: 999px;
  overflow: hidden;
}
#progFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.hint { color: var(--mute); font-size: 0.85rem; }
.coach-card label {
  display: block;
  margin: 0.8rem 0;
  color: var(--mute);
  font-size: 0.85rem;
}
.coach-card textarea {
  width: 100%;
  margin-top: 0.35rem;
  background: #0f1320;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 0.7rem;
  font-family: inherit;
  resize: vertical;
}
.hint-box, .coach-reply {
  margin-top: 0.8rem;
  padding: 0.85rem;
  border-radius: 12px;
  background: #101522;
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}
.coach-reply {
  border-left-color: var(--accent2);
  /* Preserve newlines from coach streams (e.g. "\n\n(Interrupted.)") and multi-line answers. */
  white-space: pre-wrap;
}
.stems { color: var(--mute); line-height: 1.6; }
.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  color: var(--mute);
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.hidden { display: none !important; }

/* Multi-source library sections (Books / YouTube / …) */
.library-section-title {
  grid-column: 1 / -1;
  margin: 1.25rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #8b93a7);
}
.library-section-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.tag.source {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.35);
}
/* —— Mobile tidy shell —— */
.chapter-nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.55rem 0 0.25rem;
}
.chapter-nav-row .chapter-tabs {
  flex: 1 1 auto;
  margin: 0;
}
.chapter-tabs .track-tab {
  font-size: 0.78rem;
  padding: 0.28rem 0.55rem;
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-tabs .track-tab.is-current {
  font-weight: 700;
}
#btnAllChapters {
  flex: 0 0 auto;
  font-size: 0.8rem;
}
.unit-summary {
  margin: 0.55rem 0 0.65rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(108, 92, 231, 0.28);
  border-radius: 12px;
  background: rgba(12, 16, 26, 0.65);
  list-style: disc;
  padding-left: 1.35rem;
}
.unit-summary li {
  margin: 0.28rem 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #e8e6f5;
}
.spoken-panel.is-collapsed .spoken-scroll { display: none; }
.spoken-panel .spoken-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.45rem 0.75rem;
}
.spoken-panel .spoken-toggle:hover { background: rgba(108, 92, 231, 0.08); }
.spoken-actions { margin: 0.45rem 0.5rem 0.65rem; }
#sessionControls #btnPlaySession.is-playing:not(.is-busy) .btn-label {
  /* stop affordance already in label text */
}
.tutor-load-log.hidden, #tutorLoadLog.hidden { display: none !important; }

/* Product UI: never surface debug loader / context-ring dumps */
#tutorCtxRing,
#tutorLoadLog,
#examplesOnDemand {
  display: none !important;
}

/* Tutor diag overlay (?debug=1) — mobile bottom sheet, never blocks Play */
.diag-overlay {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-height: 42vh;
  overflow-y: auto;
  z-index: 90;
  background: rgba(10, 12, 24, 0.94);
  border: 1px solid rgba(108, 92, 231, 0.5);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.72rem;
  color: #c7cdf0;
  pointer-events: auto;
}
.diag-overlay.hidden { display: none; }
.diag-overlay .diag-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.diag-overlay .diag-snap { color: #9aa3b5; font-family: ui-monospace, monospace; }
.diag-overlay .diag-btns { display: flex; gap: 6px; }
.diag-overlay .diag-btns button {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(108, 92, 231, 0.6);
  background: rgba(108, 92, 231, 0.15);
  color: #e3e7ff;
  cursor: pointer;
}
.diag-overlay .diag-log {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #aeb6d8;
}

/* Phase 2 Interactive always-listen */
#btnLiveListen.is-active {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.55);
  color: #6ee7b7;
  font-weight: 600;
}
#btnLiveListen.is-listening {
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35);
}
.live-listen-hint {
  flex-basis: 100%;
  margin: 0.2rem 0 0;
  color: #6ee7b7;
  font-size: 0.85rem;
}

/* Empty shelves still visible (Video / Social video IA) */
.library-section-empty {
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.35);
}
.library-section-empty-msg {
  margin: 0;
  font-size: 0.92rem;
  opacity: 0.85;
}


/* Always-on curriculum track (Image-2 style row under header) */
.hub-track-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0.55rem 1rem 0.65rem;
  background: linear-gradient(180deg, rgba(7, 12, 24, 0.98), rgba(7, 12, 24, 0.92));
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(10px);
}
.hub-track-bar .track-tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-width: 72rem;
  margin: 0 auto;
}
.hub-track-bar .track-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  background: rgba(15, 23, 42, 0.55);
}
.hub-track-bar .track-tab.active,
.hub-track-bar .track-tab[aria-current="page"] {
  border-color: rgba(74, 222, 128, 0.55);
  color: #ecfdf5;
  background: rgba(22, 101, 52, 0.35);
}
.nav-section-track {
  order: -1;
}
/* Ensure drawer sections keep Track first even if CSS reorders */
.nav-drawer {
  display: flex;
  flex-direction: column;
}
