.profile-avatar {
  display: inline-block;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  background: #f4f4f6;
}

.profile-avatar--large {
  width: 100px;
  height: 100px;
  border: 3px solid #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .16);
}

.avatar-settings {
  width: min(100%, 620px);
  margin: 0 auto 28px;
  padding: 20px;
  border: 1px solid #dedee5;
  border-radius: 14px;
  background: #fff;
  box-sizing: border-box;
}

.avatar-settings__intro,
.avatar-settings__hint {
  color: #575765;
}

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 18px 0;
}

.avatar-crop {
  position: relative;
  flex: 0 0 240px;
  width: 240px;
  height: 240px;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #ededf2;
  box-shadow: 0 0 0 2px #3b4ef8, 0 8px 24px rgba(0, 0, 0, .18);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.avatar-crop:focus-visible {
  outline: 3px solid #ffb400;
  outline-offset: 5px;
}

.avatar-crop.is-dragging {
  cursor: grabbing;
}

.avatar-crop img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  pointer-events: none;
  transform-origin: 0 0;
}

.avatar-crop img.is-editing {
  position: absolute;
  inset: 0 auto auto 0;
  object-fit: fill;
}

.avatar-editor__controls {
  min-width: 0;
  flex: 1;
}

#avatar-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.avatar-file-button,
.avatar-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #3b4ef8;
  border-radius: 8px;
  background: #fff;
  color: #283be5;
  font: inherit;
  cursor: pointer;
  box-sizing: border-box;
}

.avatar-file-button:focus-within,
.avatar-delete:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.avatar-zoom {
  display: block;
  margin-top: 20px;
}

.avatar-zoom input {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.avatar-settings__hint {
  margin: 16px 0 0;
  font-size: .9rem;
  line-height: 1.4;
}

.avatar-settings__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.avatar-settings__actions .submit {
  min-height: 42px;
}

.avatar-delete {
  border-color: #b42318;
  color: #b42318;
}

.avatar-settings__message {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: #18733a;
}

.avatar-settings__message.is-error {
  color: #b42318;
}

@media screen and (max-width: 600px) {
  .avatar-settings {
    padding: 16px;
  }

  .avatar-editor {
    flex-direction: column;
    align-items: stretch;
  }

  .avatar-crop {
    align-self: center;
    flex-basis: 220px;
    width: 220px;
    height: 220px;
  }
}

.profile-page {
  width: min(100%, 820px);
  margin: 0;
  padding: 8px 0 32px;
  box-sizing: border-box;
}

.profile-hero,
.profile-section {
  border: 1px solid #e2e2e8;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(24, 24, 32, .06);
}

.profile-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px;
}

.profile-hero:has(.profile-editor[open]),
.profile-section:has(.profile-editor[open]) {
  z-index: 999;
}

.profile-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.profile-hero__text {
  min-width: 0;
}

.profile-hero__text h1 {
  margin: 0 0 8px;
}

.profile-hero__text p {
  margin: 0;
  color: #5c5c68;
  line-height: 1.5;
}

.profile-section {
  position: relative;
  margin-top: 18px;
  padding: 20px 24px;
}

.profile-section__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-section h2,
.profile-editor__panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.profile-edit-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #d8d8e0;
  border-radius: 50%;
  background: #fff;
  color: #303fd1;
  cursor: pointer;
  box-sizing: border-box;
  list-style: none;
}

.profile-edit-toggle::-webkit-details-marker {
  display: none;
}

.profile-edit-toggle:hover::before,
.profile-edit-toggle:focus::before {
  content: none;
}

.profile-edit-toggle:hover {
  border-color: #303fd1;
  background: #f4f5ff;
}

.profile-edit-toggle:focus-visible {
  outline: 3px solid #ffb400;
  outline-offset: 2px;
}

.profile-edit-toggle svg {
  width: 17px;
  height: 17px;
}

.profile-editor {
  position: relative;
  flex: 0 0 auto;
  z-index: 4;
}

.profile-editor[open] {
  z-index: 100;
}

.profile-avatar-editor {
  position: absolute;
  right: -4px;
  bottom: 0;
}

.profile-avatar-editor .profile-edit-toggle {
  border: 2px solid #fff;
  background: #303fd1;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.profile-editor__panel {
  position: absolute;
  top: 44px;
  right: 0;
  width: min(560px, calc(100vw - 48px));
  padding: 20px;
  border: 1px solid #d7d7e0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(24, 24, 32, .2);
  box-sizing: border-box;
  z-index: 20;
}

.profile-avatar-editor .profile-editor__panel {
  top: 46px;
  right: auto;
  left: 0;
  width: min(620px, calc(100vw - 32px));
}

.profile-editor__panel.avatar-settings {
  margin: 0;
}

.profile-editor__panel form > label,
.profile-form-grid label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: #353541;
  font-weight: 600;
}

