/* Modifier guidance is distinct from the solid primary target key. */
#keyboard kbd.shift-target {
  outline: 2px dashed #f04449;
  outline-offset: -4px;
  border-color: #f04449;
  color: var(--ink);
  background: var(--surface);
}

/* The page owns one viewport. Oversized/accessible content can still flow,
   rather than being hidden behind a fixed-height overflow trap. */
body:has(> .course-player-page) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}
body:has(> .course-player-page) > .app-header { flex: none; }
.course-player-page { display: flex; flex: 1; min-height: 0; }
.course-player-page .course-player-layout { flex: 1; min-width: 0; min-height: 0; }
.course-player-page .course-player-main { display: flex; flex-direction: column; min-height: 0; overflow: visible; }
.course-player-page .course-player-bar { flex: none; min-height: 44px; }
.course-player-page .course-curriculum { top: 0; height: 100%; }
.course-player-page .course-workspace {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  min-height: 0;
  padding: clamp(8px, 1.5dvh, 20px) clamp(16px, 3vw, 48px);
}
.course-player-page .course-workspace-top { flex: none; flex-direction: row; align-items: center; gap: 8px; padding-bottom: 5px; width: min(100%, 1120px); margin-inline: auto; }
.course-practice-core {
  display: flex; flex: 1; flex-direction: column; justify-content: center;
  gap: clamp(8px, 2dvh, 24px); min-height: 0;
  width: min(100%, 1120px); margin-inline: auto;
  padding-block: clamp(8px, 1.5dvh, 16px);
}
.course-player-page .course-context { flex: none; padding: 0; }
.course-player-page .course-context .eyebrow { margin-bottom: 5px; }
.course-player-page .course-context h1 { font-size: clamp(1.4rem, min(3vw, 4.5dvh), 2.4rem); line-height: 1.1; }
.course-player-page .course-typing-surface {
  flex: none;
  min-height: 0;
  max-height: none;
  padding: clamp(10px, 1.8dvh, 18px) clamp(12px, 2vw, 28px);
  overflow: hidden;
}
.course-player-page .course-typing-surface:focus-within { outline: none; border-color: var(--line-strong); }
.course-player-page .course-typing-surface:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.course-player-page .course-inline-passage {
  font-size: clamp(1.125rem, min(2.1vw, 3.9dvh), 1.85rem);
  line-height: 1.45;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.course-player-page .finger-guidance {
  flex: none;
  grid-template-columns: clamp(70px, 14dvh, 130px) minmax(0, 1fr) clamp(70px, 14dvh, 130px);
  gap: clamp(8px, 1.5vw, 22px);
  margin-top: 0;
  align-items: center;
}
.course-player-page .hand-guide { display: block; width: 100%; }
#finger-guidance .hand-guide { opacity: .22; transition: opacity 120ms ease; }
#finger-guidance .hand-guide.is-needed { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #finger-guidance .hand-guide { transition: none; } }
.course-player-page .course-keyboard { gap: 4px; width: min(100%, 900px); }
.course-player-page .course-key-row { gap: 4px; }
.course-player-page .course-key-row kbd { min-width: 0; min-height: clamp(22px, 4dvh, 36px); font-size: clamp(.58rem, 1vw, .85rem); }
.course-player-page .finger-instruction { min-height: 0; margin: 8px 0 0; line-height: 1.35; }
.course-player-page .course-workspace-bottom { flex: none; min-height: 0; padding-top: 0; }
.course-player-page .course-workspace-bottom:has(#course-status:empty):has(#course-reset[hidden]) { display: none; }

/* Keep the same composition when starting/stopping; only navigation leaves. */
body.course-active .course-player-page .course-player-layout { display: flex; min-height: 0; }
body.course-active .course-player-main { flex: 1; }
body.course-active .course-player-page .course-workspace { min-height: 0; }
body.course-active .course-player-page .hand-guide { width: 100%; }
body.course-active .course-player-page .course-context { padding: 0; }
body.course-active .course-player-page .course-typing-surface {
  min-height: 0; max-height: none; overflow: hidden;
  padding: clamp(10px, 1.8dvh, 18px) clamp(12px, 2vw, 28px);
}
body.course-active .course-player-page .course-inline-passage {
  font-size: clamp(1.125rem, min(2.1vw, 3.9dvh), 1.85rem); line-height: 1.45;
}

@media (max-width: 1320px) {
  .course-player-page .course-curriculum { height: 100dvh; max-height: 100dvh; }
}
@media (min-width: 1321px) {
  /* A desktop sidebar must not retain the mobile drawer's exit transform. */
  .course-player-page .course-curriculum { transform: none; transition: none; }
}
@media (max-width: 640px) {
  .course-player-page .course-workspace { gap: 6px; padding: 8px 12px; }
  .course-player-page .course-practice-core { gap: 8px; padding-block: 6px; }
  .course-player-page .course-workspace-controls { gap: 5px; }
  .course-player-page .course-modes { width: auto; }
  .course-player-page .course-mode { padding-inline: 8px; }
  .course-player-page .course-timer { font-size: 1rem; }
  .course-player-page .course-exit { font-size: .68rem; }
  .course-player-page .finger-guidance { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .course-player-page .keyboard-guide-wrap { grid-column: 1 / -1; grid-row: 1; }
  .course-player-page .hand-guide,
  body.course-active .course-player-page .hand-guide { width: clamp(48px, 9dvh, 80px); }
  .course-player-page .course-keyboard, .course-player-page .course-key-row { gap: 2px; }
  .course-player-page .course-key-row kbd,
  body.course-active .course-player-page .course-key-row kbd { min-width: 0; min-height: clamp(22px, 3.8dvh, 30px); font-size: .55rem; }
  .course-player-page .finger-instruction { margin-top: 5px; font-size: .75rem; }
  .course-player-page .course-workspace:has(#course-reset:not([hidden])) { gap: 4px; }
  .course-player-page .course-workspace:has(#course-reset:not([hidden])) .course-practice-core { gap: 4px; padding-block: 0; }
  .course-player-page .course-workspace:has(#course-reset:not([hidden])) .hand-guide { width: 48px; }
  .course-player-page .course-workspace:has(#course-reset:not([hidden])) .course-key-row kbd { min-height: 22px; }
}

/* Reading steps stay one cohesive block, with their Next action in view. */
@media (max-height: 740px) {
  .course-player-page .course-reading:not(.goal-assessment-step):not(.goal-results-step) {
    padding: 16px clamp(20px, 3vw, 42px) 20px;
  }
  .course-reading:not(.goal-assessment-step):not(.goal-results-step) h1 { font-size: clamp(1.5rem, 2.5vw, 2.1rem); }
  .course-reading .course-reading-progress { margin-bottom: 8px; }
  .course-reading .course-reading-track { flex: none; margin-bottom: 12px; }
  .course-reading .course-reading-lead { margin: 10px 0 14px; line-height: 1.45; }
  .course-reading .course-reading-goal { padding-block: 14px; }
  .course-reading .course-step-actions { margin-top: 16px; padding-top: 12px; }
  .course-reading .course-choice { min-height: 44px; padding-block: 10px; }
  .goal-onboarding .goal-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
  .goal-onboarding .goal-choice { min-height: 44px; padding: 10px; gap: 8px; font-size: .85rem; }
  .goal-onboarding .goal-custom-label { margin-top: 10px; }
}

@media (min-width: 641px) and (max-height: 480px) {
  .course-player-page .course-practice-core {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto; align-content: center; align-items: start;
    gap: 6px 16px; padding: 8px 0;
  }
  .course-player-page .course-context { grid-column: 1; grid-row: 1; }
  .course-player-page .course-context h1 { font-size: 1.4rem; }
  .course-player-page .course-typing-surface { grid-column: 1; grid-row: 2; }
  .course-player-page .finger-guidance {
    grid-column: 2; grid-row: 1 / 3; align-self: center;
    grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 6px;
  }
  .course-player-page .course-keyboard, .course-player-page .course-key-row { gap: 2px; }
  .course-player-page .course-key-row kbd,
  body.course-active .course-player-page .course-key-row kbd { min-height: 22px; font-size: .5rem; }
  .course-player-page .finger-instruction { font-size: .7rem; }
  .course-player-page .course-workspace-bottom { grid-column: 1 / -1; }
}
