/* One compact navigation layout for phones and tablets; desktop starts at 1200px. */
@media (max-width:1199.98px) {
  .sidebar-left:not(.drawer-open) {
    display:none !important;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open {
    box-sizing:border-box;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open .link-text,
  body.sidebar-drawer-open .sidebar-left.drawer-open .logo-text {
    display:inline-block !important;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open .link-text-short {
    display:none !important;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open .ap-nav-link {
    justify-content:flex-start;
    min-height:44px;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open .ap-sidebar-search-form {
    display:flex !important;
  }
  body.sidebar-drawer-open .sidebar-left.drawer-open .ap-sidebar-search-collapsed-link {
    display:none !important;
  }
}

/* Small desktops need separate copy/image columns before the wide hero applies. */
@media (min-width:1200px) and (max-width:1279.98px) {
  body.ap-display-topbar .ap-home-hero-world-stage {
    display:grid;
    grid-template-columns:minmax(0, 2fr) minmax(0, 3fr);
    align-items:center;
    padding-bottom:64px;
  }
  body.ap-display-topbar .ap-home-front-hero__copy {
    box-sizing:border-box;
    position:static;
    grid-column:1;
    grid-row:1;
    width:100%;
    padding:24px 20px;
  }
  body.ap-display-topbar .ap-home-hero-world-stage > img {
    grid-column:2;
    grid-row:1;
  }
}

/* Two layouts: phones and tablets share the mobile workspace. */
@media (max-width: 1199.98px) {
  body .creator-workspace-shell { box-sizing: border-box; max-width: 100%; }
  body .creator-workspace-head, body .creator-workspace-head > div:first-child { height: auto; min-height: 0; flex: 0 0 auto; }
  body .creator-mode-switch { display: flex; box-sizing: border-box; width: 100%; min-width: 0; }
  body .creator-mode-switch .creator-mode-switch__item { flex: 1 1 0; min-width: 0; padding: .5rem .25rem; gap: .25rem; }
  body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-action-stack { width: 100%; }
  body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-actions { flex-wrap: wrap; width: 100%; min-width: 0; }
  body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-actions .creator-mode-switch { flex: 1 1 100%; }
  body[data-route="create"] .creator-mode-switch__item { font-size: .8rem; }
  body .creator-files-browser__actions { flex-wrap: wrap; overflow: visible; }
  body .creator-files-browser__toolbar > * { min-width: 0; max-width: 100%; }
  body .ap-hemasiri-reviews > * { min-width: 0; }
  body .ap-hemasiri-review-bar { box-sizing: border-box; width: 100%; grid-template-columns: 34px minmax(0, 1fr) 18px; }
  body .ap-book-reader, body .ap-book-reader__chapter-nav, body .ap-book-reader .ap-annual-access { box-sizing: border-box; max-width: 100%; }
  body .ap-book-reader__chapter-nav { flex-wrap: wrap; }
  body .auth-login-shell { box-sizing: border-box; max-width: 100%; }
  body .ap-auth-shell { flex-direction: column; box-sizing: border-box; }
  body .ap-auth-shell > div:last-child { flex: none !important; width: 100%; max-width: 520px; }
  body .auth-login-shell input, body .ap-auth-shell input, body form[action*="password_reset"] input { font-size: 16px; min-height: 44px; }
}
@media (min-width: 1200px) {
  body .ap-auth-shell { flex-direction: row; }
}

/* Shared control rhythm across Story, Book, Video and Files. */
body .creator-workspace-shell,
body[data-route="create"] .ap-create-toolbar-shell {
  --creator-control-height: 36px;
  --creator-control-gap: 8px;
}
body .creator-workspace-shell .creator-mode-switch__item,
body .book-create-menu__actions > button,
body .creator-files-browser__toolbar .creator-files-browser__btn,
body .creator-workspace-actions .creator-workspace-link,
body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-actions > button,
body[data-route="create"] .ap-create-toolbar-shell .creator-mode-switch__item {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  min-height: var(--creator-control-height);
  gap: 6px;
  line-height: 1.25;
}
body .creator-workspace-shell .creator-mode-switch__item i,
body .creator-files-browser__toolbar .creator-files-browser__btn i,
body .creator-workspace-actions .creator-workspace-link i,
body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-actions > button i {
  flex: 0 0 16px;
  width: 16px;
  font-size: 16px;
  line-height: 1;
  margin: 0;
}
body .book-create-menu__actions,
body .creator-files-browser__actions,
body .creator-workspace-actions,
body[data-route="create"] .ap-create-toolbar-shell .ap-create-toolbar-actions {
  align-items: center;
  gap: var(--creator-control-gap);
}
body[data-route="create"] .ap-create-toolbar-shell .ap-create-draft-badge,
body[data-route="create"] .ap-create-toolbar-shell .ap-create-top-search__toggle {
  box-sizing: border-box;
  width: var(--creator-control-height);
  height: var(--creator-control-height);
}
@media (max-width: 1199.98px) {
  body .creator-workspace-shell,
  body[data-route="create"] .ap-create-toolbar-shell {
    --creator-control-height: 44px;
  }
}

/* Keep complete footer sections together on phones and tablets. */
@media (max-width: 1199.98px) {
  body .ap-page-footer-index {
    box-sizing: border-box;
    padding: 24px 16px;
    width: 100%;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 20px;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-selector-title {
    margin: 0 0 12px;
    line-height: 1.3;
    white-space: normal;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-selector-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-footer-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    overflow-wrap: anywhere;
  }
  body .ap-mobile-nav > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    min-height: 56px;
    padding: 6px 12px;
  }
  body .ap-mobile-nav .ap-mobile-nav__actions,
  body .ap-mobile-nav .ap-music-buttons {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 4px;
  }
  body .ap-mobile-nav #hamburgerBtn,
  body .ap-mobile-nav .ap-music-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    line-height: 1;
    font-size: 22px;
  }
  body .ap-mobile-nav .ap-music-button[hidden] { display: none; }
  body .ap-mobile-nav #hamburgerBtn i,
  body .ap-mobile-nav #hamburgerBtn svg,
  body .ap-mobile-nav .ap-music-button i,
  body .ap-mobile-nav .ap-music-button svg {
    display: block;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    font-size: 22px;
    line-height: 1;
    margin: 0;
    vertical-align: middle;
  }
}

/* Icon glyphs must use the same baseline as their equal-sized buttons. */
@media (max-width: 1199.98px) {
  body .ap-mobile-nav #hamburgerBtn i,
  body .ap-mobile-nav .ap-music-button i {
    display: flex;
    align-items: center;
    justify-content: center;
    transform: none;
  }
  body .ap-mobile-nav #hamburgerBtn i::before,
  body .ap-mobile-nav .ap-music-button i::before {
    display: block;
    line-height: 1;
    vertical-align: top;
  }
  body .ap-mobile-nav #hamburgerBtn svg,
  body .ap-mobile-nav .ap-music-button svg {
    display: block !important;
    transform: none;
  }
}

/* Compact footer rhythm for phones and tablets; desktop keeps its layout. */
@media (max-width: 1199.98px) {
  body .ap-page-footer-index { padding: 24px 20px; }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer { gap: 24px 24px; }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-selector-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-footer-link {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    min-height: 36px;
    padding: 0;
  }
  body .ap-page-footer-index .ap-footer-divider { margin: 24px 0 16px; }
  body .ap-page-footer-index .ap-footer-brand-row {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  body .ap-page-footer-index .ap-footer-brand-main { gap: 12px; }
  body .ap-page-footer-index .ap-footer-logo img { height: 40px; width: 40px; }
  body .ap-page-footer-index .ap-footer-brand-col { gap: 4px; }
  body .ap-page-footer-index .ap-footer-brand-name { font-size: 14px; font-weight: 600; }
  body .ap-page-footer-index .ap-footer-brand-address { font-size: 12px; line-height: 1.5; gap: 0; }
  body .ap-page-footer-index .ap-footer-contact-controls { align-items: flex-start; gap: 8px; }
  body .ap-page-footer-index .ap-footer-locale-inline { flex-wrap: wrap; gap: 8px 20px; }
  body .ap-page-footer-index .ap-footer-locale-inline__lang,
  body .ap-page-footer-index .ap-footer-locale-inline__value { font-size: 14px; min-height: 36px; }
  body .ap-page-footer-index .ap-footer-locale-inline__label { font-size: 12px; font-weight: 500; line-height: 1.4; }
}

/* All footer links stay visible in two mobile columns. */
@media (max-width: 1199.98px) {
  body .ap-page-footer-index .ap-page-selector-shell.is-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-selector-title {
    pointer-events: none;
    cursor: default;
    margin-bottom: 8px;
  }
  body .ap-page-footer-index .ap-page-selector-shell.is-footer .ap-footer-link { min-height: 44px; }
}
