/* 白板老師 — 教室互動頁專屬響應式排版（電腦 1366×768 / 手機直放 390×844 / 手機橫放 844×390 / 全螢幕） */

.classroom-view {
  height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* === 1. 教室頂部工具列 === */
.cls-topbar {
  height: 52px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 25;
}

.cls-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cls-unit-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cls-topbar-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mode-switch {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 2px;
}

.mode-switch-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: background-color 0.15s, color 0.15s;
}

.mode-switch-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
}

[data-theme="chalkboard"] .mode-switch-btn.active,
[data-theme="studio"] .mode-switch-btn.active {
  color: #082032;
}

.mode-switch-btn.active.adv {
  background: var(--brand-purple);
  color: #ffffff;
}

[data-theme="studio"] .mode-switch-btn.active.adv {
  color: #090d16;
}

/* 課程切換器（同站保留既有課程與新論文課程） */
.course-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.course-switch-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.course-switch-btn:hover {
  color: var(--text-primary);
}

.course-switch-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

[data-theme="studio"] .course-switch-btn.active {
  background: var(--brand-accent);
  color: #08111f;
}

[data-theme="studio"] .cls-brand-mark {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
}

[data-theme="studio"] .board-frame {
  border-width: 3px;
  border-color: #24334f;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(56, 189, 248, 0.18);
}

[data-theme="studio"] .board-frame::after {
  display: none;
}

[data-theme="studio"] .tab-badge {
  color: var(--brand-accent);
}

/* 側邊欄時間軸小徽章與文案預覽樣式 */
.step-time-tag {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-subtle);
}

.step-item.active .step-time-tag {
  color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary-soft) 75%, transparent);
}

.yt-copy-block {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
}

.yt-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.yt-mini-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.cls-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cls-drawer-toggle {
  display: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.cls-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-success));
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.cls-unit-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cls-unit-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.board-hint-corner {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 9;
  background: rgba(15, 23, 42, 0.68);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.board-quiz-cta {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 11;
  box-shadow: var(--shadow-md);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: var(--radius-full);
  background: var(--brand-accent-soft);
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 800;
}

[data-theme="chalkboard"] .tab-badge {
  color: var(--brand-accent);
}

.rate-presets {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.source-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

/* === 2. 中間主要工作區 === */
.cls-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  overflow: hidden;
  position: relative;
}

/* 左側：白板舞台 + 字幕條 */
.cls-stage-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 8px;
  gap: 8px;
  overflow: hidden;
}

/* 章節快速切換條（桌面顯示於白板上方） */
.cls-chapter-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.chapter-pill {
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 4px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.chapter-pill.active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* 白板舞台容器：永遠置中且嚴格維持 16:9，絕不超出垂直高度也不留多餘黑邊 */
.board-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  container-type: size;
}

.board-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  background: radial-gradient(circle at 30% 20%, var(--board-bg), var(--board-bg-edge));
  border: 8px solid var(--board-frame);
  border-radius: 14px;
  box-shadow: var(--shadow-md), inset 0 0 0 2px var(--board-frame-inner);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

[data-theme="studio"] .board-hint-corner {
  display: none;
}

/* 白板底部筆槽點綴 */
.board-frame::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 180px;
  height: 5px;
  border-radius: 4px 4px 0 0;
  background: var(--board-tray);
  pointer-events: none;
  opacity: 0.9;
}

.board-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 點擊白板暫停／繼續的瞬間提示徽章（不會卡在中間擋畫面） */
.board-tap-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  font-size: 1.05rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 12;
}

.board-tap-indicator.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* 暫停狀態右下角輕量角標（絕不遮住中間板書） */
.board-pause-corner {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.76);
  color: #fde047;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  pointer-events: none;
}

/* 字幕條：獨立置於白板下方，絕不蓋到算式 */
.cls-subtitle-bar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}

.subtitle-speaker-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-size: 0.75rem;
  font-weight: 800;
}

.subtitle-text {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  flex: 1;
}

.large-font .subtitle-text {
  font-size: 1.14rem;
}

