/* ==========================================================================
   MOBILE SHELL — ADDITIVE ONLY
   All visual remapping is behind max-width: 768px (and html.layout-mobile).
   At desktop widths the rules in main.css / sidebar.css / timeline.css /
   components.css from main apply unchanged.
   ========================================================================== */

.mobile-header-actions,
.mobile-filter-trigger,
.mobile-period-trigger,
.mobile-city-bar,
.mobile-backdrop,
.mobile-picker-sheet,
.mobile-action-sheet,
.mobile-basemap-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   Phone + small-tablet shell (below 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Fill the live phone viewport. 100% alone follows a short ICB on iOS
     Safari; svh/dvh/-webkit-fill-available cover browsers without JS.
     --app-vh is the visualViewport height (set in mobileShell). */
  html, body {
    height: 100%;
    height: -webkit-fill-available;
    height: 100svh;
    height: 100dvh;
    overscroll-behavior: none;
    overflow-x: hidden;
  }

  html.layout-mobile,
  html.layout-mobile body {
    height: 100%;
    height: -webkit-fill-available;
    height: 100svh;
    height: 100dvh;
    height: var(--app-vh, 100dvh);
    min-height: 100%;
    min-height: -webkit-fill-available;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: var(--app-vh, 100dvh);
  }

  html.layout-mobile body {
    display: flex;
    flex-direction: column;
  }

  html.layout-mobile .app-header,
  html.layout-mobile .mobile-city-bar,
  html.layout-mobile .app-timeline-footer {
    flex: 0 0 auto;
  }

  /* Hide the desktop drawer on first paint, before JS adds layout-mobile */
  .detail-sidebar:not(.sheet-half):not(.sheet-full):not(.sheet-peek) {
    transform: translateY(100vh);
  }

  html.layout-mobile {
    --header-height: 48px;
    --filterbar-height: 0px;
    --citybar-height: 52px;
    --footer-height: 124px;
    --tap: 44px;
  }

  html.layout-mobile .app-header {
    height: var(--header-height);
    padding: 0 0.55rem 0 0.7rem;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-height) + env(safe-area-inset-top));
    gap: 0.4rem;
  }

  html.layout-mobile .brand-title {
    font-size: 0.92rem;
    letter-spacing: 0.02em;
  }

  html.layout-mobile .brand-subtitle,
  html.layout-mobile .header-right > .dropdown-container,
  html.layout-mobile .header-right > #storyToursBtn,
  html.layout-mobile .header-right > .header-quick-jump-container,
  html.layout-mobile .header-right > .sidebar-toggle-btn,
  html.layout-mobile .header-center {
    display: none;
  }

  html.layout-mobile.search-open .header-center {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    top: calc(var(--header-height) + env(safe-area-inset-top));
    max-width: none;
    margin: 0;
    padding: 8px 8px 10px;
    background: #1B130E;
    border-bottom: 1px solid var(--color-gold);
    z-index: 1800;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  }

  html.layout-mobile.search-open .search-box-wrapper {
    background: #FFFDF8;
    border-color: var(--color-gold);
    min-height: var(--tap);
  }

  html.layout-mobile.search-open .search-results-dropdown {
    background: #FFFDF8;
  }

  html.layout-mobile.search-open #globalSearchInput {
    color: var(--text-primary);
    font-size: 16px; /* prevent iOS zoom */
  }

  html.layout-mobile.search-open #globalSearchInput::placeholder {
    color: var(--text-muted);
  }

  html.layout-mobile.search-open .search-icon {
    color: var(--text-secondary);
  }

  html.layout-mobile.search-open .search-results-dropdown {
    max-height: min(50vh, 360px);
  }

  html.layout-mobile.search-open .search-result-item {
    min-height: var(--tap);
    padding: 0.7rem 1rem;
  }

  html.layout-mobile .brand-symbol {
    width: 30px;
    height: 30px;
  }

  html.layout-mobile .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
  }

  html.layout-mobile .mobile-header-actions .btn-icon {
    width: var(--tap);
    height: var(--tap);
    min-width: var(--tap);
  }

  /* Desktop chip bar collapses; chips reappear in the filter dropdown */
  html.layout-mobile .layer-filter-bar {
    position: absolute;
    width: 0;
    height: 0;
    min-height: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    overflow: visible;
    background: transparent;
    pointer-events: none;
  }

  html.layout-mobile .filter-scroll-track {
    position: static;
    width: auto;
    height: 0;
    overflow: visible;
    gap: 0;
  }

  html.layout-mobile .filter-group-layers {
    width: auto;
    min-width: 0;
  }

  html.layout-mobile .filter-label,
  html.layout-mobile .filter-group-right {
    display: none;
  }

  html.layout-mobile .mobile-filter-trigger,
  html.layout-mobile .mobile-period-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    min-height: var(--tap);
    height: var(--tap);
    padding: 0 8px;
    border: 1.5px solid var(--border-parchment-dark);
    border-radius: 10px;
    background: #FFFDF8;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }

  html.layout-mobile .mobile-filter-trigger {
    flex: 0 1 28%;
    max-width: 32%;
  }

  html.layout-mobile .mobile-period-trigger {
    flex: 1 1 32%;
  }

  html.layout-mobile .mobile-filter-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #A3937C;
  }

  html.layout-mobile .mobile-filter-dot.dot-all { background: #A3937C; }
  html.layout-mobile .mobile-filter-dot.dot-savior { background: #EAB308; }
  html.layout-mobile .mobile-filter-dot.dot-diaspora { background: #3B82F6; }
  html.layout-mobile .mobile-filter-dot.dot-church { background: #DC2626; }
  html.layout-mobile .mobile-filter-dot.dot-journey { background: #16A34A; }
  html.layout-mobile .mobile-filter-dot.dot-heatmap { background: #F97316; }
  html.layout-mobile .mobile-filter-dot.dot-provinces { background: #854D0E; }
  html.layout-mobile .mobile-filter-dot.dot-jerusalem,
  html.layout-mobile .mobile-filter-dot.dot-jerusalem-geo { background: #B45309; }

  html.layout-mobile .mobile-filter-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.layout-mobile .mobile-filter-caret,
  html.layout-mobile .mobile-period-caret {
    color: #B45309;
    font-size: 1.05rem;
    line-height: 1;
    flex: 0 0 auto;
  }

  html.layout-mobile .mobile-period-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.layout-mobile.filter-menu-open .mobile-filter-trigger,
  html.layout-mobile.period-menu-open .mobile-period-trigger {
    border-color: #D97706;
    background: #FFF8EB;
  }

  html.layout-mobile .filter-chip-rows,
  html.layout-mobile .era-selector-tabs {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + env(safe-area-inset-top) + var(--citybar-height) + 4px);
    left: 8px;
    right: 8px;
    z-index: 1550;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    max-height: min(56vh, 420px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 6px;
    background: #FFFDF8;
    border: 1.5px solid var(--border-parchment-dark);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  }

  html.layout-mobile.filter-menu-open .filter-chip-rows,
  html.layout-mobile.period-menu-open .era-selector-tabs {
    display: flex;
    pointer-events: auto;
  }

  html.layout-mobile .filter-chip-row {
    display: contents;
  }

  html.layout-mobile .filter-chip {
    flex: 0 0 auto;
    width: 100%;
    justify-content: flex-start;
    min-height: var(--tap);
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    box-sizing: border-box;
    border-radius: 8px;
  }

  /* One compact command row: filter dropdown + city/region jump */
  html.layout-mobile .mobile-city-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    height: var(--citybar-height);
    padding: 0 8px;
    background: #F4EBDA;
    border-bottom: 1px solid var(--border-parchment-dark);
    z-index: 940;
    position: relative;
  }

  html.layout-mobile .mobile-city-picker-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 38%;
    width: auto;
    min-width: 0;
    min-height: var(--tap);
    height: var(--tap);
    padding: 0 8px;
    border: 1.5px solid #D97706;
    border-radius: 10px;
    background: #FFFDF8;
    color: var(--text-primary);
    font-family: var(--font-sans);
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }

  html.layout-mobile .mobile-city-picker-icon {
    flex: 0 0 auto;
    font-size: 1rem;
    line-height: 1;
  }

  html.layout-mobile .mobile-city-picker-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  html.layout-mobile .mobile-city-picker-label {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    color: #451A03;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.layout-mobile .mobile-city-picker-current {
    display: none;
    font-size: 0.68rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.layout-mobile .mobile-city-bar.has-place .mobile-city-picker-label {
    display: none;
  }

  html.layout-mobile .mobile-city-bar.has-place .mobile-city-picker-current {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    color: #451A03;
  }

  html.layout-mobile .mobile-city-picker-caret {
    color: #B45309;
    font-size: 1.1rem;
    line-height: 1;
  }

  /* Map consumes leftover viewport after in-flow chrome so taller phones
     grow the map. Calc fallbacks cover non-flex; flex-grow fills any gap
     when 100dvh / chrome tokens do not match the visual viewport. */
  html.layout-mobile .app-main-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: calc(100vh - var(--header-height) - var(--filterbar-height) - var(--citybar-height) - var(--footer-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(100svh - var(--header-height) - var(--filterbar-height) - var(--citybar-height) - var(--footer-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--header-height) - var(--filterbar-height) - var(--citybar-height) - var(--footer-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(var(--app-vh, 100dvh) - var(--header-height) - var(--filterbar-height) - var(--citybar-height) - var(--footer-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  html.layout-mobile .map-viewport {
    width: 100%;
    min-width: 0;
  }

  /* Period title: the 5px crimson left edge is the badge's own accent
     (map.css border-left), not a covered control. FABs sit under it. */
  html.layout-mobile .floating-era-badge {
    top: 8px;
    left: 8px;
    max-width: min(54vw, 190px);
    padding: 0.28rem 0.5rem;
    z-index: 800;
  }

  html.layout-mobile .era-tag {
    display: none;
  }

  html.layout-mobile .era-title {
    font-size: 0.72rem;
    margin-bottom: 0;
  }

  html.layout-mobile .era-desc {
    display: none;
  }

  html.layout-mobile .map-floating-actions {
    top: var(--left-fab-top, 56px);
    right: auto;
    left: 8px;
    bottom: auto;
    z-index: 850;
  }

  html.layout-mobile #holyLandQuickBtn {
    display: none;
  }

  html.layout-mobile .floating-btn {
    width: var(--tap);
    height: var(--tap);
    min-width: var(--tap);
    min-height: var(--tap);
  }

  html.layout-mobile .city-label-text:not(.city-label-major),
  html.layout-mobile .region-label-text {
    display: none;
  }

  html.layout-mobile .city-label-text.city-label-major {
    font-size: 11px;
    letter-spacing: 0.02em;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.layout-mobile .city-label-text.city-label-primary {
    max-width: none;
    font-size: 12px;
  }

  html.layout-mobile:not(.mobile-zoomed) .city-label-text {
    display: none !important;
  }

  html.layout-mobile.mobile-zoomed:not(.mobile-zoomed-deep) .city-label-text:not(.city-label-primary) {
    display: none !important;
  }

  html.layout-mobile .map-legend-box {
    bottom: 12px;
    left: 10px;
    max-width: min(200px, 58vw);
    max-height: 36%;
    overflow: hidden;
  }

  html.layout-mobile .legend-body {
    max-height: 28vh;
    overflow-y: auto;
  }

  html.layout-mobile .mobile-basemap-toggle {
    display: flex;
    align-items: stretch;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 860;
    background: #FFFDF8;
    border: 1.5px solid var(--border-parchment-dark);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  }

  html.layout-mobile .mobile-basemap-btn {
    min-height: var(--tap);
    min-width: var(--tap);
    padding: 0 0.7rem;
    border: none;
    border-right: 1px solid var(--border-parchment);
    background: #FFFDF8;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
  }

  html.layout-mobile .mobile-basemap-btn:last-child {
    border-right: none;
  }

  html.layout-mobile .mobile-basemap-btn.active,
  html.layout-mobile .mobile-basemap-btn[aria-pressed="true"] {
    background: #1B130E;
    color: #FDE047;
  }

  html.layout-mobile .leaflet-control-zoom {
    margin-top: 0 !important;
    margin-right: 8px !important;
    margin-bottom: 0 !important;
    margin-left: 0 !important;
  }

  html.layout-mobile .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 20px !important;
  }

  html.layout-mobile .leaflet-top.leaflet-right {
    top: var(--zoom-stack-top, calc(8px + var(--tap) + 10px));
    right: 8px;
  }

  html.layout-mobile .leaflet-bottom.leaflet-left {
    bottom: 4px;
    left: 4px;
  }

  html.layout-mobile .leaflet-bottom.leaflet-right {
    bottom: 4px;
    right: 4px;
  }

  html.layout-mobile .leaflet-control-attribution {
    font-size: 9px;
    max-width: 46vw;
  }

  /* Bottom sheet sits ABOVE the timeline (fixed, not trapped in main) */
  html.layout-mobile .app-timeline-footer {
    z-index: 1000;
  }

  html.layout-mobile .detail-sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(var(--footer-height) + env(safe-area-inset-bottom));
    width: 100%;
    height: 42vh;
    max-height: calc(var(--app-vh, 100dvh) - var(--header-height) - var(--filterbar-height) - var(--citybar-height) - var(--footer-height) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 8px);
    border-left: none;
    border-top: 2px solid var(--color-gold);
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), height 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1400;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.28);
    overflow: hidden;
  }

  html.layout-mobile .detail-sidebar.closed,
  html.layout-mobile .detail-sidebar:not(.sheet-half):not(.sheet-full):not(.sheet-peek) {
    transform: translateY(100vh);
    pointer-events: none;
    box-shadow: none;
  }

  html.layout-mobile.sheet-open {
    --citybar-height: 0px;
  }

  html.layout-mobile.sheet-open .mobile-city-bar {
    display: none;
    overflow: hidden;
    pointer-events: none;
  }

  html.layout-mobile.sheet-open.filter-menu-open .filter-chip-rows,
  html.layout-mobile.sheet-open.period-menu-open .era-selector-tabs {
    display: none;
    pointer-events: none;
  }

  html.layout-mobile .detail-sidebar.sheet-half,
  html.layout-mobile .detail-sidebar.sheet-full,
  html.layout-mobile .detail-sidebar.sheet-peek {
    transform: translateY(0);
  }

  html.layout-mobile .detail-sidebar.sheet-peek {
    height: 88px;
  }

  html.layout-mobile .detail-sidebar.sheet-half {
    height: 46vh;
  }

  html.layout-mobile .detail-sidebar.sheet-full {
    height: calc(var(--app-vh, 100dvh) - var(--header-height) - env(safe-area-inset-top, 0px) - var(--footer-height) - env(safe-area-inset-bottom, 0px) - 8px);
  }

  html.layout-mobile .detail-sidebar.sheet-dragging {
    transition: none;
  }

  html.layout-mobile .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
  }

  html.layout-mobile .sheet-handle-bar {
    width: 48px;
    height: 5px;
    border-radius: 99px;
    background: #A08968;
  }

  html.layout-mobile .sidebar-header {
    padding: 0.45rem 1rem 0.7rem;
  }

  html.layout-mobile .sidebar-title {
    font-size: 1.05rem;
  }

  html.layout-mobile .close-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.8rem;
  }

  html.layout-mobile .sidebar-tabs {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-padding-inline: 10px;
  }

  html.layout-mobile .sidebar-tabs::-webkit-scrollbar {
    display: none;
  }

  html.layout-mobile .sidebar-tab-row {
    display: contents;
  }

  html.layout-mobile .sidebar-tab-row:first-child .tab-btn,
  html.layout-mobile .sidebar-tab-row:last-child .tab-btn,
  html.layout-mobile .sidebar-tab-row .tab-btn,
  html.layout-mobile .tab-btn {
    flex: 0 0 auto !important;
    min-height: var(--tap);
    min-width: max-content;
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    border-radius: 999px;
  }

  html.layout-mobile .sidebar-tabs::after {
    content: "";
    flex: 0 0 10px;
  }

  html.layout-mobile .sidebar-content {
    padding: 1rem 1rem 1.4rem;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    overflow-y: auto;
  }

  /* Timeline: denser chrome, same core controls, thumb above safe-area */
  html.layout-mobile .app-timeline-footer {
    height: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
    padding: 4px 8px max(28px, calc(20px + env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
    overflow: visible;
    justify-content: flex-start;
    gap: 2px;
  }

  html.layout-mobile .timeline-control-bar {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(56px, 1fr);
    grid-template-areas: "playback date";
    gap: 2px 6px;
    align-items: center;
    min-width: 0;
  }

  html.layout-mobile .playback-controls {
    grid-area: playback;
    gap: 4px;
    min-width: 0;
  }

  html.layout-mobile .speed-selector {
    margin-left: 0.05rem;
    padding: 1px;
    flex: 0 0 auto;
  }

  html.layout-mobile .current-date-badge {
    grid-area: date;
    position: relative;
    min-width: 0;
    width: 100%;
    padding: 4px 8px;
    justify-content: center;
  }

  html.layout-mobile .badge-year {
    font-size: 0.95rem;
  }

  /* Year only on phone; season stays in the a11y tree / aria-label. */
  html.layout-mobile .badge-season {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  html.layout-mobile .btn-ctrl {
    width: 44px;
    height: 44px;
  }

  html.layout-mobile .btn-play {
    width: 44px;
    height: 44px;
  }

  html.layout-mobile .speed-btn {
    min-height: var(--tap);
    min-width: var(--tap);
    padding: 2px 6px;
    font-size: 0.72rem;
  }

  html.layout-mobile .era-tab {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    width: 100%;
    justify-content: flex-start;
    min-height: var(--tap);
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    border-radius: 8px;
    box-sizing: border-box;
    text-align: left;
  }

  html.layout-mobile .timeline-slider-track-wrap {
    margin-top: 2px;
    margin-bottom: 0;
    padding: 10px 2px 18px;
    box-sizing: border-box;
  }

  html.layout-mobile .timeline-slider {
    height: 12px;
    margin: 0;
  }

  html.layout-mobile .timeline-slider::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  html.layout-mobile .timeline-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }

  html.layout-mobile .timeline-labels {
    display: none;
  }

  /* Tour stepper sits above the timeline */
  html.layout-mobile .tour-stepper-bar {
    top: auto;
    bottom: calc(var(--footer-height) + env(safe-area-inset-bottom) + 8px);
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    border-radius: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.7rem 0.85rem;
  }

  html.layout-mobile .stepper-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  html.layout-mobile .stepper-controls .btn {
    min-height: 44px;
  }

  html.layout-mobile #tourExitBtn {
    grid-column: 1 / -1;
  }

  /* Modals & satellite explorer */
  html.layout-mobile .modal-backdrop {
    padding: 0.6rem 0 0;
    align-items: flex-end;
    background: rgba(20, 14, 8, 0.78);
  }

  html.layout-mobile .modal-card {
    max-height: 86dvh;
    border-radius: 16px 16px 0 0;
    background: #FBF6EA;
    isolation: isolate;
    animation: none;
    transform: none;
  }

  html.layout-mobile .modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem 0.85rem calc(1.4rem + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    isolation: isolate;
  }

  html.layout-mobile .tour-select-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.75rem;
    min-height: 0;
    background: #FFFDF8;
    position: relative;
    z-index: 1;
    isolation: isolate;
    contain: layout paint;
    overflow: hidden;
    transform: none !important;
    margin: 0;
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
    box-shadow: none;
  }

  html.layout-mobile .tour-select-card:hover,
  html.layout-mobile .tour-select-card:active,
  html.layout-mobile .tour-select-card:focus {
    transform: none !important;
    box-shadow: none;
  }

  html.layout-mobile .tour-card-title,
  html.layout-mobile .tour-card-desc,
  html.layout-mobile .tour-card-footer {
    display: block;
    position: static;
  }

  html.layout-mobile .tour-card-body {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  html.layout-mobile .tour-card-title {
    display: block;
    line-height: 1.25;
  }

  html.layout-mobile .tour-card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  html.layout-mobile .tour-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
    margin-top: 0.35rem;
  }

  html.layout-mobile .satellite-modal-window {
    width: 100vw;
    height: var(--app-vh, 100dvh);
    border-radius: 0;
  }

  html.layout-mobile .satellite-modal-header {
    padding: 10px 12px;
    gap: 8px;
  }

  html.layout-mobile .satellite-modal-title {
    font-size: 1.05rem;
  }

  html.layout-mobile .satellite-info-card {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 12px;
  }

  html.layout-mobile .satellite-view-tabs {
    width: 100%;
    overflow-x: auto;
  }

  html.layout-mobile .sat-tab {
    min-height: 40px;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------
   Overlays (only when the mobile shell class is on)
   -------------------------------------------------------------------------- */
html.layout-mobile .mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 20, 12, 0.45);
  z-index: 1600;
}

html.layout-mobile .mobile-backdrop.visible {
  display: block;
}

html.layout-mobile .mobile-picker-sheet,
html.layout-mobile .mobile-action-sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1700;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}

html.layout-mobile .mobile-picker-sheet.open,
html.layout-mobile .mobile-action-sheet.open {
  display: flex;
}

html.layout-mobile .mobile-picker-card {
  pointer-events: auto;
  width: 100%;
  max-height: min(88dvh, 720px);
  background: var(--bg-card);
  border-radius: 18px 18px 0 0;
  border-top: 3px solid var(--color-gold);
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html.layout-mobile .mobile-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.55rem;
  background: #EBE0CC;
  border-bottom: 1px solid var(--border-parchment-dark);
}

html.layout-mobile .mobile-picker-header h3 {
  font-family: var(--font-serif-title);
  font-size: 1.02rem;
  color: var(--text-primary);
}

html.layout-mobile .mobile-picker-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0.85rem 0.35rem;
  padding: 0 0.85rem;
  min-height: 48px;
  border: 1.5px solid var(--border-parchment-dark);
  border-radius: 12px;
  background: #FFFDF8;
}

html.layout-mobile #mobileCitySearch {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
}

html.layout-mobile .mobile-picker-list,
html.layout-mobile .mobile-more-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.4rem 0 1.25rem;
}

html.layout-mobile .mobile-picker-group-label,
html.layout-mobile .mobile-more-label {
  font-family: var(--font-serif-title);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-crimson);
  padding: 0.7rem 1rem 0.25rem;
}

html.layout-mobile .mobile-picker-item,
html.layout-mobile .mobile-more-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: none;
  border-bottom: 1px solid rgba(217, 200, 172, 0.45);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
}

html.layout-mobile .mobile-picker-item:active,
html.layout-mobile .mobile-more-item:active {
  background: var(--bg-parchment-deep);
}

html.layout-mobile .mobile-picker-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Landscape phones: reclaim vertical map space
   -------------------------------------------------------------------------- */
@media (max-width: 768px) and (max-height: 500px) {
  html.layout-mobile {
    --filterbar-height: 0px;
    --citybar-height: 52px;
    --footer-height: 120px;
  }

  html.layout-mobile.filter-menu-open .filter-chip-rows,
  html.layout-mobile.period-menu-open .era-selector-tabs {
    flex-direction: column;
    max-height: min(48vh, 280px);
  }

  html.layout-mobile .filter-chip-row {
    display: contents;
  }

  html.layout-mobile .detail-sidebar.sheet-half {
    height: 62%;
  }
}
