/* Small Austin — Mobile UX, Swipe Gestures, Apple-Maps Inspector & Adaptive Solar Glass
 * Strictly scoped to <= 760px and compact landscape phones (<= 900px x <= 500px);
 * desktop layout is completely untouched.
 */

#mobile-top-bar,
#mobile-quick-rail,
#mobile-search-panel,
#mobile-sheet,
#mobile-sheet-backdrop,
#mobile-zoom-pill,
#mobile-toast {
  display: none;
}

@media (max-width: 760px), (max-width: 900px) and (max-height: 500px) {
  html,
  body,
  #stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Universal touch ergonomics on mobile interactive controls */
  #mobile-top-bar button,
  #mobile-quick-rail button,
  #mobile-zoom-pill button,
  #mobile-search-panel button,
  #mobile-sheet button,
  #inspector button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Hide ALL desktop floating panels & command menus so mobile viewport never stretches or overlaps */
  body.pa-mobile-active #hud,
  body.pa-mobile-active #bookmarks,
  body.pa-mobile-active #footer,
  body.pa-mobile-active #carto-controls,
  body.pa-mobile-active #hover-tip,
  body.pa-mobile-active #pa-explore-dock,
  body.pa-mobile-active .pa-cmd-menu,
  body.pa-mobile-active #pa-explore-drawer,
  body.pa-mobile-active #pa-skyfx-menu,
  body.pa-mobile-active #pa-sound-popover,
  body.pa-mobile-active #shortcuts-backdrop {
    display: none !important;
  }

  /* Hide desktop minimap widget completely on mobile (eliminates duplicate stacked-layers icon above zoom stack) */
  body.pa-mobile-active #pa-minimap,
  #pa-minimap {
    display: none !important;
  }

  /* In Tiny AUS mode on mobile, hand off the quick-rail slot to #ta-mobile-rail and the bottom slot to #ta-ops-fab */
  body.pa-tiny-aus-mode #mobile-quick-rail {
    display: none !important;
  }

  body.pa-tiny-aus-mode #mobile-sheet:not(.open) {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transform: translate3d(-50%, 34px, 0) !important;
  }

  body.pa-mobile-insp-open #mobile-zoom-pill,
  body.pa-mobile-sheet-open #mobile-zoom-pill,
  body.pa-mobile-tour-open #mobile-zoom-pill,
  body.pa-mobile-overlay-open #mobile-zoom-pill,
  body.pa-tiny-aus-panel-open #mobile-zoom-pill {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate3d(20px, 6px, 0) scale(0.94);
  }

  body.pa-mobile-insp-open #mobile-quick-rail,
  body.pa-mobile-sheet-open #mobile-quick-rail,
  body.pa-mobile-search-open #mobile-quick-rail,
  body.pa-mobile-tour-open #mobile-quick-rail,
  body.pa-mobile-overlay-open #mobile-quick-rail,
  body.pa-tiny-aus-panel-open #mobile-quick-rail {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate3d(0, -8px, 0);
  }

  body.pa-mobile-insp-open #mobile-sheet,
  body.pa-mobile-tour-open #mobile-sheet,
  body.pa-mobile-overlay-open #mobile-sheet,
  body.pa-tiny-aus-panel-open #mobile-sheet {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Prevent duplicate toasts while mobile copy toast is showing */
  body.pa-mobile-toast-open #toast {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* 1. Compact Top Floating Pill Bar */
  #mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    position: fixed;
    top: max(10px, calc(env(safe-area-inset-top) + 4px));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    height: 44px;
    padding: 4px 6px 4px 10px;
    z-index: 44;
    background: rgba(251, 246, 234, 0.92);
    border: 1.4px solid rgba(74, 59, 44, 0.72);
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(20, 14, 10, 0.22);
    backdrop-filter: blur(16px) saturate(1.25);
    -webkit-backdrop-filter: blur(16px) saturate(1.25);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  }

  /* 1a. One-Tap Floating Quick-Jump Chip Strip with subtle edge fade mask */
  #mobile-quick-rail {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: calc(max(10px, calc(env(safe-area-inset-top) + 4px)) + 50px);
    left: env(safe-area-inset-left, 0px);
    right: env(safe-area-inset-right, 0px);
    padding: 2px 24px 6px 14px;
    z-index: 38;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0px,
      #000 12px,
      #000 calc(100% - 28px),
      transparent 100%
    );
    mask-image: linear-gradient(
      to right,
      transparent 0px,
      #000 12px,
      #000 calc(100% - 28px),
      transparent 100%
    );
    transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #mobile-quick-rail::-webkit-scrollbar {
    display: none;
  }

  .m-qchip {
    appearance: none;
    border: 1.1px solid rgba(74, 59, 44, 0.48);
    background: rgba(251, 246, 234, 0.90);
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
    height: 31px;
    padding: 0 12px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(20, 14, 10, 0.16);
    backdrop-filter: blur(12px) saturate(1.15);
    -webkit-backdrop-filter: blur(12px) saturate(1.15);
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1),
      background 0.16s ease,
      color 0.16s ease,
      border-color 0.16s ease,
      box-shadow 0.16s ease;
  }

  .m-qchip:active {
    transform: scale(0.94);
  }

  .m-qchip.active {
    background: var(--accent, #c45735);
    border-color: rgba(74, 59, 44, 0.85);
    color: #fbf6ea;
    box-shadow: 0 3px 10px rgba(196, 87, 53, 0.34);
  }

  .m-qchip.m-qchip-bats {
    background: rgba(44, 34, 26, 0.90);
    border-color: rgba(251, 246, 234, 0.50);
    color: #fbf6ea;
  }

  .m-qchip.m-qchip-bats.active {
    background: var(--accent, #c45735);
    border-color: #fbf6ea;
    color: #fffaf0;
  }

  .m-qchip.m-qchip-aus {
    background: linear-gradient(180deg, rgba(232, 246, 244, 0.96), rgba(215, 237, 234, 0.94));
    border-color: rgba(44, 94, 92, 0.56);
    color: #1c4745;
  }

  .m-qchip.m-qchip-aus.active {
    background: var(--teal, #4c8e88);
    border-color: rgba(24, 52, 50, 0.82);
    color: #fffaf0;
    box-shadow: 0 3px 10px rgba(76, 142, 136, 0.34);
  }

  .m-brand-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .m-brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    height: 36px;
    border: none;
    background: transparent;
    padding: 0 2px 0 0;
    color: var(--ink, #2c221a);
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.12s ease;
  }

  .m-brand:active {
    transform: scale(0.96);
  }

  .m-crest {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: block;
  }

  .m-brand-text {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--live, #2e7d32);
    flex-shrink: 0;
    box-shadow: 0 0 0 2.5px rgba(46, 125, 50, 0.22);
  }

  body.pa-tiny-aus-mode .m-live-dot {
    display: none !important;
  }

  body.pa-tiny-aus-mode .m-brand-group {
    gap: 7px;
  }

  .m-city-back-btn {
    display: none;
    appearance: none;
    border: 1.1px solid rgba(74, 59, 44, 0.52);
    background: var(--accent, #c45735);
    color: #fffaf0;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.01em;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(196, 87, 53, 0.28);
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s ease;
  }

  .m-city-back-btn:active {
    transform: scale(0.94);
  }

  body.pa-tiny-aus-mode .m-city-back-btn {
    display: inline-flex;
  }

  body.dusk .m-city-back-btn,
  body.solar-dusk .m-city-back-btn,
  body.solar-night .m-city-back-btn {
    background: #d86540;
    border-color: rgba(255, 232, 214, 0.34);
    color: #fffaf0;
  }

  .m-top-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .m-icon-btn {
    appearance: none;
    border: 1.1px solid rgba(74, 59, 44, 0.30);
    background: rgba(255, 250, 240, 0.92);
    color: var(--ink, #2c221a);
    height: 34px;
    min-width: 36px;
    padding: 0 9px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1),
      background 0.15s ease,
      color 0.15s ease,
      border-color 0.15s ease;
  }

  .m-icon-btn:active {
    transform: scale(0.94);
  }

  .m-icon-btn.active {
    background: var(--ink, #2c221a);
    color: #fbf6ea;
    border-color: var(--ink, #2c221a);
  }

  .m-icon-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
  }

  /* 1b. One-Handed Floating Zoom / Locate / Share Stack (44x44px hit targets) */
  #mobile-zoom-pill {
    display: flex;
    flex-direction: column;
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 68px);
    z-index: 30;
    background: rgba(251, 246, 234, 0.94);
    border: 1.4px solid rgba(74, 59, 44, 0.72);
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(20, 14, 10, 0.24);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    overflow: hidden;
    transition: opacity 0.22s ease,
      transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      background 0.3s ease,
      border-color 0.3s ease;
  }

  .m-zoom-btn {
    appearance: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 21px;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1), background 0.14s ease, color 0.14s ease;
  }

  .m-zoom-btn + .m-zoom-btn {
    border-top: 1px solid rgba(74, 59, 44, 0.18);
  }

  .m-zoom-btn:active {
    transform: scale(0.94);
    background: rgba(74, 59, 44, 0.13);
  }

  .m-zoom-btn svg {
    display: block;
    pointer-events: none;
  }

  /* 1c. Crisp Floating Mobile Toast (for Copy Link fallback) */
  #mobile-toast {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: fixed;
    left: 50%;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px);
    transform: translate3d(-50%, 14px, 0) scale(0.95);
    z-index: 62;
    background: rgba(34, 26, 20, 0.94);
    color: #fbf6ea;
    border: 1.2px solid rgba(228, 126, 77, 0.72);
    border-radius: 999px;
    padding: 8px 15px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    box-shadow: 0 10px 28px rgba(14, 10, 8, 0.38);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1.12, 0.36, 1);
  }

  #mobile-toast.visible {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }

  #mobile-toast .m-toast-icon {
    color: #e47e4d;
    flex-shrink: 0;
  }

  /* 2. Mobile Search Dropdown Panel (with swipe-down header to dismiss) */
  #mobile-search-panel {
    display: none;
    position: fixed;
    top: calc(max(10px, calc(env(safe-area-inset-top) + 4px)) + 50px);
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    z-index: 46;
    background: rgba(251, 246, 234, 0.96);
    border: 1.4px solid rgba(74, 59, 44, 0.72);
    border-radius: 18px;
    box-shadow: 0 14px 36px rgba(20, 14, 10, 0.32);
    backdrop-filter: blur(18px) saturate(1.25);
    -webkit-backdrop-filter: blur(18px) saturate(1.25);
    padding: 6px 10px 10px;
    overflow: hidden;
    will-change: transform, opacity;
  }

  #mobile-search-panel.open {
    display: block;
    animation: m-search-drop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes m-search-drop {
    from {
      opacity: 0;
      transform: translate3d(0, -10px, 0) scale(0.98);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0) scale(1);
    }
  }

  #mobile-search-panel.dragging {
    animation: none !important;
    transition: none !important;
  }

  #mobile-search-panel.spring-back {
    animation: none !important;
    transition: transform 0.32s cubic-bezier(0.22, 1.12, 0.36, 1), opacity 0.22s ease !important;
  }

  #mobile-search-panel.dismissing {
    animation: none !important;
    transition: transform 0.17s cubic-bezier(0.4, 0, 1, 1), opacity 0.16s ease !important;
  }

  .m-search-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    touch-action: pan-x;
    user-select: none;
  }

  .m-search-grabber {
    width: 34px;
    height: 4px;
    border-radius: 999px;
    background: rgba(74, 59, 44, 0.26);
    margin: 0 auto 1px;
  }

  .m-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  /* 16px prevents iOS Safari auto-zoom when focusing input */
  #mobile-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    border: 1.2px solid rgba(74, 59, 44, 0.45);
    border-radius: 12px;
    background: #fffdf8;
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 16px;
    padding: 0 12px;
    outline: none;
    -webkit-appearance: none;
  }

  #mobile-search-input:focus {
    border-color: var(--accent, #c45735);
    box-shadow: 0 0 0 2.5px rgba(196, 87, 53, 0.16);
  }

  #mobile-search-close {
    appearance: none;
    border: 1px solid rgba(74, 59, 44, 0.30);
    background: rgba(74, 59, 44, 0.08);
    color: var(--ink, #2c221a);
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 12px;
    font-size: 21px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s ease, background 0.14s ease;
  }

  #mobile-search-close:active {
    transform: scale(0.94);
    background: rgba(74, 59, 44, 0.18);
  }

  #mobile-search-results {
    margin-top: 8px;
    max-height: 44dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    border-top: 1px solid rgba(74, 59, 44, 0.14);
  }

  #mobile-search-results:empty {
    display: none;
    margin-top: 0;
    border-top: none;
  }

  #mobile-search-results .search-item {
    min-height: 44px;
    padding: 9px 10px;
    border-radius: 10px;
    transition: background 0.14s ease;
  }

  #mobile-search-results .search-item:active {
    background: rgba(196, 87, 53, 0.14);
  }

  #mobile-search-results .search-empty {
    padding: 14px 10px;
    font-size: 13px;
    color: var(--ink-muted, #665848);
    text-align: center;
  }

  /* 3. Bottom Sheet Backdrop */
  #mobile-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 41;
    background: rgba(20, 15, 10, 0.30);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  #mobile-sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* 4. Draggable / Tappable Bottom Sheet */
  #mobile-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 43;
    background: rgba(251, 246, 234, 0.96);
    border: 1.4px solid rgba(74, 59, 44, 0.72);
    border-radius: 22px;
    box-shadow: 0 12px 34px rgba(20, 14, 10, 0.34);
    backdrop-filter: blur(18px) saturate(1.25);
    -webkit-backdrop-filter: blur(18px) saturate(1.25);
    max-height: 76dvh;
    overflow: hidden;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.2s ease,
      border-radius 0.24s ease,
      left 0.24s ease,
      right 0.24s ease,
      bottom 0.24s ease,
      background 0.3s ease,
      border-color 0.3s ease;
    will-change: transform;
  }

  /* Collapsed slim bottom pill by default (>88% pure map) */
  #mobile-sheet.collapsed {
    left: 50%;
    right: auto;
    transform: translate3d(-50%, 0, 0);
    width: min(304px, calc(100vw - 24px));
    border-radius: 999px;
    max-height: 46px;
  }

  #mobile-sheet.dragging {
    transition: none !important;
  }

  #mobile-sheet.spring-back {
    transition: transform 0.34s cubic-bezier(0.22, 1.12, 0.36, 1) !important;
  }

  .m-sheet-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 16px 9px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    flex-shrink: 0;
  }

  #mobile-sheet.collapsed .m-sheet-header {
    padding: 6px 16px 8px;
  }

  .m-drag-handle {
    width: 38px;
    height: 4.5px;
    border-radius: 999px;
    background: rgba(74, 59, 44, 0.32);
    margin-bottom: 5px;
  }

  #mobile-sheet.collapsed .m-drag-handle {
    margin-bottom: 3px;
  }

  .m-sheet-pill-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .m-sheet-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--ink, #2c221a);
    white-space: nowrap;
  }

  .m-sheet-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-muted, #665848);
    white-space: nowrap;
  }

  .m-sheet-chevron {
    display: inline-block;
    font-size: 11px;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #mobile-sheet.open .m-sheet-chevron,
  #mobile-sheet:not(.collapsed) .m-sheet-chevron {
    transform: rotate(180deg);
  }

  .m-sheet-body {
    padding: 2px 14px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 13px;
  }

  #mobile-sheet.collapsed .m-sheet-body {
    display: none;
  }

  .m-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
  }

  .m-section-label {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted, #665848);
  }

  .m-section-badge {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--accent, #c45735);
    background: rgba(196, 87, 53, 0.12);
    border-radius: 999px;
    padding: 2px 8px;
  }

  /* Quick-Jump Neighborhood Chips inside sheet */
  .m-chip-rail {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 18px 2px 0;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 24px), transparent 100%);
  }

  .m-chip-rail::-webkit-scrollbar {
    display: none;
  }

  .m-chip {
    appearance: none;
    border: 1.2px solid rgba(74, 59, 44, 0.56);
    background: #fffaf0;
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    padding: 7px 13px;
    min-height: 38px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }

  .m-chip:active {
    transform: scale(0.95);
  }

  .m-chip.active {
    background: var(--accent, #c45735);
    border-color: rgba(74, 59, 44, 0.85);
    color: #fbf6ea;
  }

  .m-chip.m-chip-bats {
    background: #2f2338;
    border-color: #2c221a;
    color: #fbf6ea;
  }

  .m-chip.m-chip-bats.active {
    background: var(--accent, #c45735);
    border-color: #2c221a;
    color: #fffaf0;
  }

  .m-chip.m-chip-aus {
    background: #e2f2f0;
    border-color: rgba(44, 94, 92, 0.62);
    color: #1c4745;
  }

  .m-chip.m-chip-aus.active {
    background: var(--teal, #4c8e88);
    border-color: #1c4745;
    color: #fffaf0;
  }

  /* Solar Phase Segmented Picker */
  .m-solar-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .m-solar-btn {
    appearance: none;
    border: 1.2px solid rgba(74, 59, 44, 0.38);
    background: rgba(255, 250, 240, 0.92);
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    min-height: 40px;
    padding: 6px 4px;
    border-radius: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }

  .m-solar-btn:active {
    transform: scale(0.95);
  }

  .m-solar-btn.active {
    background: var(--ink, #2c221a);
    border-color: var(--ink, #2c221a);
    color: #fbf6ea;
  }

  /* 2-column Layer Toggles Grid */
  .m-layer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .m-layer-chip {
    appearance: none;
    border: 1.2px solid rgba(74, 59, 44, 0.30);
    background: rgba(74, 59, 44, 0.055);
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    min-height: 42px;
    padding: 7px 10px;
    border-radius: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    text-align: left;
    min-width: 0;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  }

  .m-layer-chip:active {
    transform: scale(0.96);
  }

  .m-layer-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .m-layer-chip .m-layer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.2px solid rgba(74, 59, 44, 0.52);
    background: transparent;
    flex-shrink: 0;
  }

  .m-layer-chip.on {
    background: rgba(196, 87, 53, 0.13);
    border-color: var(--accent, #c45735);
    color: var(--ink, #2c221a);
    font-weight: 700;
  }

  .m-layer-chip.on .m-layer-dot {
    background: var(--accent, #c45735);
    border-color: var(--accent, #c45735);
  }

  /* Tours & Explore Actions */
  .m-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .m-action-btn {
    appearance: none;
    border: 1.2px solid rgba(74, 59, 44, 0.54);
    background: #fffaf0;
    color: var(--ink, #2c221a);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-align: center;
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
  }

  .m-action-btn:active {
    transform: scale(0.95);
  }

  .m-action-btn.primary {
    background: var(--accent, #c45735);
    border-color: rgba(74, 59, 44, 0.72);
    color: #fbf6ea;
  }

  .m-action-btn.active {
    background: var(--teal, #4c8e88);
    border-color: rgba(74, 59, 44, 0.72);
    color: #fbf6ea;
  }

  .m-action-btn.m-action-aus {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, #e7f5f3, #d7ece9);
    border-color: rgba(44, 94, 92, 0.56);
    color: #1c4745;
  }

  .m-action-btn.m-action-aus.active {
    background: var(--accent, #c45735);
    border-color: rgba(74, 59, 44, 0.80);
    color: #fffaf0;
  }

  .m-telemetry {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(74, 59, 44, 0.15);
    font-size: 11px;
    color: var(--ink-muted, #665848);
  }

  .m-pulse-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .m-pulse-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(74, 59, 44, 0.075);
    border: 1px solid rgba(74, 59, 44, 0.16);
    color: var(--ink, #2c221a);
    white-space: nowrap;
  }

  .m-pulse-pill.m-pulse-aus {
    background: rgba(76, 142, 136, 0.13);
    border-color: rgba(76, 142, 136, 0.34);
    color: #1c4745;
  }

  .m-pulse-pill.m-pulse-springs {
    background: rgba(76, 142, 136, 0.08);
    border-color: rgba(76, 142, 136, 0.24);
  }

  .m-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--live, #2e7d32);
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.20);
    flex-shrink: 0;
  }

  .m-telemetry-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 11px;
    color: var(--ink-muted, #665848);
  }

  .m-telemetry a {
    color: #9e4638;
    font-weight: 700;
    text-decoration: none;
  }

  /* 5. Apple Maps / iOS Bottom Sheet Inspector (#inspector) */
  @keyframes m-insp-slide-up {
    from {
      opacity: 0;
      transform: translate3d(0, 36px, 0);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  #inspector {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: auto !important;
    max-width: 100vw !important;
    max-height: 62dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    z-index: 48 !important;
    background: rgba(251, 246, 234, 0.95) !important;
    backdrop-filter: blur(20px) saturate(1.3) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.3) !important;
    border: 1px solid rgba(74, 59, 44, 0.24) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-radius: 22px 22px 0 0 !important;
    padding: 22px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)) !important;
    box-shadow: 0 -10px 36px rgba(20, 14, 10, 0.26) !important;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    will-change: transform, opacity;
  }

  #inspector.visible {
    display: block;
    animation: m-insp-slide-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #inspector.m-insp-dragging {
    animation: none !important;
    transition: none !important;
  }

  #inspector.m-insp-spring {
    animation: none !important;
    transition: transform 0.34s cubic-bezier(0.22, 1.12, 0.36, 1), opacity 0.24s ease !important;
  }

  #inspector.m-insp-dismissing {
    animation: none !important;
    transition: transform 0.18s cubic-bezier(0.4, 0, 1, 1), opacity 0.17s ease !important;
  }

  /* Subtle Apple Maps grabber handle */
  #inspector::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4.5px;
    border-radius: 999px;
    background: rgba(74, 59, 44, 0.26);
    pointer-events: none;
  }

  #inspector .insp-head {
    margin: 0 50px 4px 0 !important;
    flex-wrap: wrap;
    gap: 8px;
  }

  #inspector #insp-badge {
    font-size: 10.5px;
    padding: 3px 8px;
    border-radius: 999px;
    border-width: 1px;
  }

  #inspector h2 {
    font-size: 18px !important;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.22 !important;
    color: var(--ink, #2c221a);
  }

  #inspector .sub {
    font-size: 13px !important;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ink-muted, #665848);
    margin: 2px 0 10px !important;
  }

  #inspector #insp-meta {
    gap: 8px !important;
    margin: 10px 0 10px !important;
  }

  #inspector .insp-stat {
    background: rgba(74, 59, 44, 0.065);
    border: 1px solid rgba(74, 59, 44, 0.14);
    border-radius: 12px;
    padding: 8px 10px;
  }

  #inspector .insp-stat-label {
    font-size: 10px;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
  }

  #inspector .insp-stat-val {
    font-size: 13.5px;
    font-weight: 700;
  }

  #inspector .fact {
    font-size: 13.5px !important;
    line-height: 1.48 !important;
    color: var(--ink, #2c221a);
  }

  #inspector .close {
    top: 10px !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    line-height: 1 !important;
    background: rgba(74, 59, 44, 0.09) !important;
    color: var(--ink, #2c221a) !important;
    padding: 0 !important;
    transition: transform 0.12s ease, background 0.14s ease;
  }

  #inspector .close:active {
    transform: scale(0.92);
    background: rgba(74, 59, 44, 0.20) !important;
  }

  #inspector #insp-extra {
    margin-top: 12px !important;
    display: flex;
    flex-direction: column;
    gap: 8px !important;
  }

  #inspector #insp-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(74, 59, 44, 0.14);
  }

  #inspector .pill {
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s ease;
  }

  #inspector .pill:active {
    transform: scale(0.97);
  }

  #inspector .pill.insp-btn-hidden {
    display: none !important;
  }

  #inspector .follow-hint {
    text-align: center;
    font-size: 11.5px;
    opacity: 0.82;
  }

  #inspector img,
  #inspector video,
  #inspector canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
  }

  /* 6. Clean Plugin Drawers & Modals on Mobile (Safe-Area Aware, Zero Clipping) */
  body.pa-mobile-active #pa-tours-popover,
  body.pa-mobile-active #pa-hunt-drawer {
    top: calc(max(10px, calc(env(safe-area-inset-top) + 4px)) + 50px) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 78px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    z-index: 49 !important;
    border-radius: 18px !important;
    touch-action: pan-y;
  }

  body.pa-mobile-active .pa-tours-list,
  body.pa-mobile-active .pa-hunt-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body.pa-mobile-active .pa-hunt-close,
  body.pa-mobile-active #pa-tours-close,
  body.pa-mobile-active .pa-tc-close {
    width: 38px !important;
    height: 38px !important;
    font-size: 20px !important;
    border-radius: 10px !important;
    touch-action: manipulation;
  }

  /* Tour story card sits cleanly along bottom edge (mobile sheet auto-hides while touring) */
  body.pa-mobile-active #pa-tour-card {
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    transform: translateY(14px) !important;
    z-index: 47 !important;
    border-radius: 18px !important;
  }

  body.pa-mobile-active #pa-tour-card.visible {
    transform: translateY(0) !important;
  }

  body.pa-mobile-active .pa-tc-btn {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 12.5px;
    touch-action: manipulation;
  }

  /* Postcard Studio mobile safe areas + 16px caption input (no iOS zoom) */
  body.pa-mobile-active #pa-studio-backdrop {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
    z-index: 60 !important;
  }

  body.pa-mobile-active #pa-studio-modal {
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    touch-action: pan-y;
  }

  body.pa-mobile-active .pa-studio-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body.pa-mobile-active #pa-studio-caption {
    font-size: 16px !important;
  }

  body.pa-mobile-active .pa-studio-close {
    width: 40px !important;
    height: 40px !important;
    touch-action: manipulation;
  }

  /* Hunt seal toast positioned cleanly below top bar */
  body.pa-mobile-active #pa-hunt-toast {
    top: calc(max(10px, calc(env(safe-area-inset-top) + 4px)) + 50px) !important;
    bottom: auto !important;
    z-index: 54 !important;
  }

  /* Keep general toast comfortably above slim bottom pill */
  #toast {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px) !important;
    max-width: calc(100vw - 24px);
    text-align: center;
  }

  /* 7. Adaptive Solar Styling — Dawn & Golden Hour Warm Glassmorphism */
  body.solar-dawn #mobile-top-bar,
  body.solar-dawn #mobile-sheet,
  body.solar-dawn #mobile-zoom-pill,
  body.solar-dawn #mobile-search-panel {
    background: rgba(253, 241, 234, 0.93);
    border-color: rgba(168, 96, 78, 0.46);
    box-shadow: 0 8px 26px rgba(62, 28, 24, 0.22);
  }

  body.solar-dawn #inspector {
    background: rgba(253, 241, 234, 0.95) !important;
    border-top-color: rgba(168, 96, 78, 0.42) !important;
    box-shadow: 0 -10px 36px rgba(62, 28, 24, 0.24) !important;
  }

  body.solar-dawn .m-qchip {
    background: rgba(253, 241, 234, 0.90);
    border-color: rgba(168, 96, 78, 0.42);
  }

  body.solar-golden #mobile-top-bar,
  body.solar-golden #mobile-sheet,
  body.solar-golden #mobile-zoom-pill,
  body.solar-golden #mobile-search-panel {
    background: rgba(254, 243, 218, 0.93);
    border-color: rgba(154, 96, 38, 0.52);
    box-shadow: 0 8px 26px rgba(72, 42, 12, 0.25);
  }

  body.solar-golden #inspector {
    background: rgba(254, 243, 218, 0.95) !important;
    border-top-color: rgba(154, 96, 38, 0.46) !important;
    box-shadow: 0 -10px 36px rgba(72, 42, 12, 0.26) !important;
  }

  body.solar-golden .m-qchip {
    background: rgba(254, 243, 218, 0.90);
    border-color: rgba(154, 96, 38, 0.44);
  }

  body.solar-golden .m-qchip.active,
  body.solar-golden .m-chip.active {
    background: #b85227;
    border-color: rgba(94, 46, 16, 0.72);
    color: #fffaf0;
  }

  /* 8. Adaptive Solar Styling — Dusk & Night Dark Glassmorphism */
  body.dusk #mobile-top-bar,
  body.solar-dusk #mobile-top-bar,
  body.dusk #mobile-sheet,
  body.solar-dusk #mobile-sheet,
  body.dusk #mobile-zoom-pill,
  body.solar-dusk #mobile-zoom-pill,
  body.dusk #mobile-search-panel,
  body.solar-dusk #mobile-search-panel {
    background: rgba(28, 22, 38, 0.90);
    border-color: rgba(242, 198, 138, 0.34);
    color: #fbf6ea;
    box-shadow: 0 10px 28px rgba(6, 4, 14, 0.54);
  }

  body.solar-night #mobile-top-bar,
  body.solar-night #mobile-sheet,
  body.solar-night #mobile-zoom-pill,
  body.solar-night #mobile-search-panel {
    background: rgba(16, 18, 30, 0.92);
    border-color: rgba(232, 192, 134, 0.30);
    color: #fbf6ea;
    box-shadow: 0 12px 32px rgba(2, 4, 12, 0.64);
  }

  body.dusk #inspector,
  body.solar-dusk #inspector {
    background: rgba(26, 20, 36, 0.93) !important;
    border-top: 1px solid rgba(242, 198, 138, 0.32) !important;
    color: #fbf6ea !important;
    box-shadow: 0 -12px 40px rgba(6, 4, 14, 0.62) !important;
  }

  body.solar-night #inspector {
    background: rgba(15, 17, 29, 0.95) !important;
    border-top: 1px solid rgba(232, 192, 134, 0.28) !important;
    color: #fbf6ea !important;
    box-shadow: 0 -14px 44px rgba(2, 3, 10, 0.72) !important;
  }

  body.dusk #inspector::before,
  body.solar-dusk #inspector::before,
  body.solar-night #inspector::before,
  body.dusk .m-drag-handle,
  body.solar-dusk .m-drag-handle,
  body.solar-night .m-drag-handle,
  body.dusk .m-search-grabber,
  body.solar-dusk .m-search-grabber,
  body.solar-night .m-search-grabber {
    background: rgba(251, 246, 234, 0.34);
  }

  body.dusk #inspector h2,
  body.solar-dusk #inspector h2,
  body.solar-night #inspector h2,
  body.dusk #inspector .fact,
  body.solar-dusk #inspector .fact,
  body.solar-night #inspector .fact,
  body.dusk #inspector .insp-stat-val,
  body.solar-dusk #inspector .insp-stat-val,
  body.solar-night #inspector .insp-stat-val {
    color: #fbf6ea !important;
  }

  body.dusk #inspector .sub,
  body.solar-dusk #inspector .sub,
  body.solar-night #inspector .sub,
  body.dusk #inspector .insp-stat-label,
  body.solar-dusk #inspector .insp-stat-label,
  body.solar-night #inspector .insp-stat-label,
  body.dusk #inspector .follow-hint,
  body.solar-dusk #inspector .follow-hint,
  body.solar-night #inspector .follow-hint {
    color: rgba(251, 246, 234, 0.72) !important;
  }

  body.dusk #inspector .insp-stat,
  body.solar-dusk #inspector .insp-stat,
  body.solar-night #inspector .insp-stat {
    background: rgba(255, 250, 240, 0.07);
    border-color: rgba(242, 198, 138, 0.18);
  }

  body.dusk #inspector #insp-actions,
  body.solar-dusk #inspector #insp-actions,
  body.solar-night #inspector #insp-actions {
    border-top-color: rgba(242, 198, 138, 0.18);
  }

  body.dusk #inspector .close,
  body.solar-dusk #inspector .close,
  body.solar-night #inspector .close {
    background: rgba(251, 246, 234, 0.12) !important;
    color: #fbf6ea !important;
  }

  body.dusk #inspector .close:active,
  body.solar-dusk #inspector .close:active,
  body.solar-night #inspector .close:active {
    background: rgba(251, 246, 234, 0.24) !important;
  }

  body.dusk #inspector .pill,
  body.solar-dusk #inspector .pill,
  body.solar-night #inspector .pill {
    background: rgba(228, 126, 77, 0.22);
    border-color: rgba(242, 198, 138, 0.40);
    color: #fff8eb;
  }

  body.dusk #inspector .pill:active,
  body.solar-dusk #inspector .pill:active,
  body.solar-night #inspector .pill:active {
    background: rgba(228, 126, 77, 0.36);
  }

  body.dusk .m-brand,
  body.solar-dusk .m-brand,
  body.solar-night .m-brand,
  body.dusk .m-sheet-title,
  body.solar-dusk .m-sheet-title,
  body.solar-night .m-sheet-title,
  body.dusk .m-zoom-btn,
  body.solar-dusk .m-zoom-btn,
  body.solar-night .m-zoom-btn {
    color: #fbf6ea;
  }

  body.dusk .m-zoom-btn + .m-zoom-btn,
  body.solar-dusk .m-zoom-btn + .m-zoom-btn,
  body.solar-night .m-zoom-btn + .m-zoom-btn {
    border-top-color: rgba(242, 198, 138, 0.20);
  }

  body.dusk .m-zoom-btn:active,
  body.solar-dusk .m-zoom-btn:active,
  body.solar-night .m-zoom-btn:active {
    background: rgba(251, 246, 234, 0.14);
  }

  body.dusk .m-sheet-meta,
  body.solar-dusk .m-sheet-meta,
  body.solar-night .m-sheet-meta,
  body.dusk .m-section-label,
  body.solar-dusk .m-section-label,
  body.solar-night .m-section-label,
  body.dusk .m-telemetry,
  body.solar-dusk .m-telemetry,
  body.solar-night .m-telemetry {
    color: rgba(251, 246, 234, 0.72);
  }

  body.dusk .m-telemetry,
  body.solar-dusk .m-telemetry,
  body.solar-night .m-telemetry {
    border-top-color: rgba(242, 198, 138, 0.18);
  }

  body.dusk .m-telemetry a,
  body.solar-dusk .m-telemetry a,
  body.solar-night .m-telemetry a {
    color: #f0a06b;
  }

  body.dusk .m-telemetry-foot,
  body.solar-dusk .m-telemetry-foot,
  body.solar-night .m-telemetry-foot {
    color: rgba(251, 246, 234, 0.72);
  }

  body.dusk .m-pulse-pill,
  body.solar-dusk .m-pulse-pill,
  body.solar-night .m-pulse-pill {
    background: rgba(255, 250, 240, 0.08);
    border-color: rgba(242, 198, 138, 0.24);
    color: #fbf6ea;
  }

  body.dusk .m-pulse-pill.m-pulse-aus,
  body.solar-dusk .m-pulse-pill.m-pulse-aus,
  body.solar-night .m-pulse-pill.m-pulse-aus {
    background: rgba(76, 142, 136, 0.24);
    border-color: rgba(142, 214, 206, 0.40);
    color: #dff7f4;
  }

  body.dusk .m-icon-btn,
  body.solar-dusk .m-icon-btn,
  body.solar-night .m-icon-btn,
  body.dusk .m-qchip,
  body.solar-dusk .m-qchip,
  body.solar-night .m-qchip,
  body.dusk .m-chip,
  body.solar-dusk .m-chip,
  body.solar-night .m-chip,
  body.dusk .m-solar-btn,
  body.solar-dusk .m-solar-btn,
  body.solar-night .m-solar-btn,
  body.dusk .m-layer-chip,
  body.solar-dusk .m-layer-chip,
  body.solar-night .m-layer-chip,
  body.dusk .m-action-btn,
  body.solar-dusk .m-action-btn,
  body.solar-night .m-action-btn {
    background: rgba(44, 35, 56, 0.88);
    border-color: rgba(242, 198, 138, 0.28);
    color: #fbf6ea;
  }

  body.dusk .m-qchip.m-qchip-aus,
  body.solar-dusk .m-qchip.m-qchip-aus,
  body.solar-night .m-qchip.m-qchip-aus,
  body.dusk .m-chip.m-chip-aus,
  body.solar-dusk .m-chip.m-chip-aus,
  body.solar-night .m-chip.m-chip-aus,
  body.dusk .m-action-btn.m-action-aus,
  body.solar-dusk .m-action-btn.m-action-aus,
  body.solar-night .m-action-btn.m-action-aus {
    background: rgba(32, 62, 66, 0.90);
    border-color: rgba(142, 214, 206, 0.42);
    color: #dff7f4;
  }

  body.dusk .m-qchip.active,
  body.solar-dusk .m-qchip.active,
  body.solar-night .m-qchip.active,
  body.dusk .m-chip.active,
  body.solar-dusk .m-chip.active,
  body.solar-night .m-chip.active,
  body.dusk .m-solar-btn.active,
  body.solar-dusk .m-solar-btn.active,
  body.solar-night .m-solar-btn.active,
  body.dusk .m-icon-btn.active,
  body.solar-dusk .m-icon-btn.active,
  body.solar-night .m-icon-btn.active {
    background: #e47e4d;
    border-color: #f4b784;
    color: #181220;
    box-shadow: 0 3px 12px rgba(228, 126, 77, 0.34);
  }

  body.dusk .m-layer-chip.on,
  body.solar-dusk .m-layer-chip.on,
  body.solar-night .m-layer-chip.on {
    background: rgba(228, 126, 77, 0.24);
    border-color: #e47e4d;
    color: #fff8eb;
  }

  body.dusk .m-action-btn.primary,
  body.solar-dusk .m-action-btn.primary,
  body.solar-night .m-action-btn.primary,
  body.dusk .m-action-btn.m-action-aus.active,
  body.solar-dusk .m-action-btn.m-action-aus.active,
  body.solar-night .m-action-btn.m-action-aus.active,
  body.dusk .m-city-back-btn,
  body.solar-dusk .m-city-back-btn,
  body.solar-night .m-city-back-btn {
    background: #d96b3e;
    border-color: #f2b483;
    color: #fffaf0;
  }

  body.dusk #mobile-search-input,
  body.solar-dusk #mobile-search-input,
  body.solar-night #mobile-search-input {
    background: rgba(16, 13, 24, 0.92);
    border-color: rgba(242, 198, 138, 0.32);
    color: #fbf6ea;
  }

  body.dusk #mobile-search-input::placeholder,
  body.solar-dusk #mobile-search-input::placeholder,
  body.solar-night #mobile-search-input::placeholder {
    color: rgba(251, 246, 234, 0.50);
  }

  body.dusk #mobile-search-close,
  body.solar-dusk #mobile-search-close,
  body.solar-night #mobile-search-close {
    background: rgba(251, 246, 234, 0.10);
    border-color: rgba(242, 198, 138, 0.28);
    color: #fbf6ea;
  }

  body.dusk #mobile-search-results,
  body.solar-dusk #mobile-search-results,
  body.solar-night #mobile-search-results {
    border-top-color: rgba(242, 198, 138, 0.18);
  }

  body.dusk #mobile-search-results .search-item,
  body.solar-dusk #mobile-search-results .search-item,
  body.solar-night #mobile-search-results .search-item {
    color: #fbf6ea;
    border-bottom-color: rgba(242, 198, 138, 0.12);
  }

  body.dusk #mobile-search-results .search-item-sub,
  body.solar-dusk #mobile-search-results .search-item-sub,
  body.solar-night #mobile-search-results .search-item-sub,
  body.dusk #mobile-search-results .search-empty,
  body.solar-dusk #mobile-search-results .search-empty,
  body.solar-night #mobile-search-results .search-empty {
    color: rgba(251, 246, 234, 0.68);
  }

  body.dusk #mobile-search-results .search-item-kind,
  body.solar-dusk #mobile-search-results .search-item-kind,
  body.solar-night #mobile-search-results .search-item-kind {
    background: rgba(255, 250, 240, 0.10);
    border-color: rgba(242, 198, 138, 0.30);
    color: rgba(251, 246, 234, 0.86);
  }

  body.dusk #mobile-search-results .search-item-kind.landmark,
  body.solar-dusk #mobile-search-results .search-item-kind.landmark,
  body.solar-night #mobile-search-results .search-item-kind.landmark {
    background: rgba(228, 126, 77, 0.22);
    border-color: rgba(242, 178, 128, 0.50);
    color: #ffd8b5;
  }

  body.dusk #mobile-toast,
  body.solar-dusk #mobile-toast,
  body.solar-night #mobile-toast {
    background: rgba(20, 17, 30, 0.94);
    border-color: rgba(242, 198, 138, 0.44);
    color: #fffaf0;
  }
}

