.profile-modal-open { overflow: hidden; }

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 940;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #243f43;
  background: #153c4078;
  opacity: 0;
  backdrop-filter: blur(10px);
  transition: opacity .16s ease;
}

.profile-overlay[hidden] { display: none; }
.profile-overlay.is-open { opacity: 1; }

.profile-shell {
  width: min(1100px, 100%);
  max-height: min(900px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid #d8e6e3;
  border-radius: 28px;
  background:
    radial-gradient(circle at 100% 0, #ffe7d9 0, transparent 28%),
    radial-gradient(circle at 0 100%, #dcefeb 0, transparent 30%),
    #fffdf9;
  box-shadow: 0 30px 90px #15363a42;
  transform: translateY(10px);
  transition: transform .16s ease;
}

.profile-overlay.is-open .profile-shell { transform: translateY(0); }
.profile-shell * { box-sizing: border-box; }

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 34px 21px;
  border-bottom: 1px solid #dfebe8;
}

.profile-header > div > span,
.profile-kicker {
  color: #df7968;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .17em;
}

.profile-header h2 {
  margin: 6px 0 3px;
  color: #235c63;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(28px, 4vw, 42px);
}

.profile-header p {
  margin: 0;
  color: #748589;
  font-size: 13px;
}

.profile-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: #547579;
  background: #e8f2ef;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  padding: 13px 34px;
  border-bottom: 1px solid #e6efed;
  background: #f7fbfaaf;
}

.profile-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  color: #627c7f;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.profile-tabs button[aria-pressed="true"] {
  color: #fff;
  background: #2b7375;
  box-shadow: 0 7px 16px #2b737526;
}

.profile-body {
  max-height: calc(min(900px, 100vh - 48px) - 170px);
  overflow: auto;
  padding: 28px 34px 38px;
}

.profile-loading,
.profile-error {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: #6f8587;
  text-align: center;
}

