/* The study view behaves like an index; the painted entrance keeps its own rhythm. */
#course, .dialog {
  --control-height: 2.125rem;
  --tree-height: 1.875rem;
  line-height: 1.45;
}
.site-header { min-height: 54px; gap: 16px; padding: 7px clamp(16px, 2.2vw, 38px); }
.home-link, #course .button, .dialog .button, .dialog .small-button, .reset-button {
  min-height: var(--control-height); padding-block: 5px;
}
.site-name { line-height: 1.35; }
#course main { padding: 14px clamp(16px, 2.2vw, 38px) 28px; }
.course-heading { gap: 12px; margin-bottom: 12px; }
.course-heading h1 { line-height: 1.3; }
.summary { gap: 16px; }
.workbench { gap: 14px; }
.panel-heading { gap: 8px; margin-bottom: 9px; }
.panel-heading h2 { line-height: 1.35; }

.knowledge-panel { padding: 13px 0; min-width: 0; }
.knowledge-panel > .panel-heading { padding-inline: 8px; }
.knowledge-panel button {
  min-height: var(--tree-height); gap: 5px; line-height: 1.35;
  padding: 4px 8px; border-radius: 4px 7px 5px 6px;
}
.skill-group { margin: 9px 0 0 8px; padding-left: 8px; }
.skill-group h3 { margin: 0 0 1px; line-height: 1.35; }
.skill-group button { padding: 3px 6px; }
.skill-group button > :first-child { min-width: 0; overflow-wrap: anywhere; }
.skill-count { flex: none; min-width: 18px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.catalog { padding: 13px 11px 9px; }
.search-box { padding: 2px 8px; min-height: var(--control-height); }
.search-box input { min-height: 26px; line-height: 1.35; }
.view-filters { margin: 5px 0 6px; gap: 3px; }
.view-filters button, .manager-tabs button { min-height: var(--control-height); padding: 4px 10px; line-height: 1.3; }
.active-filter { margin-bottom: 6px; padding: 5px 8px; }
.video-list { gap: 0; }
.video-card {
  min-height: 44px; padding: 7px 8px; line-height: 1.35;
  border: solid transparent; border-width: 1px; border-bottom-color: var(--line);
  border-radius: 0; text-align: left;
}
.video-card:last-child { border-bottom-color: transparent; }
.video-card[aria-current=true], .video-card:hover { border-radius: 4px 7px 5px 6px; }
.video-card[aria-current=true]::before { top: 8px; bottom: 8px; }
.card-head { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 6px; }
.card-title { min-width: 0; font-size: .9375rem; font-weight: 500; line-height: 1.35; }
.card-source {
  align-self: start; margin-top: 2px; padding: 1px 4px;
  font-size: 12px; font-weight: 400; line-height: 1.3;
  border-radius: 3px; background: var(--surface-soft); color: var(--muted); white-space: nowrap;
}
.card-detail { display: block; margin-top: 3px; font-size: .8125rem; line-height: 1.4; }
.card-skills { display: inline; margin: 0; font-size: inherit; font-weight: 400; line-height: inherit; }
.record-icons { display: inline-block; margin-right: 6px; font-weight: 500; }
.record-icons:only-child { margin-right: 0; }
.list-empty { padding: 12px 4px; }
.list-empty p { margin: 4px 0 9px; }

.lesson { padding: 14px 16px; }
.lesson-overline { margin: 0 0 3px; }
.lesson h2 { line-height: 1.3; margin-bottom: 10px; }
.player-help { margin: 6px 0; }
.lesson-actions { gap: 6px; margin-top: 7px; }
.lesson-section { margin-top: 14px; padding-top: 10px; }
.lesson-section h3 { margin-bottom: 6px; }
.skill-tags { gap: 4px; }
.skill-tag { min-height: var(--tree-height); padding: 4px 8px; line-height: 1.35; }
.segments { gap: 7px; }
.segment { padding: 1px 0 1px 8px; }
.segment-label { margin-bottom: 1px; }
.lesson-empty { min-height: 140px; }
.lesson-empty h2 { margin: 0; }
.notice { margin: 8px 0; padding: 7px 10px; }
#course footer { padding: 12px clamp(16px, 2.2vw, 38px); }

.dialog { padding: 18px; }
.dialog-heading { gap: 10px; margin-bottom: 12px; }
.manager-toolbar { gap: 8px; margin-bottom: 9px; }
.manager-controls { gap: 8px; margin-bottom: 7px; }
.manager-controls > input { min-height: var(--control-height); padding: 5px 8px; }
.manage-row { gap: 10px; padding-block: 7px; }
.row-copy { line-height: 1.35; }
.row-copy > span { margin-top: 2px; }
.row-actions { gap: 5px; }
.row-actions button { min-height: var(--control-height); padding: 4px 8px; }
.field { margin-bottom: 12px; }
.field > input, .field > textarea { min-height: 36px; margin-top: 3px; padding: 5px 9px; }
.field > textarea { min-height: 75px; }
fieldset.field { padding: 8px 10px; }
.checkbox-grid { gap: 0 10px; }
.checkbox-grid label { min-height: var(--tree-height); padding: 4px 0; }
.dialog-actions { padding-top: 10px; margin-top: 4px; }

@media (min-width: 1001px) {
  .workbench { grid-template-columns: clamp(185px, 16vw, 245px) clamp(267px, 24vw, 365px) minmax(0, 1fr); }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .workbench { grid-template-columns: clamp(170px, 21vw, 200px) minmax(0, 1fr); }
}
/* Index entries become paired cells only when each has room for a usable title. */
@media (min-width: 600px) and (max-width: 1000px) {
  .video-list { column-gap: 8px; }
}
@media (max-width: 720px) {
  .site-header { min-height: 48px; gap: 8px; padding: 3px 12px; }
  #course main { padding: 10px 12px 20px; }
  .course-heading { flex-flow: row wrap; align-items: center; justify-content: space-between; gap: 3px 10px; }
  .course-heading h1 { font-size: 25px; }
  .summary { gap: 8px; }
  .summary strong { font-size: 16px; margin-right: 1px; }
  .workbench { gap: 10px; }
  .knowledge-panel { padding: 4px 10px; }
  .knowledge-panel > .panel-heading { margin: 0; padding: 0; }
  .knowledge-panel.expanded #knowledge-body { padding: 4px 0 6px; }
  .knowledge-panel .small-button { padding: 4px 10px; }
  .catalog, .lesson { padding: 11px; }
  .lesson-empty { min-height: 86px; }
  .search-box input, .manager-controls > input { font-size: 16px; }
  .dialog { padding: 13px; }
  .dialog-heading { margin-bottom: 8px; }
  .manage-row { align-items: center; flex-wrap: nowrap; }
  .row-copy { min-width: 0; }
  .row-actions { margin-left: 0; }
}
@media (max-width: 599px) {
  .video-list { grid-template-columns: 1fr; }
}
/* Keep the denser rhythm in the margins, not in the hit targets on touch screens. */
@media (max-width: 720px), (any-pointer: coarse) {
  #course, .dialog { --control-height: 44px; --tree-height: 44px; }
  .field > input { min-height: 44px; }
}

/* Shared tracks keep each sticky column head attached to its panel. The dock
   belongs to the course, so short sidebars do not limit how long it sticks. */
:root { scroll-padding-block-start: calc(var(--dock-height, 0px) + 4px); }
#course {
  --inset: clamp(16px, 2.2vw, 38px);
  --tree-col: clamp(185px, 16vw, 245px);
  --catalog-col: clamp(267px, 24vw, 365px);
  --tab-col: 3.5rem;
  --tracks: var(--tree-col) var(--catalog-col) minmax(0, 1fr);
}
#course.without-knowledge { --tree-col: var(--tab-col); }
#course.without-catalog { --catalog-col: var(--tab-col); }
.course-dock { position: sticky; top: 0; z-index: 10; background: var(--paper); }
.dock-inner { max-width: 1760px; margin-inline: auto; padding: 10px var(--inset) 0; }
#course main { padding: 0 var(--inset) 28px; }
.course-heading { flex-wrap: wrap; justify-content: flex-start; margin: 0 0 8px; }
.course-heading .summary { margin-inline-start: 8px; }
.sidebar-heads { display: grid; grid-template-columns: var(--tracks); gap: 14px; }
.sidebar-head {
  display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 35px;
  padding: 2px 6px 2px 8px; background: var(--paper-light);
  border: 1px solid var(--line); border-radius: 7px 9px 0 0;
}
.knowledge-head { background: var(--paper); border-color: transparent; border-bottom-color: var(--line); }
.sidebar-head h2 { margin: 0 auto 0 0; font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.sidebar-head .count-label { white-space: nowrap; }
.sidebar-toggle {
  display: inline-flex; justify-content: center; align-items: center; flex-shrink: 0;
  min-height: 28px; min-width: 28px; padding: 0 3px;
  border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink-secondary);
}
.sidebar-toggle:is(:hover,:focus-visible) { color: var(--accent); background: var(--surface-hover); }
.sidebar-toggle .closed-name { display: none; }
@media (min-width: 1001px) {
  #course .workbench { grid-template-columns: var(--tracks); }
  #knowledge-panel { grid-column: 1; grid-row: 1; padding-top: 6px; }
  #catalog-panel { grid-column: 2; grid-row: 1; padding-top: 6px; border-top: 0; border-radius: 0 0 9px 13px; }
  #course .lesson { grid-column: 3; grid-row: 1; }
  #course.without-catalog .lesson { grid-column: 2 / -1; }
  #course.without-knowledge.without-catalog .lesson { grid-column: 1 / -1; }
  .without-knowledge .knowledge-head, .without-catalog .catalog-head { padding: 0; background: transparent; border: 0; }
  .without-knowledge .knowledge-head h2, .without-catalog .catalog-head :is(h2,.count-label) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .sidebar-toggle[aria-expanded=false] { width: 100%; background: var(--paper-light); border-color: var(--line); }
  .sidebar-toggle[aria-expanded=false] .closed-name { display: inline; font-size: .8rem; }
  .sidebar-toggle[aria-expanded=false] svg { transform: rotate(180deg); }
}
/* Stacked layouts keep the two panel heads next to each other above the lesson. */
@media (max-width: 1000px) {
  .sidebar-heads { grid-template-columns: clamp(170px,21vw,200px) minmax(0,1fr); padding-bottom: 5px; }
  .sidebar-head { border: 1px solid var(--line); background: var(--paper-light); border-radius: 5px; }
  .sidebar-toggle svg { transform: rotate(90deg); }
  .sidebar-toggle[aria-expanded=false] svg { transform: rotate(-90deg); }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .without-knowledge .workbench { grid-template-columns: minmax(0,1fr); }
  .without-knowledge .workbench > :is(.lesson,.catalog) { grid-column: 1; }
  .without-catalog .knowledge-panel { grid-row: 1; }
}
@media (max-width: 720px) {
  #course { --inset: 12px; }
  .dock-inner { padding-top: 4px; }
  .course-heading { justify-content: space-between; margin-bottom: 4px; }
  .course-heading .summary { margin-inline-start: 0; }
  .sidebar-heads { grid-template-columns: minmax(0,1fr) minmax(0,1.24fr); gap: 5px; }
  .sidebar-head { padding-block: 0; gap: 2px; }
  .sidebar-head h2 { font-size: .9375rem; }
  .sidebar-head .count-label { font-size: .75rem; }
  .knowledge-panel #knowledge-body { display: block; padding: 4px 0 6px; }
  .knowledge-panel { padding-top: 5px; }
}
@media (max-width: 720px), (any-pointer: coarse) {
  .sidebar-toggle { min-width: 44px; min-height: 44px; }
}
@media (max-width: 360px) {
  .sidebar-head { padding-inline: 4px 0; }
  .sidebar-heads { grid-template-columns: minmax(0,1fr) minmax(0,1.3fr); }
}
