/* Profile editing has its own surface; shared drawers, sheets and inbox stay scoped. */
html[data-ui] #drawer:has(.xpe) > .drawer-header {
  display: none;
}

html[data-ui] #drawer:has(.xpe) > #drawer-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#drawer-body .xpe {
  --xpe-bg: #f6f7f9;
  --xpe-card: #fff;
  --xpe-text: #25262c;
  --xpe-secondary: #717580;
  --xpe-muted: #a3a6af;
  --xpe-line: #eceef2;
  --xpe-pink: #fe2c55;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--xpe-bg);
  color: var(--xpe-text);
  color-scheme: light;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

#drawer-body .xpe *,
#drawer-body .xpe *::before,
#drawer-body .xpe *::after {
  box-sizing: border-box;
}

#drawer-body .xpe [hidden] {
  display: none !important;
}

#drawer-body .xpe button {
  font-family: inherit;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#drawer-body .xpe button:disabled {
  opacity: .45;
  cursor: default;
}

#drawer-body .xpe button:focus-visible,
#drawer-body .xpe a:focus-visible {
  outline: 2px solid #ff7591;
  outline-offset: 3px;
}

#drawer-body .xpe-header {
  z-index: 2;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 70px;
  flex: 0 0 auto;
  align-items: center;
  min-height: 60px;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--xpe-line);
  background: var(--xpe-card);
}

#drawer-body .xpe-header h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--xpe-text);
  font-size: 17px;
  font-weight: 600;
  line-height: 26px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#drawer-body .xpe-back {
  display: grid;
  place-items: center;
  justify-self: start;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  padding: 11px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #31323a;
}

#drawer-body .xpe-back svg {
  width: 22px;
  height: 22px;
  transform: rotate(180deg);
}

#drawer-body .xpe-back:hover {
  background: #f4f5f7;
  color: #31323a;
}

#drawer-body .xpe-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  min-width: 64px;
  min-height: 36px;
  margin: 0;
  padding: 7px 15px;
  border: 0;
  border-radius: 18px;
  background: var(--xpe-pink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

#drawer-body .xpe-save:not(:disabled):hover {
  background: #f11d48;
  color: #fff;
}

#drawer-body .xpe-scroll {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 24px 20px 30px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #d7d9e0 transparent;
  scroll-padding-block: 18px;
  -webkit-overflow-scrolling: touch;
}

#drawer-body .xpe-hero {
  width: 100%;
  max-width: 680px;
  margin: 0 auto 25px;
  padding: 0 16px;
  text-align: center;
}

#drawer-body .xpe-avatar-picker {
  position: relative;
  display: inline-block;
  width: 88px;
  height: 88px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
}

#drawer-body .xpe-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(140deg, #ff7599 4%, #ef4d84 52%, #b079e6 100%);
  color: #fff;
  box-shadow: 0 5px 18px #df5f8c16;
}

#drawer-body .xpe-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#drawer-body .xpe-avatar-initial {
  max-width: 100%;
  overflow: hidden;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}

#drawer-body .xpe-camera {
  position: absolute;
  right: -1px;
  bottom: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 3px solid var(--xpe-bg);
  border-radius: 50%;
  background: #32333c;
  color: #fff;
  pointer-events: none;
}

#drawer-body .xpe-camera svg {
  width: 14px;
  height: 14px;
}

#drawer-body .xpe-avatar-picker input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  opacity: 0;
  cursor: pointer;
}

#drawer-body .xpe-avatar-picker:focus-within {
  outline: 2px solid #ff7591;
  outline-offset: 4px;
}

#drawer-body .xpe-avatar-picker:has(input:disabled) {
  opacity: .6;
  cursor: default;
}

#drawer-body .xpe-avatar-picker input:disabled {
  cursor: default;
}

#drawer-body .xpe-avatar-reset {
  display: block;
  min-height: 32px;
  margin: 5px auto 0;
  padding: 5px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--xpe-secondary);
  font-size: 11px;
}

#drawer-body .xpe-avatar-reset:not(:disabled):hover {
  background: #eceef3;
  color: #565966;
}

