/* TALKCHAT_R19C12R9R10R1_DESKTOP_GIFT_LAYOUT_CLEANUP
   Desktop-only gift modal layout cleanup.
   Fixes clipped category tabs, uneven card rhythm, and whole-form scrolling.
   Gift API/send behavior and mobile layout remain unchanged.
*/
@media (min-width:768px){
  #featureLayer > .social-popup.profile-popup.profile-gift-popup{
    width:min(760px,calc(100vw - 80px))!important;
    height:min(720px,calc(100dvh - 72px))!important;
    min-height:560px!important;
  }

  #featureLayer > .profile-gift-popup > header{
    min-height:54px!important;
    padding:0 16px!important;
    display:flex!important;
    align-items:center!important;
    border-bottom:1px solid var(--tc-border,#2b3745)!important;
  }

  #featureLayer > .profile-gift-popup > #profileGiftForm{
    flex:1 1 auto!important;
    min-height:0!important;
    overflow:hidden!important;
    padding:14px!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto!important;
    grid-template-rows:auto auto minmax(0,1fr) auto auto auto auto auto!important;
    gap:10px 12px!important;
    align-content:stretch!important;
    box-sizing:border-box!important;
  }

  /* Top summary: recipient at left, balance as a compact pill at right. */
  #featureLayer > .profile-gift-popup .profile-gift-target{
    grid-column:1!important;
    margin:0!important;
    min-width:0!important;
    display:flex!important;
    align-items:center!important;
    min-height:38px!important;
    color:var(--tc-muted,#a9b6c5)!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-target b{
    color:var(--tc-text,#f1f5f9)!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-balance{
    grid-column:2!important;
    align-self:center!important;
    margin:0!important;
    min-height:38px!important;
    display:flex!important;
    align-items:center!important;
    gap:5px!important;
    padding:0 12px!important;
    border:1px solid var(--tc-border,#2b3745)!important;
    border-radius:999px!important;
    background:var(--tc-elevated,#1c2733)!important;
    color:var(--tc-text,#f1f5f9)!important;
    white-space:nowrap!important;
  }

  /* Categories: force a real, readable horizontal chip row. */
  #featureLayer > .profile-gift-popup .gift-catalog-tabs{
    grid-column:1/-1!important;
    display:flex!important;
    align-items:center!important;
    gap:7px!important;
    min-height:34px!important;
    height:34px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    padding:0 0 2px!important;
    margin:0!important;
    scrollbar-width:none!important;
  }
  #featureLayer > .profile-gift-popup .gift-catalog-tabs::-webkit-scrollbar{
    display:none!important;
  }
  #featureLayer > .profile-gift-popup .gift-catalog-tabs button{
    flex:0 0 auto!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    min-height:30px!important;
    height:30px!important;
    line-height:1!important;
    padding:0 12px!important;
    margin:0!important;
    border:1px solid var(--tc-borderHi,#3a4a5b)!important;
    border-radius:999px!important;
    background:var(--tc-elevated,#1c2733)!important;
    color:var(--tc-muted,#a9b6c5)!important;
    font-size:11px!important;
    font-weight:700!important;
    white-space:nowrap!important;
    opacity:1!important;
  }
  #featureLayer > .profile-gift-popup .gift-catalog-tabs button:hover{
    background:var(--tc-hover,#24313e)!important;
    color:var(--tc-text,#f1f5f9)!important;
  }
  #featureLayer > .profile-gift-popup .gift-catalog-tabs button.active{
    border-color:#268fd8!important;
    background:#173b56!important;
    color:#55b7ff!important;
  }

  /* Catalog is the main scroll region; footer actions stay visible. */
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full{
    grid-column:1/-1!important;
    min-height:0!important;
    max-height:none!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    align-content:start!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:8px!important;
    padding:1px 4px 4px 0!important;
    scrollbar-width:thin!important;
    scrollbar-color:var(--tc-scroll-thumb,#364656) transparent!important;
  }
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full::-webkit-scrollbar{
    width:7px!important;
  }
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full::-webkit-scrollbar-track{
    background:transparent!important;
  }
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full::-webkit-scrollbar-thumb{
    background:var(--tc-scroll-thumb,#364656)!important;
    border-radius:999px!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full label{
    min-width:0!important;
    min-height:118px!important;
    padding:10px 8px 8px!important;
    display:grid!important;
    grid-template-rows:64px auto auto!important;
    place-items:center!important;
    align-content:start!important;
    gap:4px!important;
    border:1px solid var(--tc-border,#2b3745)!important;
    border-radius:9px!important;
    background:var(--tc-elevated,#1c2733)!important;
    box-sizing:border-box!important;
    overflow:hidden!important;
  }
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full label:hover{
    border-color:#3e566d!important;
    background:var(--tc-hover,#24313e)!important;
  }
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full label:has(input:checked){
    border-color:#268fd8!important;
    box-shadow:inset 0 0 0 1px #268fd8!important;
    background:#17283a!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full .gift-image,
  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full .gift-emoji{
    width:64px!important;
    height:64px!important;
    box-sizing:border-box!important;
    border-radius:12px!important;
    background:#111922!important;
    object-fit:contain!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full .gift-image{
    padding:4px!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full .gift-emoji{
    display:grid!important;
    place-items:center!important;
    font-size:36px!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-choices.gift-full label>b{
    max-width:100%!important;
    color:var(--tc-text,#f1f5f9)!important;
    font-size:12px!important;
    line-height:1.2!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  #featureLayer > .profile-gift-popup .gift-price{
    min-height:18px!important;
    display:inline-flex!important;
    align-items:center!important;
    gap:3px!important;
    color:#9fb0c2!important;
    font-size:10px!important;
    font-weight:700!important;
  }

  #featureLayer > .profile-gift-popup textarea[name="message"]{
    grid-column:1/-1!important;
    min-height:54px!important;
    max-height:54px!important;
    resize:none!important;
    margin:0!important;
    padding:9px 10px!important;
    box-sizing:border-box!important;
    border:1px solid var(--tc-border,#2b3745)!important;
    border-radius:8px!important;
    background:var(--tc-elevated,#1c2733)!important;
    color:var(--tc-text,#f1f5f9)!important;
  }

  #featureLayer > .profile-gift-popup .profile-gift-anon{
    grid-column:1!important;
    min-height:34px!important;
    margin:0!important;
    align-self:center!important;
  }

  #featureLayer > .profile-gift-popup .gift-history-toggle{
    grid-column:2!important;
    min-height:34px!important;
    margin:0!important;
    padding:0 12px!important;
    border:1px solid var(--tc-border,#2b3745)!important;
    background:var(--tc-elevated,#1c2733)!important;
    color:var(--tc-muted,#a9b6c5)!important;
    white-space:nowrap!important;
  }

  #featureLayer > .profile-gift-popup .gift-history{
    grid-column:1/-1!important;
    max-height:120px!important;
    overflow:auto!important;
    margin:0!important;
  }

  #featureLayer > .profile-gift-popup [role="alert"]{
    grid-column:1/-1!important;
    margin:0!important;
    min-height:0!important;
  }

  #featureLayer > .profile-gift-popup .feature-primary[type="submit"]{
    grid-column:1/-1!important;
    min-height:40px!important;
    margin:0!important;
    border-radius:8px!important;
    font-weight:800!important;
  }
}

/* Mobile remains controlled by the existing gift rules. */
@media (max-width:767px){
  #featureLayer > .profile-gift-popup{
    /* no r10r1 desktop layout overrides */
  }
}
