/* Phone layout for the public RTM header, landing pages and findings chooser.
   Load after the existing site and Worker styles. The native menu keeps its
   original .open state, event handlers, labels and links. */
@media (max-width: 767px) {
  body:not(.rtm-lab-page) :is(.research-strip, .rtm-research-strip) {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-sizing: border-box;
  }

  body:not(.rtm-lab-page) :is(.research-strip-inner, .rtm-research-strip-inner) {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center;
    column-gap: .6rem !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    padding-left: max(.5rem, env(safe-area-inset-left)) !important;
    padding-right: max(.5rem, env(safe-area-inset-right)) !important;
    overflow: visible !important;
    box-sizing: border-box;
  }

  body:not(.rtm-lab-page) :is(.research-strip-inner, .rtm-research-strip-inner) > * {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: 100%;
    height: auto !important;
    white-space: normal !important;
  }

  body:not(.rtm-lab-page) :is(.research-strip-inner, .rtm-research-strip-inner) > :is(.research-strip-label, .rtm-research-label) {
    position: static !important;
  }

  body:not(.rtm-lab-page) header.header {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* One row whenever it fits. At large reading sizes or narrow widths the
     controls move together to a new row instead of shrinking past an edge. */
  body:not(.rtm-lab-page) header.header > .header-inner {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    gap: .25rem .6rem !important;
    padding: .375rem max(.625rem, env(safe-area-inset-right)) .375rem max(.625rem, env(safe-area-inset-left)) !important;
  }

  body:not(.rtm-lab-page) header.header .brand {
    display: flex !important;
    flex: 0 1 auto !important;
    align-items: center;
    min-width: 0 !important;
    max-width: 100%;
  }

  body:not(.rtm-lab-page) header.header .brand > span {
    display: block !important;
    min-width: 0;
    white-space: normal !important;
  }

  body:not(.rtm-lab-page) header.header .brand strong {
    display: block !important;
    overflow-wrap: anywhere;
    white-space: normal !important;
    line-height: 1.2;
  }

  body:not(.rtm-lab-page) header.header .header-actions {
    display: flex !important;
    flex: 0 1 auto !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: .25rem !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  body:not(.rtm-lab-page) header.header .header-actions :is(.v13-lang-btn, .v13-command-btn, .icon-btn, .v13-menu-btn, .rtm-personal-nav-cta) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box;
    flex: 0 0 auto;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 100%;
  }

  body:not(.rtm-lab-page) header.header .header-actions .rtm-personal-nav-cta {
    flex-shrink: 1 !important;
    width: auto !important;
    height: auto !important;
    white-space: normal !important;
  }

  body:not(.rtm-lab-page) nav#v13MobileNav.v13-mobile-nav.open {
    display: grid !important;
    position: static !important;
    flex: 1 0 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: none !important;
    box-sizing: border-box;
    margin: 0 !important;
    gap: .25rem !important;
    overflow: visible !important;
  }

  body:not(.rtm-lab-page) nav#v13MobileNav.v13-mobile-nav.open a {
    white-space: normal !important;
    overflow-wrap: anywhere;
    min-width: 0;
    min-height: 44px !important;
    font-size: max(.875rem, 14px) !important;
    text-align: center;
  }

  /* Landing-page diagrams scale in both directions with their own frame. */
  body.portal-home .rtm-v144-home,
  body.portal-home .v261-section > .container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  body.portal-home :is(.rtm-v144-hero-grid, .v266-hero-grid, .rtm-v144-cards, .v262-case-showcase, .v261-three, .v261-workflow, .v261-tools-layout, .v261-mini-tools, .v261-author-strip, .v261-research-grid, .v261-case-grid) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }

  body.portal-home :is(.rtm-v144-copy, .rtm-v144-card, .v262-featured-copy, .v262-side-cases, .v261-lab-card, .v261-case-visual) {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
    overflow-wrap: break-word;
  }

  body.portal-home .rtm-v144-home .rtm-v144-art {
    width: min(100%, 30rem) !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-inline: auto !important;
    background-size: contain !important;
  }

  body.portal-home :is(.rtm-v144-cta, .v261-hero-actions, .v261-research-links) {
    display: flex !important;
    flex-wrap: wrap !important;
    min-width: 0;
    max-width: 100%;
  }

  body.portal-home :is(.rtm-v144-cta, .v261-hero-actions, .v261-research-links) a {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    white-space: normal !important;
  }

  /* Findings uses a different header. Keep the archive links on screen,
     including the Hebrew / English switch and the home link if present. */
  body header.site-head {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    justify-content: space-between;
    gap: .4rem .625rem !important;
    box-sizing: border-box;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    padding-inline: .625rem !important;
  }

  body header.site-head .wordmark {
    flex: 0 1 auto;
    min-width: 0 !important;
    max-width: 100%;
    white-space: normal !important;
  }

  body header.site-head > nav {
    order: 3;
    display: flex !important;
    flex: 1 0 100% !important;
    flex-wrap: wrap !important;
    gap: .25rem .5rem !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body header.site-head > nav > a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 0;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-sizing: border-box;
  }

  body .rb-hub .rb-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body .rb-hub .rb-choice {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: auto !important;
    gap: .625rem;
  }

  body .rb-hub .rb-copy {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body .rb-hub .rb-cta {
    max-width: 100%;
    white-space: normal;
    box-sizing: border-box;
  }
}