#drawer-body .xpe-display-name {
  margin: 12px 0 4px;
  color: var(--xpe-text);
  font-size: 19px;
  font-weight: 600;
  line-height: 27px;
  overflow-wrap: anywhere;
}

#drawer-body .xpe-hero-caption {
  margin: 0;
  color: var(--xpe-muted);
  font-size: 11px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

#drawer-body .xpe-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  width: 100%;
  max-width: 256px;
  margin: 16px auto 0;
  color: #969aa4;
  font-size: 10px;
  line-height: 17px;
  text-align: left;
}

#drawer-body .xpe-progress :is(p, small, h3) {
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 400;
}

#drawer-body .xpe-progress-copy {
  display: flex;
  flex: 0 0 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

#drawer-body .xpe-progress strong {
  margin-left: auto;
  color: #848996;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#drawer-body .xpe-progress-track {
  display: block;
  flex: 0 0 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: #e8eaf0;
}

#drawer-body .xpe-progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f3a1b4, #ec7895);
  transition: width .22s ease;
}

#drawer-body .xpe-form {
  display: block;
  width: 100%;
  max-width: 680px;
  min-width: 0;
  margin: 0 auto;
  padding: 0;
}

#drawer-body .xpe-form fieldset {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

#drawer-body .xpe-form[aria-busy="true"] {
  cursor: progress;
}

#drawer-body .xpe-form fieldset:disabled :is(input, textarea, select) {
  opacity: .55;
  cursor: default;
  -webkit-text-fill-color: currentColor;
}

#drawer-body .xpe-section + .xpe-section {
  margin-top: 23px;
}

#drawer-body .xpe-section-title {
  margin: 0 2px 5px;
  color: #545965;
  font-size: 13px;
  font-weight: 600;
  line-height: 21px;
}

#drawer-body .xpe-section-note {
  margin: 0 2px 11px;
  color: var(--xpe-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 19px;
  overflow-wrap: anywhere;
}

#drawer-body .xpe-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--xpe-line);
  border-radius: 15px;
  background: var(--xpe-card);
}

#drawer-body .xpe-field {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 14px 16px 12px;
  border: 0;
  color: var(--xpe-text);
  text-align: left;
  transition: background .15s ease;
}

#drawer-body .xpe-card > .xpe-field + .xpe-field,
#drawer-body .xpe-card > .xpe-field-row + .xpe-field,
#drawer-body .xpe-card > .xpe-field + .xpe-field-row,
#drawer-body .xpe-card > .xpe-field-row + .xpe-field-row {
  border-top: 1px solid var(--xpe-line);
}

#drawer-body .xpe-field:focus-within {
  background: #fffbfc;
  box-shadow: inset 0 0 0 1px #fe2c551c;
}

#drawer-body .xpe-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 5px;
  color: var(--xpe-secondary);
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
}

#drawer-body .xpe-count {
  flex: 0 0 auto;
  margin-left: auto;
  color: #b2b5bd;
  font-size: 10px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#drawer-body .xpe-field :is(input, textarea, select) {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 31px;
  margin: 0;
  padding: 3px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--xpe-text);
  box-shadow: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 25px;
  text-align: left;
  -webkit-text-fill-color: currentColor;
}

#drawer-body .xpe-field :is(input, textarea)::placeholder {
  color: #b5b8c0;
  opacity: 1;
  -webkit-text-fill-color: #b5b8c0;
}

#drawer-body .xpe-field :is(input, textarea, select):focus-visible {
  outline: 0;
}

#drawer-body .xpe-field textarea {
  height: 80px;
  min-height: 80px;
  max-height: 200px;
  resize: none;
}

#drawer-body .xpe-field select {
  padding-right: 5px;
  appearance: auto;
  -webkit-appearance: menulist;
  cursor: pointer;
}

#drawer-body .xpe-field select option {
  background: #fff;
  color: #25262c;
}

#drawer-body .xpe-field [aria-invalid="true"] {
  color: #d72850;
}

#drawer-body .xpe-field:has([aria-invalid="true"]) {
  background: #fff6f8;
  box-shadow: inset 0 0 0 1px #fe2c5540;
}

#drawer-body .xpe-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

