/* Share atlas flow — visually aligned with the existing dark Mini App. */
.nav-icon .atlas-book-icon { width:30px; height:24px; }
.atlas-share-launch {
  width:38px;
  height:38px;
  flex:0 0 38px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:7px;
  border:1.5px solid #35c779;
  border-radius:10px;
  color:#62ffad;
  background:#153e32;
}
.atlas-share-launch svg { width:23px; height:23px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.atlas-share-launch:hover { background:#215643; }
.atlas-share-launch:focus-visible,
.atlas-share-dialog button:focus-visible { outline:2px solid #62ffad; outline-offset:3px; }

/* The share control has its own space; it must never cover the title or stats. */
@media (min-width:761px) {
  .topbar .brand {
    min-width:0;
    flex:0 1 auto;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .topbar .stats { order:2; min-width:0; }
  .topbar .atlas-share-launch { order:3; }
}

@media (max-width:760px) {
  .topbar {
    height:var(--atlas-mobile-topbar);
    min-height:var(--atlas-mobile-topbar);
    padding:8px 12px 9px;
    display:grid;
    grid-template-columns:38px minmax(0,1fr) 38px;
    grid-template-rows:36px minmax(0,1fr);
    align-items:center;
    column-gap:7px;
    row-gap:6px;
  }
  .topbar::before { content:""; grid-column:1; grid-row:1; width:38px; }
  .topbar .brand {
    grid-column:2;
    grid-row:1;
    min-width:0;
    padding:0;
    margin:0;
    text-align:center;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    font-size:clamp(11px,3.7vw,15px);
  }
  .topbar .atlas-share-launch {
    position:static;
    grid-column:3;
    grid-row:1;
    width:38px;
    height:38px;
    padding:7px;
    margin:0;
  }
  .topbar .stats {
    grid-column:1 / -1;
    grid-row:2;
    max-width:none;
    min-width:0;
    height:41px;
    margin:0;
    gap:8px;
  }
  .topbar .stat { min-width:0; min-height:0; padding:5px 4px; }
  .topbar .stat strong { font-size:16px; }
  .topbar .stat span { font-size:9px; }
}

.atlas-share-overlay {
  position:fixed;
  inset:0;
  z-index:3000;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:clamp(8px, 2vw, 18px);
  padding-bottom:max(8px,env(safe-area-inset-bottom));
  background:rgba(3,11,17,.79);
  backdrop-filter:blur(6px);
}
.atlas-share-overlay[hidden] { display:none; }
.atlas-share-dialog {
  width:min(100%,880px);
  max-height:calc(100dvh - 16px);
  overflow-y:auto;
  padding:clamp(12px,2vw,20px);
  color:#e8eef3;
  background:linear-gradient(160deg,#1d3140,#0e1e29);
  border:1px solid #436071;
  border-radius:24px;
  box-shadow:0 24px 70px #0009;
}
.atlas-share-head { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.atlas-share-head h2 { font-size:21px; margin:0; font-weight:700; }
.atlas-share-close {
  flex:none;
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  background:transparent;
  color:#bccbd4;
  border:0;
  padding:0;
  font-size:28px;
  line-height:1;
}
.atlas-share-caption { font-size:14px; margin:12px 0 18px; color:#a8bac7; }
.atlas-share-image {
  width:100%;
  aspect-ratio:3/2;
  display:block;
  object-fit:contain;
  border:1px solid #428aa1;
  border-radius:15px;
  background:#061c27;
}
.atlas-share-actions { display:grid; gap:10px; margin-top:14px; }
@media (min-width:660px) {
  .atlas-share-actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .atlas-share-open-link { grid-column:1/-1; }
}
.atlas-share-action {
  width:100%;
  min-height:48px;
  border-radius:12px;
  border:1px solid #496473;
  font-weight:600;
  font-size:15px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  background:#2a4050;
  color:#eef7fa;
}
.atlas-share-action svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.atlas-share-action.primary {
  background:#42eb92;
  color:#082a1b;
  border-color:#42eb92;
  box-shadow:none;
}
.atlas-share-action.primary:hover { background:#67ffaa; }
.atlas-share-action:hover { background:#385365; }
.atlas-share-action:disabled { opacity:.5; cursor:not-allowed; }
.atlas-share-message { margin:12px 0 0; color:#a8bac7; font-size:12px; line-height:1.5; min-height:0; }
.atlas-share-message:empty { display:none; }
@media (max-width:380px) {
  .atlas-share-overlay { padding:10px; }
  .atlas-share-dialog { padding:16px; border-radius:18px; }
  .atlas-share-head h2 { font-size:19px; }
}


/* In the Mini App the header/map/footer are fixed-position siblings. Keep
   their boundaries in sync so neither the title nor buttons cover the globe. */
@media (max-width:760px) {
  :root {
    --atlas-mobile-topbar:104px;
    --atlas-mobile-bottomnav:calc(56px + env(safe-area-inset-bottom, 0px));
  }
  #map {
    top:var(--atlas-mobile-topbar);
    bottom:var(--atlas-mobile-bottomnav);
  }
  .directory-screen {
    top:var(--atlas-mobile-topbar);
    bottom:var(--atlas-mobile-bottomnav);
  }
  .stamps-screen {
    top:var(--atlas-mobile-topbar);
    bottom:var(--atlas-mobile-bottomnav);
  }
  .map-legend { top:calc(var(--atlas-mobile-topbar) + 9px); }
  .map-legend-collapsed { top:calc(var(--atlas-mobile-topbar) + 9px); }

  .bottom-nav {
    height:var(--atlas-mobile-bottomnav);
    gap:5px;
    padding:3px max(12px, env(safe-area-inset-right, 0px))
      calc(3px + env(safe-area-inset-bottom, 0px))
      max(12px, env(safe-area-inset-left, 0px));
    justify-content:center;
    align-items:center;
  }
  .bottom-nav .nav-button {
    flex:0 1 30%;
    max-width:130px;
    min-width:0;
    height:42px;
    padding:4px 5px;
    gap:5px;
    font-size:11px;
    border-radius:10px;
  }
  .bottom-nav .nav-icon { font-size:18px; }
  .bottom-nav .atlas-book-icon { width:24px; height:20px; }
}
@media (max-width:360px) {
  .topbar { column-gap:4px; padding-inline:8px; }
  .topbar .stats { gap:5px; }
  .topbar .stat strong { font-size:14px; }
  .bottom-nav .nav-button { font-size:10px; gap:3px; }
}

/* Center modal content, not the close icon; preserve its hit area. */
.atlas-share-dialog { text-align:center; }
.atlas-share-head {
  display:grid;
  grid-template-columns:34px minmax(0,1fr) 34px;
  align-items:center;
  gap:5px;
}
.atlas-share-head::before { content:""; grid-column:1; grid-row:1; }
.atlas-share-head h2 {
  grid-column:2;
  grid-row:1;
  width:100%;
  margin:0;
  text-align:center;
  font-size:clamp(17px,4.8vw,21px);
  line-height:1.22;
}
.atlas-share-close {
  grid-column:3;
  grid-row:1;
  justify-self:end;
}
.atlas-share-caption, .atlas-share-message { text-align:center; }
.atlas-share-image { margin-inline:auto; }
.atlas-share-action { text-align:center; justify-content:center; }
.atlas-share-action svg { display:block; flex:0 0 20px; }


/* If a browser blocks automatic downloads, the image can be opened directly
   and saved using Chrome's native image context menu. */
.atlas-share-open-link {
  display:block;
  width:fit-content;
  margin:2px auto 0;
  padding:5px 10px;
  color:#95eac6;
  text-decoration:underline;
  text-underline-offset:3px;
  font-size:13px;
  line-height:1.5;
}
.atlas-share-open-link[hidden] { display:none; }
.atlas-share-open-link:focus-visible { outline:2px solid #62ffad; outline-offset:3px; }
@media (max-width:380px) {
  .atlas-share-overlay { padding:7px; }
  .atlas-share-dialog { padding:12px; }
}


/* Share dialog V2 — two focused tabs, in premium Travel Atlas visual style. */
.atlas-share-dialog {
  width:min(100%,560px);
  max-height:calc(100dvh - 20px);
  padding:clamp(16px,3vw,27px);
  background:linear-gradient(155deg,#0d2a36 0%,#071a26 66%,#071824 100%);
  border:1px solid rgba(103,166,179,.42);
  box-shadow:0 22px 80px rgba(0,0,0,.67), inset 0 1px 0 rgba(160,245,213,.05);
  border-radius:24px;
  color:#eaf6f9;
  text-align:left;
  overscroll-behavior:contain;
}
.atlas-share-dialog.is-image-tab { width:min(100%,760px); }
.atlas-share-head h2 { color:#f4faff; font-size:clamp(19px,4.8vw,24px); font-weight:750; }
.atlas-share-close {
  color:#9db8c4;
  border-radius:10px;
  transition:background .15s ease,color .15s ease;
}
.atlas-share-close:hover { background:rgba(113,165,178,.15); color:#f5fff9; }
.atlas-share-caption {
  text-align:center;
  margin:8px 0 19px;
  color:#a2bdc8;
  font-size:13px;
  line-height:1.5;
}
.atlas-share-tabs {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:5px;
  padding:5px;
  margin:0 0 17px;
  background:#153545;
  border:1px solid #294d60;
  border-radius:14px;
}
.atlas-share-tab {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-width:0;
  min-height:44px;
  padding:9px 12px;
  border:1px solid transparent;
  border-radius:10px;
  color:#aabfcb;
  background:transparent;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:background .12s ease,color .12s ease;
}
.atlas-share-tab svg {
  flex:none;
  width:19px;
  height:19px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.9;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.atlas-share-tab:hover { color:#e8fcf5; }
.atlas-share-tab.is-active {
  background:linear-gradient(180deg,#2a5765,#244959);
  color:#f5fffb;
  border-color:#477580;
  box-shadow:0 2px 8px #07141c66;
}
.atlas-share-tab.is-active svg { color:#72f6ba; }
.atlas-share-tab:focus-visible { outline:2px solid #64ffc1; outline-offset:2px; }
.atlas-share-panel { min-width:0; }
.atlas-share-panel[hidden] { display:none!important; }
.atlas-share-image-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.atlas-share-image-heading strong { color:#eaf8f6; font-size:15px; }
.atlas-share-image-heading span { color:#7da6b6; font-size:11px; white-space:nowrap; }
.atlas-share-image-description {
  color:#98b8c6;
  font-size:12px;
  line-height:1.5;
  margin:6px 0 13px;
}
.atlas-share-preview-shell {
  border:1px solid #2c5868;
  border-radius:15px;
  overflow:hidden;
  background:radial-gradient(ellipse at center,#123847,#061c29 75%);
}
.atlas-share-image {
  display:block;
  width:100%;
  height:auto;
  aspect-ratio:3/2;
  object-fit:contain;
  border:0;
  border-radius:0;
  background:transparent;
}
.atlas-share-image:not([src]) { display:none; }
.atlas-share-preview-placeholder {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:180px;
  aspect-ratio:3/2;
  padding:20px;
  text-align:center;
  font-size:13px;
  color:#9bb9c6;
}
.atlas-share-preview-placeholder[hidden] { display:none; }
.atlas-share-actions { gap:10px; margin-top:14px; }
.atlas-share-action {
  min-height:48px;
  background:#173746;
  border:1px solid #345c6c;
  border-radius:12px;
  font-size:13px;
}
.atlas-share-action.primary { background:#5df3ad; border-color:#5df3ad; color:#07291c; }
.atlas-share-action.primary:hover { background:#8affc6; }
.atlas-share-action:hover { background:#244d5d; }
.atlas-share-action:disabled:hover { background:#173746; }
.atlas-share-open-link { font-size:12px; color:#90edc2; }
.atlas-share-message { color:#a5bfcc; font-size:12px; line-height:1.5; margin-top:10px; }
@media (max-width:480px) {
  .atlas-share-dialog, .atlas-share-dialog.is-image-tab { width:100%; padding:15px; }
  .atlas-share-caption { margin-bottom:14px; font-size:12px; }
  .atlas-share-tabs { margin-bottom:13px; }
  .atlas-share-image-heading strong { font-size:14px; }
  .atlas-share-action { min-height:44px; }
}

/* Native Telegram Stories is a separate action; hide it outside supported Mini Apps. */
#atlasShareStory[hidden] { display:none!important; }
@media (min-width:660px) {
  #atlasShareSave { grid-column:1/-1; }
}


/* Share image in one viewport: no scrolling down to Telegram or Stories.
   Keep the link tab's original layout and scrolling untouched. */
.atlas-share-dialog.is-image-tab {
  display:flex;
  flex-direction:column;
  box-sizing:border-box;
  max-height:calc(100dvh - 20px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  overflow:hidden;
}
.atlas-share-dialog.is-image-tab .atlas-share-head,
.atlas-share-dialog.is-image-tab .atlas-share-tabs {
  flex:0 0 auto;
}
.atlas-share-dialog.is-image-tab .atlas-share-image-panel:not([hidden]) {
  display:flex;
  flex-direction:column;
  flex:1 1 auto;
  min-height:0;
}
.atlas-share-dialog.is-image-tab .atlas-share-preview-shell {
  display:flex;
  align-items:center;
  justify-content:center;
  flex:1 1 auto;
  min-height:94px;
  height:clamp(120px,29dvh,265px);
  max-height:clamp(145px,34dvh,305px);
}
.atlas-share-dialog.is-image-tab .atlas-share-image,
.atlas-share-dialog.is-image-tab .atlas-share-preview-placeholder {
  width:100%;
  height:100%;
  max-height:100%;
  min-height:0;
  aspect-ratio:auto;
  object-fit:contain;
}
.atlas-share-dialog.is-image-tab .atlas-share-actions {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  align-items:stretch;
  gap:8px;
  flex:0 0 auto;
  margin-top:10px;
}
.atlas-share-dialog.is-image-tab #atlasShareNative,
.atlas-share-dialog.is-image-tab #atlasShareStory {
  grid-column:auto;
}
.atlas-share-dialog.is-image-tab #atlasShareSave,
.atlas-share-dialog.is-image-tab .atlas-share-open-link {
  grid-column:1/-1;
}
.atlas-share-dialog.is-image-tab .atlas-share-action {
  min-width:0;
  min-height:40px;
  padding:7px 6px;
  font-size:12px;
  line-height:1.17;
}
.atlas-share-dialog.is-image-tab .atlas-share-action svg {
  width:17px;
  height:17px;
  flex:0 0 17px;
}
.atlas-share-dialog.is-image-tab .atlas-share-open-link {
  padding:2px 4px;
  margin:0 auto;
  line-height:1.2;
  font-size:11px;
}
.atlas-share-dialog.is-image-tab .atlas-share-message {
  margin-top:6px;
  font-size:11px;
  line-height:1.3;
}
@media (max-width:760px) {
  .atlas-share-overlay { align-items:center; }
  .atlas-share-dialog.is-image-tab {
    padding:12px;
    border-radius:17px;
  }
  .atlas-share-dialog.is-image-tab .atlas-share-caption {
    display:none;
  }
  .atlas-share-dialog.is-image-tab .atlas-share-head h2 {font-size:17px;}
  .atlas-share-dialog.is-image-tab .atlas-share-tabs {
    margin:9px 0 10px;
    padding:3px;
  }
  .atlas-share-dialog.is-image-tab .atlas-share-tab {
    min-height:36px;
    padding:5px 8px;
    font-size:12px;
    gap:6px;
  }
  .atlas-share-dialog.is-image-tab .atlas-share-tab svg {width:16px;height:16px;}
  .atlas-share-dialog.is-image-tab .atlas-share-image-heading strong {font-size:13px;}
  .atlas-share-dialog.is-image-tab .atlas-share-image-description {display:none;}
  .atlas-share-dialog.is-image-tab .atlas-share-preview-shell {
    height:clamp(116px,31dvh,235px);
    max-height:clamp(116px,31dvh,235px);
    margin-top:8px;
  }
}
@media (max-height:640px) and (max-width:760px) {
  .atlas-share-dialog.is-image-tab {padding:9px 11px;}
  .atlas-share-dialog.is-image-tab .atlas-share-tabs {margin:6px 0 7px;}
  .atlas-share-dialog.is-image-tab .atlas-share-preview-shell {
    height:clamp(100px,26dvh,170px);
    max-height:clamp(100px,26dvh,170px);
  }
  .atlas-share-dialog.is-image-tab .atlas-share-actions {gap:6px;margin-top:7px;}
  .atlas-share-dialog.is-image-tab .atlas-share-action {min-height:36px;font-size:11px;}
}