/* Compact Landscape Phone Ergonomics (e.g. iPhone 844x390 / Pixel 892x412 landscape) */
@media (max-width: 900px) and (max-height: 500px) {
  #mobile-top-bar {
    height: 36px;
    top: max(6px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    padding: 3px 5px 3px 8px;
  }

  .m-brand {
    height: 30px;
  }

  .m-crest {
    width: 20px;
    height: 20px;
  }

  .m-brand-text {
    font-size: 13px;
  }

  .m-city-back-btn {
    height: 22px;
    padding: 0 7px;
    font-size: 10.5px;
  }

  .m-icon-btn {
    height: 28px;
    min-width: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  #mobile-quick-rail {
    top: calc(max(6px, env(safe-area-inset-top)) + 40px);
    padding: 0 22px 3px 12px;
    gap: 5px;
  }

  .m-qchip {
    height: 25px;
    padding: 0 10px;
    font-size: 11px;
  }

  /* Keep bottom-right controls accessible without colliding with centered collapsed pill */
  #mobile-zoom-pill {
    bottom: max(8px, env(safe-area-inset-bottom));
    right: max(10px, env(safe-area-inset-right));
    border-radius: 12px;
  }

  body.pa-mobile-active #pa-minimap {
    display: none !important;
  }

  #mobile-sheet.collapsed {
    bottom: max(6px, env(safe-area-inset-bottom));
    width: 244px;
    max-height: 36px;
  }

  #mobile-sheet.collapsed .m-sheet-header {
    padding: 4px 14px 5px;
  }

  #mobile-sheet.collapsed .m-drag-handle {
    width: 30px;
    height: 3.5px;
    margin-bottom: 2px;
  }

  /* Side-docked expanded sheet on right so the Austin map stays visible on the left */
  #mobile-sheet.open,
  #mobile-sheet:not(.collapsed) {
    left: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(380px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: calc(100dvh - 52px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  /* Side-docked Inspector card on left so landmark stays visible on the right */
  #inspector {
    left: max(10px, env(safe-area-inset-left)) !important;
    right: auto !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    width: min(370px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))) !important;
    max-height: calc(100dvh - 52px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    border-radius: 20px !important;
    border-left: 1px solid rgba(74, 59, 44, 0.24) !important;
    border-right: 1px solid rgba(74, 59, 44, 0.24) !important;
    border-bottom: 1px solid rgba(74, 59, 44, 0.24) !important;
    padding: 20px 16px 14px !important;
  }

  #mobile-search-panel {
    top: calc(max(6px, env(safe-area-inset-top)) + 40px);
    max-width: min(460px, calc(100vw - 20px));
  }

  #mobile-search-results {
    max-height: 48dvh;
  }

  #mobile-toast {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 46px);
  }
}

/* Ultra-short landscape viewports (e.g. keyboard open or 320px tall) */
@media (max-width: 900px) and (max-height: 350px) {
  #mobile-quick-rail {
    display: none !important;
  }

  .m-zoom-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }
}
