/* Phone navigation; larger layouts keep their existing masthead and panes. */
.mobile-control, .mobile-popup { display: none; }
@media (max-width: 640px) {
  .page > .masthead, .films-page .masthead {
    display: grid; grid-template-columns: minmax(76px, 1fr) auto minmax(76px, 1fr);
    align-items: center; gap: 0; flex-wrap: nowrap; min-height: 68px;
    padding: 10px 12px; position: relative; background: var(--paper);
  }
  .page:not(.films-shell) > .masthead { margin-inline: -16px; }
  .masthead > .brand {
    grid-column: 2; grid-row: 1; display: flex; align-items: center;
    justify-self: center; justify-content: center; gap: 6px; line-height: 1;
    white-space: nowrap; font-size: clamp(20px, 6vw, 26px); letter-spacing: -1px;
  }
  .masthead .brand-mark { display: block; width: 28px; height: auto; margin: 0; flex: none; align-self: center; }
  .masthead .brand-name { display: block; line-height: 1; text-align: center; }
  .masthead > .nav { display: none; }
  .mobile-control {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-height: 44px; border: 0; padding: 0; background: none; color: var(--ink);
    font: inherit; font-size: 13px; text-decoration: none;
  }
  .mobile-control svg { width: 22px; height: 22px; flex: none; }
  .mobile-filter-trigger { grid-column: 1; grid-row: 1; justify-self: start; }
  .mobile-menu-trigger { grid-column: 3; grid-row: 1; justify-self: end; width: 44px; }
  .mobile-filter-trigger[data-selected="true"] { color: var(--accent); font-weight: 700; }
  .mobile-control[aria-expanded="true"] { color: var(--accent); }
  .mobile-popup[open] {
    display: flex; flex-direction: column; position: fixed;
    inset: var(--popup-top, 76px) auto auto 12px; margin: 0;
    width: calc(100% - 28px); max-width: 420px;
    max-height: calc(100dvh - var(--popup-top, 76px) - 20px);
    padding: 0; border: 1px solid var(--ink); border-radius: 8px;
    background: var(--paper); color: var(--ink); font: inherit;
    box-shadow: 3px 3px 0 rgba(23,168,160,.45);
  }
  .mobile-popup::backdrop { background: rgba(11,59,69,.58); }
  .mobile-popup-head {
    display: flex; align-items: center; gap: 8px; padding: 12px;
    flex: none; border-bottom: 1px solid var(--line);
  }
  .mobile-popup-head h2 { font-size: 22px; margin: 0; flex: 1; line-height: 1.2; }
  .mobile-icon-button {
    display: grid; place-items: center; width: 44px; height: 44px; flex: none;
    border: 0; background: none; color: var(--ink); padding: 0;
  }
  .mobile-icon-button svg { width: 24px; height: 24px; }
  .mobile-popup-close { color: var(--accent); border: 0; border-radius: 50%; }
  .mobile-popup-close:focus-visible { outline: none; background: var(--line); }
  .mobile-popup-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 6px 16px; }
  .mobile-category, .mobile-option, .mobile-popup-nav a {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px;
    padding: 12px 0; border: 0; border-bottom: 1px solid var(--line);
    background: none; text-align: left; color: var(--ink); font: inherit;
    font-size: 17px; text-decoration: none; overflow-wrap: break-word;
  }
  .mobile-category:last-child, .mobile-option:last-child, .mobile-popup-nav a:last-child { border-bottom: 0; }
  .mobile-category-label { flex: 1; }
  .mobile-category-count { font-size: 13px; color: var(--accent); }
  .mobile-category svg { width: 18px; height: 18px; flex: none; }
  .mobile-option::before {
    content: ''; width: 22px; height: 22px; flex: none; border: 1px solid var(--ink);
    border-radius: 50%; display: grid; place-items: center; font-size: 15px;
  }
  .mobile-option[aria-pressed="true"]::before { content: '✓'; background: var(--accent); color: var(--paper); border-color: var(--accent); }
  .mobile-popup-actions { padding: 16px; display: flex; gap: 20px; align-items: center; border-top: 1px solid var(--line); flex: none; }
  .mobile-popup-actions .reset { min-height: 44px; }
  .mobile-apply { flex: 1; min-height: 44px; border: 1px solid var(--ink); border-radius: 8px; background: var(--accent); color: var(--ink); font: inherit; box-shadow: 3px 3px 0 rgba(11,59,69,.45); }
  .mobile-popup-nav a[aria-current] { color: var(--accent); font-weight: 700; }
  html:has(.films-page) { height: auto; overflow: auto; }
  .films-page { height: auto; min-height: 100dvh; overflow: visible; }
  .films-page .films-shell { height: auto; min-height: 100dvh; }
  .films-page .masthead { position: sticky; top: 0; z-index: 5; }
  .films-page .library-workspace { display: block; }
  .films-page .filter-sidebar { display: none; }
  .films-page .results-pane { min-height: calc(100dvh - 68px); }
  .films-page .results-heading { min-height: 60px; padding: 12px 16px; }
  .films-page .results-scroll { overflow: visible; padding: 20px 16px; scrollbar-gutter: auto; }
  .films-page .cards { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .films-page .film-intro h1 { font-size: clamp(36px, 9vw, 56px); overflow-wrap: normal; }
  .films-page .film-intro { padding-block: 28px; }
  .about-profile, .video-pair { grid-template-columns: minmax(0, 1fr); }
  html.mobile-overlay-open { overflow: hidden; }
}
@media (max-width: 350px) {
  .masthead > .brand { gap: 4px; }
  .masthead .brand-mark { width: 24px; }
  .mobile-control { font-size: 12px; gap: 3px; }
}
