/* Allow grid and flex children to shrink to the available viewport width. */
main { min-width: 0; }
.grid > *, .profile-fields > *, .listing-modal-fields > *,
.review-layout > *, .site-footer-main > *, .trade-search > * { min-width: 0; }
.account input, .account select, .account textarea { width: 100%; min-width: 0; max-width: 100%; }
.filters > * { min-width: 0; max-width: 100%; }
.filters select { flex: 1 1 180px; }
.card h3, .card p, .details dd, .review-card p, .review-summary p,
.messages p, .notice { overflow-wrap: anywhere; }
.details dd { min-width: 0; margin-inline-start: 0; }
.message-form input { min-width: 0; }
.site-footer-trust img { max-width: 100%; height: auto; }

/* Shared form sizing applies to account, listing, support, chat and admin forms. */
form, form fieldset, form label, form > div { min-width: 0; }
form fieldset { max-width: 100%; }
form :is(input, select, textarea) { box-sizing: border-box; min-width: 0; max-width: 100%; }
form input[type=file] { width: 100%; overflow: hidden; }
form textarea { resize: vertical; }
form :is(button, .btn), .profile-actions > a { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
form :is(.error, small, p), .validation-summary-errors { overflow-wrap: anywhere; }
.profile-card, .ticket-page, .chat, .review-form-card, .training-admin-layout > * { min-width: 0; max-width: 100%; }
.profile-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.profile-heading > div { min-width: 0; }
.profile-heading h1 { overflow-wrap: anywhere; }
.profile-inquiry-action { display: flex; align-items: end; }
.profile-inquiry-action button { width: 100%; }
.profile-identity > p { grid-column: 1 / -1; margin-block: 0; }
.profile-actions, .review-actions, .edit-actions, .ticket-page nav { flex-wrap: wrap; }
.listing-step-tabs button { min-width: 0; white-space: normal; }
.review-summary dl, .review-card dl { grid-template-columns: minmax(0, 150px) minmax(0, 1fr); }

@media (min-width: 801px) and (max-width: 1100px) {
  /* Keep fields usable beside the dashboard sidebar on landscape tablets. */
  .dashboard-content .profile-fields { grid-template-columns: minmax(0, 1fr); }
  .review-layout, .training-admin-layout { grid-template-columns: minmax(0, 1fr); }
  .review-form-card { position: static; }
}

@media (max-width: 800px) {
  form :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) { font-size: 16px; }
  form :is(button, select, input:not([type=checkbox]):not([type=radio]):not([type=hidden])) { min-height: 44px; }
  .account { margin-block: 24px; }
  .profile-actions > *, .edit-actions > * { flex: 1 1 160px; text-align: center; }
  .listing-ad-preview { max-height: calc(100dvh - 24px); }
}

@media (max-width: 650px) {
  .heading { flex-wrap: wrap; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filters > * { width: 100%; }
  .account input, .account select, .account textarea,
  .listing-modal-form input, .listing-modal-form select, .listing-modal-form textarea,
  .message-form input { font-size: 16px; }
  .account { padding: 20px 16px; }
  .details { padding: 16px; gap: 18px; }
  .profile-actions, .listing-modal-actions { flex-wrap: wrap; }
  .profile-actions > *, .listing-modal-actions > * { min-width: 0; }
  .profile-fields, .listing-page .listing-modal-fields { grid-template-columns: minmax(0, 1fr); }
  .profile-heading { gap: 12px; }
  .profile-heading h1 { font-size: 22px; }
  .profile-avatar { flex-basis: 48px; height: 48px; }
  .profile-avatar-picker { padding: 12px; }
  .review-form-card { padding: 16px; }
  .review-summary dl, .review-card dl { grid-template-columns: minmax(0, 1fr); }
  .ticket-page { padding: 0; }
  .ticket-form .btn { width: 100%; }
  .message-form { display: grid; grid-template-columns: minmax(0, 1fr); }
  .listing-step-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .listing-step-actions .btn { width: 100%; margin: 0; min-height: 44px; }
  .listing-step-actions :is([data-next-step], [data-listing-submit]) { grid-column: 1 / -1; margin-inline-start: 0; }
  .listing-photo-heading { flex-wrap: wrap; }
  .listing-photo-heading > div { flex: 1 1 150px; min-width: 0; }
  .listing-page h1 { overflow-wrap: anywhere; }
}
