#xb-profile-layer[data-open="false"] {
  display: none;
}

.xb-profile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(15 23 42 / 42%);
  backdrop-filter: blur(3px);
}

.xb-profile-dialog {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 24px 64px rgb(15 23 42 / 22%);
}

.xb-profile-dialog--loading {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}

.xb-profile-head {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid hsl(var(--border));
}

.xb-profile-head h2,
.xb-profile-section-head h3 {
  margin: 0;
  letter-spacing: 0;
  color: hsl(var(--foreground));
}

.xb-profile-head h2 {
  font-size: 16px;
  line-height: 22px;
  font-weight: 650;
}

.xb-profile-head > div > span {
  display: block;
  margin-top: 2px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
}

.xb-profile-icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.xb-profile-icon-button:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.xb-profile-form {
  display: block;
}

.xb-profile-identity {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 20px;
}

.xb-profile-avatar {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 50%;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-size: 25px;
  font-weight: 700;
}

.xb-profile-avatar img,
.xb-profile-header-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.xb-profile-avatar--image,
.xb-profile-header-avatar {
  background: transparent !important;
  background-image: none !important;
}

.xb-profile-identity-copy {
  min-width: 0;
}

.xb-profile-identity-copy > strong,
.xb-profile-identity-copy > span {
  display: block;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xb-profile-identity-copy > strong {
  font-size: 15px;
  font-weight: 650;
}

.xb-profile-identity-copy > span {
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.xb-profile-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.xb-profile-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 0 20px 22px;
}

.xb-profile-fields--password {
  padding-top: 18px;
}

.xb-profile-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.xb-profile-field--wide {
  grid-column: 1 / -1;
}

.xb-profile-field > span {
  color: hsl(var(--foreground));
  font-size: 12px;
  font-weight: 550;
}

.xb-profile-field input {
  width: 100%;
  height: 38px;
  box-sizing: border-box;
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  outline: none;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0 11px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
}

.xb-profile-field input[readonly] {
  background: hsl(var(--muted) / 0.55);
  color: hsl(var(--muted-foreground));
  cursor: default;
}

.xb-profile-field input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.14);
}

.xb-profile-section-head {
  padding: 15px 20px 0;
  border-top: 1px solid hsl(var(--border));
}

.xb-profile-section-head h3 {
  font-size: 13px;
  font-weight: 650;
}

.xb-profile-error {
  margin: -7px 20px 18px;
  border: 1px solid hsl(var(--destructive) / 0.25);
  border-radius: 6px;
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
  padding: 9px 11px;
  font-size: 12px;
  line-height: 18px;
}

.xb-profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.22);
}

.xb-profile-button {
  min-width: 72px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0;
  cursor: pointer;
}

.xb-profile-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.xb-profile-button--primary {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.xb-profile-button--secondary {
  border-color: hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.xb-profile-button--quiet {
  min-width: auto;
  background: transparent;
  color: hsl(var(--muted-foreground));
}

.xb-profile-button:hover:not(:disabled) {
  filter: brightness(0.97);
}

.xb-profile-button:focus-visible,
.xb-profile-icon-button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.xb-profile-spinner,
.xb-profile-button-spinner {
  display: inline-block;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: xb-profile-spin 0.7s linear infinite;
}

.xb-profile-spinner {
  width: 18px;
  height: 18px;
}

.xb-profile-button-spinner {
  width: 13px;
  height: 13px;
}

.xb-profile-header-avatar {
  overflow: hidden;
  padding: 0;
}

.xb-profile-toast {
  position: fixed;
  z-index: 220;
  top: 18px;
  left: 50%;
  max-width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -8px);
  opacity: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 12px 32px rgb(15 23 42 / 16%);
  padding: 10px 14px;
  font-size: 12px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.xb-profile-toast[data-visible="true"] {
  transform: translate(-50%, 0);
  opacity: 1;
}

.xb-profile-toast[data-tone="error"] {
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

@keyframes xb-profile-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .xb-profile-backdrop {
    place-items: end center;
    padding: 0;
  }

  .xb-profile-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .xb-profile-head {
    padding: 0 16px;
  }

  .xb-profile-identity {
    gap: 14px;
    padding: 20px 16px;
  }

  .xb-profile-avatar {
    width: 72px;
    height: 72px;
    flex-basis: 72px;
  }

  .xb-profile-fields {
    grid-template-columns: minmax(0, 1fr);
    padding-right: 16px;
    padding-left: 16px;
  }

  .xb-profile-field--wide {
    grid-column: auto;
  }

  .xb-profile-section-head {
    padding-right: 16px;
    padding-left: 16px;
  }

  .xb-profile-actions {
    position: sticky;
    bottom: 0;
    padding-right: 16px;
    padding-left: 16px;
  }

  .xb-profile-actions .xb-profile-button {
    min-width: 96px;
  }

  .xb-profile-error {
    margin-right: 16px;
    margin-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xb-profile-spinner,
  .xb-profile-button-spinner {
    animation-duration: 1.4s;
  }

  .xb-profile-toast {
    transition: none;
  }
}