#drawer-body .xpe-field-row > .xpe-field + .xpe-field {
  border-top: 0;
  border-left: 1px solid var(--xpe-line);
}

#drawer-body .xpe-id-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 15px 16px;
  color: var(--xpe-secondary);
  font-size: 12px;
  line-height: 21px;
}

#drawer-body .xpe-id-row > :first-child {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

#drawer-body .xpe-id-row > :first-child > :last-child {
  display: block;
  min-width: 0;
  color: #7c818d;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

#drawer-body .xpe-copy {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 36px;
  margin: -6px -4px -6px 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: #f6f7f9;
  color: #828793;
  font-size: 11px;
}

#drawer-body .xpe-copy svg {
  width: 14px;
  height: 14px;
}

#drawer-body .xpe-copy:not(:disabled):hover {
  background: #eceef3;
  color: #575c68;
}

#drawer-body .xpe-inline-status,
#drawer-body .xpe-error {
  margin: 14px 0;
  padding: 11px 13px;
  border: 1px solid #ebeef3;
  border-radius: 10px;
  background: #eef1f6;
  color: #777e8d;
  font-size: 12px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

#drawer-body .xpe-error {
  border-color: #f7dae2;
  background: #fff1f5;
  color: #c74868;
}

#drawer-body .xpe-error > p {
  margin: 0;
}

#drawer-body .xpe-error button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin: -4px -3px -4px 7px;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #dc355c;
  font-size: 12px;
  font-weight: 500;
}

#drawer-body .xpe-error button:not(:disabled):hover {
  background: #fe2c550a;
  color: #b92247;
}

#drawer-body .xpe-footer-note {
  margin: 16px 2px 0;
  color: #a7abb4;
  font-size: 10px;
  line-height: 19px;
  overflow-wrap: anywhere;
}

html[data-ui="mobile"] #drawer:has(.xpe) {
  bottom: var(--xpe-keyboard-inset, 0px);
  background: #f6f7f9;
  color: #25262c;
}

html[data-ui="mobile"] #drawer-body .xpe-header {
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
}

html[data-ui="mobile"] #drawer-body .xpe-scroll {
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
}

html[data-ui="desktop"] #drawer:has(.xpe) {
  background: #161618;
}

html[data-ui="desktop"] #drawer:has(.xpe) > #drawer-body {
  padding: 24px 32px 32px;
}

html[data-ui="desktop"] #drawer-body .xpe {
  max-width: 960px;
  margin: 0 auto;
  border: 1px solid #ffffff12;
  border-radius: 20px;
  box-shadow: 0 16px 50px #0002;
}

html[data-ui="desktop"] #drawer-body .xpe-header {
  min-height: 72px;
  padding: 13px 24px;
}

html[data-ui="desktop"] #drawer-body .xpe-header h1 {
  font-size: 18px;
}

html[data-ui="desktop"] #drawer-body .xpe-scroll {
  display: grid;
  grid-template-columns: 225px minmax(0, 1fr);
  align-items: start;
  gap: 30px;
  padding: 30px;
}

html[data-ui="desktop"] #drawer-body .xpe-hero {
  margin: 0;
  padding: 20px 10px;
}

html[data-ui="desktop"] #drawer-body .xpe-avatar-picker {
  width: 104px;
  height: 104px;
}

html[data-ui="desktop"] #drawer-body .xpe-avatar-initial {
  font-size: 39px;
}

html[data-ui="desktop"] #drawer-body .xpe-display-name {
  margin-top: 17px;
}

html[data-ui="desktop"] #drawer-body .xpe-progress {
  margin-top: 24px;
}

/* A wide WebApp retains the mobile page and readable mobile form width. */
@media (min-width: 760px) {
  html[data-ui="mobile"] #drawer-body .xpe-scroll {
    padding-top: 32px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  }

  html[data-ui="mobile"] #drawer-body .xpe-header {
    padding-right: max(24px, calc((100% - 680px) / 2));
    padding-left: max(24px, calc((100% - 680px) / 2));
  }

  html[data-ui="mobile"] #drawer-body .xpe-hero {
    margin-bottom: 30px;
  }
}

