/* Phone layout only. Preserve all existing styles at 768px and above. */
@media screen and (max-width: 767px) {
  /* Let the content determine the hero height instead of reserving an empty band. */
  body.home-redesign-page .home-hero__content {
    min-height: 0;
    height: auto;
    padding-top: 36px;
    padding-bottom: 32px;
  }
  body.home-redesign-page .home-hero__copy { min-width: 0; width: 100%; }
  body.home-redesign-page .home-hero h1 {
    max-width: 100%;
    font-size: clamp(30px, 8.2vw, 36px);
    line-height: 1.25;
    letter-spacing: -.025em;
    text-wrap: balance;
  }
  body.home-redesign-page .home-hero h1 > span,
  body.home-redesign-page .home-hero h1 > span:first-child {
    display: inline;
    white-space: normal;
    word-break: normal;
  }
  body.home-redesign-page .home-hero h1 wbr { display: none; }
  body.home-redesign-page .home-hero h1 .home-hero__phrase { display: inline-block; }
  body.home-redesign-page .home-hero__identity {
    max-width: 31em;
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: .025em;
    margin-bottom: 16px;
  }
  body.home-redesign-page .home-hero__actions { margin-top: 24px; }

  /* Keep every footer destination and 44px touch targets, use the empty second column. */
  html body .site-footer-v3 .site-footer-v3__main { min-height: 0; }
  html body .site-footer-v3 .site-footer-v3__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
    padding-block: 24px 20px;
  }
  html body .site-footer-v3__brand { grid-column: 1 / -1; }
  html body .site-footer-v3__brand-name { font-size: 20px; line-height: 1.4; }
  html body .site-footer-v3 .site-footer-v3__social { margin-top: 8px; flex-wrap: wrap; gap: 4px 12px; }
  html body .site-footer-v3__social a { min-height: 44px; font-size: 12px; }
  html body .site-footer-v3__links { gap: 0; }
  html body .site-footer-v3__links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    width: 100%;
    font-size: 14px;
    line-height: 1.6;
  }
  html body .site-footer-v3__group:last-child {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 1px solid var(--site-footer-v3-border, #343434);
  }
  html body .site-footer-v3__group:last-child .site-footer-v3__links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
  }
  html body .site-footer-v3__legal-inner { gap: 2px; padding-block: 12px; }

  /* Five sibling sections retain the same order on every knowledge page. */
  html body .knowledge-sections {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }
  html body .knowledge-sections a {
    min-width: 0;
    min-height: 44px;
    padding: 8px 4px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
  }
}

/* Mobile-only refinements for public content. No desktop rules. */
@media (max-width: 767px) {
  /* The original toggle hid the old series/year controls but left the newer
     taxonomy rows visible. Keep both sets on the same existing open state. */
  .catalog-single-type-page .single-type-toolbar:not(.is-filter-open) ~ .taxonomy-filters {
    display: none;
  }
  .catalog-single-type-page .single-type-toolbar {
    grid-template-columns: minmax(0, 1fr) 68px;
    align-items: end;
    gap: 10px;
  }
  .catalog-single-type-page .single-type-toolbar > label {
    grid-column: 1 / -1;
  }
  .catalog-single-type-page .single-type-toolbar .catalog-search {
    min-width: 0;
  }
  .catalog-single-type-page .single-type-filter-toggle {
    min-height: 44px;
  }
  .catalog-single-type-page .single-type-toolbar select,
  .catalog-single-type-page .taxonomy-filters select,
  .knowledge-round4-page .round4-index-toolbar input,
  .knowledge-round4-page .round4-index-toolbar select,
  .knowledge-round4-page .polish-filter-dialog select {
    font-size: 16px;
  }
  /* Remove the old diagram's left gutter; each topic is now a full-width link. */
  html[data-knowledge-navigation-v2] .knowledge-map-view .knowledge-map__nodes {
    padding: 10px 0 0;
    gap: 6px;
  }
  html[data-knowledge-navigation-v2] .knowledge-map-view .knowledge-map__node {
    min-height: 44px;
    padding: 10px 12px;
    align-items: center;
  }
  html[data-knowledge-navigation-v2] .knowledge-map-view .knowledge-map__node-copy {
    display: block;
  }
  /* Formula controls remain readable and usable by touch, including iOS inputs. */
  html[data-encyclopedia-closure] .equation-head {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  html[data-encyclopedia-closure] .formula-actions {
    flex: 1 1 240px;
    max-width: 100%;
    gap: 8px;
  }
  html[data-encyclopedia-closure] .formula-actions select {
    flex: 1 1 140px;
    width: auto;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  html[data-encyclopedia-closure] .formula-actions .button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }
  html[data-encyclopedia-closure] #catalog-search,
  html[data-encyclopedia-closure] #global-search,
  html[data-encyclopedia-closure] #copy-content {
    min-height: 44px;
    font-size: 16px;
  }
  html[data-encyclopedia-closure] .chapter-tabs button {
    min-height: 44px;
  }
}

