/* Keep directory pagination geometrically centered on every result page. */
@media (min-width: 761px) {
  html[class] body .pagination-area {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) !important;
    align-items: center !important;
    width: 100% !important;
  }
  html[class] body .pagination-area > p {
    grid-column: 1 !important;
    justify-self: start !important;
    margin: 0 !important;
  }
  html[class] body .pagination-area > .pagination {
    grid-column: 2 !important;
    justify-self: center !important;
    justify-content: center !important;
    align-items: center !important;
  }
}

/* Desktop shell alignment: header/footer match the homepage without touching tool layouts. */
@media (min-width: 761px) {
  html[class] body .directory-header > .header-inner,
  html[class] body .directory-footer > .footer-inner {
    box-sizing: border-box !important;
    width: min(calc(100% - 96px), 1376px) !important;
    max-width: 1376px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* Authoritative mobile header controls — keep this block last. */
@media (max-width: 760px) {
  html[class] body .page > .topbar .top-actions .language-switcher > button.language-switcher__button,
  html[class] body .directory-header .header-inner .directory-actions .language-switcher > button.language-switcher__button {
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) 14px !important;
    place-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 44px !important;
    padding: 0 8px !important;
    gap: 5px !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-current-flag {
    grid-column: 1 !important;
    display: grid !important;
    place-items: center !important;
    width: 22px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-current-flag + [data-dir-icon="globe"] {
    display: none !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-switcher__label {
    grid-column: 2 !important;
    justify-self: stretch !important;
    width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > [data-dir-icon="chevron-down"] {
    grid-column: 3 !important;
    display: grid !important;
    place-items: center !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.menu-toggle,.mobile-menu-btn) {
    display: grid !important;
    place-items: center !important;
    box-sizing: border-box !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 8px !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.menu-toggle,.mobile-menu-btn) > svg {
    place-self: center !important;
    margin: 0 !important;
  }
}

@media (max-width: 760px) {
  html, body { width: 100% !important; max-width: 100% !important; overflow-x: clip !important; }
  body * { min-width: 0; }

  body { font-size: 15px !important; line-height: 1.55 !important; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  main h1 { font-size: clamp(30px, 8.8vw, 36px) !important; line-height: 1.16 !important; letter-spacing: -.02em !important; }
  main h2 { font-size: clamp(20px, 5.8vw, 24px) !important; line-height: 1.28 !important; }
  main h3 { font-size: clamp(17px, 4.8vw, 19px) !important; line-height: 1.34 !important; }
  main :where(p, li, label, small) { line-height: 1.55 !important; }
  main :where(input, select, textarea) { min-height: 44px !important; font-size: 16px !important; }
  main :where(button, .btn, .button, .primary-btn, .secondary-btn) { min-height: 44px; font-size: 14px !important; }

  html[class] body .pagination-area {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
    overflow: visible !important;
    justify-items: stretch !important;
  }
  html[class] body .pagination-area > p {
    width: 100% !important;
    margin: 0 !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
    white-space: normal !important;
  }
  html[class] body .pagination {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(72px, auto) minmax(0, 1fr) !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    overflow: visible !important;
    justify-self: center !important;
  }
  html[class] body .pagination :where(.page-prev, .page-next) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    padding: 0 8px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  html[class] body .pagination .page-number,
  html[class] body .pagination .page-ellipsis { display: none !important; }
  html[class] body .pagination::before {
    content: attr(data-page-summary) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 72px !important;
    min-height: 44px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
  }

  html[class] body .mode-tabs,
  html[class] body .tip-mode-tabs,
  html[class] body .guide-links {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  html[class] body :where(.mode-tabs, .tip-mode-tabs, .guide-links)::-webkit-scrollbar { display: none; }
  html[class] body :where(.mode-tabs, .tip-mode-tabs, .guide-links) > * {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;
    white-space: nowrap !important;
    scroll-snap-align: start;
  }
  html[class] body .tip-preset-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
  }
  html[class] body .tip-preset-row::-webkit-scrollbar { display: none; }
  html[class] body .tip-preset-row > button { flex: 0 0 auto !important; min-width: 64px !important; }
  .tip-stepper, .tip-stepper > * { min-width: 0 !important; max-width: 100% !important; }

  .currency-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
  }
  .currency-tabs::-webkit-scrollbar { display: none; }
  .currency-tabs > button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;
    white-space: nowrap !important;
  }

  .toc-card {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
  }
  .toc-card::-webkit-scrollbar { display: none; }
  .toc-card > a { flex: 0 0 auto !important; width: auto !important; min-width: max-content !important; max-width: none !important; }

  .constants-table,
  .constants-table > div {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .constants-table > div {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }
  .constants-table :where(strong, span) {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
  }

  .perf-badges,
  .perf-badges > span {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .perf-badges > span { padding-block: 10px !important; }
  .perf-badges :where(strong, small) {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .currency-mini-row,
  .currency-mini-row > label,
  .currency-mini-row > label > span {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    white-space: normal !important;
  }
  .currency-results :where(strong, span) {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .tip-field, .tip-stepper { height: auto !important; overflow: visible !important; }
  .tip-stepper { width: 100% !important; display: grid !important; grid-template-columns: 44px minmax(0, 1fr) 44px !important; }
  .tip-stepper input { width: 100% !important; min-width: 0 !important; }

  .performance-page .perf-hero-exact,
  .perf-hero-exact {
    position: relative !important;
    display: block !important;
    inset: auto !important;
    width: min(100%, 330px) !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
    transform: none !important;
    object-fit: contain !important;
  }

  .sci-sidebar, .sci-side-card, .sci-modes { width: 100% !important; max-width: 100% !important; }
  .sci-modes button {
    display: grid !important;
    grid-template-columns: 28px minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .sci-modes button :where(strong, small, span) {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
  }

  html[class] body .related-row,
  html[class] body .related-grid,
  html[class] body:not(.popular-page) .popular-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  html[class] body .related-row::-webkit-scrollbar,
  html[class] body .related-grid::-webkit-scrollbar,
  html[class] body:not(.popular-page) .popular-grid::-webkit-scrollbar { display: none; }
  html[class] body .related-row > *,
  html[class] body .related-grid > *,
  html[class] body:not(.popular-page) .popular-grid > * {
    flex: 0 0 min(82vw, 304px) !important;
    width: min(82vw, 304px) !important;
    min-width: min(82vw, 304px) !important;
    max-width: min(82vw, 304px) !important;
    scroll-snap-align: start;
  }
  :where(.table-wrap, .table-scroll, .schedule-table-wrap, .amortization-table-wrap) {
    max-width: 100% !important;
    overflow-x: clip !important;
  }
}

/* Final header action alignment across home, directory and tool templates. */
@media (max-width: 760px) {
  html[class] body .topbar .top-actions .language-switcher > button.language-switcher__button,
  html[class] body .directory-header .header-inner .directory-actions .language-switcher > button.language-switcher__button {
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) 14px !important;
    place-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 44px !important;
    padding: 0 8px !important;
    gap: 5px !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header)
    button.language-switcher__button > .language-current-flag {
    grid-column: 1 !important;
    display: grid !important;
    place-items: center !important;
    width: 22px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header)
    button.language-switcher__button > .language-current-flag + [data-dir-icon="globe"] {
    display: none !important;
  }
  html[class] body :where(.topbar,.directory-header)
    button.language-switcher__button > .language-switcher__label {
    grid-column: 2 !important;
    justify-self: stretch !important;
    width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  html[class] body :where(.topbar,.directory-header)
    button.language-switcher__button > [data-dir-icon="chevron-down"] {
    grid-column: 3 !important;
    display: grid !important;
    place-items: center !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header)
    :where(.menu-toggle,.mobile-menu-btn) {
    display: grid !important;
    place-items: center !important;
    box-sizing: border-box !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header)
    :where(.menu-toggle,.mobile-menu-btn) > svg {
    place-self: center !important;
    margin: 0 !important;
  }
}

/* Content-only mobile safety layer. Navigation is intentionally untouched. */
@media (max-width: 760px) {
  html[class] body main :where(
    .container,.directory-container,.page-shell,.tool-shell,.dt-wrap,.fc-wrap,
    .chem-container,.dev-container,.uc-wrap,.ut-wrap,.matrix-page
  ) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
  }

  html[class] body main :where(
    .dt-card,.dt-detail,.fc-card,.fc-detail-card,.chem-card,.dev-card,
    .uc-card,.ut-card,.tool-card,.result-card,form,fieldset
  ) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  html[class] body main :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* These rows contain more choices than a phone can show. Keep side-swipe,
     but add a visual edge cue so hidden choices do not look missing. */
  html[class] body main :where(
    .mode-tabs,.currency-tabs,.toc-card,.tip-preset-row,.tip-mode-tabs,
    .guide-links,.quick-tags,.trust-row,.hero-category-chips,
    .browse-categories,.sort-tabs,.category-tabs,.filters
  ) {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 24px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 20px),transparent 100%);
    mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 20px),transparent 100%);
  }
  html[class] body main :where(
    .mode-tabs,.currency-tabs,.toc-card,.tip-preset-row,.tip-mode-tabs,
    .guide-links,.quick-tags,.trust-row,.hero-category-chips,
    .browse-categories,.sort-tabs,.category-tabs,.filters
  )::-webkit-scrollbar { display: none; }
  html[class] body main :where(
    .mode-tabs,.currency-tabs,.toc-card,.tip-preset-row,.tip-mode-tabs,
    .guide-links,.quick-tags,.trust-row,.hero-category-chips,
    .browse-categories,.sort-tabs,.category-tabs,.filters
  ) > * {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
    scroll-snap-align: start;
  }

  html[class] body main :where(.table-wrap,.table-scroll,.schedule-table-wrap,.amortization-table-wrap,pre,.dt-code) {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  html[class] body :where(.footer,.directory-footer,.site-footer) {
    max-width: 100% !important;
    overflow-x: clip !important;
  }
}

/* Final locale-aware mobile polish. Keep this block last: translated pages
   load several legacy template rules with different measurements. */
@media (max-width: 760px) {
  /* Directory search: icon and translated placeholder must never collide. */
  html[class] body .hero-search {
    display: grid !important;
    grid-template-columns: 20px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 0 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html[class] body .hero-search > span {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 0 0 14px !important;
  }

  html[class] body .hero-search > input {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 46px !important;
    padding: 0 14px 0 6px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  html[class] body .hero-search > button {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-height: 44px !important;
    border-radius: 0 0 8px 8px !important;
  }

  /* Translated labels stay on one usable horizontal rail instead of being
     squeezed, wrapped or visually cut in the middle. */
  html[class] body :where(
    .quick-tags, .trust-row, .hero-category-chips, .browse-categories,
    .sort-tabs, .category-tabs, .filters
  ) {
    padding-right: 22px !important;
    scroll-padding-inline: 0 22px;
    -webkit-mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 18px),transparent 100%);
    mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 18px),transparent 100%);
  }

  html[class] body :where(
    .quick-tags, .trust-row, .hero-category-chips, .browse-categories,
    .sort-tabs, .category-tabs, .filters
  ) > * {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
  }

  /* Germanic/Romance translations are often 25–60% longer than English. */
  html:lang(de) body main h1,
  html:lang(fr) body main h1,
  html:lang(it) body main h1,
  html:lang(es) body main h1,
  html:lang(pt) body main h1,
  html:lang(pl) body main h1,
  html:lang(fi) body main h1,
  html:lang(nb) body main h1,
  html:lang(nl) body main h1,
  html:lang(sv) body main h1 {
    font-size: clamp(29px, 8.2vw, 32px) !important;
    line-height: 1.14 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: auto;
  }

  html[class] body main :where(label, .field-label, .fc-field label, .dt-field) {
    overflow-wrap: anywhere;
  }
}

/*
 * AtlasCalc shared layout rhythm
 * Keep each tool's art direction, while making the page frame, controls and
 * reading measure predictable across every template family.
 */
@media (min-width: 99999px) {
  html[class] {
    --atlas-page-width: 1240px;
    --atlas-page-gutter: 32px;
    --atlas-control-height: 44px;
  }

  html[class] body :where(
    .directory-container, .page-shell, .tool-shell, .dt-wrap, .fc-wrap,
    .chem-container, .dev-container, .uc-wrap, .ut-wrap, .matrix-page
  ) {
    box-sizing: border-box !important;
    width: min(var(--atlas-page-width), calc(100% - (var(--atlas-page-gutter) * 2))) !important;
    max-width: var(--atlas-page-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  html[class] body main {
    font-size: 15px;
    line-height: 1.6;
  }

  html[class] body main h1 {
    line-height: 1.12;
    letter-spacing: -.025em;
  }

  html[class] body main h2 { line-height: 1.25; }
  html[class] body main h3 { line-height: 1.32; }

  html[class] body main :where(input:not([type="checkbox"]):not([type="radio"]), select) {
    min-height: var(--atlas-control-height);
  }

  html[class] body main :where(button, .btn, .button, .primary-btn, .secondary-btn) {
    min-height: 42px;
  }

  html[class] body :where(.footer, .directory-footer, .site-footer) > .footer-inner {
    box-sizing: border-box !important;
    width: min(var(--atlas-page-width), calc(100% - (var(--atlas-page-gutter) * 2))) !important;
    max-width: var(--atlas-page-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

@media (max-width: 760px) {
  html[class] {
    --atlas-mobile-gutter: 16px;
    --atlas-mobile-section-gap: 16px;
    --atlas-mobile-radius: 14px;
  }

  html[class] body main {
    width: 100% !important;
    max-width: 100% !important;
  }

  html[class] body :where(
    .directory-container, .page-shell, .tool-shell, .dt-wrap, .fc-wrap,
    .chem-container, .dev-container, .uc-wrap, .ut-wrap, .matrix-page
  ) {
    box-sizing: border-box !important;
    width: auto !important;
    max-width: none !important;
    margin-left: var(--atlas-mobile-gutter) !important;
    margin-right: var(--atlas-mobile-gutter) !important;
  }

  html[class] body main :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 46px !important;
    font-size: 16px !important;
  }

  html[class] body main :where(button, .btn, .button, .primary-btn, .secondary-btn) {
    min-height: 44px !important;
    line-height: 1.2 !important;
  }

  html[class] body main :where(
    .dt-card, .dt-detail, .fc-card, .fc-detail-card, .chem-card,
    .dev-card, .uc-card, .ut-card, .tool-card, .result-card
  ) {
    box-sizing: border-box !important;
    max-width: 100% !important;
    border-radius: var(--atlas-mobile-radius) !important;
  }

  html[class] body main :where(table, pre, .table-wrap, .dt-code) {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  html[class] body main :where(.tabs, .filters, .category-tabs, .dt-tabs, .fc-tabs-nav) {
    max-width: 100% !important;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  html[class] body main :where(.tabs, .filters, .category-tabs, .dt-tabs, .fc-tabs-nav)::-webkit-scrollbar {
    display: none;
  }

  html[class] body :where(.footer, .directory-footer, .site-footer) {
    margin-top: 32px;
  }
}

/* Mobile drawer language selector: keep one geometry across every shell.
   This must stay after the legacy homepage and directory rules. */
@media (max-width: 760px) {
  html[class] body .mobile-menu__tools .language-switcher {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
  }

  html[class] body .mobile-menu__tools [data-atlas-language-ready] {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--color-muted, #65758b) !important;
    font-size: 14px !important;
    font-weight: 650 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
  }

  html[class] body .mobile-menu__tools .language-menu {
    position: absolute !important;
    inset: auto 0 calc(100% + 8px) 0 !important;
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-rows: 44px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: min(62dvh, 520px) !important;
    gap: 4px !important;
    padding: 8px !important;
    border-radius: 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  html[class] body .mobile-menu__tools .language-option {
    grid-template-columns: 24px minmax(0, 1fr) auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    height: 44px !important;
    padding: 8px !important;
    gap: 8px !important;
    font-size: 13px !important;
  }
}

/* Flag artwork must fill the same frame on every site shell. */
html body .language-current-flag > svg,
html body .language-option__flag > svg {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: fill !important;
}

/* One language selector geometry for every mobile page shell. */
@media (max-width: 760px) {
  html[class] body :where(.topbar, .directory-header) .language-menu {
    box-sizing: border-box !important;
    width: min(320px, calc(100vw - 32px)) !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 44px !important;
    gap: 4px !important;
    padding: 8px !important;
  }
  html[class] body :where(.topbar, .directory-header) .language-option {
    box-sizing: border-box !important;
    grid-template-columns: 24px minmax(0, 1fr) auto !important;
    width: 100% !important;
    min-height: 44px !important;
    height: 44px !important;
    padding: 8px !important;
    gap: 8px !important;
    font-size: 13px !important;
  }
  html[class] body :where(.topbar, .directory-header) .language-option__flag {
    width: 24px !important;
    height: 16px !important;
  }
  html[class] body :where(.topbar, .directory-header) .language-option > span:nth-child(2) {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  html[class] body :where(.topbar, .directory-header) .language-option small {
    display: block !important;
    font-size: 9px !important;
    line-height: 1 !important;
  }
}

/* Legacy desktop overrides disabled: original desktop templates own their geometry. */
@media (min-width: 99999px) {
  html, body { width: 100%; max-width: 100%; overflow-x: clip; }
  body { font-size: 16px !important; line-height: 1.6 !important; }
  main :where(input, select, textarea) { font-size: 16px !important; }
  main :where(p, li, td, th, label) { line-height: 1.6; }
  .directory-page :where(.calculator-card,.tool-card) :where(p,small) { font-size: 14px; line-height: 1.45; }
  .directory-page :where(.calculator-card,.tool-card) :where(h3,strong) { line-height: 1.3; }
  body :where(main, section, article, header, footer, nav, form, fieldset, div) { min-width: 0; }
  body :where(img, svg, canvas, video) { max-width: 100%; }
  body :where(button, .button, .btn, [class*="button"], [class*="-btn"]) {
    min-height: 40px; height: auto; line-height: 1.25;
  }
  body :where(.result-card, .result-panel, .results-panel, .result-box, .metric-card,
              .calculator-card, .input-card, .tool-card, .faq-item, .related-card) {
    min-width: 0; height: auto;
  }
  body :where(.result-card, .result-panel, .results-panel, .result-box, .metric-card)
       :where(strong, b, span, small, p, output) {
    min-width: 0; max-width: 100%; overflow-wrap: anywhere;
  }
  body :where(.table-wrap, .table-scroll, .schedule-table-wrap, .amortization-table-wrap) {
    width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain;
  }
  body :where(.pagination-area, .pagination) { min-width: 0; max-width: 100%; }
  body .pagination :where(a, button, span) { min-width: 0; }
  body :where(input, select, textarea) { max-width: 100%; }
  body main button {
    max-width: 100%;
    height: auto !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  body main button :where(span, small, b, strong, i, em) {
    min-width: 0;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  body main :where(strong, b, output) { max-width: 100%; overflow-wrap: anywhere; }
  .day30-examples button,
  .month6-examples button {
    grid-template-columns: 46px minmax(0, 1fr) minmax(90px, 150px) 20px !important;
    white-space: normal !important;
  }
  .day30-examples button i,
  .month6-examples button i { white-space: normal !important; overflow-wrap: anywhere; }

  /* Shared desktop shell: homepage, directory pages and calculator pages. */
  body :where(.topbar, .directory-header .header-inner) {
    min-height: 64px !important;
    height: 64px !important;
    align-items: center !important;
  }
  body :where(.topbar, .directory-header) :where(.nav, .directory-nav) {
    align-items: center !important;
    gap: 28px !important;
  }
  body :where(.topbar, .directory-header) :where(.nav, .directory-nav) > a {
    font-size: 14px !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
  }
  body :where(.topbar, .directory-header) :where(.top-actions, .directory-actions) {
    align-items: center !important;
    gap: 12px !important;
  }
  body :where(.topbar, .directory-header) :where(.language, .lang-btn, .language-switcher__button) {
    min-height: 38px !important;
    height: 38px !important;
    padding: 0 14px !important;
    gap: 8px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    line-height: 1 !important;
  }
  body :where(.topbar, .directory-header) .language-menu {
    top: calc(100% + 8px) !important;
    right: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 4px !important;
    width: 360px !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(440px, calc(100vh - 88px)) !important;
    padding: 8px !important;
    border: 1px solid #d8e1ec !important;
    border-radius: 12px !important;
    background: #fff !important;
    box-shadow: 0 18px 48px rgba(16,42,76,.16) !important;
    overflow-y: auto !important;
  }
  body :where(.topbar, .directory-header) .language-option {
    display: grid !important;
    grid-template-columns: 26px minmax(0, 1fr) 42px !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-height: 42px !important;
    height: 42px !important;
    padding: 7px 8px !important;
    border: 0 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    text-align: left !important;
    white-space: nowrap !important;
  }
  body :where(.topbar, .directory-header) .language-option__flag {
    display: block !important;
    width: 26px !important;
    height: 17px !important;
  }
  body :where(.topbar, .directory-header) .language-option > span:nth-child(2) {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  body :where(.topbar, .directory-header) .language-option small {
    display: block !important;
    font-size: 9px !important;
    line-height: 1 !important;
    letter-spacing: .35px !important;
    text-align: right !important;
  }
  body :where(.topbar, .directory-header) .language-current-flag {
    width: 22px !important;
    height: 15px !important;
  }

  body :where(.footer, .directory-footer) {
    font-size: 15px !important;
    line-height: 1.55 !important;
  }
  body :where(.footer, .directory-footer) h3 {
    font-size: 14px !important;
    line-height: 1.25 !important;
  }
}

/* Final mobile geometry contract shared by home, directory and tool pages. */
@media (max-width: 760px) {
  html[class] {
    --atlas-mobile-gutter: 16px;
    --atlas-mobile-header: 60px;
  }

  html[class] body :where(.topbar, .directory-header) {
    min-height: var(--atlas-mobile-header) !important;
    height: var(--atlas-mobile-header) !important;
  }

  html[class] body .directory-header {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  html[class] body .directory-header .header-inner {
    width: auto !important;
    max-width: none !important;
    height: var(--atlas-mobile-header) !important;
    min-height: var(--atlas-mobile-header) !important;
    margin-inline: var(--atlas-mobile-gutter) !important;
    padding-inline: 0 !important;
  }

  html[class] body :where(.directory-container, .dt-wrap, .chem-container, .dev-container) {
    width: auto !important;
    max-width: none !important;
    margin-left: var(--atlas-mobile-gutter) !important;
    margin-right: var(--atlas-mobile-gutter) !important;
  }

  html[class] body .chem-container {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  html[class] body .detail-hero {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  html[class] body main h1,
  html[class] body .page > .hero h1,
  html.locale-mobile[lang="zh-CN"] body .page > .hero h1,
  html.locale-mobile[lang="zh"] body .page > .hero h1 {
    font-size: clamp(31px, 8.7vw, 34px) !important;
    line-height: 1.16 !important;
    letter-spacing: -.025em !important;
  }

  html[class] body :where(.footer, .directory-footer, .site-footer) > .footer-inner {
    box-sizing: border-box !important;
    width: auto !important;
    max-width: none !important;
    margin-left: var(--atlas-mobile-gutter) !important;
    margin-right: var(--atlas-mobile-gutter) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  html[class] body :where(.footer, .directory-footer, .site-footer) {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  html[class] body :where(.footer, .directory-footer, .site-footer) :where(a, button, p, small) {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Dense tool workspaces: remove desktop two-column pressure on phones. */
  html[class] body .matrix-page {
    width: auto !important;
    max-width: none !important;
    margin-inline: var(--atlas-mobile-gutter) !important;
    padding-inline: 0 !important;
  }

  html[class] body .matrix-controls {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  html[class] body .matrix-controls :where(label, select),
  html[class] body .matrix-actions,
  html[class] body .matrix-actions > button {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  html[class] body .dt-hero {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  html[class] body :where(.tip-mode-tabs, .tip-preset-row, .tip-tabs) {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  html[class] body :where(.tip-mode-tabs, .tip-preset-row, .tip-tabs)::-webkit-scrollbar {
    display: none;
  }

  html[class] body :where(.tip-mode-tabs, .tip-preset-row, .tip-tabs) > button {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
  }

  html[class] body :where(.tip-tool-card, .matrix-card, .dt-card) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Navigation baseline: match the Japanese calculator directory on phones. */
  html[class] body :where(.topbar, .directory-header) {
    box-sizing: border-box !important;
    width: calc(100% - 32px) !important;
    max-width: calc(100% - 32px) !important;
    min-height: 60px !important;
    height: 60px !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
    padding: 0 !important;
  }

  html[class] body .page > .topbar {
    padding: 0 !important;
  }

  html[class] body .directory-header .header-inner {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 60px !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html[class] body :where(.topbar, .directory-header)
    :where(.logo, .home-directory-brand, .directory-brand) {
    width: 124px !important;
    min-width: 124px !important;
    max-width: 124px !important;
    height: 27px !important;
    margin: 0 !important;
  }

  html[class] body .page > .topbar :where(.logo, .home-directory-brand),
  html[class] body .directory-header .header-inner .directory-brand {
    width: 124px !important;
    min-width: 124px !important;
    max-width: 124px !important;
    height: 27px !important;
    margin: 0 !important;
  }

  html[class] body :where(.topbar, .directory-header .header-inner)
    :where(.top-actions, .directory-actions) {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 162px !important;
    width: 162px !important;
    min-width: 162px !important;
    max-width: 162px !important;
    height: 44px !important;
    margin-left: auto !important;
    gap: 8px !important;
  }

  html[class] body :where(.topbar, .directory-header)
    :where(.language, .lang-btn, .language-switcher__button) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 10px !important;
    gap: 5px !important;
    border: 1px solid #dce7f1 !important;
    border-radius: 999px !important;
    background: #fff !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    line-height: 1.15 !important;
    overflow: hidden !important;
  }

  html[class] body .topbar .top-actions .language-switcher__button,
  html[class] body .directory-header .directory-actions .language-switcher__button {
    flex: 0 0 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    padding-inline: 10px !important;
    gap: 5px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
  }

  html[class] body .topbar .top-actions > .language-switcher,
  html[class] body .directory-header .directory-actions > .language-switcher {
    flex: 0 0 110px !important;
    flex-basis: 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    height: 44px !important;
  }

  html[class] body .topbar .top-actions > .language-switcher > .language-switcher__button,
  html[class] body .directory-header .directory-actions > .language-switcher > .language-switcher__button {
    flex: 0 0 110px !important;
    flex-basis: 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
  }

  html[class]:is(.locale-mobile, .en-mobile) body.directory-page
    .directory-header .directory-actions .language-switcher
    > button.lang-btn.language-switcher__button {
    box-sizing: border-box !important;
    flex: 0 0 110px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding-inline: 10px !important;
    gap: 5px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
  }

  html[class] body :where(.topbar, .directory-header)
    :where(.language, .lang-btn, .language-switcher__button) .language-current-flag {
    width: 22px !important;
    min-width: 22px !important;
    height: 15px !important;
    order: -1;
  }

  /* Compact mobile language control: flag + label + chevron only. */
  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button[data-icon="globe"] > svg,
  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button > [data-dir-icon="globe"] {
    display: none !important;
  }

  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button .language-switcher__label {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: left !important;
  }

  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button :where(.nav-chevron, [data-dir-icon="chevron-down"]) {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 14px !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
  }

  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button {
    padding-inline: 9px !important;
    gap: 6px !important;
    color: #17365d !important;
    background: #f9fbfd !important;
    box-shadow: 0 3px 10px rgba(20, 60, 105, .06) !important;
  }

  html[class] body :where(.topbar, .directory-header)
    .language-switcher__button:focus-visible {
    outline: 2px solid #2878d0 !important;
    outline-offset: 2px !important;
  }

  html[class] body :where(.topbar, .directory-header)
    :where(.menu-toggle, .mobile-menu-btn) {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: 1px solid #dce7f1 !important;
    border-radius: 14px !important;
    background: #fff !important;
  }

  /* Final readable language-button sizing after the Japanese-layout baseline. */
  html[class] body :where(.topbar, .directory-header .header-inner)
    :where(.top-actions, .directory-actions) {
    flex-basis: 172px !important;
    width: 172px !important;
    min-width: 172px !important;
    max-width: 172px !important;
  }

  html[class] body .topbar .top-actions > .language-switcher,
  html[class] body .directory-header .directory-actions > .language-switcher,
  html[class] body .topbar .top-actions > .language-switcher > .language-switcher__button,
  html[class] body .directory-header .directory-actions > .language-switcher > .language-switcher__button,
  html[class]:is(.locale-mobile, .en-mobile) body.directory-page
    .directory-header .directory-actions .language-switcher
    > button.lang-btn.language-switcher__button {
    box-sizing: border-box !important;
    flex: 0 0 120px !important;
    flex-basis: 120px !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    padding: 0 8px !important;
    gap: 5px !important;
  }

  html[class] body .topbar .top-actions > .language-switcher > .language-switcher__button,
  html[class] body .directory-header .directory-actions > .language-switcher > .language-switcher__button {
    padding-inline: 8px !important;
  }

  @media (max-width: 350px) {
    html[class] body .page > .topbar :where(.logo, .home-directory-brand),
    html[class] body .directory-header .header-inner .directory-brand {
      width: 108px !important;
      min-width: 108px !important;
      max-width: 108px !important;
    }
  }
}

/* Locale layout corrections must win over legacy template CSS above. */
@media (max-width: 760px) {
  html[class] body .hero-search {
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 0 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  html[class] body .hero-search > span {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 0 0 12px !important;
  }
  html[class] body .hero-search > input {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 46px !important;
    padding: 0 12px 0 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  html[class] body .hero-search > button {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-height: 44px !important;
    border-radius: 0 0 8px 8px !important;
  }
  html[class] body :where(.quick-tags,.trust-row,.hero-category-chips,.browse-categories,.sort-tabs,.category-tabs,.filters) {
    padding-right: 22px !important;
    scroll-padding-inline: 0 22px;
    -webkit-mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 18px),transparent 100%);
    mask-image: linear-gradient(90deg,#000 0,#000 calc(100% - 18px),transparent 100%);
  }
  html[class] body :where(.quick-tags,.trust-row,.hero-category-chips,.browse-categories,.sort-tabs,.category-tabs,.filters) > * {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
  }
  html:lang(de) body main h1,
  html:lang(fr) body main h1,
  html:lang(it) body main h1,
  html:lang(es) body main h1,
  html:lang(pt) body main h1,
  html:lang(pl) body main h1,
  html:lang(fi) body main h1,
  html:lang(nb) body main h1,
  html:lang(nl) body main h1,
  html:lang(sv) body main h1 {
    font-size: clamp(29px, 8.2vw, 32px) !important;
    line-height: 1.14 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: auto;
  }
  html[class] body main :where(label,.field-label,.fc-field label,.dt-field) {
    overflow-wrap: anywhere;
  }
}

/* Unified mobile header and language control — final authority. */
@media (max-width: 0px) {
  html[class] {
    --atlas-mobile-gutter: 16px;
    --atlas-mobile-header-height: 60px;
    --atlas-mobile-logo-width: clamp(104px, 31vw, 124px);
    --atlas-language-width: clamp(106px, 31vw, 132px);
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  html[class] body {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: clip !important;
    zoom: 1 !important;
  }

  html[class] body :where(.topbar,.directory-header) {
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    width: calc(100% - (var(--atlas-mobile-gutter) * 2)) !important;
    max-width: calc(100% - (var(--atlas-mobile-gutter) * 2)) !important;
    min-height: var(--atlas-mobile-header-height) !important;
    height: var(--atlas-mobile-header-height) !important;
    margin: 0 var(--atlas-mobile-gutter) !important;
    padding: 0 !important;
  }

  html[class] body .directory-header .header-inner,
  html[class] body .page > .topbar {
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: var(--atlas-mobile-header-height) !important;
    height: var(--atlas-mobile-header-height) !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html[class] body :where(.topbar,.directory-header)
    :where(.logo,.home-directory-brand,.directory-brand) {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 var(--atlas-mobile-logo-width) !important;
    width: var(--atlas-mobile-logo-width) !important;
    min-width: var(--atlas-mobile-logo-width) !important;
    max-width: var(--atlas-mobile-logo-width) !important;
    height: 28px !important;
    margin: 0 !important;
  }

  html[class] body :where(.topbar,.directory-header .header-inner)
    :where(.top-actions,.directory-actions) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 calc(var(--atlas-language-width) + 52px) !important;
    width: calc(var(--atlas-language-width) + 52px) !important;
    min-width: calc(var(--atlas-language-width) + 52px) !important;
    max-width: calc(var(--atlas-language-width) + 52px) !important;
    height: 44px !important;
    margin-left: auto !important;
    gap: 8px !important;
  }

  html[class] body :where(.topbar,.directory-header)
    :where(.top-actions,.directory-actions) > .language-switcher {
    box-sizing: border-box !important;
    position: relative !important;
    flex: 0 0 var(--atlas-language-width) !important;
    width: var(--atlas-language-width) !important;
    min-width: var(--atlas-language-width) !important;
    max-width: var(--atlas-language-width) !important;
    height: 44px !important;
    padding: 0 !important;
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher > .language-switcher__button {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) 14px !important;
    align-items: center !important;
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 9px !important;
    gap: 6px !important;
    border: 1px solid #d8e3ee !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg,#fff 0%,#f7fafc 100%) !important;
    color: #15365e !important;
    box-shadow: 0 3px 10px rgba(25,61,103,.07) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    overflow: hidden !important;
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher > .language-switcher__button:active {
    background: #edf4fb !important;
    transform: translateY(1px);
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher__button .language-current-flag {
    grid-column: 1 !important;
    display: block !important;
    width: 22px !important;
    min-width: 22px !important;
    height: 15px !important;
    border-radius: 2px !important;
    overflow: hidden !important;
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher__button .language-switcher__label {
    grid-column: 2 !important;
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: left !important;
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher__button :where(.nav-chevron,[data-dir-icon="chevron-down"]) {
    grid-column: 3 !important;
    display: grid !important;
    place-items: center !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
  }

  html[class] body :where(.topbar,.directory-header)
    .language-switcher .atlas-language-fallback {
    box-sizing: border-box !important;
    right: -52px !important;
    width: min(300px,calc(100vw - 32px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(68vh,520px) !important;
    padding: 8px !important;
    border-radius: 14px !important;
  }

  html[class] body :where(.topbar,.directory-header)
    :where(.menu-toggle,.mobile-menu-btn) {
    box-sizing: border-box !important;
    display: grid !important;
    place-items: center !important;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: 1px solid #d8e3ee !important;
    border-radius: 12px !important;
    background: #fff !important;
  }

  html[class] body main :where(.container,.directory-container,.page-shell,.tool-shell,.dt-wrap,.fc-wrap,.chem-container,.dev-container,.uc-wrap,.ut-wrap,.matrix-page) {
    box-sizing: border-box !important;
    max-width: calc(100vw - 32px) !important;
  }
}

/* Approved fixed mobile navigation geometry. */
@media (max-width: 0px) {
  html[class] {
    --atlas-mobile-logo-width: 124px;
    --atlas-language-width: 120px;
  }
  html[class] body .page > .topbar > .home-directory-brand { display: none !important; }
  html[class] body .page > .topbar > img.logo {
    display: block !important;
    object-fit: contain !important;
  }
  html[class] body .page > .topbar {
    width: calc(100% - 32px) !important;
    max-width: calc(100% - 32px) !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.logo,.directory-brand) {
    display: block !important;
    flex: 0 0 var(--atlas-mobile-logo-width) !important;
    width: var(--atlas-mobile-logo-width) !important;
    min-width: var(--atlas-mobile-logo-width) !important;
    max-width: var(--atlas-mobile-logo-width) !important;
    height: 27px !important;
  }
  html[class] body :where(.topbar,.directory-header .header-inner) :where(.top-actions,.directory-actions) {
    flex: 0 0 172px !important;
    width: 172px !important;
    min-width: 172px !important;
    max-width: 172px !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.top-actions,.directory-actions) > .language-switcher {
    flex: 0 0 120px !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
  }
  html[class] body :where(.menu-toggle,.mobile-menu-btn) > svg { display: none !important; }
  html[class] body :where(.menu-toggle,.mobile-menu-btn)::before {
    content: "" !important;
    display: block !important;
    width: 18px !important;
    height: 12px !important;
    border-top: 2px solid #15365e !important;
    border-bottom: 2px solid #15365e !important;
    background: linear-gradient(#15365e,#15365e) center / 18px 2px no-repeat !important;
  }
  @media (max-width: 350px) {
    html[class] { --atlas-mobile-logo-width: 108px; }
  }
}

/* Active unified language control: adaptive label width, fixed safe menu. */
@media (max-width: 760px) {
  html[class] body .page > .topbar > .top-actions,
  html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
    .directory-header .header-inner > .directory-actions {
    flex: 0 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  html[class] body .page > .topbar > .top-actions > .language-switcher,
  html[class] body .page > .topbar > .top-actions > .language-switcher > .language-switcher__button,
  html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
    .directory-header .header-inner > .directory-actions > .language-switcher,
  html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
    .directory-header .header-inner > .directory-actions > .language-switcher > .language-switcher__button {
    box-sizing: border-box !important;
    flex: 0 1 auto !important;
    flex-basis: auto !important;
    width: var(--atlas-language-natural-width,120px) !important;
    min-width: 112px !important;
    max-width: min(158px,calc(100vw - 216px)) !important;
  }
  html[class] body :where(.topbar,.directory-header .header-inner)
    :where(.top-actions,.directory-actions) {
    flex: 0 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  html[class] body :where(.topbar,.directory-header)
    :where(.top-actions,.directory-actions) > .language-switcher,
  html[class] body :where(.topbar,.directory-header)
    :where(.top-actions,.directory-actions) > .language-switcher > .language-switcher__button {
    box-sizing: border-box !important;
    flex: 0 1 auto !important;
    width: var(--atlas-language-natural-width,120px) !important;
    min-width: 112px !important;
    max-width: min(158px,calc(100vw - 216px)) !important;
  }
  html[class] body :where(.topbar,.directory-header)
    .language-switcher > .language-switcher__button {
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) 14px !important;
    align-items: center !important;
    height: 44px !important;
    padding: 0 8px !important;
    gap: 5px !important;
  }
  html[class] body :where(.topbar,.directory-header)
    .language-switcher > .atlas-language-fallback {
    position: fixed !important;
    top: 60px !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: calc(100dvh - 76px) !important;
  }
  @media (max-width: 350px) {
    html[class] body .page > .topbar > .top-actions > .language-switcher,
    html[class] body .page > .topbar > .top-actions > .language-switcher > .language-switcher__button,
    html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
      .directory-header .header-inner > .directory-actions > .language-switcher,
    html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
      .directory-header .header-inner > .directory-actions > .language-switcher > .language-switcher__button {
      max-width: calc(100vw - 200px) !important;
    }
    html[class] body :where(.topbar,.directory-header)
      :where(.top-actions,.directory-actions) > .language-switcher,
    html[class] body :where(.topbar,.directory-header)
      :where(.top-actions,.directory-actions) > .language-switcher > .language-switcher__button {
      max-width: calc(100vw - 200px) !important;
    }
  }
}

/* Full-width mobile navigation shell; content keeps a consistent safe area. */
@media (max-width: 760px) {
  html[class] body .page > .topbar {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    margin: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  html[class] body > .directory-header,
  html[class] body .directory-header {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html[class] body .directory-header > .header-inner,
  html[class] body .directory-header .header-inner {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    margin: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* Sticky navigation and full-width directory search. */
@media (max-width: 760px) {
  html[class] body :where(.topbar,.directory-header) {
    position: sticky !important;
    top: 0 !important;
    z-index: 10000 !important;
    background: rgba(255,255,255,.98) !important;
    box-shadow: 0 1px 0 rgba(20,52,88,.09),0 5px 16px rgba(20,52,88,.05) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  html[class] body .hero-search {
    position: relative !important;
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    grid-template-rows: 46px 44px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 90px !important;
    padding: 0 !important;
    gap: 0 !important;
    overflow: hidden !important;
  }
  html[class] body .hero-search > span {
    position: absolute !important;
    z-index: 2 !important;
    top: 14px !important;
    left: 14px !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    pointer-events: none;
  }
  html[class] body .hero-search > input {
    grid-column: 1 !important;
    grid-row: 1 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 46px !important;
    padding: 0 14px 0 44px !important;
  }
  html[class] body .hero-search > button {
    grid-column: 1 !important;
    grid-row: 2 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 44px !important;
  }
}

/* Final mobile interaction repair: keep all tool workspaces usable and controls aligned. */
@media (max-width: 760px) {
  html[class] body > .page,
  html[class] body main.page {
    overflow-x: clip !important;
    overflow-y: visible !important;
  }
  html[class] body :where(.dt-workspace,.dt-details) {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html[class] body .dt-form {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html[class] body .dt-actions {
    display: flex !important;
    align-items: stretch !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  html[class] body .dt-actions .dt-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 132px !important;
    max-width: 100% !important;
    min-height: 44px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }
  html[class] body main :where(.btn,.button,.primary-btn,.secondary-btn,.fc-buttons button) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header) .language-switcher__button {
    justify-items: center !important;
    line-height: 1 !important;
  }
  html[class] body :where(.topbar,.directory-header) .language-current-flag,
  html[class] body :where(.topbar,.directory-header) .language-switcher__button > svg,
  html[class] body :where(.topbar,.directory-header) .language-switcher__button::after {
    align-self: center !important;
    justify-self: center !important;
  }
  html[class] body :where(.topbar,.directory-header) .language-switcher__label {
    min-width: 0 !important;
    text-align: center !important;
    line-height: 1.2 !important;
  }
}

/* Last cascade rule: center navigation action contents on every mobile template. */
@media (max-width: 760px) {
  html[class] body .topbar > .top-actions,
  html[class] body .directory-header .header-inner > .directory-actions {
    column-gap: 8px !important;
  }
  html[class] body .topbar > .top-actions > .language-switcher,
  html[class] body .directory-header .header-inner > .directory-actions > .language-switcher {
    padding: 0 !important;
    margin: 0 !important;
  }
  html[class] body .page > .topbar .top-actions .language-switcher > button.language-switcher__button,
  html[class] body .directory-header .header-inner .directory-actions .language-switcher > button.language-switcher__button {
    display: grid !important;
    grid-template-columns: 22px minmax(0,1fr) 22px !important;
    place-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 40px !important;
    padding: 0 7px !important;
    gap: 4px !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-current-flag {
    grid-column: 1 !important;
    display: grid !important;
    place-items: center !important;
    width: 22px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-current-flag + [data-dir-icon="globe"] {
    display: none !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > .language-switcher__label {
    grid-column: 2 !important;
    justify-self: stretch !important;
    width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > [data-dir-icon="chevron-down"] {
    grid-column: 3 !important;
    display: grid !important;
    place-items: center !important;
    width: 22px !important;
    height: 22px !important;
    margin: 0 !important;
  }
  html[class] body :where(.topbar,.directory-header) button.language-switcher__button > [data-dir-icon="chevron-down"] > svg {
    width: 14px !important;
    height: 14px !important;
    margin: auto !important;
  }
  html[class] body .page > .topbar > .top-actions > .language-switcher > .language.language-switcher__button {
    grid-template-columns: 22px minmax(0,1fr) 22px !important;
    height: 40px !important;
    min-height: 40px !important;
  }
  html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
    .directory-header .header-inner > .directory-actions > .language-switcher
    > button.lang-btn.language-switcher__button {
    height: 40px !important;
    min-height: 40px !important;
  }
  html[class] body .page > .topbar > .menu-toggle,
  html[class]:is(.locale-mobile,.en-mobile,.ja-mobile) body.directory-page
    .directory-header .header-inner > .mobile-menu-btn {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.menu-toggle,.mobile-menu-btn) {
    display: grid !important;
    place-items: center !important;
    box-sizing: border-box !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    line-height: 1 !important;
    text-align: center !important;
  }
  html[class] body :where(.topbar,.directory-header) :where(.menu-toggle,.mobile-menu-btn) > svg {
    place-self: center !important;
    margin: 0 !important;
  }
}
/* Unified Sapicalculator mobile branding across every page. */
@media (max-width: 760px) {
  /* Keep the home and directory headers on the same mobile contract. */
  html body :where(.topbar, .directory-header) {
    min-height: 60px !important;
    height: 60px !important;
  }

  html body :where(.topbar .top-actions, .directory-header .directory-actions) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    width: 164px !important;
    min-width: 164px !important;
    max-width: 164px !important;
    gap: 8px !important;
  }

  html body :where(.topbar .language-switcher, .directory-header .language-switcher) {
    display: block !important;
    flex: 0 0 112px !important;
    width: 112px !important;
    min-width: 112px !important;
    max-width: 112px !important;
  }

  html body :where(.topbar .language-switcher__button, .directory-header .language-switcher__button) {
    display: grid !important;
    box-sizing: border-box !important;
    width: 112px !important;
    min-width: 112px !important;
    max-width: 112px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 8px !important;
    grid-template-columns: 22px minmax(0, 1fr) 14px !important;
    align-items: center !important;
    gap: 5px !important;
    overflow: hidden !important;
  }

  html body :where(.topbar .menu-toggle, .directory-header .mobile-menu-btn) {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  html[class] body .page > .topbar .menu-toggle,
  html[class] body .directory-header .header-inner .mobile-menu-btn {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
  }

  html body :where(.topbar .language-switcher__label, .directory-header .language-switcher__label) {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Give translated language names enough room on normal phone widths. */
  html[class] body :where(.topbar .top-actions, .directory-header .directory-actions) {
    width: min(180px, calc(100vw - 210px)) !important;
    min-width: min(180px, calc(100vw - 210px)) !important;
    max-width: min(180px, calc(100vw - 210px)) !important;
  }

  html[class] body :where(.topbar .language-switcher, .directory-header .language-switcher),
  html[class] body :where(.topbar .language-switcher__button, .directory-header .language-switcher__button) {
    width: min(128px, calc(100vw - 218px)) !important;
    min-width: min(128px, calc(100vw - 218px)) !important;
    max-width: min(128px, calc(100vw - 218px)) !important;
  }

  .top-actions > .contact-btn,
  .directory-actions > .submit-btn {
    display: none !important;
  }

  html body :where(.top-actions .contact-btn, .directory-actions .submit-btn) {
    display: none !important;
  }

  html body :where(.top-actions, .directory-actions) {
    gap: 8px !important;
  }

  html body :where(.home-directory-brand, .directory-brand) {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  /* Header-only lockup: keep the mark and word visible and centered on every tool/locale page. */
  html body header :where(.home-directory-brand, .directory-brand) {
    display: inline-flex !important;
    align-items: center !important;
    align-self: center !important;
    height: 28px !important;
    min-height: 28px !important;
    line-height: 1 !important;
  }

  html body header :where(.home-directory-brand, .directory-brand) > .brand-mark-img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 24px !important;
    height: 24px !important;
    flex: 0 0 24px !important;
    margin: 0 !important;
  }

  html body header :where(.home-directory-brand, .directory-brand) > .brand-word {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: 20px !important;
    line-height: 20px !important;
    margin: 0 !important;
    transform: none !important;
  }

  /* Some calculator-page styles reset the brand to block layout. Override that reset. */
  html[class] body .page > .topbar > .home-directory-brand,
  html[class] body .directory-header .header-inner > .directory-brand {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    height: 28px !important;
    min-height: 28px !important;
    gap: 8px !important;
    background-image: none !important;
  }

  html body :where(.brand-mark-img) {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    flex: 0 0 24px !important;
    display: block !important;
    object-fit: contain !important;
  }

  html body :where(.brand-word) {
    color: #102a56 !important;
    font-size: 18px !important;
    max-width: 150px !important;
    max-height: 22px !important;
    font-weight: 800 !important;
    letter-spacing: -0.04em !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  html body :where(.brand-word span) {
    color: #16b67a !important;
    font-weight: 850 !important;
  }

  html body :where(.mobile-menu__logo) {
    width: 120px !important;
    max-width: 120px !important;
    height: auto !important;
    object-fit: contain !important;
  }
}
