/* Shared two-zone teaching layout: lesson content above, instrument below. */
body[data-page-layout="teaching"] main {
  height: calc(100dvh - var(--app-header-height));
  max-width: 1240px;
  padding: 0 30px;
  overflow: hidden;
}

body[data-page-layout="teaching"] .view {
  height: 100%;
  min-height: 0;
  padding-top: 0;
}

body[data-page-layout="teaching"] .teaching-view > .view-heading {
  display: none;
}

body[data-page-layout="teaching"] > .app-shell > .site-footer {
  display: none;
}

.teaching-workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
}

.teaching-content {
  min-height: 0;
  overflow: hidden;
}

.teaching-content > .ear-layout,
.teaching-content > .voice-shell {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 18px 0 24px;
}

.teaching-content > .voice-shell {
  overflow: hidden;
  padding-top: 0;
}

.teaching-content > .voice-shell .voice-panel {
  max-height: calc(100% - 48px);
  overflow: auto;
}

.teaching-content .theory-layout {
  height: 100%;
  min-height: 0;
}

.teaching-content .lesson-sidebar {
  position: static;
  height: 100%;
  max-height: none;
  overflow-y: auto;
}

.teaching-content .theory-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.teaching-content .theory-head {
  flex: 0 0 auto;
}

.teaching-content .theory-visual {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 30px;
}

.teaching-instrument {
  min-height: 0;
  border-top: 1px solid var(--line);
  padding: 8px 0 12px;
  background: var(--bg);
}

.teaching-instrument.is-hidden {
  display: none;
}

.teaching-instrument .keyboard-wrap {
  max-width: none;
  margin: 0;
}

.lesson-sidebar-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.lesson-sidebar-title small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.lesson-catalog-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}

.lesson-catalog-toggle:hover,
.lesson-catalog-toggle[aria-expanded="true"] {
  border-color: var(--accent-line);
  color: var(--text);
  background: var(--accent-soft);
}

.teaching-instrument .keyboard-label {
  color: var(--muted);
}

.teaching-instrument [data-teaching-keyboard] {
  height: 148px;
}

.teaching-instrument [data-teaching-keyboard] .key-binding,
.teaching-instrument [data-teaching-keyboard] .black-key .key-binding {
  display: none;
}

@media (max-width: 700px) {
  body[data-page-layout="teaching"] main {
    width: 100%;
    max-width: none;
    height: calc(100dvh - var(--app-header-height));
    padding: 0;
  }

  .teaching-content .theory-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .teaching-content > .ear-layout,
  .teaching-content > .voice-shell {
    height: 100%;
    padding: 12px 14px 18px;
  }

  .teaching-content > .voice-shell {
    padding: 0;
  }

  .teaching-content > .voice-shell .voice-panel {
    max-height: calc(100% - 43px);
    padding: 14px 14px 20px;
  }

  .teaching-content .lesson-sidebar {
    flex: 0 0 auto;
    height: auto;
    max-height: 53px;
    overflow: hidden;
    padding: 0 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    transition: max-height .2s ease;
  }

  .teaching-content .lesson-sidebar.catalog-open {
    max-height: min(44svh, 330px);
    overflow-y: auto;
  }

  .teaching-content .lesson-sidebar-head {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: 52px;
    padding: 0;
    border-bottom: 0;
    background: var(--surface);
  }

  .lesson-sidebar-title {
    display: block;
  }

  .lesson-sidebar-title strong {
    display: block;
    font-size: 14px;
  }

  .lesson-sidebar-title small {
    display: block;
    margin-top: 2px;
    font-size: 10px;
  }

  .lesson-catalog-toggle {
    display: inline-flex;
  }

  .teaching-content .theory-panel {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    border-top: 0;
  }

  .teaching-content .theory-head {
    padding: 12px 14px 10px;
  }

  .teaching-content .theory-head h2 {
    font-size: 20px;
  }

  .teaching-content .theory-head p {
    font-size: 11px;
  }

  .teaching-content .theory-visual {
    padding: 12px 14px 22px;
  }

  .teaching-instrument {
    padding: 7px 10px max(9px, env(safe-area-inset-bottom));
  }

  .teaching-instrument .keyboard-label {
    display: none;
  }

  .teaching-instrument .keyboard-tools {
    min-height: 28px;
    margin-bottom: 3px;
  }

  .teaching-instrument [data-teaching-keyboard] {
    height: 118px;
  }
}

/* Short landscape phone windows need room for both the lesson and the keys. */
@media (min-width: 701px) and (max-width: 1000px) and (max-height: 500px) {
  body[data-page-layout="teaching"] .teaching-workspace {
    grid-template-rows: minmax(150px, 1fr) auto;
  }

  body[data-page-layout="teaching"] .teaching-instrument {
    padding: 4px 8px 6px;
  }

  body[data-page-layout="teaching"] .teaching-instrument .keyboard-tools {
    min-height: 26px;
    margin: 0 0 2px;
  }

  body[data-page-layout="teaching"] .teaching-instrument [data-teaching-keyboard] {
    height: 96px;
  }

  body[data-page-layout="teaching"] .teaching-content > .ear-layout,
  body[data-page-layout="teaching"] .teaching-content > .voice-shell {
    padding: 8px 12px;
  }

  body[data-page-layout="teaching"] .teaching-content > .ear-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page-layout="teaching"] .teaching-content > .ear-layout .ear-visual,
  body[data-page-layout="teaching"] .teaching-content > .voice-shell .voice-visual {
    display: none;
  }

  body[data-page-layout="teaching"] .teaching-content > .voice-shell .voice-panel-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page-layout="teaching"] .teaching-content > .voice-shell .voice-panel {
    height: calc(100% - 48px);
    max-height: none;
  }
}
