/*
 * Shared phone layout, including iPhone 16 Pro / Pro Max and newer sizes.
 * Match the available CSS viewport, rather than a particular device name.
 * Load after the legacy page styles: Safari must never inherit keep-all.
 */
@media screen and (max-width: 767px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body { min-width: 0; padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }

  :is(.home, .inner-page) :is(h1, h2, h3, h4, p, li, dt, dd, th, td, figcaption) {
    word-break: normal !important;
    overflow-wrap: anywhere !important;
    line-break: strict;
  }

  :is(.home, .inner-page) :is(h1, h2, h3, h4) { text-wrap: balance; }
  .inner-page .main-content :is(section, div, article, figure, ul, ol, li, dl, dt, dd) { min-width: 0; }
  .inner-page :is(.main-content, .section-block, .page-intro) { width: 100%; max-width: 100%; min-width: 0; }
  .inner-page .main-content :is(img, video, iframe) { max-width: 100%; }

  /* Zero minimum tracks stop long Japanese text expanding a whole grid. */
  .inner-page .main-content :is(
    .step-grid, .prep-grid, .card-grid, .policy-grid, .class-grid,
    .access-grid, .checkup-grid, .care-cards-grid, .facility-grid,
    .merit-grid, .meal-grid, .meal-grid--link, .meal-gallery,
    .doctor-profile-wrap, .split-layout, .feature-box, .highlight-banner,
    .hours-grid, .timeline, .timeline-item
  ),
  .inner-page .main-content [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 22px;
    min-width: 0;
    max-width: 100%;
  }

  .inner-page .main-content [class$="-card"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 22px;
  }

  .inner-page .section-block { padding: 48px 22px; }
  .inner-page .section-head { margin-bottom: 28px; }
  .inner-page .section-h2 {
    font-size: clamp(21px, 5.6vw, 25px);
    line-height: 1.75;
    letter-spacing: .04em;
  }
  .inner-page .heading-note { display: block; font-size: .82em; margin-top: 5px; }
  .inner-page .main-content :is(p, li, dt, dd) { line-height: 2; letter-spacing: .035em; }
  .inner-page .main-content :is(.step-title, .card-title, .care-card-title, .class-title) {
    font-size: 19px;
    line-height: 1.75;
    letter-spacing: .035em;
  }
  .inner-page .reserve-box { min-width: 0; padding: 22px; }
  .inner-page .reserve-box h3 { font-size: 19px; line-height: 1.8; }
  .inner-page .reserve-steps { padding-left: 1.4em; }
  .inner-page .main-content :is(.btn-tel, .btn-detail, .btn-primary) {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.8;
  }
  .inner-page .main-content :is(th, td) { white-space: normal; }
  .inner-page .main-content table { max-width: 100%; }
  .inner-page .main-content :is(.table-wrap, .table-scroll, .hours-table-wrap) {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Desktop copy line breaks should not create short orphan lines on phones. */
  br.pc-br,
  .home :is(.about-copy, .team-copy, .stay-editorial-copy, .doctor-copy, .support-photo-copy) p br,
  .home :is(.about-copy, .team-copy, .stay-editorial-copy, .doctor-copy, .support-photo-copy) h2 br {
    display: none !important;
  }
  .home .care-photo-grid { grid-template-columns: minmax(0, 1fr); }
  .home .care-photo-card h3 { min-width: 0; gap: 12px; }
  .home .care-photo-card h3 span { flex-shrink: 0; }
  .home .text-link { min-width: 0; max-width: 100%; gap: 20px; }
  .home .n-quick-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .n-header { width: 100%; min-width: 0; }
  .n-header-brand { min-width: 0; }
  .n-header .n-brand strong, .n-header-tel { white-space: nowrap; }
  .n-mobile-nav { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
  .n-bottom-bar {
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}
