/* Telegram-iOS profile + message context presentation. This file is the only
   visual implementation for these two surfaces. */

/* ---------- Person profile ---------- */
#personProfileScreen{
  --tg-profile-nav-h:44px;
  position:fixed;
  inset:0;
  display:flex;
  flex-direction:column;
  background:var(--background-grouped,#f2f2f7);
  color:var(--label-primary,#111);
  overflow:hidden;
  overscroll-behavior:none;
}
#personProfileScreen[aria-hidden="true"]{pointer-events:none}
.tgios-profile-nav{
  position:absolute;
  z-index:4;
  top:0;left:0;right:0;
  height:calc(var(--sat,0px) + var(--tg-profile-nav-h));
  padding:var(--sat,0px) max(4px,var(--sar,0px)) 0 max(4px,var(--sal,0px));
  display:grid;
  grid-template-columns:44px minmax(0,1fr) 44px;
  align-items:center;
  background:color-mix(in srgb,var(--surface-primary,#fff) 90%,transparent);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
  backdrop-filter:saturate(180%) blur(20px);
  box-shadow:0 .5px 0 transparent;
  transition:background-color .18s ease,box-shadow .18s ease;
}
#personProfileScreen.is-collapsed .tgios-profile-nav{box-shadow:0 .5px 0 var(--separator,rgba(60,60,67,.25))}
.tgios-profile-nav-btn{
  width:44px;height:44px;padding:0;border:0;background:transparent;
  display:grid;place-items:center;color:var(--accent,#0a84ff);border-radius:12px;
  -webkit-tap-highlight-color:transparent;
}
.tgios-profile-nav-btn:active{opacity:.55}
.tgios-profile-nav-btn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.85;stroke-linecap:round;stroke-linejoin:round}
.tgios-profile-nav-title{min-width:0;text-align:center;opacity:0;transform:translateY(5px);transition:opacity .16s ease,transform .16s ease}
#personProfileScreen.is-collapsed .tgios-profile-nav-title{opacity:1;transform:none}
.tgios-profile-nav-title strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:16px;line-height:20px;font-weight:650}
.tgios-profile-nav-title small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:13px;color:var(--label-secondary,#8e8e93)}
.tgios-profile-scroll{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;padding-bottom:calc(var(--sab,0px) + 22px)}
.tgios-profile-hero{
  min-height:360px;
  padding:calc(var(--sat,0px) + 64px) 16px 18px;
  display:flex;flex-direction:column;align-items:center;
  background:var(--surface-primary,#fff);
}
.tgios-profile-avatar-button{width:108px;height:108px;padding:0;border:0;border-radius:50%;background:transparent;display:block}
#pAv.tgios-profile-avatar{width:108px;height:108px;border-radius:50%;border:0!important;box-shadow:none!important;font-size:42px;overflow:hidden}
.tgios-profile-name{margin-top:14px;max-width:min(340px,90vw);font-size:22px;line-height:27px;font-weight:650;letter-spacing:-.25px;text-align:center;overflow-wrap:anywhere}
.tgios-profile-status{margin-top:3px;font-size:14px;line-height:18px;color:var(--label-secondary,#8e8e93);text-align:center}
.tgios-profile-status.online{color:var(--accent,#0a84ff)}
.tgios-profile-actions{width:100%;max-width:430px;margin-top:17px;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:2px}
.tgios-profile-action{
  min-width:0;min-height:62px;padding:5px 2px;border:0;background:transparent;color:var(--accent,#0a84ff);
  display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:4px;
  font:inherit;-webkit-tap-highlight-color:transparent;
}
.tgios-profile-action:active{opacity:.52}
.tgios-profile-action-icon{height:28px;display:grid;place-items:center}
.tgios-profile-action-icon svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
.tgios-profile-action-label{max-width:100%;font-size:11px;line-height:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tgios-profile-gap{height:8px;background:var(--background-grouped,#f2f2f7);border-top:.5px solid var(--separator,rgba(60,60,67,.2));border-bottom:.5px solid var(--separator,rgba(60,60,67,.2))}
.tgios-grouped-section{margin:0;background:var(--surface-primary,#fff)}
.tgios-profile-info-row{position:relative;min-height:55px;padding:8px 16px;display:flex;align-items:center;gap:12px}
.tgios-profile-info-row::after{content:"";position:absolute;left:16px;right:0;bottom:0;height:.5px;background:var(--separator,rgba(60,60,67,.25))}
.tgios-profile-info-row:last-child::after{display:none}
.tgios-profile-info-copy{flex:1;min-width:0}
.tgios-profile-info-label{font-size:12.5px;line-height:16px;color:var(--label-secondary,#8e8e93)}
.tgios-profile-info-value{margin-top:1px;font-size:16px;line-height:20px;color:var(--label-primary,#111);overflow-wrap:anywhere}
.tgios-profile-info-value.link{color:var(--accent,#0a84ff)}
.tgios-profile-copy-btn{width:44px;height:44px;border:0;background:transparent;color:var(--accent,#0a84ff);display:grid;place-items:center}
.tgios-profile-copy-btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tgios-profile-contact-section{margin-top:8px;border-top:.5px solid var(--separator,rgba(60,60,67,.2));border-bottom:.5px solid var(--separator,rgba(60,60,67,.2))}
.tgios-profile-list-action{width:100%;min-height:51px;padding:0 16px;border:0;background:var(--surface-primary,#fff);color:var(--accent,#0a84ff);font:inherit;font-size:16px;text-align:left}
.tgios-profile-list-action:active{background:var(--selection,rgba(120,120,128,.12))}
.tgios-profile-list-action.danger{color:var(--destructive,#ff3b30)}
.tgios-shared-section{margin-top:8px;background:var(--surface-primary,#fff);border-top:.5px solid var(--separator,rgba(60,60,67,.2))}
.tgios-profile-tabs{position:sticky;top:calc(var(--sat,0px) + var(--tg-profile-nav-h));z-index:3;height:46px;display:flex;align-items:stretch;overflow-x:auto;background:color-mix(in srgb,var(--surface-primary,#fff) 94%,transparent);-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);border-bottom:.5px solid var(--separator,rgba(60,60,67,.2));scrollbar-width:none}
.tgios-profile-tabs::-webkit-scrollbar{display:none}
.tgios-profile-tab{position:relative;flex:1 0 auto;min-width:78px;padding:0 12px;border:0;background:transparent;color:var(--label-secondary,#8e8e93);font:inherit;font-size:14px;font-weight:600}
.tgios-profile-tab.on{color:var(--accent,#0a84ff)}
.tgios-profile-tab.on::after{content:"";position:absolute;left:12px;right:12px;bottom:0;height:2px;border-radius:2px;background:var(--accent,#0a84ff)}
.tgios-profile-pane{min-height:112px;background:var(--surface-primary,#fff)}
.tgios-profile-media-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1px;background:var(--separator,rgba(60,60,67,.2))}
.tgios-profile-media-item{position:relative;width:100%;aspect-ratio:1;border:0;padding:0;background:var(--background-secondary,#e5e5ea);overflow:hidden}
.tgios-profile-media-item img,.tgios-profile-media-item video{width:100%;height:100%;object-fit:cover;display:block}
.tgios-profile-media-item.is-locked{display:grid;place-items:center;color:var(--label-secondary,#8e8e93)}
.tgios-profile-media-item.is-locked svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.6}
.tgios-profile-media-badge{position:absolute;right:5px;bottom:5px;padding:2px 5px;border-radius:5px;background:rgba(0,0,0,.6);color:#fff;font-size:10px}
.tgios-profile-list{display:flex;flex-direction:column}
.tgios-profile-file-row,.tgios-profile-link-row,.tgios-profile-voice-row{position:relative;width:100%;min-height:58px;padding:8px 16px;border:0;background:transparent;color:var(--label-primary,#111);display:flex;align-items:center;gap:11px;text-align:left;font:inherit}
.tgios-profile-file-row::after,.tgios-profile-link-row::after,.tgios-profile-voice-row::after{content:"";position:absolute;left:58px;right:0;bottom:0;height:.5px;background:var(--separator,rgba(60,60,67,.2))}
.tgios-profile-file-row:last-child::after,.tgios-profile-link-row:last-child::after,.tgios-profile-voice-row:last-child::after{display:none}
.tgios-profile-row-icon{width:32px;height:32px;flex:0 0 32px;display:grid;place-items:center;color:var(--accent,#0a84ff)}
.tgios-profile-row-icon svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tgios-profile-row-copy{min-width:0;flex:1}
.tgios-profile-row-copy strong{display:block;font-size:15px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tgios-profile-row-copy small{display:block;margin-top:2px;font-size:12px;color:var(--label-secondary,#8e8e93);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tgios-profile-empty{padding:28px 18px;text-align:center;color:var(--label-secondary,#8e8e93);font-size:14px}

/* ---------- Message context menu ---------- */
#msgContextWrap.tgios-context-overlay{
  position:fixed;inset:0;display:block;padding:0;
  background:rgba(16,18,22,.24);
  -webkit-backdrop-filter:blur(20px) saturate(120%);
  backdrop-filter:blur(20px) saturate(120%);
  touch-action:none;overscroll-behavior:none;
  animation:tgios-context-fade .18s ease-out;
}
@keyframes tgios-context-fade{from{opacity:0}to{opacity:1}}
.tgios-context-stage{position:absolute;inset:0;overflow:hidden;outline:0}
.tgios-reaction-capsule{
  position:fixed;height:50px;padding:3px 6px;border-radius:25px;
  display:flex;align-items:center;gap:0;
  background:color-mix(in srgb,var(--surface-primary,#fff) 88%,transparent);
  border:.5px solid color-mix(in srgb,var(--separator,rgba(60,60,67,.25)) 70%,transparent);
  box-shadow:0 8px 24px rgba(0,0,0,.13);
  -webkit-backdrop-filter:blur(22px) saturate(180%);backdrop-filter:blur(22px) saturate(180%);
  transform-origin:50% 100%;animation:tgios-context-pop .21s cubic-bezier(.2,.8,.2,1);
}
.tgios-reaction-button{width:42px;height:42px;padding:0;border:0;background:transparent;border-radius:21px;font-size:27px;line-height:42px;text-align:center;transition:transform .16s cubic-bezier(.2,.8,.2,1)}
.tgios-reaction-button:active{transform:scale(1.28)}
.tgios-reaction-more{display:grid;place-items:center;color:var(--label-secondary,#8e8e93);font-size:0}
.tgios-reaction-more svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tgios-context-message-host{position:fixed;z-index:2;pointer-events:none;transform-origin:center;animation:tgios-message-lift .21s cubic-bezier(.2,.8,.2,1)}
.tgios-context-message-host .bwrap{width:100%!important;max-width:none!important;margin:0!important;pointer-events:none}


.tgios-context-placeholder{visibility:hidden;flex:none}
.tgios-context-actions{
  position:fixed;width:244px;max-height:340px;overflow-y:auto;-webkit-overflow-scrolling:touch;
  border-radius:15px;background:color-mix(in srgb,var(--surface-primary,#fff) 91%,transparent);
  border:.5px solid color-mix(in srgb,var(--separator,rgba(60,60,67,.25)) 75%,transparent);
  box-shadow:0 12px 36px rgba(0,0,0,.18);
  -webkit-backdrop-filter:blur(22px) saturate(180%);backdrop-filter:blur(22px) saturate(180%);
  transform-origin:50% 0;animation:tgios-context-pop .20s cubic-bezier(.2,.8,.2,1);
  scrollbar-width:none;
}
.tgios-context-actions::-webkit-scrollbar{display:none}
@keyframes tgios-context-pop{from{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}
@keyframes tgios-message-lift{from{transform:scale(.985)}to{transform:scale(1)}}
.tgios-context-info{min-height:44px;padding:0 14px;display:flex;align-items:center;gap:9px;color:var(--label-secondary,#8e8e93);font-size:13px;border-bottom:.5px solid var(--separator,rgba(60,60,67,.22))}
.tgios-context-info svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tgios-context-action{width:100%;min-height:46px;padding:0 14px;border:0;background:transparent;color:var(--label-primary,#111);font:inherit;font-size:16px;display:flex;align-items:center;justify-content:space-between;gap:16px;text-align:left;position:relative}
.tgios-context-action:not(:last-child)::after{content:"";position:absolute;left:14px;right:0;bottom:0;height:.5px;background:var(--separator,rgba(60,60,67,.2))}
.tgios-context-action:active{background:var(--selection,rgba(120,120,128,.12))}
.tgios-context-action.danger{color:var(--destructive,#ff3b30)}
.tgios-context-action-icon{width:24px;height:24px;flex:0 0 24px;display:grid;place-items:center}
.tgios-context-action-icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}

@media(min-width:900px){
  #personProfileScreen{position:fixed;inset:0 0 0 auto;width:var(--profile-inspector-width,360px);max-width:var(--profile-inspector-width,360px);height:100vh;border-left:.5px solid var(--separator,rgba(60,60,67,.2));box-shadow:-14px 0 34px rgba(0,0,0,.1);transform:translateX(100%);visibility:hidden;pointer-events:none;transition:transform .2s ease,visibility 0s linear .2s}
  #personProfileScreen.open{transform:translateX(0);visibility:visible;pointer-events:auto;transition:transform .2s ease,visibility 0s}
  .tgios-profile-hero{min-height:342px}
  #msgContextWrap.tgios-context-overlay{background:rgba(0,0,0,.08);-webkit-backdrop-filter:none;backdrop-filter:none}
}

@media(max-width:899px){
  #personProfileScreen{width:100%;height:100dvh;transform:translateX(100%);visibility:hidden;pointer-events:none;transition:transform .24s cubic-bezier(.2,.75,.2,1),visibility 0s linear .24s}
  #personProfileScreen.open{transform:translateX(0);visibility:visible;pointer-events:auto;transition:transform .24s cubic-bezier(.2,.75,.2,1),visibility 0s}
}

@media(max-width:374px){
  .tgios-profile-actions{grid-template-columns:repeat(4,minmax(0,1fr))}
  #profSearchBtn{display:none}
}

@media(orientation:landscape) and (max-height:500px){
  .tgios-profile-hero{min-height:270px;padding-top:calc(var(--sat,0px) + 50px)}
  .tgios-profile-avatar-button,#pAv.tgios-profile-avatar{width:78px;height:78px}
  .tgios-profile-name{margin-top:8px;font-size:20px}
  .tgios-profile-actions{margin-top:9px}
}

@media(prefers-reduced-motion:reduce){
  #personProfileScreen,.tgios-profile-nav-title,.tgios-context-overlay,.tgios-reaction-capsule,.tgios-context-message-host,.tgios-context-actions,.tgios-reaction-button{animation:none!important;transition:none!important}
}

/* ---------- Profile More action sheet ---------- */
.tgios-profile-more-overlay{position:fixed;inset:0;padding:0;background:transparent!important;display:block}
.tgios-profile-more-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.18);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
.tgios-profile-more-sheet{position:absolute;left:max(8px,var(--sal,0px));right:max(8px,var(--sar,0px));bottom:calc(max(8px,var(--sab,0px)) + 2px);display:flex;flex-direction:column;gap:8px;pointer-events:auto}
#profileMoreList{overflow:hidden;border-radius:14px;background:color-mix(in srgb,var(--surface-primary,#fff) 94%,transparent);-webkit-backdrop-filter:blur(22px) saturate(180%);backdrop-filter:blur(22px) saturate(180%);box-shadow:0 12px 36px rgba(0,0,0,.18)}
.tgios-profile-more-row,.tgios-profile-more-cancel{position:relative;width:100%;min-height:52px;padding:0 16px;border:0;background:transparent;color:var(--accent,#0a84ff);font:inherit;font-size:17px;display:flex;align-items:center;justify-content:space-between;text-align:left}
.tgios-profile-more-row:not(:last-child)::after{content:"";position:absolute;left:16px;right:0;bottom:0;height:.5px;background:var(--separator,rgba(60,60,67,.22))}
.tgios-profile-more-row:active,.tgios-profile-more-cancel:active{background:var(--selection,rgba(120,120,128,.12))}
.tgios-profile-more-row.danger{color:var(--destructive,#ff3b30)}
.tgios-profile-more-icon{width:24px;height:24px;display:grid;place-items:center;flex:0 0 24px}
.tgios-profile-more-icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
.tgios-profile-more-cancel{justify-content:center;border-radius:14px;background:var(--surface-primary,#fff);font-weight:600;box-shadow:0 8px 28px rgba(0,0,0,.14)}
@media(min-width:900px){.tgios-profile-more-sheet{left:auto;right:18px;bottom:auto;top:58px;width:286px}.tgios-profile-more-backdrop{background:transparent;-webkit-backdrop-filter:none;backdrop-filter:none}}
@media(prefers-reduced-motion:reduce){.tgios-profile-more-overlay,.tgios-profile-more-sheet{animation:none!important;transition:none!important}}
