/* Mobile flow prevents the hero, globe and palette from sharing fixed positions.
   Desktop rules and MapLibre's native pinch zoom remain unchanged. */
@media (max-width: 800px) {
  html { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  body { height: auto; min-height: 100svh; overflow: visible; }
  .app {
    height: auto;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .topbar {
    position: relative;
    padding: 0;
    gap: 12px;
    flex-wrap: wrap;
    background: none;
  }
  .nav { flex-wrap: wrap; align-items: center; max-width: 100%; }
  .nav .btn { min-height: 44px; }
  .hero { position: static; transform: none; width: 100%; }
  .hero h1 { font-size: clamp(38px, 10vw, 52px); margin: 12px 0; }
  .hero p { margin: 0; max-width: 480px; }
  .hero .status { max-width: 100%; line-height: 1.4; margin-top: 12px; }
  .dot { flex-shrink: 0; }
  .globe-wrap {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    align-self: center;
    width: min(100%, 480px);
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    padding-top: 58px;
  }
  #globe { position: relative; inset: auto; width: 100%; aspect-ratio: 1; }
  #globe .maplibregl-ctrl-group { display: none; }
  .mapmode { top: 0; right: 54px; }
  .locate { top: 0; right: 0; }
  .location-note {
    top: 5px;
    left: 0;
    right: auto;
    max-width: calc(100% - 140px);
    overflow-wrap: anywhere;
    font-size: 10px;
  }
  .paint-swatch {
    position: static;
    transform: none;
    align-self: center;
    margin: 0;
  }
  .modal-backdrop {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 20px; }
  .card h2 { font-size: clamp(20px, 6vw, 26px); }
  .card-head { gap: 8px; }
  .close { flex-shrink: 0; min-width: 44px; min-height: 44px; }
  .field input { font-size: 16px; }
  .message { overflow-wrap: anywhere; }
}

/* v1.111: shared direct basemap toolbar, aligned with the header navigation. */
.home-map-tools { display:flex; align-items:center; gap:6px; pointer-events:auto; flex-shrink:0; }
.home-map-tools button {
  position:static !important; flex:0 0 auto; height:44px !important;
  min-width:44px; margin:0; padding:0 10px; font-size:11px; letter-spacing:0;
}
.home-map-tools .home-search-btn, .home-map-tools .locate { width:44px !important; padding:0; font-size:22px; }
.home-map-tools button.active { border-color:#55f5ff; background:#12323b; box-shadow:0 0 12px #55f5ff44; }
@media(min-width:801px){
  .topbar { display:flex; align-items:center; gap:14px; padding:18px 20px; }
  .topbar .brand { font-size:24px; flex-shrink:0; }
  .topbar .nav { margin:0 !important; gap:5px; align-items:center; flex-shrink:0; }
  .topbar .nav .btn { min-height:44px; padding:8px 9px; font-size:11px; white-space:nowrap; }
  .topbar .nav #accountName { max-width:90px !important; font-size:11px; }
  .home-map-tools { margin-left:auto; }
  .home-search-panel { top:70px; right:20px; }
  .location-note { top:70px; right:20px; }
}
@media(min-width:801px) and (max-width:1199px){
  .mobile-menu-btn { display:flex; align-items:center; justify-content:center; width:44px; height:44px; border:1px solid #39475a; border-radius:50%; background:#0b1019e8; color:white; font-size:22px; cursor:pointer; }
  .topbar .nav { display:none; position:absolute; top:70px; left:20px; width:280px; padding:10px; flex-direction:column; align-items:stretch; border:1px solid #303a49; border-radius:16px; background:#070b12f7; max-height:calc(100dvh - 90px); overflow-y:auto; }
  .topbar .nav.mobile-open { display:flex; }
  .topbar .nav #accountName { max-width:100% !important; }
}

/* v1.70: public home remains full-screen on mobile. */
@media(max-width:800px){html,body{height:100%;overflow:hidden}.app{height:100svh;min-height:100svh;display:block;padding:0}}

/* v1.109: compact brand strip, toolbar and bottom wordmark. */
@media (max-width: 800px) {
  .app {
    --home-top: calc(env(safe-area-inset-top, 0px) + 40px);
    --home-left: calc(env(safe-area-inset-left, 0px) + 8px);
    --home-right: calc(env(safe-area-inset-right, 0px) + 8px);
    --home-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    height: 100dvh !important;
    min-height: 100dvh !important;
  }
  .globe-opacity { display: none !important; }
  .topbar {
    top: var(--home-top);
    left: var(--home-left);
    right: var(--home-right);
    height: 44px;
    padding: 0;
    gap: 0;
    background: none;
  }
  .topbar .brand {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(env(safe-area-inset-top, 0px) + 32px);
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    border-bottom: 1px solid #ffffff18;
    background: #070b12ed;
    font-size: 20px;
    line-height: 1;
    pointer-events: none;
  }
  .mobile-menu-btn { width: 44px; height: 44px; }
  .topbar .nav {
    top: 52px;
    left: 0;
    right: auto;
    width: min(280px, calc(100vw - var(--home-left) - var(--home-right)));
    max-height: calc(100dvh - var(--home-top) - var(--home-bottom) - 84px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .globe-wrap .home-search-btn,
  .globe-wrap .photo-mode,
  .globe-wrap #mapModeBtn,
  .globe-wrap .locate {
    top: var(--home-top) !important;
    height: 44px !important;
    min-width: 44px;
    padding: 0 !important;
    touch-action: manipulation;
  }
  .globe-wrap .locate { right: var(--home-right) !important; width: 44px !important; }
  .globe-wrap #mapModeBtn { right: calc(var(--home-right) + 50px) !important; width: 48px; }
  .globe-wrap .photo-mode { right: calc(var(--home-right) + 104px) !important; width: 62px; }
  .globe-wrap .home-search-btn { right: calc(var(--home-right) + 172px) !important; width: 44px !important; }
  .globe-wrap .home-search-panel {
    top: calc(var(--home-top) + 52px) !important;
    right: var(--home-right) !important;
    width: min(390px, calc(100vw - var(--home-left) - var(--home-right))) !important;
    max-height: calc(100dvh - var(--home-top) - var(--home-bottom) - 84px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .home-search-row input { height: 44px; font-size: 16px; }
  .home-search-row button, .home-search-result { min-height: 44px; }
  .location-note {
    top: calc(var(--home-top) + 52px);
    left: var(--home-left);
    right: var(--home-right);
    max-width: none;
    pointer-events: none;
  }
  .hero {
    left: var(--home-left) !important;
    right: var(--home-right);
    bottom: var(--home-bottom);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    backdrop-filter: none;
    box-shadow: none;
    text-shadow: 0 2px 6px #000, 0 0 12px #000;
  }
  .hero .kicker, .hero p, .hero .status, .hero h1 br { display: none; }
  .hero h1 {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin: 0;
    font-size: 24px;
    line-height: 1;
  }
}
/* v1.111 compact mobile toolbar and desktop opacity control. */
@media(max-width:800px){
  .topbar .home-map-tools { margin-left:auto; gap:clamp(0px, calc((100vw - var(--home-left) - var(--home-right) - 280px) / 4), 4px); }
  .home-map-tools button { width:44px !important; min-width:44px !important; height:44px !important; padding:0 !important; font-size:9px; letter-spacing:0; }
  .home-map-tools #satelliteModeBtn { width:60px !important; }
  .home-map-tools .home-search-btn, .home-map-tools .locate { font-size:22px; }
}
@media(min-width:801px){
  .app > .paint-swatch { display:none; }
  .app > .globe-opacity { left:20px !important; right:auto !important; bottom:20px !important; transform:none !important; width:max-content; gap:6px; padding:7px 9px; }
  .globe-opacity input { width:88px; margin:0; }
  .globe-opacity b { min-width:29px; }
}
/* Auth state always wins over historical mobile display overrides. */
#editorBtn[hidden], .topbar .nav [hidden] { display:none !important; }
/* Expanded desktop navigation is centered against the viewport itself. */
@media(min-width:1200px){
  .topbar .nav { position:absolute; left:50%; transform:translateX(-50%); width:max-content; }
  .topbar .nav #accountName { position:absolute; right:calc(100% + 12px); top:50%; transform:translateY(-50%); }
}
/* Sharing occupies the brand strip on mobile, keeping the map toolbar intact. */
#shareViewBtn { display:grid; place-items:center; }
#shareViewStatus { position:fixed; z-index:60; top:76px; right:20px; max-width:calc(100vw - 40px); color:white; font-size:12px; pointer-events:none; }
#shareViewStatus:not(:empty) { padding:9px 12px; background:#070b12ed; border:1px solid #55f5ff; border-radius:12px; }
#shareViewDialog { color:#fff; max-height:calc(100dvh - 32px); overflow:auto; }
#shareViewDialog::backdrop { background:#02040acc; }
#shareViewHint { font-size:13px; line-height:1.5; }
@media(max-width:800px){
 .app { --home-top:calc(env(safe-area-inset-top, 0px) + 52px); }
 .topbar .brand { height:calc(env(safe-area-inset-top, 0px) + 44px); padding-left:52px; padding-right:52px; }
 .topbar .home-map-tools #shareViewBtn { position:fixed !important; top:env(safe-area-inset-top, 0px); right:calc(env(safe-area-inset-right, 0px) + 8px); border:0; background:transparent; box-shadow:none; }
 #shareViewStatus { top:calc(env(safe-area-inset-top, 0px) + 104px); right:calc(env(safe-area-inset-right, 0px) + 8px); }
}

/* v1.117 share preview */
#shareViewDialog{max-height:calc(100dvh - 32px);overflow:auto;box-sizing:border-box;width:min(560px,calc(100vw - 24px))}#shareViewPreview{display:block;max-width:100%;max-height:42dvh;object-fit:contain;margin:12px auto;background:white}#shareViewDialog [hidden]{display:none!important}#shareViewDialog .wide{margin-top:8px;box-sizing:border-box;text-align:center;min-height:44px}#shareViewDownload{text-decoration:none}
#shareViewDialog .wide{display:flex;width:100%;align-items:center;justify-content:center}
@media(max-width:800px){.topbar .brand #appRefreshBtn{position:fixed;top:env(safe-area-inset-top,0px);left:calc(env(safe-area-inset-left,0px) + 8px);width:44px;height:44px;margin:0;border:0;background:transparent;box-shadow:none;z-index:11}}
