/* Phone refinement. The existing desktop stylesheet stays unchanged. */
@media (max-width: 800px), (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  :root {
    --mobile-left: max(16px, env(safe-area-inset-left, 0px));
    --mobile-right: max(16px, env(safe-area-inset-right, 0px));
    --header-height: calc(64px + env(safe-area-inset-top, 0px));
  }

  html { -webkit-text-size-adjust: 100%; }
  button, [role="tab"] { -webkit-user-select: none; user-select: none; }
  .site-header {
    grid-template-columns: 1fr auto;
    padding: env(safe-area-inset-top, 0px) var(--mobile-right) 0 var(--mobile-left);
  }
  .desktop-nav { display: none; }
  .header-left { gap: 8px; }
  .header-left > a, .header-contact { min-height: 48px; }
  .menu-toggle { display: inline-flex !important; order: -1; width: 48px; min-height: 48px; margin-left: -8px; gap: 6px; }
  .menu-toggle span { width: 22px; height: 1.5px; }

  .opening { height: 100vw; min-height: 0; max-height: 100svh; }
  .opening video { object-position: 50% 50%; }
  .enter > span, .film-toggle {
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    font-size: 14px;
    padding: 12px 16px;
    align-items: center;
  }
  .enter > span { left: var(--mobile-left); }
  .film-toggle { right: var(--mobile-right); }

  .masthead { padding: 20px var(--mobile-right) 34px var(--mobile-left); }
  .masthead h1 { font-size: clamp(30px, 8vw, 36px); }
  .feed, .live-intro, .fm-view, .fm-teaser { width: calc(100% - var(--mobile-left) - var(--mobile-right)); }
  .entry { margin-bottom: 72px; }
  .entry--video { width: 100%; margin-left: 0; }
  .entry h2 { margin-top: 20px; font-size: 16px; }
  .entry .subtitle, .video-description { font-size: 14px; line-height: 1.55; }
  .video-description { max-width: 34ch; }
  .entry-actions { gap: 12px; margin-top: 18px; }
  .outline-button { min-height: 48px; min-width: 120px; padding: 10px 16px; font-size: 14px; }
  .video-fallback { display: inline-flex; align-items: center; min-height: 48px; margin-top: 4px; font-size: 14px; }

  .live-intro { margin-bottom: 36px; }
  .live-intro h2 { font-size: clamp(26px, 7vw, 34px); margin-bottom: 16px; }
  .live-intro p { font-size: 16px; line-height: 1.55; }
  .live-signup { min-height: 48px; font-size: 14px; }

  .listen-panel { margin-top: 28px; }
  .service-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
  .service-tabs button { min-height: 48px; font-size: 15px; padding: 10px 8px; }
  .embed-wrap { margin-top: 16px; }
  .embed-note { margin-top: 8px; font-size: 14px; }
  .embed-note a { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; }

  .fm-description { font-size: 16px; line-height: 1.55; margin-bottom: 32px; }
  .fm-links { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 16px; }
  .fm-links a { min-height: 48px; font-size: 14px; border-bottom: 1px solid #ddd; }
  .fm-archive { margin-top: 48px; }
  .fm-episode { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding-block: 8px; }
  .fm-episode-title { font-size: 16px; }
  .fm-episode a, #fm-all { min-height: 48px; }
  .fm-episode-links { gap: 4px 16px; font-size: 14px; }
  #fm-all { font-size: 14px; margin-top: 16px; }
  .fm-teaser { margin-top: 64px; padding-block: 24px; gap: 8px; flex-direction: column; }
  .fm-teaser > span:first-child { font-size: 28px; line-height: 1.2; }
  .fm-teaser > span:last-child { font-size: 14px; }

  footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 64px var(--mobile-right) calc(24px + env(safe-area-inset-bottom, 0px)) var(--mobile-left);
    font-size: 14px;
  }
  footer > a { min-height: 48px; margin: 0; justify-content: center; }
  footer p { grid-column: 1 / -1; font-size: 12px; margin-top: 12px; }

  .mobile-menu {
    width: min(calc(100vw - 20px), 380px);
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    scroll-padding-top: calc(72px + env(safe-area-inset-top, 0px));
  }
  .menu-top {
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: var(--header-height);
    flex-shrink: 0;
    padding: env(safe-area-inset-top, 0px) 8px 0 max(8px, env(safe-area-inset-left, 0px));
    background: #fff;
  }
  .mobile-menu nav { padding-inline: var(--mobile-left) 16px; }
  .mobile-menu nav a { min-height: 64px; font-size: 24px; padding-block: 14px; }
  .menu-contact { min-height: 64px; padding: 20px 16px 20px var(--mobile-left); flex-shrink: 0; }

  .contact-view {
    padding: calc(80px + env(safe-area-inset-top, 0px)) var(--mobile-right) calc(80px + env(safe-area-inset-bottom, 0px)) var(--mobile-left);
  }
  .contact-view > .close-button {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
  }
  #contact-email { max-width: 100%; font-size: clamp(20px, 6.2vw, 28px); overflow-wrap: anywhere; }
  .notice { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); font-size: 14px; }

  .outline-button:active { color: #fff; background: #111; }
  .menu-toggle:active, .close-button:active, .mobile-menu nav a:active, .menu-contact:active, .service-tabs button:active { background: #f1f1f1; }

  @media (hover: none) {
    .site-header a:hover, footer a:hover, .fm-episode a:hover, #contact-email:hover { text-decoration: none; }
    .service-tabs button:hover { color: var(--muted); }
    .service-tabs button[aria-selected="true"]:hover { color: var(--ink); }
  }
}

/* Keep provider controls at least 300px wide on the smallest phones. */
@media (max-width: 359px) {
  .embed-wrap { margin-inline: calc(-1 * var(--mobile-left)) calc(-1 * var(--mobile-right)); }
  .embed-note { padding-inline: var(--mobile-left) var(--mobile-right); }
}
