/* The map and its controls use separate rows on phones. Desktop stays unchanged. */
.map-results-toggle { display: none; }

@media (max-width: 760px) {
  :root {
    --phone-gutter: max(14px, env(safe-area-inset-left), env(safe-area-inset-right));
    --phone-nav: calc(60px + env(safe-area-inset-bottom));
    --header: calc(110px + env(safe-area-inset-top));
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px 44px;
    gap: 7px 10px;
    padding: calc(7px + env(safe-area-inset-top)) var(--phone-gutter) 7px;
  }
  .brand { gap: 6px; justify-self: start; }
  .brand-mark { width: 32px; }
  .header-actions { grid-area: 1 / 2; gap: 6px; }
  .search-box { grid-area: 2 / 1 / 3 / -1; position: static; width: 100%; margin: 0; box-shadow: none; }
  .search-box input, .area-control select { min-width: 0; font-size: 16px; }
  .header-actions :is(.icon-button, select) { min-height: 44px; }

  .editorial-panel { padding: 21px var(--phone-gutter) calc(28px + var(--phone-nav)); }
  .intro-row h1 { font-size: clamp(2.1rem, 9.5vw, 3.5rem); overflow-wrap: anywhere; }
  .intro-row .lede { margin-block: 10px 0; }
  .decision-button { margin-top: 15px; min-height: 46px; }
  .decision-button small { text-align: right; }

  .filter-bar, .decision-filters, .collection-strip {
    margin-inline-end: calc(-1 * var(--phone-gutter));
    padding-inline-end: var(--phone-gutter);
  }
  .filter-bar { padding-block: 17px 12px; }
  .decision-filters { margin-top: 0; }
  :is(.filter, .smart-filter, .clear-filters, .area-control) { min-height: 44px; }
  .filter { flex: 0 0 auto; }

  .venue-card { border-radius: 18px; }
  .venue-card .venue-image { height: clamp(138px, 44vw, 220px); min-height: 0; }
  .venue-card.featured .venue-image { height: clamp(165px, 52vw, 250px); }
  .venue-body, .featured .venue-body { padding: 14px; }
  .venue-head h2, .dialog-body h2, .map-preview h3 { overflow-wrap: anywhere; }
  .venue-head h2 { font-size: clamp(1.25rem, 6vw, 1.65rem); }
  .venue-card .save-icon { width: 44px; height: 44px; }
  .venue-card .primary-button, .dialog-actions > * { min-height: 44px; }
  .venue-dialog { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .dialog-hero { height: clamp(150px, 54vw, 260px); }

  .mobile-nav { height: var(--phone-nav); padding-inline: var(--phone-gutter); }
  .mobile-nav button { min-height: 44px; line-height: 1.15; }
  .mobile-nav button span { line-height: 1; }
  .toast { bottom: calc(var(--phone-nav) + 10px); max-width: calc(100% - 24px); }
  .consent-banner { bottom: calc(var(--phone-nav) + 8px); padding: 14px; left: var(--phone-gutter); right: var(--phone-gutter); }
  .consent-actions { flex-wrap: wrap; }
  .consent-actions button { min-height: 44px; }

  body:has(.full-map-view:not(.hidden)) { overflow: hidden; }
  body:has(.full-map-view:not(.hidden)) .site-footer { display: none; }

  .full-map-view {
    display: grid;
    grid-template: minmax(0, 1fr) auto / minmax(0, 1fr);
    height: calc(100vh - var(--header) - var(--phone-nav));
    height: calc(100dvh - var(--header) - var(--phone-nav));
    min-height: 235px;
  }
  .full-map-canvas { grid-row: 1; min-height: 0; }
  .results-rail {
    grid-row: 2;
    position: relative; inset: auto; min-width: 0;
    max-height: min(44dvh, 360px);
    padding: 0 var(--phone-gutter);
    overflow: auto;
    overscroll-behavior: contain;
    border-width: 1px 0 0;
    border-radius: 0;
    background: var(--panel);
  }
  .rail-heading {
    position: sticky; top: 0; z-index: 1;
    align-items: center; gap: 8px; min-height: 56px;
    padding-block: 5px;
    background: var(--panel);
  }
  .rail-heading > div { min-width: 0; flex: 1; }
  .rail-heading h2 { font-size: clamp(.85rem, 3.8vw, 1.12rem); }
  .rail-heading .icon-button { flex: none; width: 44px; height: 44px; }
  .map-results-toggle {
    display: inline-flex; align-items: center; min-height: 44px; flex: none;
    gap: 6px; padding: 0 9px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel2); color: var(--text);
    font-size: .79rem; font-weight: 750; cursor: pointer;
  }
  .map-results-toggle::after { content: ''; width: 6px; height: 6px; border: solid var(--cyan); border-width: 0 2px 2px 0; transform: rotate(225deg); margin-top: 3px; }
  .map-results-toggle[aria-expanded="true"]::after { transform: rotate(45deg); margin-top: -3px; }
  .results-rail:not(.is-open) :is(.map-filters, .decision-filters-rail, .saved-route-rail, .rail-list, .rail-note) { display: none; }
  .map-filters { padding-block: 4px 8px; }
  .decision-filters-rail { margin: 0 0 6px; padding: 0; }
  .decision-filters-rail .area-control { min-width: min(190px, 64vw); }
  .rail-list { max-height: none; overflow: visible; }
  .full-map-view:not(.route-mode) .rail-item > div { min-width: 0; overflow-wrap: anywhere; }

  .map-key-full { inset: 9px auto auto 9px; max-width: calc(100% - 60px); padding: 6px 9px; gap: 5px 10px; }
  .map-key-full b { font-size: .68rem; }
  .full-map-view .map-error { margin-top: 44px; }
  .map-preview-full:not([hidden]) {
    display: block; inset: auto 52px 25px 9px; width: auto;
    max-height: 68%; overflow: auto;
  }
  .map-preview-full .map-preview-inner { grid-template-columns: clamp(55px, 18vw, 86px) minmax(0, 1fr); }
  .map-preview-full .map-preview-photo img { width: 100%; height: 100%; min-height: 88px; object-fit: cover; }
  .map-preview-full .map-preview-copy { padding: 8px 10px; }
  .map-preview-full .map-preview-copy h3 { font-size: .92rem; }
  .map-preview-full .map-preview-copy button { min-height: 44px; }
}

@media (max-width: 760px) and (max-height: 500px) {
  .full-map-view { min-height: 0; }
  .results-rail.is-open { max-height: max(56px, 40%); }
  .map-key-full { display: none; }
}
