:root {
  /* Global motion tokens shared across pages/components. */
  --motion-fast: 180ms;
  --motion-base: 260ms;
  --motion-slow: 420ms;
  --motion-ease-enter: cubic-bezier(0.22, 0.61, 0.36, 1);
  --motion-ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --footer-dock-outer-pad-inline: 14px;
  --footer-dock-outer-pad-bottom: 12px;
  --footer-dock-buttons-gap: 12px;
  --footer-dock-buttons-pad-x: 14px;
  --footer-dock-buttons-pad-y: 12px;
  --footer-dock-nav-min-height: 52px;
  --footer-dock-nav-pad-x: 16px;
  --footer-dock-nav-pad-y: 12px;
  --footer-dock-active-gap: 8px;
  --footer-dock-icon-size: 22px;
  --footer-dock-text-size: 12px;
  --footer-dock-text-line: 14px;
  --footer-dock-radius: 16px;
  --footer-floating-cta-bottom: 104px;
  --footer-toolbar-bottom: 95px;
  --footer-limit-bottom: 160px;
  --footer-toolbar-backdrop-height: 160px;
  --app-shell-background:
    radial-gradient(54% 30% at 50% 0%, rgba(124, 92, 255, 0.16) 0%, rgba(124, 92, 255, 0.04) 34%, rgba(124, 92, 255, 0) 72%),
    linear-gradient(180deg, rgba(22, 24, 32, 0.98) 0%, rgba(20, 23, 31, 0.99) 100%);
}

/* Accessibility guard: keep motion minimal when reduced-motion is requested. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 1ms;
    --motion-base: 1ms;
    --motion-slow: 1ms;
  }
}

.root-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: center;
}

.page {
  flex: 1;
  padding: 0 16px calc(112px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 560px;
  position: relative;
  z-index: 1;
}

body:not(.login-only) .page {
  background: var(--app-shell-background);
  background-repeat: no-repeat;
}

.section {
  display: none;
  min-height: calc(100dvh - 8px);
  padding-bottom: calc(var(--footer-toolbar-backdrop-height) - 24px + env(safe-area-inset-bottom));
}

.section.active {
  display: block;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 9;
  padding: 8px 0;
  background: transparent;
}

.top-bar .title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 22px;
}

.top-bar .burger {
  background: transparent;
  color: var(--text-primary);
  border: none;
  padding: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.top-bar .burger-icon {
  width: 24px;
  height: 24px;
  stroke: #f5f5f5;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.footer.tap-bar.bottom-bar {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  background: transparent;
  z-index: 8;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.25s ease;
  border-top: none;
  box-shadow: none;
  padding: 0 var(--footer-dock-outer-pad-inline) calc(var(--footer-dock-outer-pad-bottom) + env(safe-area-inset-bottom));
}

.footer.tap-bar.bottom-bar.hidden {
  transform: translateY(120%);
  opacity: 0;
}

body.profile-modal-open .footer.tap-bar.bottom-bar {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}

body.app-scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

.footer.tap-bar.bottom-bar.menu-open {
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
}

/* Telegram fullscreen safe-area padding: apply only when fullscreen is actually active (mobile Mini App). */
body.tg-fullscreen .page {
  padding-top: calc(var(--tg-top-inset, 0px) + 8px);
}

body.tg-fullscreen .top-bar {
  padding-top: calc(8px + var(--tg-top-inset, 0px));
}

.footer.tap-bar.bottom-bar .footer-buttons {
  position: relative;
  width: fit-content;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--footer-dock-buttons-gap);
  padding: var(--footer-dock-buttons-pad-y) var(--footer-dock-buttons-pad-x);
  margin: 0 auto;
  background: rgba(24, 27, 36, 0.94);
  border-radius: var(--footer-dock-radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.footer-active-pill {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--footer-pill-w, 0px);
  height: var(--footer-pill-h, 0px);
  transform: translate3d(var(--footer-pill-x, 0px), var(--footer-pill-y, 0px), 0)
    scale(var(--footer-pill-scale, 1));
  background: rgba(124, 92, 255, 0.12);
  border-radius: var(--footer-dock-radius);
  opacity: 0;
  transform-origin: center;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    height 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.25s ease;
  pointer-events: none;
}

.footer-buttons:not(.pill-ready) .footer-active-pill {
  transition: none;
  opacity: 0;
  --footer-pill-scale: 0.92;
}

