/* Learning workspace: media keeps its ratio; captions own the remaining space. */
html:has(> body.desktop-player), html:has(> body.compact-player) { scrollbar-gutter: auto; overflow: hidden; }
html:has(> body.desktop-player) { scrollbar-gutter: stable; }
:is(.desktop-player, .compact-player) {
  --player-width: var(--site-content-width);
  --player-video-width: 760px;
  --player-gap: 12px;
  height: 100dvh;
  overflow: hidden;
}
.desktop-player { display: flex; align-items: flex-start; justify-content: center; }
.desktop-player #app {
  width: 100%; height: min(100dvh, 1080px); min-height: 0;
  display: flex; flex-direction: column; gap: 0;
  padding: 0 0 16px;
}
.desktop-player .site-header {
  width: 100%; flex: 0 0 auto;
  margin-block: 0;
}
.desktop-player .workspace {
  width: calc(100% - 2 * var(--site-content-inset)); max-width: var(--player-width); flex: 1; min-height: 0;
  margin: 0 auto; display: flex; flex-direction: column; border-radius: 20px;
}
.desktop-player .lesson-head { flex: 0 0 auto; padding: 14px 22px; }
.desktop-player .eyebrow { display: none; }
.desktop-player .lesson-title-holder { min-width: 0; width: 100%; }
.desktop-player .lesson-head h1 {
  margin: 0 0 4px; font-size: 22px; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.desktop-player .lesson-head p { font-size: var(--font-caption); line-height: 1.5; }
.desktop-player .study-layout {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 1fr);
  flex: 1; min-height: 0; overflow: hidden;
}
.desktop-player .watch-panel {
  min-height: 0; min-width: 0; padding: 12px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  overflow: hidden; background: linear-gradient(155deg, #f7f9f3, #fcfdfb);
}
.desktop-player .video-wrap {
  width: 100%; max-width: var(--player-video-width); aspect-ratio: 16 / 9;
  height: auto; min-height: 0; max-height: none; flex: 0 0 auto;
  border-radius: 12px; box-shadow: 0 6px 22px #233f2410;
}
.video-wrap video { object-fit: contain; }
.desktop-player .video-tag { display: none; }
.desktop-player .controls {
  position: static; transform: none; display: flex; flex-direction: column;
  flex: 0 0 auto; align-items: center; gap: 8px; width: 100%; margin: 0; padding: 10px 24px 12px;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; background: white; backdrop-filter: none;
}
.desktop-player .timeline { grid-area: timeline; width: 100%; height: 22px; margin: 0; gap: 12px; }
.desktop-player .tool-row {
  grid-area: tools; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%; max-width: 600px; min-height: 54px; margin: 0; gap: 0; align-items: start;
}
:is(.desktop-player, .compact-player) .tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 44px; padding: 0; gap: 4px; background: none; border-radius: 8px;
  text-decoration: none; color: var(--secondary); font-size: var(--font-caption);
}
:is(.desktop-player, .compact-player) .tool:hover { color: var(--green); background: none; }
:is(.desktop-player, .compact-player) .tool-icon { position: relative; display: grid; height: 23px; font-size: 20px; line-height: 1; }
:is(.desktop-player, .compact-player) .tool-icon svg { width: 23px; height: 23px; }
.small-a { font-size: 11px; right: -7px; bottom: 0; }
.desktop-player .transport {
  grid-area: transport; display: grid; position: static; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; min-height: 57px; width: 100%; gap: 0;
}
:is(.desktop-player, .compact-player) .transport-buttons { display: flex; align-items: center; gap: 12px; }
:is(.desktop-player, .compact-player) .transport-buttons > button { width: 40px; height: 44px; min-width: 40px; }
.desktop-player .transport-buttons { gap: 35px; }
.desktop-player .transport-buttons .play-button { width: 57px; height: 57px; min-width: 57px; background: #388f47; color: white; }
.desktop-player .position { display: block; grid-column: 3; justify-self: end; text-align: right; font-size: var(--font-caption); color: var(--muted); }
.desktop-player .tool { min-height: 48px; gap: 6px; }
.desktop-player .tool-icon { height: 26px; font-size: 21px; }
.desktop-player .tool-icon svg { width: 24px; height: 24px; }
.transport-side { display: grid; place-items: center; width: 44px; height: 44px; padding: 9px; color: var(--secondary); flex-shrink: 0; }
.transport-side svg { width: 24px; height: 24px; }
.listening-guide { container: listening-guide / size; width: 100%; max-width: var(--player-video-width); flex: 1; min-height: 0; display: grid; align-items: center; padding: 0; }
.guide-card { width: 100%; padding: 18px 20px 14px; border: 1px solid #dfe8d9; border-radius: 16px; background: linear-gradient(120deg, #ffffffdb, #f0f5eacc); box-shadow: 0 4px 18px #28452c04; }
.guide-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.guide-eyebrow { display: block; font-size: 9px; line-height: 1.5; letter-spacing: .16em; color: #85947b; }
.listening-guide h2 { margin: 4px 0 0; font-size: 16px; line-height: 1.5; font-weight: 500; color: #314d39; letter-spacing: .04em; }
.guide-spark { font-size: 28px; color: #a6ba91; line-height: 1; padding-right: 3px; }
.listening-guide ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; margin: 0; padding: 0; }
.listening-guide li { min-width: 0; padding: 0 14px; }
.listening-guide li:first-child { padding-left: 0; }
.listening-guide li:last-child { padding-right: 0; }
.listening-guide li + li { border-left: 1px solid #dfe7d8; }
.guide-number { display: inline-grid; place-items: center; width: 25px; height: 25px; margin-bottom: 8px; border-radius: 8px; background: #e6efdf; color: #5f7c50; font-size: 11px; font-variant-numeric: tabular-nums; }
.listening-guide h3 { margin: 0 0 5px; font-size: 13px; line-height: 1.5; font-weight: 500; color: #3f5740; }
.listening-guide li p { margin: 0; font-size: 12px; line-height: 1.8; color: #7b8874; }
.guide-motto { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid #e1e9db; font-size: 11px; line-height: 1.6; color: #86967c; }
.guide-motto span { color: #9caf8c; font-size: 12px; }
@container listening-guide (max-height: 260px) {
  .guide-card { padding: 14px 16px 12px; }
  .guide-heading { margin-bottom: 12px; }
  .guide-eyebrow { display: none; }
  .guide-number { margin-bottom: 5px; }
  .guide-motto { margin-top: 12px; padding-top: 10px; }
}
@container listening-guide (max-height: 215px) {
  .listening-guide li p { display: none; }
  .listening-guide li { display: flex; align-items: center; gap: 8px; }
  .guide-number { margin: 0; flex-shrink: 0; }
  .listening-guide h3 { margin: 0; }
  .guide-heading { margin-bottom: 14px; }
}
@container listening-guide (max-height: 145px) {
  .guide-heading { display: none; }
  .guide-card { padding: 12px 14px; border-radius: 12px; }
  .listening-guide li { padding-inline: 10px; gap: 6px; }
  .listening-guide h3 { font-size: 12px; }
  .guide-motto { margin-top: 10px; padding-top: 8px; }
}
@container listening-guide (max-height: 90px) {
  .guide-card { padding: 8px 10px; }
  .guide-motto { display: none; }
}
@container listening-guide (max-height: 45px) {
  .guide-card { display: none; }
}
@container listening-guide (max-width: 380px) {
  .guide-card { padding-inline: 10px; }
  .listening-guide li { padding-inline: 8px; gap: 4px; }
  .guide-number { width: 21px; height: 23px; font-size: 10px; }
  .listening-guide h3 { font-size: 12px; }
}
.desktop-player .player-status { position: absolute; left: 12px; right: 56px; bottom: 10px; opacity: 0; pointer-events: none; font-size: var(--font-caption); }
.desktop-player .player-status.error { opacity: 1; padding: 8px; border-radius: 6px; background: #fff1e8; }
.player-status.error { color: #a65439; }
.desktop-player .attribution { flex: 0 0 auto; font-size: 11px; }
.desktop-player .page-foot { display: none; }
:is(.desktop-player, .compact-player) .transcript-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
:is(.desktop-player, .compact-player) .transcript-head { position: static; display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; padding: 18px 20px 14px; gap: 10px; border-bottom: 1px solid var(--line); }
.transcript-head h2 { white-space: nowrap; }
.transcript-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.transcript-actions #restart { background: #eef5e9; color: var(--green); }
.video-collapse { min-height: 32px; padding: 5px 8px; font-size: var(--font-caption); color: var(--secondary); white-space: nowrap; }
:is(.desktop-player, .compact-player) .follow-button { position: static; min-height: 36px; flex-shrink: 0; font-size: var(--font-caption); box-shadow: none; }
:is(.desktop-player, .compact-player) .follow-button[aria-pressed='true'] { display: inline-flex; color: var(--green); background: #eef5e9; }
:is(.desktop-player, .compact-player) .transcript {
  flex: 1; min-height: 0; height: 0; padding: 0 18px 14px;
  overflow-y: auto; overscroll-behavior: contain; scroll-padding-block: 14px;
  scrollbar-width: thin; scrollbar-color: #cbd7c4 transparent;
}
.desktop-player .sentence { padding: 16px 18px; margin-bottom: 10px; }
.desktop-player .sentence-en { font-size: 18px; line-height: 1.65; }
.desktop-player .sentence-zh { font-size: var(--font-small); line-height: 1.75; }
.transcript-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.progress-state { min-width: 0; font-size: var(--font-caption); color: var(--muted); }
.progress-state.warning { color: #a35c32; }
.transcript-footer #saved-progress { margin: 0; font-size: var(--font-caption); font-variant-numeric: tabular-nums; line-height: 1.5; color: inherit; }
.desktop-player .mobile-only { display: none !important; }
.compact-player .desktop-only { display: none !important; }
.mobile-only { display: inline-flex; }
.settings-note { margin-top: 20px; color: var(--secondary); font-size: var(--font-small); line-height: 1.8; }

/* Phones keep video above a separately scrolling transcript and a bottom controller. */
body.compact-player { padding: 0 !important; background: var(--surface); }
.compact-player #app { width: 100%; height: 100dvh; }
.compact-player .workspace { width: 100%; max-width: 640px; height: 100dvh; margin: 0 auto; border: 0; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; }
.compact-player .lesson-head { position: static; display: flex; align-items: center; flex: 0 0 auto; min-height: 52px; padding: 8px 12px; gap: 8px; border: 0; background: var(--surface); }
.back-button { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; padding: 7px; color: var(--secondary); }
.back-button svg { width: 22px; height: 22px; }
.compact-player .lesson-title-holder { min-width: 0; flex: 1; }
.compact-player .lesson-head h1 { margin: 0; font-size: 16px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact-player .study-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.compact-player .watch-panel { flex: 0 0 auto; padding: 0 12px 8px; border: 0; background: var(--surface); }
.compact-player .video-wrap { width: 100%; max-width: 560px; margin-inline: auto; height: auto; aspect-ratio: 16 / 9; max-height: none; border-radius: 10px; box-shadow: none; }
.compact-player .watch-panel.video-collapsed { display: none; }
.compact-player .video-play { width: 52px; height: 52px; }
.compact-player .fullscreen { padding: 7px; bottom: 6px; right: 6px; }
.compact-player .player-status { position: absolute; bottom: 5px; left: 8px; right: 44px; opacity: 0; pointer-events: none; font-size: var(--font-caption); }
.compact-player .player-status.error { opacity: 1; padding: 6px; background: #fff1e8; border-radius: 4px; }
.compact-player .transcript-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; padding: 8px 12px; min-height: 0; gap: 10px; }
.compact-player .transcript-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 4px; }
.compact-player .transcript-actions > button { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-width: 0; height: 36px; min-height: 36px; margin: 0; padding: 5px 4px; font-size: 12px; line-height: 1.4; white-space: nowrap; border-radius: 18px; }
.compact-player .transcript-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--font-small); line-height: 1.5; }
.compact-player .transcript-head p { display: none; }
.compact-player .transcript-head h2 span { display: none; }
.compact-player .transcript { padding: 0 12px 10px; }
.compact-player .sentence { padding: 14px 16px; margin-bottom: 10px; border-radius: 11px; }
.compact-player .sentence.active { background: #fff0bd; border-color: #eadfae; }
.compact-player .sentence-time { min-height: 16px; margin-bottom: 7px; font-size: var(--font-caption); max-width: calc(100% - 54px); }
.compact-player .sentence-en { font-size: 18px; line-height: 1.6; font-weight: 500; }
.compact-player .sentence-zh { font-size: var(--font-body); line-height: 1.7; margin-top: 8px; color: var(--secondary); }
.compact-player .sentence-save { width: 40px; height: 40px; top: 8px; right: 8px; background: #ffffffa6; }
.compact-player .transcript-footer { padding: 2px 16px; }
.compact-player .controls {
  position: static; transform: none; display: grid;
  grid-template-areas: 'tools' 'timeline' 'transport'; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 22px 57px;
  flex: 0 0 auto; gap: 8px; width: 100%; padding: 8px 16px max(10px, env(safe-area-inset-bottom));
  margin: 0; border-radius: 0; border: 0; border-top: 1px solid var(--line);
  box-shadow: 0 -3px 16px #25352b04; background: var(--surface); backdrop-filter: none;
}
.compact-player .tool-row { grid-area: tools; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; gap: 4px; margin: 0; align-items: center; }
.compact-player .tool-row > * { min-width: 0; }
.compact-player .tool { min-height: 50px; height: 50px; flex-direction: column; gap: 6px; font-size: var(--font-caption); }
.compact-player .tool-icon { height: 26px; }
.compact-player .tool-icon svg { width: 24px; height: 24px; }
.compact-player .timeline { grid-area: timeline; width: 100%; height: 22px; gap: 12px; margin: 0; }
.compact-player .timeline input { min-width: 0; width: 0; flex: 1; }
.compact-player .timeline output { font-size: var(--font-caption); min-width: 30px; }
.compact-player .transport { grid-area: transport; position: static; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; width: 100%; min-height: 57px; gap: 8px; }
:is(.desktop-player, .compact-player) .transport-buttons { grid-column: 2; }
.compact-player #open-settings { grid-column: 3; justify-self: end; }
.compact-player .transport-buttons { gap: 20px; }
.compact-player .transport-buttons .play-button { width: 57px; height: 57px; min-width: 57px; background: var(--green); color: white; }
.compact-player .position { display: none; }
.compact-player input[type='range'] { height: 5px; }
.compact-player input[type='range']::-webkit-slider-thumb { width: 20px; height: 20px; border: 3px solid var(--green); }

@media (min-width: 801px) and (max-height: 760px) {
  .desktop-player #app { padding-bottom: 10px; }
  .desktop-player .lesson-head { padding: 10px 18px; }
  .desktop-player .lesson-head h1 { font-size: 20px; }
  .desktop-player .watch-panel { padding: 12px; gap: 10px; }
  .desktop-player .transcript-head { padding: 12px 16px; }
}
@media (min-width: 801px) and (max-height: 680px) {
  .desktop-player .lesson-head p { display: none; }
  .desktop-player .lesson-head { padding-block: 6px; }
  .desktop-player .controls { padding: 8px 20px; gap: 5px; }
}
@media (min-width: 801px) and (max-height: 520px) {
  .desktop-player #app { padding-block: 6px; }
  .desktop-player #app > .site-header { display: none; }
  .desktop-player .workspace { width: calc(100% - 24px); }
  .desktop-player .lesson-head { padding: 6px 14px; }
  .desktop-player .lesson-head h1 { font-size: 17px; margin: 0; }
  .desktop-player .lesson-head p { display: none; }
  .desktop-player .study-layout { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
  .desktop-player .watch-panel { padding: 8px; gap: 8px; }
  .desktop-player .video-wrap { max-width: 320px; }
  .desktop-player .controls { display: grid; grid-template-areas: 'tools timeline' 'transport transport'; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 5px 20px; }
  .desktop-player .tool-row { min-height: 54px; }
  .desktop-player .position { display: none; }
  .desktop-player .transcript-head { padding: 8px 12px; }
  .desktop-player .transcript-head p { display: none; }
}
@media (min-width: 600px) and (max-width: 800px) and (max-height: 700px) and (orientation: landscape) {
  .compact-player .workspace { max-width: none; }
  .compact-player .lesson-head { min-height: 42px; padding-block: 3px; }
  .compact-player .study-layout { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); }
  .compact-player .watch-panel { padding: 4px 8px; }
  .compact-player .transcript-head { padding: 2px 12px; min-height: 36px; }
  .compact-player .transcript-footer { padding: 0 12px; }
  .compact-player .transcript { padding-inline: 8px; }
  .compact-player .controls { grid-template-areas: 'tools timeline' 'transport transport'; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 44px; align-items: center; gap: 3px 14px; padding: 4px 16px max(4px, env(safe-area-inset-bottom)); }
  .compact-player .timeline { grid-area: timeline; }
  .compact-player .tool-row { grid-area: tools; }
  .compact-player .transport { grid-area: transport; min-height: 44px; }
  .compact-player .transport-buttons { gap: 10px; }
  .compact-player .transport-buttons .play-button { width: 44px; height: 44px; min-width: 44px; }
}
