/* Account dialogs live in document root, not the constrained chat sidebar. */
body > #account-panel{
  box-sizing:border-box!important;position:fixed!important;z-index:2100!important;
  inset:auto!important;overflow-y:auto!important;overflow-x:hidden!important;
  background:var(--panel)!important;color:var(--fg)!important;
  border:1px solid var(--border)!important;border-radius:20px!important;
  box-shadow:0 28px 90px #102c2540!important;
  scrollbar-width:thin;overscroll-behavior:contain;
}
body > #account-panel[hidden]{display:none!important}
/* Sign in and registration need a comfortable central width, not the sidebar width. */
body > #account-panel:not([data-profile-signed="true"]){
  top:50%!important;left:50%!important;right:auto!important;bottom:auto!important;
  transform:translate(-50%,-50%)!important;
  width:min(500px,calc(100vw - 32px))!important;
  max-width:calc(100vw - 32px)!important;
  max-height:min(84dvh,760px)!important;
  padding:26px!important;
}
body > #account-panel:not([data-profile-signed="true"]) #account-form{
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:12px!important;
}
body > #account-panel:not([data-profile-signed="true"]) :is(input[type="email"],input[type="password"],input[type="text"],select){
  width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box!important;
}
body > #account-panel:not([data-profile-signed="true"]) :is(#yap-registration-details,#yap-signup-consent){
  min-width:0!important;max-width:100%!important;width:100%!important;box-sizing:border-box!important;
  grid-column:1/-1!important;margin:0!important;
}
body > #account-panel:not([data-profile-signed="true"]) #yap-registration-details label{display:block;max-width:100%;min-width:0}
body > #account-panel:not([data-profile-signed="true"]) #yap-registration-details label[for="yap-age-adult"]{display:flex!important}
body > #account-panel:not([data-profile-signed="true"]) .yap-account-mode{display:flex!important;flex-wrap:wrap;gap:8px!important}
body > #account-panel:not([data-profile-signed="true"]) #account-form button[type="submit"]{min-height:44px!important;grid-column:1/-1!important}
body > #account-panel:not([data-profile-signed="true"]) .yap-support-menu{margin-bottom:16px}
body > #account-panel:not([data-profile-signed="true"]) :is(#account-state,#cloud-quota){font-size:12px;line-height:1.5}
/* Signed-in profile menu retains the small anchored dropdown. */
body > #account-panel[data-profile-signed="true"]{
  top:auto!important;left:12px!important;right:auto!important;bottom:85px!important;
  transform:none!important;width:min(314px,calc(100vw - 24px))!important;
  max-width:calc(100vw - 24px)!important;max-height:min(76dvh,650px)!important;
  padding:8px!important;
}
@media(max-width:700px){
 body > #account-panel:not([data-profile-signed="true"]){padding:18px!important;max-height:calc(100dvh - 30px)!important}
 body > #account-panel[data-profile-signed="true"]{left:9px!important;bottom:calc(84px + env(safe-area-inset-bottom))!important}
}

/* Clear visual hierarchy: authentication first, support options below. */
body:has(> #account-panel:not([hidden]):not([data-profile-signed="true"]))::before{
  content:"";position:fixed;inset:0;z-index:2050;
  background:rgba(7,34,26,.24);backdrop-filter:blur(2px);
}
body > #account-panel:not([data-profile-signed="true"]){
  display:flex!important;flex-direction:column!important;gap:0!important;
}
body > #account-panel:not([data-profile-signed="true"]) > .yap-account-mode{order:1!important;padding-right:36px}
body > #account-panel:not([data-profile-signed="true"]) > .yap-account-mode-description{order:2!important}
body > #account-panel:not([data-profile-signed="true"]) > #account-form{order:3!important}
body > #account-panel:not([data-profile-signed="true"]) > #account-state{order:4!important}
body > #account-panel:not([data-profile-signed="true"]) > #cloud-quota{order:5!important}
body > #account-panel:not([data-profile-signed="true"]) > .yap-support-menu{
  order:10!important;margin-top:18px!important;margin-bottom:0!important;
}
body > #account-panel #yap-account-dismiss{
  position:sticky!important;top:0;align-self:flex-end;z-index:2;
  flex:none;min-width:36px;width:36px;height:36px;min-height:36px;
  display:grid;place-items:center;padding:0;margin:0 0 -36px auto!important;
  color:var(--fg)!important;background:var(--panel)!important;
  border:1px solid var(--border)!important;border-radius:11px!important;
  font:500 25px/1 system-ui!important;cursor:pointer!important;
  order:-1!important;box-shadow:none!important;
}
body > #account-panel #yap-account-dismiss:hover{background:var(--bubble)!important}
body > #account-panel #yap-account-dismiss:focus-visible{outline:2px solid #16b970;outline-offset:2px}
body > #account-panel[data-profile-signed="true"] #yap-account-dismiss{display:none!important}
@media(prefers-reduced-motion:reduce){body:has(> #account-panel:not([hidden]):not([data-profile-signed="true"]))::before{backdrop-filter:none}}

body > #account-panel[hidden]{display:none!important}


/* Account dialog drag handle. Only the title bar moves the dialog, never form controls. */
body > #account-panel:not([data-profile-signed="true"]) > .yap-account-drag-handle{order:-2!important;display:flex;align-items:center;gap:9px;flex:none;min-height:46px;padding:3px 42px 14px 2px;margin:0 0 6px;cursor:grab;touch-action:none;user-select:none;color:var(--fg);font-weight:750;font-size:17px;letter-spacing:-.03em}
body > #account-panel:not([data-profile-signed="true"]) > .yap-account-drag-handle:before{content:"";width:21px;height:21px;background:url("/assets/yapthing-brand-mark.svg") center / contain no-repeat;flex:none}
body > #account-panel:not([data-profile-signed="true"]) > .yap-account-drag-handle:active{cursor:grabbing}
body > #account-panel[data-profile-signed="true"] > .yap-account-drag-handle{display:none!important}
body > #account-panel:not([data-profile-signed="true"])[data-dragged="true"]{top:var(--yap-dialog-y)!important;left:var(--yap-dialog-x)!important;right:auto!important;bottom:auto!important;transform:none!important}
body > #account-panel:not([data-profile-signed="true"]) > #yap-account-dismiss{position:sticky!important;top:0;order:-1!important;margin:-54px 0 18px auto!important}
@media(max-width:700px){body > #account-panel:not([data-profile-signed="true"]) > .yap-account-drag-handle{font-size:15px}}