/* The installed app stays mobile in landscape; the single body scrolls. */
@media (min-width: 600px) and (max-height: 500px) {
  html[data-ui="mobile"] #drawer-body .xpe-header {
    min-height: 48px;
    padding-top: max(2px, env(safe-area-inset-top, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-bottom: 2px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }

  html[data-ui="mobile"] #drawer-body .xpe-scroll {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: start;
    gap: 22px;
    padding-top: 18px;
    padding-right: max(22px, env(safe-area-inset-right, 0px));
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    padding-left: max(22px, env(safe-area-inset-left, 0px));
  }

  html[data-ui="mobile"] #drawer-body .xpe-hero {
    margin: 0;
    padding: 5px 8px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-avatar-picker {
    width: 64px;
    height: 64px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-avatar-initial {
    font-size: 25px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-camera {
    width: 25px;
    height: 25px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-camera svg {
    width: 12px;
    height: 12px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-display-name {
    margin-top: 9px;
    font-size: 16px;
    line-height: 23px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-progress {
    margin-top: 12px;
  }

  html[data-ui="mobile"] #drawer-body .xpe-section + .xpe-section {
    margin-top: 18px;
  }
}

@media (max-width: 360px) {
  #drawer-body .xpe-field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  #drawer-body .xpe-field-row > .xpe-field + .xpe-field {
    border-top: 1px solid var(--xpe-line);
    border-left: 0;
  }

  #drawer-body .xpe-field {
    padding-right: 13px;
    padding-left: 13px;
  }
}

@media (max-width: 1100px) {
  html[data-ui="desktop"] #drawer:has(.xpe) > #drawer-body {
    padding: 18px 24px 24px;
  }

  html[data-ui="desktop"] #drawer-body .xpe-scroll {
    grid-template-columns: 175px minmax(0, 1fr);
    gap: 22px;
    padding: 24px;
  }
}

@media (max-width: 820px) {
  html[data-ui="desktop"] #drawer-body .xpe-scroll {
    display: block;
    padding: 22px;
  }

  html[data-ui="desktop"] #drawer-body .xpe-hero {
    margin: 0 auto 22px;
    padding: 0;
  }

  html[data-ui="desktop"] #drawer-body .xpe-avatar-picker {
    width: 80px;
    height: 80px;
  }

  html[data-ui="desktop"] #drawer-body .xpe-progress {
    margin-top: 14px;
  }
}

@media (max-height: 600px) {
  html[data-ui="desktop"] #drawer:has(.xpe) > #drawer-body {
    padding: 12px;
  }

  html[data-ui="desktop"] #drawer-body .xpe {
    border-radius: 14px;
  }

  html[data-ui="desktop"] #drawer-body .xpe-header {
    min-height: 56px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #drawer-body .xpe *,
  #drawer-body .xpe *::before,
  #drawer-body .xpe *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Public profile additions share saved data while retaining each UI's style. */
html[data-ui="mobile"] .xmp-profile-avatar {
  overflow: hidden;
}

html[data-ui="mobile"] .xmp-profile-avatar .xmp-avatar-photo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

html[data-ui="mobile"] .xmp-profile-extra,
html[data-ui="desktop"] .xdp-profile-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
  margin: 12px 0 0;
  color: #888b95;
  font-size: 11px;
  font-weight: 400;
  line-height: 20px;
}

html[data-ui="mobile"] .xmp-profile-extra > :is(span, a),
html[data-ui="desktop"] .xdp-profile-extra > :is(span, a) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  padding: 2px 7px;
  border-radius: 5px;
  background: #ffffff06;
  color: inherit;
  overflow-wrap: anywhere;
}

html[data-ui="mobile"] .xmp-profile-extra svg,
html[data-ui="desktop"] .xdp-profile-extra svg {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
}

html[data-ui="mobile"] .xmp-profile-extra a:hover,
html[data-ui="desktop"] .xdp-profile-extra a:hover {
  color: #ff6f8e;
}

html[data-ui="mobile"] .xmp-profile-extra a:focus-visible,
html[data-ui="desktop"] .xdp-profile-extra a:focus-visible {
  outline: 2px solid #ff7591;
  outline-offset: 3px;
}