@media (max-width: 767px) {
  body.gematria-workspace-v150 #calculator .calc-main > .control-row {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
  }
  body.gematria-workspace-v145 .seo-table-wrap > table.seo-letter-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }
  body.gematria-workspace-v145 .seo-table-wrap > .seo-letter-table :is(td, th) {
    padding-inline: .2rem !important;
    overflow-wrap: anywhere;
  }
  body.personal-analysis-page .pa-contact-email {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.guide-home .rtm-model-page .rtm-law .rtm-section-body {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  body .content-card > table.method-table {
    width: 100%;
    table-layout: fixed;
    overflow-wrap: anywhere;
  }
  body header.header > .header-inner > .mobile-menu-btn {
    box-sizing: border-box;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
  }
}
@media (max-width: 780px) {
  body .archive #archive-image-button {
    width: min(100%, 720px);
  }
}

/* Existing shortcut links are inserted into the public shell after it loads. */
@media (max-width: 767px), (max-width: 932px) and (max-height: 500px) and (pointer: coarse) {
  body:not(.portal-home):not(.rtm-lab-page) > :is(nav#v154MobileQuickbar, header.header, .research-strip, .rtm-research-strip) {
    box-sizing: border-box;
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-left: max(clamp(14px, 4vw, 20px), env(safe-area-inset-left, 0px)) !important;
    margin-right: max(clamp(14px, 4vw, 20px), env(safe-area-inset-right, 0px)) !important;
  }
  body:not(.portal-home):not(.rtm-lab-page) > header.header > .header-inner,
  body:not(.portal-home):not(.rtm-lab-page) > :is(.research-strip, .rtm-research-strip) > :is(.research-strip-inner, .rtm-research-strip-inner) {
    box-sizing: border-box;
    display: flex !important;
    flex-wrap: wrap !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin-inline: 0 !important;
    padding-inline: 6px !important;
  }
  /* This shortcut bar is inserted by the site's JavaScript after load. */
  body:not(.portal-home):not(.rtm-lab-page) > nav#v154MobileQuickbar.v154-mobile-quickbar {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 82px), 1fr)) !important;
    gap: 6px !important;
    padding: 6px !important;
    overflow: visible !important;
    scroll-snap-type: none !important;
    direction: inherit !important;
  }

  body:not(.portal-home):not(.rtm-lab-page) > #v154MobileQuickbar > :is(a, button) {
    min-width: 0 !important;
    min-height: 44px !important;
    box-sizing: border-box;
    padding: 4px 6px !important;
    white-space: normal !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
    text-align: center;
  }
}

@media (max-width: 480px) {
  body:not(.portal-home):not(.rtm-lab-page) > nav#v154MobileQuickbar.v154-mobile-quickbar {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  body:not(.portal-home):not(.rtm-lab-page) > #v154MobileQuickbar > :last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
  }
}