/* === 右側教學面板（章節步驟 / 5題測驗 / 課綱與均一） === */
.cls-sidebar {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-tab-btn {
  border: none;
  background: transparent;
  padding: 11px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}

.sidebar-tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary-soft) 35%, transparent);
}

.sidebar-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-group-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--brand-primary);
  margin: 8px 2px 2px;
  text-transform: none;
}

.step-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-page);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.84rem;
  transition: border-color 0.15s, background-color 0.15s;
}

.step-item:hover {
  border-color: var(--brand-primary);
}

.step-item.active {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  font-weight: 700;
}

.step-item.done .step-index-dot {
  background: var(--brand-success);
  color: #ffffff;
}

.step-index-dot {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-item.active .step-index-dot {
  background: var(--brand-primary);
  color: #ffffff;
}

.parent-card {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.parent-card h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-primary);
}

.parent-card p,
.parent-card li {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin: 0 0 5px;
}

.parent-card ul {
  margin: 0;
  padding-left: 16px;
}

.junyi-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  margin-bottom: 6px;
  font-size: 0.83rem;
  font-weight: 600;
}

.junyi-link-item:hover {
  border-color: var(--brand-primary);
  text-decoration: none;
}

/* === 3. 教室底部播放控制列 === */
.cls-controls {
  height: 58px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 25;
}

.ctrl-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-play-main {
  min-width: 118px;
  padding: 9px 16px;
  font-size: 0.92rem;
  border-radius: var(--radius-full);
}

