:root {
  --app-bar-height: 66px;
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-top: env(safe-area-inset-top, 0px);
}

html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
button, a, input, select { touch-action: manipulation; }

.install-app-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(231, 184, 91, .45);
  border-radius: 9px;
  color: #ffd986;
  background: rgba(231, 184, 91, .1);
  font: 800 11px/1 system-ui, sans-serif;
  letter-spacing: .02em;
  cursor: pointer;
}
.install-app-button:hover { border-color: #e7b85b; background: rgba(231, 184, 91, .16); }
body.is-standalone .install-app-button { display: none !important; }

.app-tabbar {
  display: none;
  position: fixed;
  inset: auto 0 0;
  z-index: 80;
  min-height: calc(var(--app-bar-height) + var(--app-safe-bottom));
  padding: 5px max(8px, env(safe-area-inset-right, 0px)) var(--app-safe-bottom) max(8px, env(safe-area-inset-left, 0px));
  border-top: 1px solid rgba(171, 198, 224, .18);
  background: rgba(7, 20, 38, .96);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, .2);
  backdrop-filter: blur(20px);
}
.app-tabbar-list {
  width: min(100%, 560px);
  min-height: 56px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  list-style: none;
}
.app-tabbar a,
.app-tabbar button {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border: 0;
  border-radius: 10px;
  color: #91a5bb;
  background: transparent;
  text-decoration: none;
  font: 750 10px/1.1 system-ui, sans-serif;
}
.app-tabbar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-tabbar .active { color: #ffd986; background: rgba(231, 184, 91, .09); }
.app-tabbar .atlas-tab { position: relative; }
.app-tabbar .atlas-tab svg { width: 23px; height: 23px; }
.app-tabbar .atlas-tab::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 2px;
  border-radius: 99px;
  background: #e7b85b;
  opacity: 0;
}
.app-tabbar .atlas-tab.active::before { opacity: 1; }

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 19;
  border: 0;
  background: rgba(3, 10, 19, .64);
  backdrop-filter: blur(2px);
}

.pwa-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  align-items: end;
  padding: 18px;
  background: rgba(2, 7, 14, .7);
  backdrop-filter: blur(6px);
}
.pwa-sheet-backdrop[hidden] { display: none; }
.pwa-sheet {
  width: min(100%, 520px);
  margin: 0 auto max(4px, var(--app-safe-bottom));
  padding: 22px;
  border: 1px solid rgba(231, 184, 91, .36);
  border-radius: 20px;
  color: #e8eef5;
  background: linear-gradient(145deg, #112b49, #071426);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}
.pwa-sheet-head { display: flex; align-items: flex-start; gap: 13px; }
.pwa-sheet-icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 14px; }
.pwa-sheet h2 { margin: 0; color: #f5f1e8; font: 800 22px/1.1 Georgia, serif; }
.pwa-sheet p { margin: 6px 0 0; color: #91a5bb; font: 13px/1.55 system-ui, sans-serif; }
.pwa-sheet ol { margin: 17px 0 0; padding-left: 21px; color: #c7d4e1; font: 13px/1.65 system-ui, sans-serif; }
.pwa-sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.pwa-sheet-actions button { flex: 1; min-height: 42px; border-radius: 9px; font-weight: 800; cursor: pointer; }
.pwa-sheet-primary { border: 1px solid #e7b85b; color: #071426; background: #e7b85b; }
.pwa-sheet-close { border: 1px solid rgba(171, 198, 224, .2); color: #e8eef5; background: rgba(22, 57, 93, .65); }

.app-status-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--app-safe-bottom));
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100% - 28px);
  padding: 10px 13px;
  border: 1px solid rgba(231, 184, 91, .32);
  border-radius: 999px;
  color: #e8eef5;
  background: rgba(7, 20, 38, .96);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .38);
  font: 750 12px/1 system-ui, sans-serif;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.app-status-toast.show { opacity: 1; transform: translate(-50%, 0); }
.app-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #63d29b; }
.app-status-toast.offline .app-status-dot { background: #ffbf69; }
.app-update-button { border: 0; color: #ffd986; background: transparent; font-weight: 900; pointer-events: auto; cursor: pointer; }

@media (max-width: 900px) {
  .app-tabbar { display: block; }
  body { padding-bottom: calc(var(--app-bar-height) + var(--app-safe-bottom)); }
  .app-status-toast { bottom: calc(var(--app-bar-height) + 15px + var(--app-safe-bottom)); }
  .pwa-sheet-backdrop { padding-bottom: calc(14px + var(--app-bar-height) + var(--app-safe-bottom)); }
  .toast { bottom: calc(var(--app-bar-height) + 14px + var(--app-safe-bottom)) !important; }
}

@media (max-width: 560px) {
  .install-app-button { width: 34px; min-width: 34px; padding-inline: 6px; }
  .install-app-button .install-label { display: none; }
  .pwa-sheet-backdrop { padding-inline: 10px; }
  .pwa-sheet { padding: 19px; border-radius: 17px; }
}

@media (display-mode: standalone) {
  body { min-height: 100dvh; }
  .topbar { padding-top: var(--app-safe-top); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
.account-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  max-width: 150px;
  overflow: hidden;
  padding: 7px 11px;
  border: 1px solid rgba(231, 184, 91, .28);
  border-radius: 9px;
  color: #f3d895;
  background: rgba(231, 184, 91, .07);
  font: 800 .74rem/1 Manrope, Inter, system-ui, sans-serif;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip:hover,
.account-chip.signed-in {
  border-color: rgba(231, 184, 91, .54);
  color: #071426;
  background: #e7b85b;
}

@media (max-width: 760px) {
  .account-chip {
    max-width: 92px;
    min-height: 31px;
    padding-inline: 8px;
  }
}
