/* Content-sized mobile layouts shared by legacy pages and the resource hub. */
.diagnostic-loading { max-width: 580px; }
.diagnostic-loading h3 { font-size: 1.5rem; line-height: 1.3; margin-bottom: 18px; }
.diagnostic-loading p { color: var(--muted); line-height: 1.65; margin-bottom: 22px; }
.hub-split > *, .hub-question > *, .form-grid > *, .fields-row > *,
.hub-step > *, .case-timeline li > * { min-width: 0; }
.hub-page :is(h1,h2,h3), .case-card h2, .form-heading h3 {
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* Collapse the hub navigation before the links crowd the brand and languages. */
@media (max-width: 1120px) {
  .hub-page .header .menu-toggle {
    display: flex;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-left: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #ffffff29;
    border-radius: 12px;
    background: #ffffff12;
    padding: 10px;
  }
  .hub-page .header .menu-toggle span { display: block; width: 21px; height: 2px; background: #fff; }
  .hub-page .header nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 16px 24px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #11182f;
    border-top: 1px solid #ffffff20;
    max-height: calc(100dvh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .hub-page .header nav.open { display: flex; }
  .hub-page .header nav a { padding: 14px; min-height: 44px; font-size: 15px; }
  .hub-page .header .language-switch { margin-left: auto; }
}

@media (max-width: 860px) {
  .diagnostic-shell {
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: auto auto;
    align-content: start;
    min-height: 0;
    height: auto;
  }
  .diagnostic-aside {
    align-self: start;
    min-width: 0;
    min-height: 0;
    padding: 20px 16px;
  }
  .diagnostic-aside :is(.aside-title,.aside-bottom) { display: none; }
  .diagnostic-aside ol {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    align-items: start;
    gap: 8px;
  }
  .diagnostic-aside li {
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    line-height: 1.4;
    color: #adb3ce;
  }
  .diagnostic-aside li > span { width: 34px; height: 34px; flex: 0 0 34px; font-size: 12px; }
  .diagnostic-aside li > div { max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
  .diagnostic-aside li:not(:last-child)::after { top: 17px; left: calc(50% + 23px); width: calc(100% - 38px); height: 1px; }
  .diagnostic-main { min-width: 0; padding: 28px 24px; }
  .header nav { top: 100%; }
  .diagnostic-section, #contact, .hub-result, #stage-title { scroll-margin-top: 100px; }
  .field input:not([type="radio"]):not([type="checkbox"]),
  .field textarea, .hub-form input:not([type="radio"]):not([type="checkbox"]),
  .hub-form textarea, .brief-text { font-size: 16px; }
  .field, .field input, .field textarea, .hub-form input, .hub-form textarea { min-width: 0; max-width: 100%; }
  .hub-form fieldset, .diagnostic-main fieldset { min-width: 0; }
  .hub-form legend, .field legend { max-width: 100%; white-space: normal; }
  body .hub-consent { max-height: calc(100dvh - 32px); overflow-y: auto; }
}

@media (max-width: 600px) {
  .diagnostic-aside { padding: 18px 10px; }
  .diagnostic-aside ol { gap: 5px; }
  .diagnostic-aside li { font-size: 11px; }
  .diagnostic-main { padding: 24px 18px; }
  .form-heading { flex-direction: column-reverse; align-items: flex-start; gap: 12px; }
  .form-heading h3 { font-size: clamp(1.3rem,5.8vw,1.65rem); line-height: 1.25; margin: 0; }
  .stage-counter { font-size: 11px; white-space: nowrap; }
  .form-intro { margin-top: 14px; line-height: 1.65; }
  .fields-row, .choice-grid, .process-choices { grid-template-columns: minmax(0,1fr); }
  .choice { align-items: flex-start; line-height: 1.5; }
  .choice input { flex-shrink: 0; margin-top: 3px; }
  .choice > span { min-width: 0; }
  .form-actions { flex-direction: column; align-items: stretch; gap: 12px; }
  .form-actions .button, .form-actions .back-button { width: 100%; min-height: 48px; white-space: normal; }
  .form-actions .left-caption { max-width: none; }
  .process-tabs { flex-wrap: wrap; gap: 8px; }
  .process-tab { max-width: 100%; white-space: normal; line-height: 1.5; }
  .result-card-top { flex-wrap: wrap; }
  .result-card-top > div:not(.score) { flex: 1 1 140px; min-width: 0; }
  .results-footer { flex-wrap: wrap; gap: 12px; }
  .results-footer button { min-height: 44px; }
  .hub-actions, .document-actions { min-width: 0; }
  .hub-actions .button, .document-actions > *, .download-actions .button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .document-actions > * { flex: 1 1 100%; }
  .document-actions .button { width: 100%; }
  .hub-page .hero-hub h1 { font-size: clamp(2rem,8.5vw,2.7rem); }
  .hub-table-wrap, .case-table-scroll, .hub-flow { max-width: 100%; overscroll-behavior-x: contain; }
  .hub-flow article { flex-shrink: 0; }
  .hub-form .hub-mode label { flex-basis: 100%; }
  .case-metrics { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .case-metrics dt { min-height: 0; }
  .case-metrics dd { margin-top: 6px; }
  .case-metrics > div + div { padding-top: 18px; border-top: 1px solid #dce1ee; }
  .case-card-numbers { gap: 12px; }
  .case-contact .button, .case-hero-actions .button { max-width: 100%; white-space: normal; }
  dialog { max-height: calc(100dvh - 32px); }
}

/* Keep all three header controls visible on narrow phones. */
@media (max-width: 480px) {
  .header, .hub-page .header { height: auto; min-height: 74px; }
  .header .nav-wrap { min-height: 74px; padding-inline: 14px; gap: 7px; }
  .header .brand { min-width: 0; flex-shrink: 1; gap: 6px; font-size: clamp(10px,2.8vw,13px); white-space: nowrap; }
  .header .brand svg { width: 22px; height: 22px; flex: 0 0 22px; }
  .header .language-switch { margin-left: auto; padding: 2px; gap: 0; }
  .header .language-switch :is(a,button) { min-width: 28px; min-height: 38px; padding: 4px; font-size: 11px; }
  .header .menu-toggle { flex: 0 0 44px; width: 44px; height: 44px; margin-left: 0; }
  .header nav { top: 100%; max-height: calc(100dvh - 82px); }
  .hub-page .header nav { max-height: calc(100dvh - 82px); }
  .hub-slots { grid-template-columns: minmax(0,1fr); }
}