.ctrl-scrubber-wrap {
  flex: 1;
  min-width: 80px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-range {
  flex: 1;
  accent-color: var(--brand-primary);
  cursor: pointer;
  height: 6px;
}

.step-counter {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* === 4. 全螢幕模式（原生 Fullscreen 與網頁劇院模式共用） === */
.classroom-view.is-fullscreen .cls-main {
  grid-template-columns: minmax(0, 1fr);
}

.classroom-view.is-fullscreen .cls-sidebar {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 58px;
  width: min(360px, 88vw);
  z-index: 45;
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform 0.22s ease;
}

.classroom-view.is-fullscreen .cls-sidebar.drawer-open {
  transform: translateX(0);
}

.classroom-view.is-fullscreen .cls-drawer-toggle {
  display: inline-flex;
}

.classroom-view.is-fullscreen .board-frame {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
}

/* === 4B. YouTube 16:9 劇院錄影模式（專為 1920×1080 滿版輸出打造） === */
.yt-hud-bar {
  display: none;
}

.classroom-view.is-yt-mode {
  background: #03060c;
  padding: 0;
}

.classroom-view.is-yt-mode .cls-topbar,
.classroom-view.is-yt-mode .cls-chapter-strip,
.classroom-view.is-yt-mode .cls-sidebar,
.classroom-view.is-yt-mode .cls-controls,
.classroom-view.is-yt-mode .board-hint-corner {
  display: none !important;
}

.classroom-view.is-yt-mode .cls-main {
  grid-template-columns: 1fr;
  height: 100dvh;
}

.classroom-view.is-yt-mode .cls-stage-col {
  padding: 0;
  gap: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #03060c;
}

.classroom-view.is-yt-mode .board-viewport {
  flex: 1;
  min-height: 0;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.classroom-view.is-yt-mode .board-frame {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* YouTube 劇院底部專屬字幕帶（獨立列於畫布正下方，100% 永不壓蓋圖表結論與論文出處） */
.classroom-view.is-yt-mode .cls-subtitle-bar {
  flex-shrink: 0;
  width: 100%;
  min-height: 0;
  padding: 10px 44px 12px;
  background: #050a14;
  border: none;
  border-top: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 0;
  z-index: 30;
  box-shadow: none;
  gap: 14px;
}

.classroom-view.is-yt-mode.yt-hide-cc .cls-subtitle-bar {
  display: none !important;
}

.classroom-view.is-yt-mode.yt-hide-hud .yt-hud-bar {
  display: none !important;
}

.classroom-view.is-yt-mode .subtitle-speaker-badge {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.classroom-view.is-yt-mode .subtitle-text {
  color: #f8fafc;
  font-size: clamp(0.95rem, 1.15vw, 1.18rem);
  font-weight: 600;
  line-height: 1.42;
}

.classroom-view.is-yt-mode .yt-hud-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 40;
  padding: 5px 8px;
  border-radius: var(--radius-full);
  background: rgba(7, 12, 24, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.25);
  backdrop-filter: blur(8px);
  opacity: 0.42;
  transition: opacity 0.2s ease;
}

.classroom-view.is-yt-mode .yt-hud-bar:hover,
.classroom-view.is-yt-mode .yt-hud-bar:focus-within {
  opacity: 1;
}

.yt-hud-bar .btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-full);
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(148, 163, 184, 0.3);
  color: #f1f5f9;
}

.yt-hud-step {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: #cbd5e1;
  padding: 0 4px;
}

/* 大螢幕 1920×1080 正常模式質感最佳化 */
@media (min-width: 1680px) {
  .cls-main {
    grid-template-columns: minmax(0, 1fr) 390px;
  }

  .cls-stage-col {
    padding: 14px 22px 12px;
    gap: 10px;
  }

  .subtitle-text {
    font-size: 1.06rem;
  }
}

/* === 5. 手機直放模式 (<= 900px 且高度 > 500px，例如 390×844) === */
@media (max-width: 900px) and (min-height: 501px) {
  .classroom-view {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .cls-topbar {
    position: sticky;
    top: 0;
    height: auto;
    min-height: 46px;
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .cls-unit-title {
    font-size: 0.9rem;
  }

  .cls-unit-sub {
    font-size: 0.68rem;
  }

  .cls-topbar .hide-mobile-text {
    display: none;
  }

  .btn-yt-mode {
    display: none;
  }

  .cls-topbar-center {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }

  .cls-topbar-center .course-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cls-topbar-center .course-switch-btn {
    padding: 4px 6px;
    font-size: 0.74rem;
    text-align: center;
  }

  .cls-topbar-center .mode-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cls-topbar-center .mode-switch-btn {
    padding: 5px 8px;
    font-size: 0.76rem;
    text-align: center;
  }

  .cls-main {
    display: flex;
    flex-direction: column;
    overflow: visible;
    flex: 1 0 auto;
  }

  .cls-stage-col {
    padding: 8px 10px 6px;
    gap: 7px;
    overflow: visible;
    flex: none;
  }

  .board-viewport {
    flex: none;
    display: block;
    container-type: normal;
  }

  .board-frame {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    border-width: 5px;
    border-radius: 10px;
  }

  .board-hint-corner {
    display: none;
  }

  .cls-subtitle-bar {
    padding: 8px 10px;
    min-height: 44px;
  }

  .subtitle-text {
    font-size: 0.88rem;
  }

  .cls-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    gap: 6px;
    z-index: 35;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.14);
  }

  .ctrl-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .btn-play-main {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .ctrl-scrubber-wrap {
    width: 100%;
  }

  .cls-sidebar {
    border-left: none;
    border-top: 1px solid var(--border-color);
    overflow: visible;
    min-height: 260px;
    padding-bottom: 16px;
  }

  .sidebar-panel {
    overflow: visible;
    max-height: none;
  }

  /* 手機直放進入全螢幕劇院模式時，鎖定滿版讓白板居中最大且控制列固定在最底 */
  .classroom-view.is-fullscreen {
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }

  .classroom-view.is-fullscreen .cls-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 88px;
  }

  .classroom-view.is-fullscreen .cls-stage-col {
    flex: 1;
    min-height: 0;
    justify-content: center;
  }

  .classroom-view.is-fullscreen .cls-sidebar {
    position: fixed;
    top: 86px;
    right: 0;
    bottom: 88px;
    width: min(350px, 88vw);
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
    border-top: none;
    border-left: 1px solid var(--border-color);
  }

  .classroom-view.is-fullscreen .sidebar-panel {
    overflow-y: auto;
  }
}

/* === 6. 手機橫放劇院模式 (max-height: 500px 且橫向，例如 844×390) === */
@media (max-height: 500px) and (orientation: landscape) {
  .classroom-view {
    height: 100dvh;
    overflow: hidden;
  }

  .cls-topbar {
    height: 38px;
    padding: 0 8px;
    gap: 6px;
  }

  .cls-unit-title {
    font-size: 0.84rem;
  }

  .cls-unit-sub,
  .board-hint-corner {
    display: none;
  }

  .cls-topbar .hide-landscape,
  .btn-yt-mode {
    display: none;
  }

  .course-switch-btn {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  .cls-topbar .btn {
    padding: 4px 8px;
    font-size: 0.76rem;
    min-height: 28px;
  }

  .mode-switch-btn {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  .cls-drawer-toggle {
    display: inline-flex;
  }

  .cls-main {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .cls-stage-col {
    padding: 4px 8px;
    gap: 4px;
  }

  .cls-chapter-strip {
    display: none;
  }

  .board-frame,
  .classroom-view.is-fullscreen .board-frame {
    border-width: 4px;
    border-radius: 8px;
    height: 100%;
    width: auto;
    max-width: 100%;
    max-height: 100%;
  }

  .board-frame::after {
    display: none;
  }

  /* 橫放時把字幕壓縮成單行高對比條，不壓縮白板也不遮白板 */
  .cls-subtitle-bar {
    min-height: 30px;
    max-height: 34px;
    padding: 3px 10px;
    border-radius: 8px;
    gap: 6px;
  }

  .subtitle-speaker-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .subtitle-text {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .cls-controls {
    height: 42px;
    padding: 0 8px;
    gap: 6px;
  }

  .cls-controls .btn {
    padding: 5px 9px;
    font-size: 0.78rem;
    min-height: 30px;
  }

  .btn-play-main {
    min-width: 86px;
  }

  /* 側邊欄改為右滑抽屜，絕不擠壓橫放白板 */
  .cls-sidebar {
    position: fixed;
    top: 38px;
    right: 0;
    bottom: 42px;
    width: min(350px, 82vw);
    z-index: 45;
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform 0.2s ease;
  }

  .cls-sidebar.drawer-open {
    transform: translateX(0);
  }
}

/* === 7. 白板 SVG 動畫關鍵影格 === */
@keyframes wbStrokeDraw {
  from {
    stroke-dashoffset: var(--stroke-len, 600);
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes wbPopIn {
  0% {
    opacity: 0;
    transform: scale(0.84);
  }
  70% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes wbWriteReveal {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0.7;
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes wbFadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wb-anim-stroke {
  stroke-dasharray: var(--stroke-len, 600);
  stroke-dashoffset: var(--stroke-len, 600);
  animation: wbStrokeDraw var(--anim-dur, 700ms) cubic-bezier(0.25, 0.8, 0.25, 1) var(--anim-delay, 0ms) forwards;
}

.wb-anim-write {
  animation: wbWriteReveal var(--anim-dur, 650ms) cubic-bezier(0.2, 0.65, 0.3, 1) var(--anim-delay, 0ms) both;
}

.wb-anim-pop {
  transform-box: fill-box;
  transform-origin: center;
  animation: wbPopIn var(--anim-dur, 420ms) ease-out var(--anim-delay, 0ms) both;
}

.wb-anim-fade {
  animation: wbFadeSlideUp var(--anim-dur, 400ms) ease-out var(--anim-delay, 0ms) both;
}

/* 靜態還原先前步驟時立即呈現，無重複動畫（保留裝飾元素的刻意透明度） */
.wb-instant * {
  animation: none !important;
  stroke-dashoffset: 0 !important;
  clip-path: none !important;
}

.wb-instant .wb-anim-pop,
.wb-instant .wb-anim-fade,
.wb-instant .wb-anim-write {
  opacity: 1 !important;
}

/* 暫停時凍結白板繪圖動畫 */
.board-paused .wb-anim-stroke,
.board-paused .wb-anim-write,
.board-paused .wb-anim-pop,
.board-paused .wb-anim-fade {
  animation-play-state: paused !important;
}
