﻿/* final viewport + modal priority fix */
:root{
  --yak-fullscreen-top-offset: 56px;
  --yak-fullscreen-top-offset-short: 56px;
  --yak-fullscreen-top-offset-tiny: 56px;
  --yak-screen-bottom-pad: calc(var(--layout-nav-height, var(--nav-h, 78px)) + 8px);
  --yak-profile-modal-top-gap: max(10px, calc(var(--safe-top) + 8px));
  --yak-profile-modal-bottom-gap: max(10px, calc(var(--safe-bottom) + 8px));
}

html.is-tg-fullscreen{
  --tg-top-ui-offset: var(--yak-fullscreen-top-offset) !important;
}

html.is-tg-fullscreen.is-short-screen{
  --tg-top-ui-offset: var(--yak-fullscreen-top-offset-short) !important;
}

html.is-tg-fullscreen.is-tiny-screen{
  --tg-top-ui-offset: var(--yak-fullscreen-top-offset-tiny) !important;
}

.screen.active{
  scroll-padding-top: 8px;
  scroll-padding-bottom: var(--yak-screen-bottom-pad);
}

#profile-screen.screen.active{
  overflow-y:auto !important;
  overflow-x:hidden !important;
  padding:0 0 var(--yak-screen-bottom-pad) !important;
}

#profile-screen .cards-stack.redesign-profile-stack{
  min-height:min-content;
  padding-bottom:6px;
}

#profile-screen .redesign-profile-hero,
#profile-screen .redesign-quick-links,
#profile-screen #wallet-screen.profile-history-only{
  scroll-margin-top: calc(var(--safe-top) + var(--tg-top-ui-offset, 0px) + 82px);
}

.profile-action-modal{
  position:fixed;
  inset:0;
  z-index:120;
  display:flex !important;
  align-items:flex-start !important;
  justify-content:center !important;
  padding:
    var(--yak-profile-modal-top-gap)
    max(8px, env(safe-area-inset-right, 0px) + 8px)
    var(--yak-profile-modal-bottom-gap)
    max(8px, env(safe-area-inset-left, 0px) + 8px) !important;
  overflow:hidden !important;
}

.profile-action-card{
  width:min(100%, 560px) !important;
  max-height:calc(var(--tg-vh, 100dvh) - var(--yak-profile-modal-top-gap) - var(--yak-profile-modal-bottom-gap)) !important;
  min-height:0 !important;
  margin:0 auto !important;
  display:grid !important;
  grid-template-rows:auto minmax(0, 1fr) !important;
  overflow:hidden !important;
}

.profile-action-head{
  position:sticky;
  top:0;
  z-index:2;
  flex:0 0 auto;
}

.profile-action-body{
  min-height:0 !important;
  overflow:hidden !important;
  display:block !important;
}

.profile-action-body > #wallet-screen{
  height:100%;
  min-height:0;
  overflow-x:hidden;
  overflow-y:auto;
  padding-right:2px;
  padding-bottom:2px;
  -webkit-overflow-scrolling:touch;
}

.profile-action-body > #wallet-screen .wallet-layout{
  min-height:min-content;
}

@media (max-width: 720px){
  .profile-action-modal{
    padding:
      max(8px, calc(var(--safe-top) + 6px))
      6px
      max(8px, calc(var(--safe-bottom) + 6px))
      6px !important;
  }

  .profile-action-card{
    width:100% !important;
    max-height:calc(var(--tg-vh, 100dvh) - max(8px, calc(var(--safe-top) + 6px)) - max(8px, calc(var(--safe-bottom) + 6px))) !important;
    border-radius:22px !important;
    padding:12px !important;
  }

  .profile-action-head{
    margin-bottom:8px !important;
  }

  .profile-action-close{
    width:38px !important;
    height:38px !important;
  }

  .profile-action-body > #wallet-screen .wallet-layout{
    gap:8px !important;
  }

  .profile-action-body > #wallet-screen .panel-card{
    padding:10px !important;
  }

  .profile-action-body > #wallet-screen .panel-title{
    font-size:15px !important;
    line-height:1.1 !important;
  }

  .profile-action-body > #wallet-screen .field input,
  .profile-action-body > #wallet-screen .buy-btn,
  .profile-action-body > #wallet-screen .ton-btn,
  .profile-action-body > #wallet-screen .danger-btn,
  .profile-action-body > #wallet-screen .dark-btn,
  .profile-action-body > #wallet-screen .profile-info-chip{
    min-height:40px !important;
  }
}