.profile-editor__panel input:not([type="range"]),
.profile-editor__panel select,
.profile-editor__panel textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #bdbdc7;
  border-radius: 8px;
  background: #fff;
  color: #24242d;
  font: inherit;
  box-sizing: border-box;
}

.profile-editor__panel textarea {
  min-height: 112px;
  font-size: 17px;
  line-height: 1.5;
  resize: vertical;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.profile-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  margin: 20px 0 0;
}

.profile-info-grid div {
  min-width: 0;
}

.profile-info-grid dt {
  margin-bottom: 4px;
  color: #6a6a75;
  font-size: .95rem;
  line-height: 1.4;
}

.profile-info-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.profile-description,
.profile-email-value {
  margin: 16px 0 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.profile-description.is-empty {
  color: #73737e;
  font-style: italic;
}

.profile-notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 9px;
  background: #eaf7ef;
  color: #176837;
}

.profile-notice.is-error {
  background: #fff0ef;
  color: #a31d14;
}

.profile-mobile-account-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.profile-mobile-account-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #d8d8e0;
  border-radius: 9px;
  background: #fff;
  color: #303fd1;
  text-decoration: none;
  box-sizing: border-box;
}

.profile-mobile-account-actions a:last-child {
  color: #a31d14;
}

.account-settings-page {
  width: min(100%, 820px);
  margin: 0;
  padding: 8px 0 32px;
  box-sizing: border-box;
}

.account-settings-heading {
  margin-bottom: 22px;
}

.account-settings-heading h1 {
  margin: 0 0 7px;
}

.account-settings-heading p,
.account-settings-card__intro {
  color: #656571;
  line-height: 1.45;
}

.account-settings-heading p,
.account-settings-card__intro {
  margin: 0;
}

.account-settings-card {
  margin-top: 18px;
}

.account-settings-card:first-of-type {
  margin-top: 0;
}

.account-settings-card h2 {
  margin-bottom: 7px;
}

.account-settings-card--danger {
  border-color: #efc4c0;
}

.account-settings-card--danger h2 {
  color: #9d2118;
}

.account-settings-form {
  width: min(100%, 520px);
  margin-top: 20px;
}

.account-settings-form label {
  display: inline-block;
  margin-bottom: 6px;
  color: #353541;
  font-weight: 600;
}

.account-settings-form .input {
  width: 100%;
  min-height: 44px;
  padding: 9px 42px 9px 11px;
  border: 1px solid #bdbdc7;
  border-radius: 8px;
  background: #fff;
  color: #24242d;
  font: inherit;
  box-sizing: border-box;
}

.account-settings-form .submit,
.account-settings-form .submit_red {
  min-height: 44px;
  border-radius: 8px;
}

.account-settings-form .submit_red {
  min-width: 130px;
}

@media screen and (max-width: 768px) {
  .profile-page {
    margin-right: auto;
    margin-left: auto;
  }

  .profile-hero__text,
  .profile-hero__text p,
  .profile-section,
  .profile-description,
  .profile-email-value {
    text-align: center;
  }

  .account-settings-heading,
  .account-settings-heading p,
  .account-settings-card,
  .account-settings-card__intro {
    text-align: center;
  }

  .account-settings-form {
    margin-right: auto;
    margin-left: auto;
  }

  .account-settings-page {
    margin-right: auto;
    margin-left: auto;
  }

  .profile-section__heading {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .profile-section__heading h2 {
    grid-column: 2;
  }

  .profile-section__heading .profile-editor {
    grid-column: 3;
  }

  .profile-editor__panel {
    text-align: left;
  }
}

.profile-editor__panel .profile-notice {
  margin: 12px 0 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media screen and (max-width: 600px) {
  .profile-page {
    padding-inline: 10px;
  }

  .account-settings-page {
    padding-inline: 10px;
  }

  .profile-editor__panel input:not([type="range"]),
  .profile-editor__panel select,
  .account-settings-form .input {
    font-size: 16px;
  }

  .profile-hero {
    align-items: flex-start;
    padding: 18px;
  }

  .profile-avatar--large {
    width: 82px;
    height: 82px;
  }

  .profile-section {
    padding: 18px;
  }

  .profile-form-grid,
  .profile-info-grid {
    grid-template-columns: 1fr;
  }

  .profile-editor__panel {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: 12px;
    bottom: auto;
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top));
    padding-top: 58px;
    overflow-y: auto;
    z-index: 1001;
  }

  .profile-avatar-editor .profile-editor__panel {
    top: max(16px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    width: auto;
  }

  .profile-editor[open]::before {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(17, 17, 24, .48);
    content: "";
  }

  .profile-editor[open] > .profile-edit-toggle {
    position: fixed;
    top: max(28px, calc(env(safe-area-inset-top) + 12px));
    right: 24px;
    z-index: 1002;
    border-color: #d8d8e0;
    background: #fff;
    color: #24242d;
  }

  .profile-editor[open] > .profile-edit-toggle svg {
    display: none;
  }

  .profile-editor[open] > .profile-edit-toggle::after {
    content: "×";
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1;
  }
}
