:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0e1b2c;
  --surface-2: #132338;
  --line: rgba(173, 198, 226, 0.16);
  --text: #f5f8fc;
  --muted: #91a4bc;
  --accent: #ff7455;
  --accent-soft: rgba(255, 116, 85, 0.15);
  --cyan: #64d9dc;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 4%, rgba(100, 217, 220, 0.09), transparent 28rem),
    radial-gradient(circle at 91% 34%, rgba(255, 116, 85, 0.08), transparent 32rem),
    var(--bg);
}

.course-home,
.home-splash {
  display: none;
}

.course-home-mode body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -22%, rgba(100, 217, 220, 0.2), transparent 38rem),
    radial-gradient(circle at 84% 58%, rgba(255, 116, 85, 0.07), transparent 30rem),
    linear-gradient(155deg, #071824 0%, #04111c 58%, #020b13 100%);
}

.course-home-mode .app-shell {
  display: none;
}

.course-home-mode .course-home {
  display: block;
  min-height: 100dvh;
  padding: 0;
}

.course-home-card {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}

.course-home-card::before,
.course-home-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.course-home-card::before {
  top: -24rem;
  left: 50%;
  width: 46rem;
  height: 46rem;
  border: 1px solid rgba(100, 217, 220, 0.1);
  box-shadow:
    0 0 0 6rem rgba(100, 217, 220, 0.022),
    0 0 0 12rem rgba(100, 217, 220, 0.014);
  transform: translateX(-50%);
}

.course-home-card::after {
  right: -12rem;
  bottom: -16rem;
  width: 34rem;
  height: 34rem;
  background: radial-gradient(circle, rgba(255, 116, 85, 0.07), transparent 68%);
}

.course-member-bar {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 82px;
  padding: max(20px, env(safe-area-inset-top)) clamp(22px, 5vw, 72px) 14px;
  align-items: center;
  gap: 13px;
  border: 0;
}

.course-member-avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #06313a;
  background: linear-gradient(145deg, #8ff1dc, #55d8d2);
  font: 800 1.1rem/1 Georgia, serif;
  box-shadow: 0 10px 28px rgba(80, 225, 211, 0.2);
}

.course-member-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.course-member-label {
  overflow: hidden;
  color: #69e4da;
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-member-copy strong {
  font-size: 0.86rem;
}

.course-member-status {
  display: flex;
  min-height: 28px;
  margin-left: auto;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(100, 217, 220, 0.28);
  border-radius: 999px;
  color: #bcefee;
  background: rgba(1, 18, 30, 0.48);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.course-member-status span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #61e7d8;
  box-shadow: 0 0 12px rgba(97, 231, 216, 0.8);
}

.course-home-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  min-height: calc(100dvh - 82px);
  padding: clamp(4px, 1.2vh, 14px) clamp(20px, 5vw, 72px) max(24px, env(safe-area-inset-bottom));
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
}