.footer-buttons.has-pill .footer-active-pill {
  opacity: 1;
  --footer-pill-scale: 1;
}

.footer.tap-bar.bottom-bar .footer-nav {
  display: flex;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  min-height: var(--footer-dock-nav-min-height);
  color: #8f97aa;
  text-decoration: none;
  border: none;
  background: transparent;
  border-radius: var(--footer-dock-radius);
  padding: var(--footer-dock-nav-pad-y) var(--footer-dock-nav-pad-x);
  position: relative;
  z-index: 1;
  transition: color 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    gap 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.2s ease;
}

.footer.tap-bar.bottom-bar .footer-nav:focus-visible {
  outline: none;
  color: #f5f7ff;
}

.footer.tap-bar.bottom-bar .footer-nav.active {
  color: #ffffff;
  gap: var(--footer-dock-active-gap);
}

.footer.tap-bar.bottom-bar .footer-nav:active {
  transform: scale(0.97);
}

.footer-icon {
  width: var(--footer-dock-icon-size);
  height: var(--footer-dock-icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.footer-icon svg {
  width: var(--footer-dock-icon-size);
  height: var(--footer-dock-icon-size);
  display: block;
}

.footer-nav svg path {
  fill: currentColor;
}

#footer-shop .footer-icon--static svg path {
  fill: none;
  stroke: currentColor;
}

.footer-icon--active {
  display: none;
}

.footer-nav.active .footer-icon--static {
  display: none;
}

.footer-nav.active .footer-icon--active {
  display: inline-flex;
}

.footer.tap-bar.bottom-bar .footer-text {
  font-size: var(--footer-dock-text-size);
  line-height: var(--footer-dock-text-line);
  font-weight: 600;
  color: currentColor;
  white-space: nowrap;
  overflow: hidden;
  display: inline-block;
  max-width: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    max-width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
  .footer.tap-bar.bottom-bar .footer-nav:hover {
    color: #dde0e9;
  }
}

.footer.tap-bar.bottom-bar .footer-nav.active .footer-text {
  max-width: var(--footer-text-width, 0px);
  opacity: 1;
  transform: translateX(0);
}

@media (max-width: 420px) {
  :root {
    --footer-dock-outer-pad-inline: 10px;
    --footer-dock-outer-pad-bottom: 10px;
    --footer-dock-buttons-gap: 8px;
    --footer-dock-buttons-pad-x: 12px;
    --footer-dock-buttons-pad-y: 10px;
    --footer-dock-nav-min-height: 48px;
    --footer-dock-nav-pad-x: 12px;
    --footer-dock-nav-pad-y: 10px;
    --footer-dock-active-gap: 6px;
    --footer-dock-icon-size: 20px;
    --footer-dock-text-size: 11px;
    --footer-dock-text-line: 13px;
    --footer-dock-radius: 16px;
    --footer-floating-cta-bottom: 90px;
    --footer-toolbar-bottom: 81px;
    --footer-limit-bottom: 146px;
    --footer-toolbar-backdrop-height: 150px;
  }
}

@media (max-width: 380px) {
  :root {
    --footer-dock-outer-pad-inline: 8px;
    --footer-dock-outer-pad-bottom: 8px;
    --footer-dock-buttons-gap: 4px;
    --footer-dock-buttons-pad-x: 10px;
    --footer-dock-buttons-pad-y: 8px;
    --footer-dock-nav-min-height: 46px;
    --footer-dock-nav-pad-x: 10px;
    --footer-dock-nav-pad-y: 9px;
    --footer-dock-active-gap: 4px;
    --footer-dock-icon-size: 18px;
    --footer-dock-text-size: 11px;
    --footer-dock-text-line: 12px;
    --footer-dock-radius: 14px;
    --footer-floating-cta-bottom: 80px;
    --footer-toolbar-bottom: 71px;
    --footer-limit-bottom: 136px;
    --footer-toolbar-backdrop-height: 142px;
  }

  .footer.tap-bar.bottom-bar .footer-text {
    letter-spacing: -0.02em;
  }
}

@media (max-width: 359px) {
  .footer.tap-bar.bottom-bar .footer-buttons {
    width: 100%;
    justify-content: space-between;
    gap: 0;
  }

  .footer.tap-bar.bottom-bar .footer-nav,
  .footer.tap-bar.bottom-bar .footer-nav.active {
    flex: 1 1 0;
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }

  .footer.tap-bar.bottom-bar .footer-text {
    display: none;
  }
}