.profile-error strong { color: #9e554a; font-size: 20px; }
.profile-error p { margin: 0 0 10px; }

.profile-overview { display: grid; gap: 18px; }

.profile-card {
  border: 1px solid #dce8e6;
  border-radius: 21px;
  padding: 24px;
  background: #fffdfbd9;
  box-shadow: 0 14px 35px #2b5d6310;
}

.profile-card h3 {
  margin: 8px 0 12px;
  color: #265f67;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 25px;
}

.profile-subtle {
  margin: 0 0 16px;
  color: #74878a;
  font-size: 13px;
  line-height: 1.75;
}

.profile-preview-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr);
  align-items: center;
  gap: 28px;
  background:
    radial-gradient(circle at 90% 10%, #ffe2d4 0, transparent 32%),
    linear-gradient(135deg, #fffdfb, #f1f8f6);
}

.profile-preview-identity {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.profile-preview-identity h3 {
  margin: 5px 0;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 4vw, 40px);
}

.profile-preview-identity p {
  margin: 0;
  color: #677d80;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.profile-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(145deg, #357e7b, #e58a75);
  box-shadow: 0 12px 25px #25545b25;
  font-family: "Noto Serif SC", serif;
  font-size: 30px;
  font-weight: 900;
}

.profile-avatar.large {
  width: 112px;
  height: 112px;
  border-radius: 36px;
  font-size: 38px;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-edit-grid {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 18px;
}

.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
}

.profile-avatar-actions {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.profile-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.profile-choose-avatar {
  border: 1px solid #bfd6d1;
}

.profile-selected-file {
  grid-column: 1 / -1;
  max-width: 100%;
  overflow: hidden;
  color: #5e787b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-avatar-actions small,
.profile-avatar-actions .profile-inline-status,
.profile-avatar-actions .profile-danger {
  grid-column: 1 / -1;
}

.profile-avatar-actions small {
  color: #8a999b;
  line-height: 1.5;
}

.profile-form { display: grid; gap: 14px; margin-top: 16px; }

.profile-form label {
  display: grid;
  gap: 7px;
  color: #536f72;
  font-size: 13px;
  font-weight: 800;
}

.profile-form input,
.profile-form textarea {
  width: 100%;
  border: 1px solid #ccddda;
  border-radius: 11px;
  padding: 11px 12px;
  color: #294f54;
  background: #fff;
  font: inherit;
  line-height: 1.6;
}

.profile-form textarea { resize: vertical; }

.profile-character-count {
  justify-self: end;
  color: #8b999b;
  font-weight: 400;
}

.profile-primary,
.profile-secondary,
.profile-danger,
.profile-text-button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.profile-primary { color: #fff; background: linear-gradient(135deg, #286970, #3c8d83); }
.profile-secondary { color: #2b6c70; background: #e6f2ef; }
.profile-danger { color: #a05248; background: #fff0ed; }
.profile-text-button { color: #657d80; background: transparent; }
.profile-primary:disabled,
.profile-secondary:disabled,
.profile-danger:disabled { opacity: .55; cursor: wait; }

.profile-inline-status {
  min-height: 18px;
  color: #7b8d8f;
  font-size: 12px;
  font-style: normal;
}

.profile-choice-card { display: grid; justify-items: start; gap: 12px; }

.profile-mbti-hidden {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px dashed #bed3cf;
  border-radius: 15px;
  color: #74888a;
  background: #f5faf8;
}

.profile-mbti-hidden strong { color: #3a6b70; }
.profile-mbti-hidden span { font-size: 12px; line-height: 1.6; }

.profile-mbti-result {
  width: 100%;
  display: grid;
  gap: 21px;
  padding: 24px;
  border: 1px solid #d7e7e3;
  border-radius: 19px;
  background: linear-gradient(135deg, #f1f8f6, #fff7f2);
}

.profile-mbti-result.is-compact { gap: 14px; padding: 17px; }

.profile-mbti-result-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
}

.profile-mbti-result-heading > strong {
  color: #fff;
  border-radius: 15px;
  padding: 13px;
  background: linear-gradient(145deg, #2d7075, #e18471);
  font-size: 26px;
  letter-spacing: .08em;
}

.profile-mbti-result-heading span {
  color: #285f67;
  font-weight: 900;
}

.profile-mbti-result-heading p {
  margin: 4px 0 0;
  color: #6d8083;
  font-size: 12px;
  line-height: 1.6;
}

.profile-mbti-axes { display: grid; gap: 10px; }
.profile-mbti-axis > div:first-child { display: flex; justify-content: space-between; gap: 14px; color: #637d80; font-size: 11px; }
.profile-mbti-track { position: relative; height: 8px; margin-top: 5px; border-radius: 99px; background: linear-gradient(90deg, #2e7478, #edf1ec 50%, #e18a75); }
.profile-mbti-track i { position: absolute; top: 50%; width: 14px; height: 14px; border: 3px solid #fff; border-radius: 50%; background: #315f64; box-shadow: 0 2px 7px #27484c36; transform: translate(-50%, -50%); }

.profile-visibility-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 11px;
  padding: 15px 16px;
  border: 1px solid #d9e7e4;
  border-radius: 14px;
  color: #496b70;
  background: #f7fbfa;
  cursor: pointer;
}

.profile-visibility-toggle input { margin-top: 3px; accent-color: #2d7474; }
.profile-visibility-toggle span { display: grid; gap: 4px; }
.profile-visibility-toggle small { color: #829294; line-height: 1.5; }

.profile-mbti-intro {
  max-width: 820px;
  display: grid;
  justify-items: start;
  gap: 14px;
  margin: 0 auto;
  padding: clamp(25px, 5vw, 48px);
}

.profile-mbti-intro > p,
.profile-test-disclaimer {
  color: #6f8285;
  line-height: 1.8;
}

.profile-mbti-intro ul { display: grid; gap: 8px; margin: 0; padding-left: 21px; color: #617a7d; font-size: 13px; line-height: 1.6; }
.profile-mbti-intro .profile-mbti-result { margin-top: 10px; }

.profile-mbti-question,
.profile-mbti-finish {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(25px, 5vw, 48px);
}

.profile-test-progress { height: 6px; margin: 13px 0 34px; overflow: hidden; border-radius: 99px; background: #e5eeeb; }
.profile-test-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2e7478, #e58b76); transition: width .2s ease; }
.profile-mbti-question h3 { max-width: 600px; margin-bottom: 25px; font-size: clamp(24px, 4vw, 34px); line-height: 1.45; }
.profile-mbti-options { display: grid; gap: 12px; }

.profile-mbti-option {
  min-height: 68px;
  border: 1px solid #d3e2df;
  border-radius: 15px;
  padding: 17px 20px;
  color: #3d6469;
  text-align: left;
  background: #f8fbfa;
  font: inherit;
  font-weight: 800;
  line-height: 1.6;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}

.profile-mbti-option:hover { border-color: #4c8a87; background: #eef7f4; transform: translateX(4px); }
.profile-mbti-question .profile-text-button { margin-top: 18px; }
.profile-mbti-finish { display: grid; gap: 18px; }
.profile-mbti-finish > h3 { font-size: clamp(27px, 5vw, 40px); }
.profile-test-disclaimer { margin: 0; font-size: 12px; }
.profile-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.profile-quick-button {
  position: fixed;
  z-index: 250;
  left: 14px;
  bottom: 14px;
  display: none;
  min-width: 58px;
  height: 46px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #2b7075, #3f9086);
  box-shadow: 0 12px 28px #1c52582d;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.profile-quick-button[hidden] { display: none !important; }

@media (max-width: 800px) {
  .profile-quick-button { display: block; }
  .profile-overlay { padding: 0; place-items: stretch; }
  .profile-shell { width: 100%; max-height: 100vh; height: 100vh; border: 0; border-radius: 0; }
  .profile-body { max-height: calc(100vh - 160px); padding: 21px 18px 34px; }
  .profile-header { padding: 22px 20px 17px; }
  .profile-tabs { padding: 11px 18px; overflow-x: auto; }
  .profile-preview-card,
  .profile-edit-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .profile-header p { display: none; }
  .profile-preview-identity { align-items: flex-start; }
  .profile-avatar.large { width: 84px; height: 84px; border-radius: 26px; }
  .profile-avatar-editor { align-items: flex-start; flex-direction: column; }
  .profile-avatar-actions { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-avatar-actions .profile-primary,
  .profile-avatar-actions .profile-secondary { width: 100%; }
  .profile-card { padding: 19px; border-radius: 17px; }
  .profile-mbti-result-heading { grid-template-columns: 1fr; }
  .profile-mbti-result-heading > strong { justify-self: start; }
  .profile-visibility-toggle { grid-template-columns: auto 1fr; }
  .profile-visibility-toggle .profile-inline-status { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .profile-overlay,
  .profile-shell,
  .profile-mbti-option { transition: none; }
}
