/* The same chapter control moves into the portal header on narrow screens. */
@media (max-width: 880px) {
  html { scroll-padding-top: calc(var(--chapter-header-height, 0px) + 12px); }
  .portal-nav.mobile-chapter-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
    isolation: isolate;
  }
  .portal-nav.mobile-chapter-nav > a { font-size: 1rem; min-width: 0; }
  .portal-nav.mobile-chapter-nav > span {
    max-width: 43vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .875rem;
  }
  .portal-nav.mobile-chapter-nav .stage-control {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: 0;
    width: 100%;
    border-radius: 12px;
    padding: 4px 10px;
    background: #e5f8f4;
    border: 1px solid #9bd8ce;
    color: #123d37;
    font-size: .875rem;
    white-space: nowrap;
  }
  .portal-nav.mobile-chapter-nav .stage-control select {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    min-height: 44px;
    padding: 6px 28px 6px 4px;
    font-size: 1rem;
    color: #123d37;
    appearance: none;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23123d37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 2px center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .portal-nav.mobile-chapter-nav .stage-control:focus-within {
    outline: 3px solid #f2d661;
    outline-offset: 2px;
  }
}
