@media (max-width: 640px) {
  html body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
    font-size: 14px;
  }

  #root .container {
    padding: 12px max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  #root .dual-wizard {
    padding: 0 !important;
    min-width: 0;
  }

  #root .dual-wizard > div {
    margin-bottom: 24px !important;
  }

  #root .wizard-progress-track {
    gap: 6px !important;
  }

  #root .wizard-progress-track > div:nth-child(even) {
    display: none;
  }

  #root .wizard-progress-track > div:nth-child(odd) {
    flex: 1;
    flex-direction: column;
    gap: 6px !important;
    min-width: 0;
  }

  #root .wizard-progress-track > div > span {
    font-size: 12px !important;
    white-space: nowrap;
  }

  #root .mobile-step-heading {
    margin-bottom: 16px !important;
    padding-bottom: 12px !important;
    border-bottom-width: 1px !important;
  }

  #root .mobile-step-heading > div,
  #root .product-step-label {
    font-size: 12px !important;
    padding: 4px 10px !important;
    margin-bottom: 8px !important;
  }

  #root .mobile-step-heading h2,
  #root .product-groups-heading h2 {
    font-family: inherit;
    font-size: 22px !important;
    letter-spacing: 0;
  }

  #root .asset-selector-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  #root .asset-selector-grid > div {
    min-width: 0;
    padding: 14px 10px !important;
    overflow-wrap: anywhere;
  }

  #root input:not([type='checkbox']), #root select, #root textarea {
    font-size: 16px !important;
    min-height: 44px;
    min-width: 0;
    max-width: 100%;
  }

  #root button, #root .button {
    min-height: 44px;
    font-family: inherit !important;
    letter-spacing: 0;
    line-height: 1.45;
    touch-action: manipulation;
  }

  #root .direction-choices {
    gap: 10px !important;
  }

  #root .direction-choices button {
    min-width: 0;
    padding: 14px 10px !important;
    box-shadow: none;
  }

  #root .direction-choices button > div:first-child {
    font-size: 17px !important;
    margin-bottom: 8px !important;
  }

  #root .direction-choices button > div:last-child {
    font-size: 12px !important;
    line-height: 1.6;
  }

  #root .settlement-choices {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px !important;
  }

  #root .settlement-choices > button {
    padding: 8px 4px !important;
    font-size: 13px !important;
    box-shadow: none;
  }

  #root .settlement-specific {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    margin-left: 0 !important;
    margin-top: 8px;
  }

  #root .settlement-specific input {
    flex: 1;
  }

  #root .target-price-fields {
    flex-direction: column;
    gap: 10px !important;
  }

  #root .target-price-fields > div {
    min-width: 0;
    padding: 12px !important;
  }

  #root .target-price-fields input {
    font-size: 22px !important;
  }

  #root .quick-price-choices {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #root .quick-price-choices button {
    padding: 10px 6px !important;
    font-size: 13px !important;
    box-shadow: none;
  }

  #root .product-groups-heading {
    gap: 14px;
    border-bottom-width: 1px;
  }

  #root .product-groups-filters,
  #root .product-sort-controls,
  #root .product-income-controls {
    width: 100%;
    justify-content: space-between;
  }

  #root .product-groups-filters > label {
    min-height: 44px;
    width: 100%;
  }

  #root .product-sort-controls > label {
    flex: 1;
    min-width: 0;
  }

  #root .product-sort-controls select {
    flex: 1;
    width: 100%;
  }

  #root .product-income-amount {
    width: 100%;
  }

  #root .product-income-amount input {
    flex: 1;
    width: 100%;
  }

  #root .product-group-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 16px;
  }

  #root .product-group-stat {
    text-align: left;
    grid-column: auto;
  }

  #root .product-group-trigger {
    grid-column: auto;
  }

  #root .product-group-table-scroll {
    overflow: visible;
  }

  #root .product-group-table,
  #root .product-group-table tbody {
    display: block;
    min-width: 0;
    width: 100%;
  }

  #root .product-group-table colgroup {
    display: none;
  }

  #root .product-group-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-strong);
  }

  #root .product-group-table tbody tr:last-child {
    border-bottom: 0;
  }

  #root .product-group-table tbody th,
  #root .product-group-table tbody td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  #root .product-group-table td[data-mobile-label]::before {
    content: attr(data-mobile-label);
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
  }

  #root .product-yield-quote, #root .product-option-quote {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
    white-space: normal;
  }

  #root .product-option-exchange {
    flex-basis: 100%;
  }

  #root .product-income-difference {
    text-align: left;
  }

  #root .product-group-table button {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
  }

  #root .product-group-pagination {
    justify-content: center;
    gap: 12px;
  }

  #root .product-group-pagination > span,
  #root .product-group-pagination > div {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  #root .product-group-pagination button {
    flex: 1;
  }

  #root .comparison-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #root .comparison-toolbar > button {
    min-width: 0;
    justify-content: center;
    padding: 10px 6px !important;
    font-size: 13px !important;
  }

  #root .comparison-mode-summary {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #root .comparison-estimates,
  #root .comparison-estimates[data-mode='pro'] {
    grid-template-columns: minmax(0, 1fr);
  }

  #root .comparison-parameter-fields {
    flex-direction: column;
    align-items: stretch !important;
  }

  #root .comparison-parameter-fields > div {
    min-width: 0;
    width: 100%;
  }

  #root .comparison-parameter-amount {
    flex-wrap: wrap;
  }

  #root .comparison-parameter-amount input {
    width: 100% !important;
  }

  #root .comparison-summary-cards {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #root .comparison-summary {
    overflow-wrap: anywhere;
  }

  #root .comparison-summary-heading {
    flex-wrap: wrap;
    gap: 12px;
  }

  #root .comparison-fee-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #root .comparison-fee-row > div:first-child {
    grid-column: 1 / -1;
  }

  #root .comparison-fee-row input {
    width: 100%;
  }

  #root .comparison-estimates .estimate-panel {
    padding: 16px;
  }

  #root .estimate-metrics,
  #root .estimate-metrics--pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #root .estimate-panel .comparison-metric__value {
    font-size: 14px;
    line-height: 1.5;
  }

  #root .panel {
    min-width: 0;
    padding: 14px;
  }

  #root :is(a, button, input, select, summary):focus-visible {
    outline: 2px solid #9ed4ff !important;
    outline-offset: 3px;
  }
}