/* Mobile only: preserve the application and workbench desktop layouts. */
@media (max-width: 767px) {
  /* Account mode controls must not shrink each Chinese label into two lines. */
  .platform-web .flex.items-center.justify-between.gap-3 > .inline-flex.rounded-xl {
    flex-shrink: 0;
    align-self: flex-start;
  }
  .platform-web .flex.items-center.justify-between.gap-3 > .inline-flex.rounded-xl > button {
    min-width: 48px;
    min-height: 44px;
    white-space: nowrap;
  }
  .platform-web form input:not([type="checkbox"]):not([type="range"]):not([type="hidden"]) {
    font-size: 16px;
  }
  .platform-web > .fixed.inset-0 > .max-w-md > .flex.items-center.justify-between > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin-right: -10px;
  }
  /* Result-section actions must wrap inside the calculator card, not be clipped. */
  .platform-web .flex.items-center.gap-3.border-b.border-gray-100.p-4 {
    flex-wrap: wrap;
  }
  .platform-web .flex.items-center.gap-3.border-b.border-gray-100.p-4 > button {
    flex-basis: 100%;
    min-height: 32px;
  }
  .platform-web .flex.items-center.gap-3.border-b.border-gray-100.p-4 > .shrink-0 {
    width: 100%;
    min-width: 0;
  }
  .platform-web .flex.items-center.gap-3.border-b.border-gray-100.p-4 > .shrink-0 button {
    min-height: 44px;
    max-width: 100%;
  }

  /* The spectroscopy workspace has a long name plus two independent actions. */
  #root .min-h-screen.flex-col.bg-slate-100 > header {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header > .min-w-0 {
    flex-basis: 100%;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header .truncate {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.5;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header .truncate > span {
    display: inline-block;
    margin-left: 0;
    margin-right: 8px;
    vertical-align: middle;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header > .shrink-0 {
    margin-left: auto;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header button {
    min-height: 44px;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > header button[aria-label="返回工具箱"] {
    width: 44px;
  }
  #root .min-h-screen.flex-col.bg-slate-100 > main > aside > .space-y-4 > .flex.gap-2.overflow-x-auto > button {
    min-height: 44px;
  }
}
@media (max-width: 359px) {
  /* Keep all four workspace modes visible on the narrowest phones. */
  #root .min-h-screen.flex-col.bg-slate-100 > main > aside > .space-y-4 > .flex.gap-2.overflow-x-auto {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }
}

/* Public service pages: phone layout only. Desktop rules remain untouched. */
@media screen and (max-width: 767px) {
  /* A forced desktop line break left a single-character line on phones. */
  .round6-about-hero h1 {
    text-wrap: balance;
  }
  .round6-about-hero h1 br {
    display: none;
  }
  .round6-current-capabilities__grid {
    gap: 20px;
  }
  .round6-current-capability {
    min-height: 0;
    align-content: start;
    gap: 18px;
    padding: 20px 0;
  }

  /* Keep the template and its action readable at 320 CSS pixels. */
  .round6-project-page .round6-contact-card__body {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .round6-project-page .round6-contact-card__qr {
    width: 132px;
    justify-self: center;
  }
  .round6-project-page .round6-contact-primary {
    padding: 10px 12px;
    font-size: 14px;
  }
  .round6-project-page .polish-contact-template textarea {
    width: 100%;
    min-height: 150px;
    font-size: 16px;
    line-height: 1.65;
  }
  .round6-project-page .polish-contact-template button {
    min-height: 44px;
  }

  /* The desktop vertical note becomes a normal label below the contact QR. */
  .round6-project-page .cooperation-contact {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 14px;
  }
  .round6-project-page .round1-contact-qr-block {
    width: min(220px, 100%);
  }
  .round6-project-page .cooperation-contact__note {
    width: min(260px, 100%);
    display: grid;
    grid-template-columns: 3.5em minmax(0, 1fr);
    min-height: 44px;
    letter-spacing: normal;
    line-height: 1.5;
  }
  .round6-project-page .cooperation-contact__note span {
    min-width: 0;
    writing-mode: horizontal-tb;
    padding: 8px;
  }
  .round6-project-page .cooperation-detail-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
  }

  /* Disclosure panels stay in reading order instead of jumping below links. */
  .pricing-page .pricing-more {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .pricing-page .pricing-more details[open] {
    order: 0;
  }
  .pricing-page .pricing-more summary {
    min-height: 48px;
    font-size: 14px;
  }
  .pricing-page .pricing-more__body {
    overflow-wrap: anywhere;
  }

  /* Engineering diagrams must remain complete instead of being center-cropped. */
  .report-samples-page #contentState article img[src^="/assets/images/cases/"],
  [data-page-kind="report-sample-detail"] #contentState img[src^="/assets/images/cases/"] {
    height: auto;
    width: 100%;
    object-fit: contain;
  }
  .report-samples-page #contentState article > div:last-child {
    padding: 20px !important;
  }

  /* One shared header, then a compact return link for the sample detail. */
  body[data-page-kind="report-sample-detail"] {
    display: flex;
    flex-direction: column;
  }
  [data-page-kind="report-sample-detail"] > .catalog-header {
    order: -2;
  }
  [data-page-kind="report-sample-detail"] > nav {
    position: static;
    order: -1;
    z-index: auto;
    box-shadow: none;
  }
  [data-page-kind="report-sample-detail"] > nav > div {
    height: auto;
    min-height: 44px;
    justify-content: flex-start;
    padding: 6px 18px;
  }
  [data-page-kind="report-sample-detail"] > nav > div > a:first-child {
    display: none;
  }
  [data-page-kind="report-sample-detail"] > nav > div > a:last-child {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
  }
  [data-page-kind="report-sample-detail"] > main {
    width: 100%;
    padding: 24px 18px 40px !important;
  }
  /* Title and overview precede the diagram; the file remains after the body. */
  [data-page-kind="report-sample-detail"] #contentState > section {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  [data-page-kind="report-sample-detail"] #contentState > section > aside {
    display: contents;
  }
  [data-page-kind="report-sample-detail"] #contentState > section > aside > section:first-child {
    order: -1;
  }
  [data-page-kind="report-sample-detail"] #contentState > section > aside > section {
    margin: 0;
  }
  [data-page-kind="report-sample-detail"] #contentState :is(.p-8, .p-7) {
    padding: 20px !important;
  }
  [data-page-kind="report-sample-detail"] #contentState :is(.rounded-\[28px\], .rounded-\[30px\]) {
    border-radius: 12px !important;
    box-shadow: none;
  }
}

@media screen and (max-width: 767px) {
  /* Focusing the first link while max-height animates from 0 scrolls it under the header. */
  html body.home-redesign-page .home-redesign-header .mobile-nav {
    transition: none;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner {
    gap: 0;
    padding-block: 12px 16px;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner > a,
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner .knowledge-nav-disclosure > a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 9px 0;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: normal;
    text-decoration: none;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner > a {
    border-bottom: 1px solid #d7d8d5;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner > .mobile-login-trigger {
    width: 100%;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner > .mobile-toolbox-trigger {
    justify-content: center;
    width: 100%;
  }
  html body.home-redesign-page .home-redesign-header .mobile-nav-inner .knowledge-nav-disclosure__menu a {
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: normal;
  }
}
