/* Mobile layout corrections; desktop composition is preserved. */
@media (max-width: 850px) {
  html { scroll-padding-top: 16px !important; }
  html body > .topbar,
  html body .portfolio-reader > .portfolio-contents {
    position: static !important;
    top: auto !important;
  }
  html body main[id], html body main [id] { scroll-margin-top: 16px !important; }
  html body:has(.footer .case-return-top) { padding-bottom: 0 !important; }
  html body:has(.footer .case-return-top) > .footer {
    position: static !important;
    min-height: 0 !important;
    height: 0;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none !important;
    transition: none !important;
  }
  html body:has(.footer .case-return-top) > .footer .footer-inner,
  html body:has(.footer .case-return-top) > .footer .footer-copyright { display: none !important; }
  html body:has(.footer .case-return-top) > .footer .case-return-top {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    transform: none !important;
    z-index: 1000;
  }
  html body .case-return-top .case-return-top-link {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    gap: 0;
    font-size: 0;
    box-shadow: 0 2px 12px #0005;
  }
  html body .case-return-top .case-return-top-link span { font-size: 22px; }
  html body:not([data-page-view="home"]) .portfolio-reader > .portfolio-contents {
    max-height: 64px !important;
    padding-block: 4px !important;
    overflow: hidden !important;
  }
  html body:not([data-page-view="home"]) .portfolio-contents nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 18px !important;
    max-height: 56px;
    overflow-x: auto !important;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
  }
  html body:not([data-page-view="home"]) .portfolio-contents nav > a {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    box-sizing: border-box;
  }
  html body:not([data-page-view="home"]) .portfolio-contents-title { display: none; }
}
@media (max-width: 600px) {
  html { scrollbar-gutter: auto; }
  html body > .topbar .site-nav {
    width: calc(100% - 32px);
    height: auto;
    min-height: 108px;
    padding-block: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 38px 44px;
    gap: 10px 8px;
    align-items: center;
  }
  html body > .topbar .brand-group { grid-column: 1; grid-row: 1; }
  html body > .topbar .brand-lockup span { font-size: 18px; white-space: normal; max-width: 140px; }
  html body > .topbar .navlinks {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
  }
  html body > .topbar .nav-contact {
    grid-column: 2;
    grid-row: 1;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 12px;
  }
  html body > .topbar .header-menu-control .header-menu-trigger {
    min-width: 44px;
    width: 44px;
  }
  html body > .topbar .header-menu-group { min-width: 0; }
  html body > .topbar .header-menu-panel {
    box-sizing: border-box;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - var(--portfolio-header-height, 108px) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  html body .portfolio-reader > .portfolio-contents { padding-inline: 16px; }
  html body #top.hero { padding-block: 24px; }
  html body #top.hero .hero-grid { gap: 24px; padding: 20px; }
  html body #top.hero h1 {
    font-size: clamp(26px, 7.8vw, 40px);
    line-height: 1.12;
    overflow-wrap: anywhere;
  }
  html body #top.hero .hero-summary { font-size: 16px; line-height: 1.55; }
  html body main h1, html body main h2 { overflow-wrap: break-word; }
  html body .resume-fact { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; }
  html body .resume-fact > div { min-width: 0; }
  html body .resume-fact h2 { overflow-wrap: anywhere; }
  html body main :is(p, li) { overflow-wrap: break-word; }
  html body main :is(video, iframe) { max-width: 100%; }
  html body #skills .skills-composition-grid { grid-template-columns: minmax(0, 1fr); }
  html body #skills .resume-accordion-list { min-width: 0; max-width: 100%; }
  html body #skills .resume-accordion { min-width: 0; max-width: 100%; }
  html body #skills .resume-accordion summary { overflow-wrap: anywhere; }
  html body #skills .skills-tool-row { min-width: 0; max-width: 100%; }
  html body #skills .skills-tool-row li { min-width: 0; max-width: 100%; }
  html body #skills .skills-tool-row li > span:last-child { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  html body #skills .resume-accordion-body :is(p, li, span, a),
  html body #skills .skills-tool-agents {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  html body dialog {
    box-sizing: border-box;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  html body :is(.gallery-prev, .gallery-next, .viewer-prev, .viewer-next) {
    min-width: 44px;
    min-height: 44px;
  }
}