.course-calendar {
  width: min(330px, 100%);
  padding: 17px 20px 16px;
  border: 1px solid rgba(173, 198, 226, 0.14);
  border-radius: 20px;
  background: rgba(9, 28, 41, 0.78);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.course-calendar-heading {
  display: flex;
  margin-bottom: 12px;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.course-calendar-heading span,
.course-start-copy > span {
  color: #68e4da;
  font-size: 0.6rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.course-calendar-heading h1,
.course-start-copy h2 {
  margin: 5px 0 0;
  color: #f3fbff;
  letter-spacing: -0.02em;
}

.course-calendar-heading h1 {
  font-size: 0.9rem;
}

.course-start-copy h2 {
  font-size: clamp(1.35rem, 2.7vw, 2rem);
  letter-spacing: -0.02em;
}

.course-calendar-heading > strong {
  color: #9fb3c5;
  font-size: 0.74rem;
  font-weight: 700;
}

.course-weekdays,
.course-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.course-weekdays {
  margin-bottom: 8px;
  color: #71899c;
  font-size: 0.62rem;
  font-weight: 750;
  text-align: center;
}

.course-calendar-grid span {
  position: relative;
  display: grid;
  min-height: 27px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #b9c8d5;
  font-size: 0.72rem;
  font-weight: 700;
}

.course-calendar-grid .is-empty {
  visibility: hidden;
}

.course-calendar-grid .is-today {
  border-color: rgba(100, 217, 220, 0.65);
  color: #061b27;
  background: #69dfd6;
  box-shadow: 0 7px 22px rgba(100, 217, 220, 0.2);
}

.course-calendar-grid .has-study::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  margin-top: 20px;
  border-radius: 50%;
  background: #ff7658;
}

.course-start-panel {
  display: flex;
  width: min(620px, 100%);
  min-height: 100%;
  padding: clamp(24px, 4vh, 54px) 0 clamp(8px, 2vh, 22px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.course-daily-goal {
  display: flex;
  margin-bottom: clamp(12px, 2vh, 22px);
  align-items: baseline;
  justify-content: center;
  gap: 13px;
  color: #f6fbff;
}

.course-daily-goal strong {
  color: transparent;
  background: linear-gradient(155deg, #ffffff 10%, #c8f6f1 48%, #69dfd6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  font: 800 clamp(5.4rem, 10vw, 8.6rem)/0.82 Georgia, "Times New Roman", serif;
  letter-spacing: -0.08em;
  filter: drop-shadow(0 14px 36px rgba(100, 217, 220, 0.11));
}

.course-daily-goal span {
  color: #a6bdcb;
  font-size: clamp(0.92rem, 1.6vw, 1.18rem);
  font-weight: 750;
}

.course-start-copy {
  max-width: 520px;
}

.course-start-copy p {
  margin: 10px 0 0;
  color: #91a7b8;
  font-size: clamp(0.78rem, 1.3vw, 0.92rem);
  line-height: 1.8;
}

.course-start-button {
  display: flex;
  width: min(330px, 100%);
  min-height: 58px;
  margin-top: clamp(22px, 3.5vh, 36px);
  padding: 0 18px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(100, 217, 220, 0.72);
  border-radius: 999px;
  color: #06212c;
  background: linear-gradient(135deg, #8cecdf, #55d8d2);
  box-shadow: 0 14px 34px rgba(61, 221, 207, 0.18);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.course-start-button:hover:not(:disabled),
.course-start-button:focus-visible:not(:disabled) {
  outline: none;
  box-shadow: 0 18px 42px rgba(61, 221, 207, 0.28);
  transform: translateY(-2px);
}

.course-start-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.course-start-button span:last-child {
  font-size: 1.24rem;
}

.course-episode-picker[hidden] {
  display: none;
}

.course-episode-picker {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  padding: 20px;
  place-items: center;
}

.course-episode-picker-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(1, 10, 18, 0.76);
  opacity: 0;
  backdrop-filter: blur(10px);
  transition: opacity 180ms ease;
}

.course-episode-picker-dialog {
  position: relative;
  width: min(740px, 100%);
  max-height: min(680px, calc(100dvh - 40px));
  padding: 24px;
  overflow: auto;
  border: 1px solid rgba(100, 217, 220, 0.36);
  border-radius: 26px;
  color: #f3fbff;
  background: linear-gradient(155deg, #103447, #071d2b 72%);
  box-shadow: 0 36px 100px rgba(0, 0, 0, 0.54);
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease;
}

.course-episode-picker.is-open .course-episode-picker-backdrop,
.course-episode-picker.is-open .course-episode-picker-dialog {
  opacity: 1;
}

.course-episode-picker.is-open .course-episode-picker-dialog {
  transform: translateY(0) scale(1);
}

.course-picker-open {
  overflow: hidden;
}

.course-episode-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.course-episode-picker-header span {
  color: #68e4da;
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.course-episode-picker-header h2 {
  margin: 6px 0 0;
  font-size: 1.22rem;
}

.course-episode-picker-header p {
  margin: 7px 0 0;
  color: #91a7b8;
  font-size: 0.76rem;
}

.course-episode-picker-close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(100, 217, 220, 0.28);
  border-radius: 12px;
  color: #c8f3f0;
  background: rgba(5, 25, 37, 0.62);
  cursor: pointer;
  font-size: 1.3rem;
}

.course-episode-picker-close:hover,
.course-episode-picker-close:focus-visible {
  border-color: #67dfd5;
  outline: none;
}

.course-episode-picker-note {
  margin: 14px 0 0;
  color: #70899b;
  font-size: 0.66rem;
  text-align: center;
}

.course-episode-list {
  display: grid;
  margin-top: 18px;
  gap: 10px;
}

.course-episode-card {
  display: grid;
  min-height: 86px;
  padding: 12px 15px;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(100, 217, 220, 0.24);
  border-radius: 18px;
  color: #f5fbff;
  background: rgba(11, 38, 52, 0.76);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.course-episode-card:hover {
  border-color: rgba(100, 217, 220, 0.7);
  background: rgba(17, 53, 68, 0.96);
  transform: translateY(-2px);
}

.course-episode-card.is-loading {
  opacity: 0.72;
}

.course-episode-number {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
  color: #0d3038;
  background: #67dfd5;
  font-size: 0.78rem;
  font-weight: 900;
}

.course-episode-details {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.course-episode-details strong {
  overflow: hidden;
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-episode-details small {
  color: #8ea4b5;
  font-size: 0.7rem;
}

.course-episode-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.course-mode-button {
  display: inline-flex;
  min-height: 38px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(100, 217, 220, 0.42);
  border-radius: 11px;
  color: #bff5f1;
  background: rgba(4, 25, 37, 0.62);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.course-mode-button.is-shadowing {
  border-color: #69e2d8;
  color: #082d35;
  background: linear-gradient(145deg, #78eadf, #56d2ce);
  box-shadow: 0 8px 22px rgba(82, 219, 210, 0.16);
}

.course-mode-button.is-chinese-first {
  border-color: rgba(244, 202, 126, 0.65);
  color: #ffe1aa;
  background: rgba(111, 77, 25, 0.22);
}

.chinese-first-note {
  margin: 8px 12px 0;
  color: #e4c899;
  font-size: 0.72rem;
  text-align: center;
}

@media (max-width: 420px) {
  .course-episode-actions {
    flex-wrap: wrap;
  }

  .course-mode-button {
    padding-inline: 10px;
  }
}

.course-mode-button:hover,
.course-mode-button:focus-visible {
  border-color: #8df2e8;
  outline: none;
  transform: translateY(-1px);
}

.course-mode-button.is-shadowing:hover,
.course-mode-button.is-shadowing:focus-visible {
  background: linear-gradient(145deg, #90f3e8, #68ddd6);
}

.course-mode-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.42;
}

.course-home-status {
  min-height: 1.2em;
  margin: 13px 0 0;
  color: #70899b;
  font-size: 0.66rem;
  text-align: center;
}

.course-home-mode .home-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: #061421;
  opacity: 1;
  transition: opacity 260ms ease-out;
}

.home-splash.fade-out {
  opacity: 0;
  pointer-events: none;
}

.home-splash-content {
  display: grid;
  justify-items: center;
  gap: 22px;
}

.home-splash-brand {
  color: #effcff;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(2.1rem, 8vw, 3.7rem);
  font-weight: 760;
  letter-spacing: -0.05em;
}

.home-splash-wave {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 5px;
}

.home-splash-wave span {
  width: 4px;
  height: 8px;
  border-radius: 99px;
  background: #67e0d6;
  animation: home-wave 850ms ease-in-out infinite alternate;
}

.home-splash-wave span:nth-child(2),
.home-splash-wave span:nth-child(6) { animation-delay: -150ms; }
.home-splash-wave span:nth-child(3),
.home-splash-wave span:nth-child(5) { animation-delay: -300ms; }
.home-splash-wave span:nth-child(4) { animation-delay: -450ms; }

@keyframes home-wave {
  from { height: 7px; opacity: 0.55; }
  to { height: 31px; opacity: 1; }
}

@media (max-width: 560px) {
  .course-member-bar {
    min-height: 70px;
    padding: max(14px, env(safe-area-inset-top)) 18px 8px;
  }

  .course-member-avatar {
    width: 42px;
    height: 42px;
  }

  .course-member-copy strong {
    font-size: 0.78rem;
  }

  .course-home-main {
    min-height: calc(100dvh - 70px);
    padding: 6px 18px max(18px, env(safe-area-inset-bottom));
  }

  .course-calendar {
    width: min(310px, 100%);
    padding: 14px 16px 12px;
    border-radius: 17px;
  }

  .course-calendar-heading {
    margin-bottom: 9px;
  }

  .course-calendar-heading span {
    display: none;
  }

  .course-calendar-heading h1 {
    margin-top: 0;
    font-size: 0.82rem;
  }

  .course-calendar-grid span {
    min-height: 24px;
    font-size: 0.67rem;
  }

  .course-calendar-grid .has-study::after {
    margin-top: 18px;
  }

  .course-start-panel {
    width: 100%;
    padding: 18px 0 4px;
  }

  .course-daily-goal {
    margin-bottom: 12px;
    gap: 10px;
  }

  .course-daily-goal strong {
    font-size: clamp(4.8rem, 24vw, 6.8rem);
  }

  .course-start-copy p {
    max-width: 330px;
    margin-right: auto;
    margin-left: auto;
  }

  .course-start-button {
    min-height: 54px;
    margin-top: 22px;
  }

  .course-episode-picker {
    padding: 0;
    align-items: end;
  }

  .course-episode-picker-dialog {
    width: 100%;
    max-height: min(78dvh, 660px);
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 26px 26px 0 0;
    transform: translateY(28px);
  }

  .course-episode-card {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .course-episode-number {
    grid-row: 1 / span 2;
  }

  .course-episode-actions {
    grid-column: 2;
    justify-content: stretch;
  }

  .course-mode-button {
    flex: 1 1 0;
  }
}

@media (max-height: 720px) and (max-width: 560px) {
  .course-calendar {
    padding-top: 11px;
    padding-bottom: 9px;
  }

  .course-calendar-grid span {
    min-height: 21px;
  }

  .course-start-panel {
    padding-top: 12px;
  }

  .course-daily-goal strong {
    font-size: 4.4rem;
  }

  .course-start-copy p {
    line-height: 1.55;
  }

  .course-start-button {
    margin-top: 15px;
  }
}

button,
input,
select {
  font: inherit;
}

button,
label,
input[type="range"],
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 56px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.course-home-link {
  display: inline-flex;
  min-height: 36px;
  padding: 7px 11px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(14, 27, 44, 0.58);
  font-size: 0.75rem;
  font-weight: 720;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.course-home-link:hover,
.course-home-link:focus-visible {
  border-color: rgba(100, 217, 220, 0.58);
  color: var(--cyan);
  background: rgba(14, 38, 50, 0.86);
  outline: none;
}

/* Bare glyph over the picture, like the toggles opposite it: the disc and blur
   covered a chunk of frame for one chevron. An SVG stroke ignores text-shadow,
   so the same two-layer shadow is applied as a drop-shadow filter. */
.stage-home-link {
  position: absolute;
  z-index: 7;
  top: 6px;
  left: 6px;
  min-height: 0;
  padding: 7px 9px;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  color: #ffffff;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 10px rgba(0, 0, 0, 0.7));
}

.stage-home-icon {
  width: 22px;
  height: 22px;
}

.stage-home-link:hover {
  color: #ffffff;
  background: none;
}

.stage-home-link:focus-visible {
  background: none;
  outline: 2px solid rgba(143, 244, 239, 0.9);
  outline-offset: 1px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(14, 27, 44, 0.78);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 760;
}

.admin-link[hidden] {
  display: none;
}

.admin-link:hover,
.admin-link:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 760;
  letter-spacing: -0.04em;
}

.player-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #050e18;
  box-shadow: var(--shadow);
}

.sentence-library {
  display: none;
}

.sentence-sidebar-toggle {
  display: none;
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(29, 69, 91, 0.2), transparent 34%),
    #02070c;
}

/* Top-right, so the controls never sit on the subtitle line. They are drawn as
   bare labels with a shadow rather than chips: less ink over the picture, and
   the tap area stays comfortable through padding that costs nothing visually. */
.media-toggle-group {
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.media-overlay-toggle {
  display: grid;
  padding: 7px 8px;
  align-items: center;
  justify-items: center;
  border: 0;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  /* Two shadows: a tight one for edge definition on light picture, a wider
     halo so the glyph still separates from a busy cartoon background. */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  transition: color 140ms ease;
}

.media-overlay-toggle:hover {
  color: #fff;
}

.media-overlay-toggle:focus-visible {
  outline: 2px solid rgba(143, 244, 239, 0.9);
  outline-offset: 1px;
}

/* Language shown: full white. Hidden: dimmed, but still legible enough to find. */
.media-overlay-toggle[aria-pressed="true"] {
  color: #fff;
}

.playback-mode-toggle {
  color: #a9f0ea;
}

.playback-mode-toggle[data-playback-mode="watch"] {
  color: #a8efc9;
}

.playback-mode-toggle:hover {
  color: #e6fffb;
}

.playback-mode-label,
.video-toggle-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.language-toggle-label {
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  line-height: 1;
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  transition: opacity 180ms ease;
}

.stage.audio-only video {
  opacity: 0;
  pointer-events: none;
}

.audio-visual {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background:
    radial-gradient(circle, rgba(100, 217, 220, 0.13), transparent 22%),
    linear-gradient(140deg, #0b1a2b, #07101d 62%, #101627);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.stage.audio-only .audio-visual {
  opacity: 1;
}

.sound-orbit {
  position: relative;
  width: 118px;
  height: 118px;
  margin-bottom: 38px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 60px rgba(255, 116, 85, 0.26);
}

.voice-wave-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.voice-wave-icon i {
  display: block;
  width: 6px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.22);
  animation: voice-wave 1.05s ease-in-out infinite alternate;
}

.voice-wave-icon i:nth-child(2),
.voice-wave-icon i:nth-child(4) {
  height: 38px;
  animation-delay: -0.22s;
}

.voice-wave-icon i:nth-child(3) {
  height: 54px;
  animation-delay: -0.44s;
}

.voice-wave-icon i:nth-child(5) {
  animation-delay: -0.66s;
}

.sound-orbit span {
  position: absolute;
  inset: -16px;
  border: 1px solid rgba(100, 217, 220, 0.34);
  border-radius: 50%;
  animation: orbit 2.4s ease-out infinite;
}

.sound-orbit span:nth-child(2) {
  animation-delay: 0.8s;
}

.sound-orbit span:nth-child(3) {
  animation-delay: 1.6s;
}

.audio-visual p {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

@keyframes orbit {
  from { opacity: 0.8; transform: scale(0.78); }
  to { opacity: 0; transform: scale(1.5); }
}

@keyframes voice-wave {
  from { transform: scaleY(0.5); opacity: 0.72; }
  to { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.caption-wrap {
  /* Film and broadcast subtitles use an outline rather than a drop shadow: a
     shadow only guards the side it is offset toward, an outline guards the
     glyph from every direction. Eight hard offsets compose one, which is the
     portable way to do it — -webkit-text-stroke paints centred and eats into
     the letterform, which closes up dense CJK strokes. Kept at 1px for the
     same reason. The last, softer shadow adds depth over mid-tone frames. */
  --caption-outline:
    1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000,
    1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000,
    0 2px 6px rgba(0, 0, 0, 0.85);

  position: absolute;
  z-index: 6;
  right: 14%;
  /* Sized off the picture (see syncStageMetrics), not the viewport: a fixed
     offset sat 20% up the frame on a phone and 7% on a desktop. */
  bottom: clamp(10px, calc(var(--stage-height, 200px) * 0.065), 56px);
  left: 14%;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

/* Portrait dock for the beat map, under the study row. Empty and hidden
   everywhere else, so it costs nothing outside portrait. */
.beat-dock {
  display: none;
}

.caption-wrap p {
  min-height: 1.4em;
  margin: 0;
  padding: 2px 6px 3px;
  border-radius: 5px;
  color: #fff;
  background: none;
  /* Same idea for the type: a share of the picture width, floored so it stays
     readable on a phone and capped so it does not shout on a desktop. */
  font-size: clamp(0.94rem, calc(var(--stage-width, 100vw) * 0.04), 1.62rem);
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  text-shadow: var(--caption-outline);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.caption-wrap p.visible {
  opacity: 1;
  transform: translateY(0);
}

.caption-wrap p.is-teaching {
  display: grid;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  gap: 5px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  text-shadow: none;
}

.caption-wrap p.is-source-translation {
  padding: 0;
}

.caption-wrap p.is-source-translation .teaching-caption-translation {
  font-size: 1em;
}

.caption-wrap p.is-watch-caption {
  display: grid;
  width: fit-content;
  max-width: 100%;
  gap: 3px;
  padding: 9px 16px 10px;
  text-align: center;
}

.watch-caption-english {
  color: #fff;
  font-size: 1.06em;
  font-weight: 800;
  line-height: 1.3;
}

.watch-caption-chinese {
  color: #eafffb;
  font-size: 0.84em;
  font-weight: 700;
  line-height: 1.35;
}

.teaching-caption-ipa {
  color: #fff;
  font-family: "Charis SIL", "Doulos SIL", Georgia, serif;
  font-size: 1.18em;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.teaching-caption-sound-map {
  display: grid;
  width: fit-content;
  max-width: min(720px, 86vw);
  min-width: 0;
  justify-self: center;
}

.teaching-caption-beats {
  display: grid;
  /* fitTeachingBeatLayout reads the track ceiling to work out how many beats
     fit on one line, so it has to stay a custom property. */
  --teaching-beat-track-max: 72px;
  grid-template-columns: repeat(
    var(--teaching-beat-columns, 1),
    minmax(42px, var(--teaching-beat-track-max))
  );
  justify-content: center;
  gap: 5px;
}

.teaching-caption-beat {
  position: relative;
  display: grid;
  min-width: 0;
  /* The caption overlay is click-through; the beats are the exception. */
  pointer-events: auto;
  padding: 0;
  cursor: pointer;
  font: inherit;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  color: #fff;
  background: rgba(8, 30, 40, 0.86);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.18);
  text-shadow: none;
  /* Beats last around 250ms, so the old symmetric 120ms ramp meant a tile was
     mid-transition for half its life and never looked settled. This duration is
     the decay, used when a beat stops being current; the attack is overridden
     to near-instant on .is-active below, which is what gives it a downbeat. */
  transition:
    border-color 220ms ease-out,
    background 220ms ease-out,
    box-shadow 220ms ease-out,
    transform 220ms ease-out,
    opacity 220ms ease-out;
}

.teaching-caption-beat-number {
  padding: 3px 6px;
  color: #bcefe8;
  background: rgba(255, 255, 255, 0.08);
  font-family: Inter, "Noto Sans SC", sans-serif;
  font-size: 0.55em;
  font-weight: 820;
  line-height: 1;
}

.teaching-caption-beat-sound {
  display: flex;
  min-height: 36px;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding: 5px 7px 7px;
  overflow-wrap: anywhere;
  font-size: clamp(0.88em, 2vw, 1.12em);
  line-height: 1.05;
}

/* The tile keeps its grid width. When a beat's IPA is wider than the tile,
   only the type shrinks, driven by --teaching-beat-font-scale. The glyph run
   must keep its natural width while it is measured, so it never shrinks. */
.teaching-caption-beat-glyphs {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: calc(1em * var(--teaching-beat-font-scale, 1));
}

/* Still too wide at the floor: fall back to the previous wrapping behaviour
   for that one beat instead of shrinking the type past legibility. */
.teaching-caption-beat[data-beat-fit="wrap"] .teaching-caption-beat-glyphs {
  flex: 0 1 auto;
  white-space: normal;
}

.teaching-caption-beat:hover {
  border-color: rgba(94, 234, 212, 0.7);
}

.teaching-caption-beat:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 2px;
}

.teaching-caption-beat:active {
  transform: translateY(1px);
}

.teaching-caption-beat.is-past {
  opacity: 0.62;
}

.teaching-caption-beat.is-active {
  z-index: 1;
  border-color: #5eead4;
  background: rgba(13, 83, 86, 0.96);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.28), 0 10px 22px rgba(0, 0, 0, 0.3);
  /* A 2px lift was invisible at this size; the lift plus a small scale reads as
     a hit even on the shortest beats. */
  transform: translateY(-3px) scale(1.05);
  transition-duration: 45ms;
}

.teaching-caption-beat.is-active .teaching-caption-beat-number {
  color: #062f32;
  background: #5eead4;
}

/* Docked under the study row, the beats sit on a dark panel rather than on a
   bright picture. The translucent fill and drop shadow that kept them readable
   over video composite to #081C27 on the #09111D dock — near-invisible, with
   only the border holding the shape. On a panel the tile becomes a solid,
   lighter surface instead, so the fill does the separating. */
#beatDock .teaching-caption-beat {
  border-color: rgba(255, 255, 255, 0.09);
  background: #16242f;
  box-shadow: none;
}

#beatDock .teaching-caption-beat:hover {
  border-color: rgba(94, 234, 212, 0.7);
}

#beatDock .teaching-caption-beat.is-active {
  border-color: #5eead4;
  background: #0d5356;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.26);
}

#beatDock .teaching-caption-beat-number {
  color: #a9ded8;
  background: rgba(255, 255, 255, 0.05);
}

#beatDock .teaching-caption-beat.is-active .teaching-caption-beat-number {
  color: #062f32;
  background: #5eead4;
}

/* The global reduce block already flattens durations; drop the movement too and
   let colour alone carry the beat. */
@media (prefers-reduced-motion: reduce) {
  .teaching-caption-beat.is-active {
    transform: none;
  }
}

.teaching-caption-beat-empty {
  color: rgba(255, 255, 255, 0.78);
  font-family: Inter, "Noto Sans SC", sans-serif;
  font-size: 0.74em;
  font-weight: 650;
}

.teaching-caption-translation {
  width: fit-content;
  max-width: min(620px, 82vw);
  justify-self: center;
  padding: 2px 6px 3px;
  color: #ffffff;
  font-size: 0.86em;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: var(--caption-outline);
}

@media (max-width: 540px) {
  .caption-wrap {
    right: 8%;
    left: 8%;
  }

  .caption-wrap p.is-teaching {
    padding: 0;
  }

  .teaching-caption-sound-map {
    max-width: 84vw;
  }

  .teaching-caption-beats {
    --teaching-beat-track-max: 58px;
    grid-template-columns: repeat(
      var(--teaching-beat-columns, 1),
      minmax(34px, var(--teaching-beat-track-max))
    );
    gap: 4px;
  }

  .teaching-caption-beat-sound {
    min-height: 31px;
    padding-inline: 4px;
    font-size: 0.84em;
  }
}

.caption-wrap.hidden {
  display: none;
}

.stage-play {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: transparent;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  opacity: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.stage-play::before,
.stage-play::after {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  content: "";
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
}

.stage-play::before {
  width: clamp(64px, 7vw, 82px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(5, 13, 25, 0.82);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34), 0 0 0 8px rgba(5, 13, 25, 0.12);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(5px);
}

.stage-play::after {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #fff;
  transform: translate(-50%, -50%);
}

.stage.has-started .stage-play::before,
.stage.has-started .stage-play::after {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.88);
}

.stage-play:focus-visible {
  outline: 2px solid rgba(99, 230, 167, 0.78);
  outline-offset: -3px;
}

.transport {
  padding: 15px 18px 17px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: #09111d;
}

/* Watch mode is for following the episode, not drilling it, so the block row
   and the sentence/teaching buttons come off. The sidebar is deliberately left
   alone — the learner collapses it themselves with its handle. */
body[data-playback-mode="watch"] .transport {
  display: none;
}

.timeline-row {
  display: grid;
  grid-template-columns: 44px minmax(140px, 1fr) 44px auto;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
}

.timeline-row[hidden] {
  display: none;
}

.timeline-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.timeline,
.volume {
  height: 4px;
  margin: 0;
  border-radius: 999px;
  outline: none;
  background: linear-gradient(to right, var(--accent) 0 var(--progress, 0%), #344254 var(--progress, 0%) 100%);
  cursor: pointer;
  appearance: none;
}

.timeline::-webkit-slider-thumb,
.volume::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  appearance: none;
}

.timeline::-moz-range-thumb,
.volume::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
}

.study-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-top: 13px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sentence-context {
  min-width: 0;
}

.sentence-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.65rem;
}

.study-kicker {
  color: var(--cyan);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sentence-counter-control {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.sentence-counter-control[hidden] {
  display: none;
}

.sentence-counter-button {
  display: inline-flex;
  width: 35px;
  min-height: 25px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 0;
  border-bottom: 1px dashed rgba(145, 164, 188, 0.48);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  cursor: text;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.sentence-counter-button:hover,
.sentence-counter-button:focus-visible {
  border-bottom-color: rgba(100, 217, 220, 0.9);
  color: #e8ffff;
  background: rgba(100, 217, 220, 0.09);
  outline: none;
}

.sentence-counter-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.sentence-counter-input {
  width: 35px;
  height: 25px;
  box-sizing: border-box;
  padding: 0 4px;
  border: 1px solid rgba(100, 217, 220, 0.72);
  border-radius: 6px;
  color: #fff;
  background: #102236;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  outline: none;
  appearance: textfield;
}

.sentence-counter-button[hidden],
.sentence-counter-input[hidden] {
  display: none;
}

.sentence-counter-input:focus {
  box-shadow: 0 0 0 2px rgba(100, 217, 220, 0.16);
}

.sentence-counter-input::-webkit-inner-spin-button,
.sentence-counter-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.study-actions {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}

.study-controls-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.study-controls-row > .study-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sentence-arrow-button {
  width: 36px;
  min-width: 36px;
  padding-inline: 0;
  font-size: 1rem;
}

.track-select-control {
  position: relative;
  display: block;
  flex: 0 0 auto;
}

.track-select-control::after {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: #91a4bc;
  content: "";
  pointer-events: none;
  transform: rotate(45deg);
}

.track-select {
  min-width: 106px;
  height: 32px;
  padding: 0 31px 0 12px;
  border: 1px solid rgba(100, 217, 220, 0.38);
  border-radius: 7px;
  color: #d9ffff;
  background: #0d1928;
  font-size: 0.72rem;
  font-weight: 680;
  cursor: pointer;
  appearance: none;
}

.track-select:hover,
.track-select:focus-visible {
  border-color: rgba(100, 217, 220, 0.75);
  color: #fff;
  background: #14253a;
  outline: none;
}

.track-select:focus-visible {
  box-shadow: 0 0 0 2px rgba(100, 217, 220, 0.16);
}

.track-select option {
  color: #f5f8fc;
  background: #0d1928;
}

.study-button {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #c5d2e2;
  background: #0d1928;
  font-size: 0.72rem;
  font-weight: 680;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.next-sentence-button {
  margin-left: auto;
}

.study-button:hover,
.study-button:focus-visible {
  border-color: rgba(100, 217, 220, 0.55);
  color: #fff;
  background: #14253a;
  outline: none;
}

.study-button:disabled {
  color: #536277;
  background: rgba(13, 25, 40, 0.55);
  cursor: not-allowed;
}

/* fitStudyControls scaled the row down to fit, so there is nothing left to
   scroll to and the untransformed layout box must not create one. */
.chunk-list[data-fitted="scaled"] {
  min-height: 0;
  overflow-x: hidden;
}

.chunk-list {
  display: flex;
  min-width: 0;
  min-height: 42px;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-color: rgba(100, 217, 220, 0.35) transparent;
  scrollbar-width: thin;
}

.secondary-teaching-row {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 37px;
  box-sizing: border-box;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  border: 1px solid rgba(152, 170, 211, 0.16);
  border-radius: 8px;
  background: rgba(16, 30, 48, 0.78);
  overflow-x: auto;
  scrollbar-color: rgba(100, 217, 220, 0.35) transparent;
  scrollbar-width: thin;
}

.secondary-teaching-row[hidden] {
  display: none;
}

.secondary-teaching-button {
  position: relative;
  height: 27px;
  cursor: pointer;
  font-weight: 760;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.secondary-teaching-label {
  padding: 0 4px;
  color: #a99bd5;
  font-size: 0.58rem;
  font-weight: 780;
  letter-spacing: 0.08em;
}

.secondary-teaching-token {
  min-width: 42px;
  padding: 0 6px;
  border: 1px solid rgba(164, 137, 230, 0.42);
  border-radius: 6px;
  color: #d9cef8;
  background: rgba(113, 82, 171, 0.13);
  cursor: pointer;
  font-size: 0.58rem;
  font-weight: 760;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.secondary-teaching-token:hover,
.secondary-teaching-token:focus-visible {
  border-color: rgba(193, 172, 255, 0.84);
  color: #fff;
  background: rgba(125, 91, 190, 0.25);
  outline: none;
}

.secondary-teaching-token[aria-pressed="true"] {
  border-color: #b99cff;
  color: #fff;
  background: rgba(145, 105, 224, 0.34);
  box-shadow: inset 0 -2px 0 #b99cff;
}

.secondary-teaching-parent {
  border-color: rgba(193, 172, 255, 0.78);
  color: #fff;
  background: rgba(125, 91, 190, 0.26);
}

.secondary-teaching-token.is-missing-recording {
  border-style: dashed;
  color: rgba(220, 225, 238, 0.62);
  background: rgba(100, 110, 135, 0.12);
}

.secondary-teaching-token.is-missing-recording::before {
  margin-right: 3px;
  content: "○";
  font-size: 0.52rem;
}

.secondary-teaching-sentence {
  min-width: 70px;
  border-color: rgba(255, 112, 92, 0.8);
  color: #fff2ed;
  background: rgba(217, 78, 55, 0.22);
}

.secondary-teaching-token.learning-group-color-0 {
  border-color: rgba(91, 211, 190, 0.66);
  color: #dffff8;
  background: rgba(52, 178, 151, 0.16);
}

.secondary-teaching-token.learning-group-color-1 {
  border-color: rgba(105, 169, 235, 0.68);
  color: #e3f1ff;
  background: rgba(66, 132, 210, 0.17);
}

.secondary-teaching-token.learning-group-color-2 {
  border-color: rgba(236, 174, 87, 0.7);
  color: #fff1d8;
  background: rgba(218, 139, 51, 0.17);
}

.secondary-teaching-token.learning-group-color-3 {
  border-color: rgba(179, 135, 230, 0.7);
  color: #f3e8ff;
  background: rgba(136, 87, 196, 0.18);
}

.secondary-teaching-parent.learning-group-color-0 {
  background: rgba(52, 178, 151, 0.28);
}

.secondary-teaching-parent.learning-group-color-1 {
  background: rgba(66, 132, 210, 0.29);
}

.secondary-teaching-parent.learning-group-color-2 {
  background: rgba(218, 139, 51, 0.29);
}

.secondary-teaching-parent.learning-group-color-3 {
  background: rgba(136, 87, 196, 0.3);
}

.secondary-teaching-token.learning-group-color-0[aria-pressed="true"] {
  background: rgba(52, 178, 151, 0.34);
  box-shadow: inset 0 -2px 0 #5bd3be;
}

.secondary-teaching-token.learning-group-color-1[aria-pressed="true"] {
  background: rgba(66, 132, 210, 0.36);
  box-shadow: inset 0 -2px 0 #69a9eb;
}

.secondary-teaching-token.learning-group-color-2[aria-pressed="true"] {
  background: rgba(218, 139, 51, 0.35);
  box-shadow: inset 0 -2px 0 #ecae57;
}

.secondary-teaching-token.learning-group-color-3[aria-pressed="true"] {
  background: rgba(136, 87, 196, 0.36);
  box-shadow: inset 0 -2px 0 #b387e6;
}

.secondary-teaching-sentence[aria-pressed="true"] {
  border-color: #ff806b;
  background: rgba(217, 78, 55, 0.38);
  box-shadow: inset 0 -2px 0 #ff806b;
}

.secondary-teaching-token[class*="learning-group-color-"]:hover,
.secondary-teaching-token[class*="learning-group-color-"]:focus-visible,
.secondary-teaching-sentence:hover,
.secondary-teaching-sentence:focus-visible {
  filter: brightness(1.22);
}

.secondary-teaching-button.is-playing::after {
  position: absolute;
  right: 5px;
  bottom: 3px;
  left: 5px;
  height: 2px;
  border-radius: 999px;
  background: var(--cyan);
  content: "";
}

.chunk-mode-actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 7px;
  margin-left: 8px;
}

.chunk-mode-actions::before {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: -9px;
  width: 1px;
  background: rgba(173, 198, 226, 0.2);
  content: "";
}

.chunk-list > .chunk-mode-actions:first-child {
  margin-left: 0;
}

.chunk-list > .chunk-mode-actions:first-child::before {
  display: none;
}

.chunk-token {
  position: relative;
  min-width: 42px;
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid rgba(173, 198, 226, 0.22);
  border-radius: 8px;
  color: #d9e4f1;
  background: #101e30;
  font-size: 0.8rem;
  font-weight: 720;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.chunk-token:hover,
.chunk-token:focus-visible {
  border-color: rgba(100, 217, 220, 0.72);
  color: #fff;
  background: #172a40;
  outline: none;
  transform: translateY(-1px);
}

.chunk-token[aria-pressed="true"] {
  border-color: var(--accent);
  color: #fff;
  background: rgba(255, 116, 85, 0.16);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.chunk-list[data-range-gesture="dragging"] {
  cursor: ew-resize;
  user-select: none;
}

.sound-chunk-token.is-range-preview,
.sound-group-token.is-range-preview {
  border-color: rgba(100, 217, 220, 0.9);
  color: #fff;
  background: rgba(100, 217, 220, 0.16);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.sound-chunk-token.is-range-selected,
.sound-group-token.is-range-selected {
  border-color: rgba(100, 217, 220, 0.88);
  color: #fff;
  background: linear-gradient(180deg, rgba(100, 217, 220, 0.22), rgba(51, 184, 169, 0.14));
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.sound-chunk-token.is-range-start,
.sound-group-token.is-range-start {
  border-left-color: #8af7de;
  box-shadow: inset 3px 0 0 rgba(138, 247, 222, 0.85), inset 0 -2px 0 var(--cyan);
}

.sound-chunk-token.is-range-end,
.sound-group-token.is-range-end {
  border-right-color: #8af7de;
  box-shadow: inset -3px 0 0 rgba(138, 247, 222, 0.85), inset 0 -2px 0 var(--cyan);
}

.sound-chunk-token.is-range-start.is-range-end,
.sound-group-token.is-range-start.is-range-end {
  box-shadow: inset 0 0 0 2px rgba(138, 247, 222, 0.75);
}

.chunk-token.is-playing::after {
  position: absolute;
  right: 6px;
  bottom: 4px;
  left: 6px;
  height: 2px;
  border-radius: 999px;
  background: var(--cyan);
  content: "";
}

.study-mode-switch {
  position: relative;
  display: inline-flex;
  width: 76px;
  min-width: 76px;
  height: 38px;
  box-sizing: border-box;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(173, 198, 226, 0.24);
  border-radius: 9px;
  background: #0b1624;
  box-shadow: inset 0 0 0 1px rgba(3, 11, 20, 0.32);
}

.study-mode-switch::after {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 50%;
  width: 1px;
  background: rgba(173, 198, 226, 0.16);
  content: "";
  pointer-events: none;
  transform: translateX(-0.5px);
}

.study-mode-token {
  position: relative;
  z-index: 1;
  width: 33px;
  min-width: 33px;
  min-height: 30px;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #b4c3d3;
  background: transparent;
  box-shadow: none;
  font-size: 0.78rem;
}

.study-mode-token:hover,
.study-mode-token:focus-visible {
  color: #e8ffff;
  transform: none;
}

.study-mode-source-token:not([aria-pressed="true"]):hover,
.study-mode-source-token:not([aria-pressed="true"]):focus-visible {
  background: rgba(100, 217, 220, 0.11);
}

.study-mode-teaching-token:not([aria-pressed="true"]):hover,
.study-mode-teaching-token:not([aria-pressed="true"]):focus-visible {
  background: rgba(111, 232, 189, 0.11);
}

.study-mode-source-token[aria-pressed="true"] {
  color: #f5ffff;
  background: rgba(58, 179, 190, 0.32);
  box-shadow: inset 0 0 0 1px rgba(100, 217, 220, 0.68), 0 2px 8px rgba(0, 0, 0, 0.18);
}

.study-mode-teaching-token[aria-pressed="true"] {
  color: #fff;
  background: rgba(48, 177, 133, 0.35);
  box-shadow: inset 0 0 0 1px rgba(111, 232, 189, 0.72), 0 2px 8px rgba(0, 0, 0, 0.18);
}

.whole-sentence-token {
  min-width: 68px;
}

.phrase-group-list {
  display: flex;
  min-width: 0;
  flex: 0 1 auto;
  align-items: center;
  gap: 5px;
}

.phrase-group-token {
  min-width: calc(42px + (var(--phrase-span, 1) - 1) * 16px);
}

.phrase-group-token,
.whole-sentence-token {
  border-color: rgba(126, 163, 192, 0.42);
  color: #dbeaf4;
  background: rgba(20, 47, 66, 0.78);
}

.teaching-action-token {
  min-width: 72px;
  border-color: rgba(255, 151, 112, 0.88);
  color: #fff8f3;
  background: linear-gradient(180deg, rgba(255, 116, 85, 0.58), rgba(179, 69, 48, 0.48));
  box-shadow: 0 5px 16px rgba(255, 99, 68, 0.16), inset 0 0 0 1px rgba(255, 235, 226, 0.12);
}

.teaching-action-token:hover,
.teaching-action-token:focus-visible,
.teaching-action-token[aria-pressed="true"] {
  border-color: #ffb18e;
  color: #fff;
  background: linear-gradient(180deg, #ff8162, #d95338);
  box-shadow: 0 7px 20px rgba(255, 99, 68, 0.28), inset 0 -2px 0 #ffd2c0;
}

.teaching-action-token:disabled,
.teaching-action-token.is-missing-recording {
  border-style: dashed;
  border-color: rgba(157, 178, 194, 0.28);
  color: rgba(184, 201, 214, 0.48);
  background: rgba(29, 45, 59, 0.56);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.quiz-action-token {
  min-width: 66px;
  margin-left: 3px;
  border-color: rgba(232, 196, 123, 0.5);
  color: #f1d7a1;
  background: rgba(108, 79, 31, 0.22);
}

.quiz-action-token:hover,
.quiz-action-token:focus-visible,
.quiz-action-token[aria-expanded="true"] {
  border-color: #f1ce85;
  color: #fff1cc;
  background: rgba(149, 108, 40, 0.4);
}

.quiz-action-token:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quiz-prompt[hidden] {
  display: none;
}

.quiz-prompt {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 13, 21, 0.32);
  backdrop-filter: blur(2px);
}

.quiz-prompt-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(420px, 100%);
  max-height: 100%;
  overflow: hidden;
  padding: 26px 28px 24px;
  border: 1px solid rgba(190, 224, 225, 0.2);
  border-radius: 20px;
  background: linear-gradient(155deg, #18333b, #10232b);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.quiz-prompt-heading {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 32px;
  padding-right: 44px;
  font-size: 0.75rem;
}

.quiz-prompt-scope {
  position: relative;
  min-width: 0;
  max-width: 100%;
  color: #a6bcc3;
  font-weight: 400;
  letter-spacing: 0;
}

.quiz-prompt-scope::after {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.quiz-scope-select {
  max-width: 100%;
  min-height: 32px;
  padding: 4px 23px 4px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  appearance: none;
  color: inherit;
  background: transparent;
  font: inherit;
  text-overflow: ellipsis;
  cursor: pointer;
}

.quiz-scope-select:hover,
.quiz-scope-select:focus-visible {
  border-color: rgba(190, 224, 225, 0.3);
  color: #f1f8f8;
  background: rgba(190, 224, 225, 0.08);
}

.quiz-scope-select:focus-visible {
  outline: 2px solid #e5c98f;
  outline-offset: 2px;
}

.quiz-scope-select option {
  color: #f1f8f8;
  background: #10232b;
}

.quiz-prompt-close {
  position: absolute;
  top: 20px;
  right: 22px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #a8bdc5;
  background: transparent;
  cursor: pointer;
  font-size: 1.3rem;
}

.quiz-prompt-close:hover,
.quiz-prompt-close:focus-visible {
  color: #fff1cc;
  background: rgba(241, 206, 133, 0.12);
}

.quiz-prompt-body {
  min-height: 0;
  margin: 22px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #53757e transparent;
}

.quiz-prompt-cue {
  margin: 0;
  padding: 3px 0;
  color: #f1f8f8;
  font-size: clamp(1.625rem, 3vw, 2.25rem);
  font-weight: 750;
  line-height: 1.45;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.quiz-prompt-hint[hidden] {
  display: none;
}

.quiz-prompt-hint {
  margin: 0;
  color: #a6bcc3;
  font-size: 0.75rem;
  line-height: 1.65;
  text-wrap: balance;
}

.quiz-prompt-footer {
  display: grid;
  gap: 10px;
}

.quiz-prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-icon-button,
.quiz-next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #acc4ca;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.quiz-icon-button {
  width: 40px;
  height: 40px;
}

.quiz-listen-button {
  width: 36px;
  min-height: 36px;
  height: 36px;
  margin-left: 6px;
  vertical-align: middle;
  transform: translateY(-3px);
}

.quiz-icon-button svg,
.quiz-next-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quiz-icon-button:hover,
.quiz-icon-button:focus-visible,
.quiz-icon-button.is-playing {
  color: #d8fffb;
  border-color: #5eb9b3;
  background: rgba(94, 185, 179, 0.1);
}

.quiz-icon-button[aria-busy="true"] {
  color: #e5c98f;
  border-color: rgba(229, 201, 143, 0.5);
  border-style: dashed;
}

.quiz-icon-button[aria-pressed="true"] {
  color: #e5c98f;
  border-color: rgba(229, 201, 143, 0.5);
}

.quiz-icon-button[aria-pressed="true"] svg {
  fill: rgba(229, 201, 143, 0.22);
}

.quiz-next-button {
  padding: 8px 16px;
  color: #dffffa;
  border-color: #458d87;
  background: #23635f;
  font-weight: 650;
}

.quiz-next-button:hover,
.quiz-next-button:focus-visible {
  background: #2c7972;
  border-color: #73d9ce;
}

.quiz-icon-button:focus-visible,
.quiz-next-button:focus-visible {
  outline: 2px solid #e5c98f;
  outline-offset: 2px;
}

.quiz-icon-button:disabled,
.quiz-next-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .quiz-prompt {
    padding: 12px;
  }

  .quiz-prompt-card {
    padding: 12px 20px;
    border-radius: 16px;
  }

  .quiz-prompt-close {
    top: 6px;
    right: 14px;
  }

  .quiz-prompt-body {
    margin: 12px 0;
  }

  .quiz-prompt-footer {
    gap: 6px;
  }
}

@media (max-width: 360px) {
  .quiz-prompt-card {
    padding: 8px 14px;
  }

  .quiz-prompt-close {
    top: 2px;
    right: 8px;
  }

  .quiz-scope-select {
    min-height: 28px;
  }

  .quiz-prompt-body {
    margin: 8px 0;
  }

  .quiz-prompt-cue {
    line-height: 1.35;
  }

  .quiz-prompt-footer {
    gap: 4px;
  }

  .quiz-prompt-hint {
    font-size: 0.6875rem;
    line-height: 1.4;
  }

}

.phrase-group-token[aria-pressed="true"],
.whole-sentence-token[aria-pressed="true"] {
  border-color: #66e0d7;
  color: #fff;
  background: linear-gradient(180deg, rgba(57, 183, 175, 0.38), rgba(30, 116, 118, 0.32));
  box-shadow: inset 0 0 0 1px rgba(225, 255, 251, 0.58), inset 0 -3px 0 #66e0d7;
}

.phrase-group-token.is-learning-context,
.whole-sentence-token.is-learning-context {
  color: #fff;
  background: linear-gradient(180deg, rgba(57, 183, 175, 0.38), rgba(30, 116, 118, 0.32));
  box-shadow: inset 0 0 0 1px rgba(225, 255, 251, 0.58), inset 0 -3px 0 #66e0d7;
}

.phrase-group-token.is-unconfigured {
  border-style: dashed;
  filter: saturate(0.45);
}

.phrase-group-token.is-missing-recording,
.whole-sentence-token.is-missing-recording {
  border-style: dashed;
}

.scope-mode-sentence-token[aria-pressed="true"] {
  color: #fff;
  background: rgba(89, 147, 213, 0.38);
  box-shadow: inset 0 0 0 1px rgba(128, 190, 255, 0.7), 0 2px 8px rgba(0, 0, 0, 0.18);
}

.scope-mode-chunk-token[aria-pressed="true"] {
  color: #fff;
  background: rgba(198, 132, 58, 0.4);
  box-shadow: inset 0 0 0 1px rgba(245, 184, 102, 0.72), 0 2px 8px rgba(0, 0, 0, 0.18);
}

.chunk-empty {
  flex: 0 0 auto;
  color: #6f839c;
  font-size: 0.7rem;
}

.icon-button,
.text-button {
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 800;
}

.icon-button:hover,
.icon-button:focus-visible,
.text-button:hover,
.text-button:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.text-button {
  min-width: 42px;
  height: 30px;
  padding: 0 7px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
}

.volume {
  width: 76px;
  --progress: 85%;
}

.speed {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #0d1928;
  font-size: 0.72rem;
  cursor: pointer;
  outline: none;
}

.error-message {
  display: none;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  color: #ffd1c7;
  background: var(--accent-soft);
  font-size: 0.8rem;
}

.error-message.visible {
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .topbar {
    align-items: center;
  }

  .player-card {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .transport {
    padding: 12px;
    border-top-color: rgba(100, 217, 220, 0.14);
    background: linear-gradient(180deg, #071521, #081725);
  }

  .timeline-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 8px;
  }

  .timeline-tools {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin: 4px 0 0;
  }

  .study-row {
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
  }

  .sentence-context,
  #previousSentence,
  #nextSentence {
    display: none !important;
  }

  .study-controls-row {
    display: block;
  }

  .chunk-list {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 2px 0;
  }

  .secondary-teaching-row {
    margin-top: 6px;
  }

  .sentence-library {
    display: block;
    border-top: 1px solid rgba(100, 217, 220, 0.14);
    background: #091824;
  }

  .sentence-list {
    max-height: min(52vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(100, 217, 220, 0.38) transparent;
    scrollbar-width: thin;
  }

  .sentence-list-item {
    position: relative;
    display: grid;
    width: 100%;
    min-height: 84px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    box-sizing: border-box;
    align-items: start;
    padding: 15px 16px 14px;
    border: 0;
    border-bottom: 1px solid rgba(143, 177, 204, 0.09);
    color: #eaf5ff;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: color 140ms ease, background 140ms ease;
  }

  .sentence-list-item:last-child {
    border-bottom: 0;
  }

  .sentence-list-item:hover,
  .sentence-list-item:focus-visible {
    background: rgba(20, 55, 77, 0.62);
    outline: none;
  }

  .sentence-list-item[data-selected="true"] {
    color: #efffff;
    background: linear-gradient(90deg, rgba(55, 201, 194, 0.18), rgba(21, 70, 88, 0.14));
  }

  .sentence-list-item[data-selected="true"]::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: #61e7d8;
    content: "";
  }

  .sentence-list-number {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    margin-top: 1px;
    border-radius: 9px;
    color: #91aabb;
    background: rgba(22, 48, 67, 0.82);
    font-size: 0.7rem;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
  }

  .sentence-list-item[data-selected="true"] .sentence-list-number {
    color: #05262c;
    background: #61e7d8;
  }

  .sentence-list-copy {
    display: block;
    min-width: 0;
  }

  .sentence-list-english,
  .sentence-list-chinese {
    display: block;
    overflow-wrap: anywhere;
    transition: filter 160ms ease, opacity 160ms ease;
  }

  .sentence-list-english {
    color: inherit;
    font-size: 0.96rem;
    font-weight: 800;
    line-height: 1.35;
  }

  .sentence-list-chinese {
    margin-top: 5px;
    color: #9fb3c3;
    font-size: 0.78rem;
    line-height: 1.4;
  }

  .sentence-list-item[data-selected="true"] .sentence-list-chinese {
    color: #b5dadd;
  }

  .study-button {
    padding-inline: 7px;
  }

}

@media (max-width: 500px) {
  .media-toggle-group {
    top: 6px;
    right: 6px;
  }

  .caption-wrap {
    right: 8%;
    left: 8%;
  }

  .study-controls-row > .study-button {
    padding-inline: 8px;
  }

  .study-controls-row {
    display: block;
  }

  .chunk-list {
    display: block;
  }

  .chunk-list > .phrase-group-list {
    width: 100%;
    overflow-x: auto;
    padding-top: 3px;
    padding-bottom: 2px;
    scrollbar-color: rgba(100, 217, 220, 0.35) transparent;
    scrollbar-width: thin;
  }

  .chunk-mode-actions {
    min-width: 0;
    width: auto;
    align-items: center;
    gap: 4px;
    justify-self: center;
    margin-left: 0;
  }

  .chunk-mode-actions .study-mode-switch {
    width: 60px;
    min-width: 60px;
    height: 34px;
    padding: 3px;
  }

  .chunk-mode-actions .study-mode-token {
    width: 25px;
    min-width: 25px;
    min-height: 26px;
  }

  .chunk-mode-actions::before {
    display: none;
  }

  .track-select {
    min-width: 94px;
    padding-left: 10px;
  }
}

/* Desktop and landscape learning workspace: video + teaching controls + sentence list. */
@media (min-width: 761px), (orientation: landscape) and (min-width: 620px) {
  html:not(.course-home-mode),
  html:not(.course-home-mode) body {
    height: 100%;
    overflow: hidden;
  }

  html:not(.course-home-mode) body {
    background: #030a12;
  }

  html:not(.course-home-mode) .app-shell {
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  html:not(.course-home-mode) .player-card {
    --sentence-sidebar-width: clamp(340px, 32vw, 520px);

    position: relative;
    display: grid;
    width: 100%;
    height: 100dvh;
    grid-template-columns: minmax(0, 1fr) var(--sentence-sidebar-width);
    /* Row 3 is the beat dock; it collapses to nothing while hidden. */
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transition: grid-template-columns 220ms ease;
  }

  html:not(.course-home-mode) .stage {
    min-width: 0;
    min-height: 0;
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: auto;
    border-right: 1px solid rgba(100, 217, 220, 0.18);
  }

  html:not(.course-home-mode) .transport {
    min-width: 0;
    grid-column: 1;
    grid-row: 2;
    padding: 12px 16px 14px;
    border-top-color: rgba(100, 217, 220, 0.15);
    border-right: 1px solid rgba(100, 217, 220, 0.18);
    background: linear-gradient(180deg, #071521, #081725);
  }

  html:not(.course-home-mode) .study-row {
    display: block;
    margin-top: 0;
    padding: 0;
    border: 0;
  }

  html:not(.course-home-mode) .sentence-context,
  html:not(.course-home-mode) #previousSentence,
  html:not(.course-home-mode) #nextSentence {
    display: none !important;
  }

  html:not(.course-home-mode) .study-controls-row {
    display: block;
  }

  html:not(.course-home-mode) .chunk-list {
    width: 100%;
    min-height: 46px;
    padding: 3px 1px;
  }

  html:not(.course-home-mode) .secondary-teaching-row {
    margin-top: 6px;
  }

  html:not(.course-home-mode) .beat-dock:not([hidden]) {
    display: flex;
    grid-column: 1;
    grid-row: 3;
    justify-content: center;
    padding: 10px 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: #09111d;
  }

  html:not(.course-home-mode) .sentence-library {
    display: flex;
    min-width: 0;
    min-height: 0;
    grid-column: 2;
    grid-row: 1 / span 3;
    overflow: hidden;
    border-left: 1px solid rgba(100, 217, 220, 0.14);
    background: #091824;
    opacity: 1;
    visibility: visible;
    transition: opacity 160ms ease, visibility 160ms ease;
  }

  html:not(.course-home-mode) .sentence-sidebar-toggle {
    position: absolute;
    z-index: 9;
    top: 0;
    right: calc(var(--sentence-sidebar-width) - 20px);
    bottom: 0;
    display: grid;
    width: 40px;
    padding: 0;
    place-items: center;
    border: 0;
    color: #d7ffff;
    background: transparent;
    cursor: pointer;
    transition: right 220ms ease;
  }

  html:not(.course-home-mode) .sentence-sidebar-toggle > span {
    display: grid;
    width: 28px;
    height: 64px;
    place-items: center;
    border: 1px solid rgba(100, 217, 220, 0.58);
    border-radius: 999px;
    color: #d7ffff;
    background: rgba(5, 31, 43, 0.9);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    transform: scale(0.86);
    transition: opacity 140ms ease, transform 140ms ease, background 140ms ease;
  }

  /* A touch screen never hovers, so the handle would stay invisible even though
     its hit area works. Show it outright there. */
  @media (hover: none) {
    html:not(.course-home-mode) .sentence-sidebar-toggle > span {
      opacity: 0.92;
      transform: scale(1);
    }
  }

  html:not(.course-home-mode) .sentence-sidebar-toggle:hover > span,
  html:not(.course-home-mode) .sentence-sidebar-toggle:focus-visible > span {
    background: rgba(13, 92, 101, 0.96);
    opacity: 1;
    transform: scale(1);
  }

  html:not(.course-home-mode) .sentence-sidebar-toggle:focus-visible {
    outline: none;
  }

  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr) 0;
  }

  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed .sentence-library {
    border-left-color: transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed .stage,
  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed .transport {
    border-right-color: transparent;
  }

  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed .sentence-sidebar-toggle {
    right: 0;
  }

  html:not(.course-home-mode) .player-card.is-sentence-sidebar-collapsed .sentence-sidebar-toggle > span {
    opacity: 0.9;
    transform: scale(0.92);
  }

  html:not(.course-home-mode) .sentence-list {
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(100, 217, 220, 0.38) transparent;
    scrollbar-width: thin;
  }

  html:not(.course-home-mode) .sentence-list-item {
    position: relative;
    display: grid;
    width: 100%;
    min-height: 82px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 11px;
    box-sizing: border-box;
    align-items: start;
    padding: 15px 18px;
    border: 0;
    border-bottom: 1px solid rgba(143, 177, 204, 0.09);
    color: #eaf5ff;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: color 140ms ease, background 140ms ease;
  }

  html:not(.course-home-mode) .sentence-list-item:last-child {
    border-bottom: 0;
  }

  html:not(.course-home-mode) .sentence-list-item:hover,
  html:not(.course-home-mode) .sentence-list-item:focus-visible {
    background: rgba(20, 55, 77, 0.62);
    outline: none;
  }

  html:not(.course-home-mode) .sentence-list-item[data-selected="true"] {
    color: #efffff;
    background: linear-gradient(90deg, rgba(55, 201, 194, 0.18), rgba(21, 70, 88, 0.14));
  }

  html:not(.course-home-mode) .sentence-list-item[data-selected="true"]::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: #61e7d8;
    content: "";
  }

  html:not(.course-home-mode) .sentence-list-number {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    margin-top: 1px;
    border-radius: 9px;
    color: #91aabb;
    background: rgba(22, 48, 67, 0.82);
    font-size: 0.7rem;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
  }

  html:not(.course-home-mode) .sentence-list-item[data-selected="true"] .sentence-list-number {
    color: #05262c;
    background: #61e7d8;
  }

  html:not(.course-home-mode) .sentence-list-copy {
    display: block;
    min-width: 0;
  }

  html:not(.course-home-mode) .sentence-list-english,
  html:not(.course-home-mode) .sentence-list-chinese {
    display: block;
    overflow-wrap: anywhere;
    transition: filter 160ms ease, opacity 160ms ease;
  }

  html:not(.course-home-mode) .sentence-list-english {
    color: inherit;
    font-size: 0.96rem;
    font-weight: 800;
    line-height: 1.35;
  }

  html:not(.course-home-mode) .sentence-list-chinese {
    margin-top: 5px;
    color: #9fb3c3;
    font-size: 0.78rem;
    line-height: 1.4;
  }

  html:not(.course-home-mode) .sentence-list-item[data-selected="true"] .sentence-list-chinese {
    color: #b5dadd;
  }
}

@media (min-width: 1180px) {
  html:not(.course-home-mode) .player-card {
    --sentence-sidebar-width: clamp(390px, 30vw, 540px);
  }
}

@media (orientation: landscape) and (min-width: 620px) and (max-height: 560px) {
  html:not(.course-home-mode) .player-card {
    --sentence-sidebar-width: clamp(300px, 34vw, 410px);
  }

  html:not(.course-home-mode) .transport {
    padding-block: 8px 10px;
  }

  html:not(.course-home-mode) .sentence-list-item {
    min-height: 68px;
    padding-block: 11px;
  }
}

/* Portrait phones: the learning regions must fill exactly one viewport. */
@media (max-width: 760px) and (orientation: portrait) {
  html:not(.course-home-mode),
  html:not(.course-home-mode) body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  html:not(.course-home-mode) .app-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  html:not(.course-home-mode) .player-card {
    display: grid;
    width: 100%;
    height: 100%;
    /* Row 3 holds the relocated captions and collapses to nothing while they
       are hidden, so the sentence list keeps the leftover height. */
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  html:not(.course-home-mode) .beat-dock:not([hidden]) {
    display: flex;
    grid-row: 3;
    justify-content: center;
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: #09111d;
  }

  html:not(.course-home-mode) .stage {
    min-height: 0;
    grid-row: 1;
  }

  html:not(.course-home-mode) .transport {
    min-height: 0;
    grid-row: 2;
  }

  html:not(.course-home-mode) .sentence-library {
    display: flex;
    min-height: 0;
    grid-row: 4;
    overflow: hidden;
  }

  html:not(.course-home-mode) .sentence-list {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
  }

  html:not(.course-home-mode) .error-message.visible {
    position: fixed;
    z-index: 20;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    margin: 0;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
  }
}

/* Keep the full-row playback hit area behind the sentence text. */
.sentence-list-item {
  isolation: isolate;
}

.sentence-list-play {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.sentence-list-play:focus-visible {
  outline: 2px solid #61e7d8;
  outline-offset: -3px;
}

.sentence-list-number,
.sentence-list-copy {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.sentence-list-language {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  min-height: 24px;
}

.sentence-list-language + .sentence-list-language {
  margin-top: 3px;
}

html .sentence-list-language .sentence-list-text {
  min-width: 0;
  margin-top: 0;
  padding-top: 2px;
}

/* Keep list positions stable when switching the global language controls. */
.sentence-list-language.is-text-hidden .sentence-list-text {
  visibility: hidden;
  user-select: none;
}