/* modal body scroll fix */
.profile-action-modal{
  overflow-y:auto !important;
  overscroll-behavior:contain;
}

.profile-action-card{
  display:grid !important;
  grid-template-rows:auto minmax(0,1fr) !important;
  overflow:hidden !important;
}

.profile-action-body{
  min-height:0 !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

/* profile modal visual polish (single source in style.layout.css) */
.profile-action-modal{
  backdrop-filter:blur(10px) saturate(1.12) !important;
  background:linear-gradient(180deg,rgba(2,7,22,.38),rgba(1,4,14,.62)) !important;
}

.profile-action-card{
  border-radius:30px 30px 0 0 !important;
  padding:18px 16px 20px !important;
  background:
    radial-gradient(circle at top,rgba(67,110,197,.18),transparent 28%),
    linear-gradient(180deg,rgba(8,20,50,.985),rgba(4,11,28,.995)) !important;
  border:1px solid rgba(112,145,218,.16) !important;
  box-shadow:
    0 28px 64px rgba(0,0,0,.38),
    inset 0 1px 0 rgba(255,255,255,.07),
    0 0 0 1px rgba(112,145,218,.04) !important;
}

.profile-action-head{
  align-items:center !important;
  margin-bottom:12px !important;
}

.profile-action-head .panel-title{
  font-size:24px !important;
  font-weight:900 !important;
  letter-spacing:.01em !important;
  color:#f4f7ff !important;
}

.profile-action-close{
  width:44px !important;
  height:44px !important;
  border-radius:15px !important;
  background:linear-gradient(180deg,rgba(12,25,60,.98),rgba(7,14,35,.99)) !important;
  border:1px solid rgba(106,139,214,.16) !important;
  color:#eef3ff !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 10px 20px rgba(0,0,0,.14) !important;
}

.profile-action-body{
  gap:12px !important;
}

.profile-action-body > #wallet-screen .panel-card{
  border-radius:22px !important;
  background:
    radial-gradient(circle at top right,rgba(71,110,195,.14),transparent 34%),
    linear-gradient(180deg,rgba(10,22,54,.97),rgba(6,13,33,.99)) !important;
  border:1px solid rgba(108,143,220,.14) !important;
  box-shadow:
    0 16px 30px rgba(0,0,0,.18),
    inset 0 1px 0 rgba(255,255,255,.05) !important;
}

.profile-action-body > #wallet-screen .panel-title{
  color:#f4f6ff !important;
}

.profile-action-body > #wallet-screen .field input,
.profile-action-body > #wallet-screen .profile-info-chip{
  border-radius:16px !important;
  background:linear-gradient(180deg,rgba(9,20,50,.98),rgba(6,13,31,.99)) !important;
  border:1px solid rgba(103,137,214,.15) !important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04) !important;
}

.profile-action-body > #wallet-screen .field input{
  color:#eef4ff !important;
  -webkit-text-fill-color:#eef4ff !important;
  caret-color:#ffffff !important;
  font-weight:800 !important;
}

.profile-action-body > #wallet-screen .field input::placeholder{
  color:rgba(216,228,255,.42) !important;
  -webkit-text-fill-color:rgba(216,228,255,.42) !important;
}

.profile-action-body > #wallet-screen .field input:-webkit-autofill,
.profile-action-body > #wallet-screen .field input:-webkit-autofill:hover,
.profile-action-body > #wallet-screen .field input:-webkit-autofill:focus{
  -webkit-text-fill-color:#eef4ff !important;
  -webkit-box-shadow:0 0 0 1000px rgba(9,20,50,.98) inset !important;
  box-shadow:0 0 0 1000px rgba(9,20,50,.98) inset !important;
  transition:background-color 9999s ease-out 0s !important;
}

.profile-action-body > #wallet-screen .buy-btn,
.profile-action-body > #wallet-screen .ton-btn,
.profile-action-body > #wallet-screen .danger-btn,
.profile-action-body > #wallet-screen .dark-btn{
  min-height:50px !important;
  border-radius:17px !important;
}

@media (max-width:640px){
  .profile-action-card{
    border-radius:26px 26px 0 0 !important;
    padding:16px 14px 18px !important;
  }

  .profile-action-head .panel-title{
    font-size:22px !important;
  }

  .profile-action-close{
    width:42px !important;
    height:42px !important;
    border-radius:14px !important;
  }
}

