.profile-page {
  margin: 0;
  min-height: 100vh;
  background: #f7f7f7;
  color: #111;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 0.25s ease, color 0.25s ease;
}

.app-layout {
  min-height: 100vh;
  display: flex;
}

.profile-content {
  width: 100%;
  margin-left: 0;
  min-height: 100vh;
  padding: 56px 64px;
  box-sizing: border-box;
  transition: margin-left 0.25s ease;
}

/* Host layout only */
body.host-layout .profile-content {
  width: calc(100% - var(--sidebar-width, 280px));
  margin-left: var(--sidebar-width, 280px);
}

.profile-header {
  max-width: 1280px;
  margin: 0 auto 42px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
}

.profile-header-text {
  max-width: 720px;
}

.profile-eyebrow,
.card-eyebrow,
.identity-label {
  margin: 0 0 10px;
  color: #6355e7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.profile-header h1 {
  margin: 0;
  font-size: clamp(36px, 4vw, 52px);
  line-height: 1.05;
  letter-spacing: -1.8px;
  font-weight: 750;
}

.profile-header-text > p:last-child {
  margin: 15px 0 0;
  color: #777;
  font-size: 16px;
  line-height: 1.7;
}

.edit-profile-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  height: 48px;
  padding: 0 22px;
  border: 1px solid rgba(99, 85, 231, 0.25);
  border-radius: 13px;
  background: linear-gradient(135deg, #6956e8, #5744d3);
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(91, 72, 220, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.edit-profile-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(91, 72, 220, 0.22);
}

.profile-overview {
  width: 100%;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 24px;
}

.identity-card,
.account-card,
.referral-card,
.profile-note {
  border: 1px solid #ddd;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.identity-card {
  min-height: 390px;
  padding: 38px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.identity-card::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  top: -110px;
  right: -100px;
  border-radius: 50%;
  background: rgba(99, 85, 231, 0.06);
  filter: blur(5px);
}

.avatar-wrapper {
  position: relative;
  width: fit-content;
  margin-bottom: 25px;
}

.profile-avatar {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6956e8, #5744d3);
  color: #ffffff;
  font-size: 38px;
  font-weight: 750;
  box-shadow: 0 12px 28px rgba(91, 72, 220, 0.2);
}

.avatar-status {
  position: absolute;
  width: 15px;
  height: 15px;
  right: 3px;
  bottom: 4px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #198754;
}

.identity-label {
  margin-bottom: 8px;
  font-size: 10px;
}

.identity-info h2 {
  margin: 0;
  color: #111;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.7px;
  word-break: break-word;
}

.identity-email {
  margin: 9px 0 18px;
  color: #777;
  font-size: 14px;
  word-break: break-word;
}

.role-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(99, 85, 231, 0.18);
  border-radius: 999px;
  background: rgba(99, 85, 231, 0.08);
  color: #6355e7;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.account-card {
  min-height: 390px;
  padding: 34px 36px;
  border-radius: 24px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.card-heading h2 {
  margin: 0;
  color: #111;
  font-size: 22px;
  letter-spacing: -0.4px;
}

.card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(99, 85, 231, 0.18);
  border-radius: 12px;
  background: rgba(99, 85, 231, 0.06);
  color: #6355e7;
  font-size: 17px;
}

.card-eyebrow {
  margin-bottom: 7px;
  font-size: 9px;
}

.account-details {
  margin-top: 8px;
}

.account-detail {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid #eee;
}

.account-detail:last-child {
  border-bottom: 0;
}

.detail-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #eee;
  border-radius: 11px;
  background: #f7f7f7;
  color: #6355e7;
  font-size: 13px;
  font-weight: 700;
}

.detail-content {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
}

.detail-label {
  color: #777;
  font-size: 14px;
}

.detail-value {
  color: #111;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.referral-card {
  max-width: 1280px;
  margin: 22px auto 0;
  min-height: 170px;
  padding: 30px 34px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  position: relative;
  overflow: hidden;
}

.referral-card::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -150px;
  top: -120px;
  border-radius: 50%;
  background: rgba(99, 85, 231, 0.05);
}

.referral-info {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.referral-icon {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(99, 85, 231, 0.18);
  border-radius: 17px;
  background: rgba(99, 85, 231, 0.06);
  color: #6355e7;
  font-size: 24px;
}

.referral-info h2 {
  margin: 0;
  color: #111;
  font-size: 20px;
  letter-spacing: -0.4px;
}

.referral-info p:last-child {
  max-width: 600px;
  margin: 8px 0 0;
  color: #777;
  font-size: 13px;
  line-height: 1.6;
}

.referral-action {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.referral-code-box {
  min-width: 290px;
  height: 52px;
  display: flex;
  align-items: stretch;
  border: 1px solid #ddd;
  border-radius: 14px;
  overflow: hidden;
  background: #f7f7f7;
}

.referral-code {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 17px;
  color: #6355e7;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 1px;
}

#copyReferralBtn {
  min-width: 76px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, #6956e8, #5744d3);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s ease;
}

#copyReferralBtn:hover {
  filter: brightness(1.08);
}

.copy-message {
  min-height: 17px;
  margin: 7px 3px 0;
  color: #198754;
  font-size: 11px;
}

.profile-note {
  max-width: 1280px;
  margin: 22px auto 0;
  padding: 20px 24px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 15px;
  background: #ffffff;
}

.note-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: rgba(99, 85, 231, 0.06);
  color: #6355e7;
}

.profile-note h3 {
  margin: 0 0 4px;
  color: #111;
  font-size: 13px;
}

.profile-note p {
  margin: 0;
  color: #777;
  font-size: 12px;
  line-height: 1.5;
}

/* =========================
   DARK MODE
========================= */

html[data-theme="dark"] .profile-page {
  background: #0b1120;
  color: #e5e7eb;
}

html[data-theme="dark"] .identity-card,
html[data-theme="dark"] .account-card,
html[data-theme="dark"] .referral-card,
html[data-theme="dark"] .profile-note {
  background: #111827;
  border-color: #263247;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .identity-info h2,
html[data-theme="dark"] .card-heading h2,
html[data-theme="dark"] .referral-info h2,
html[data-theme="dark"] .profile-note h3,
html[data-theme="dark"] .detail-value {
  color: #f3f4f6;
}

html[data-theme="dark"] .profile-header-text > p:last-child,
html[data-theme="dark"] .identity-email,
html[data-theme="dark"] .detail-label,
html[data-theme="dark"] .referral-info p:last-child,
html[data-theme="dark"] .profile-note p {
  color: #9ca3af;
}

html[data-theme="dark"] .account-detail {
  border-color: #263247;
}

html[data-theme="dark"] .detail-icon {
  background: #1e293b;
  border-color: #334155;
  color: #a89cff;
}

html[data-theme="dark"] .avatar-status {
  border-color: #111827;
}

html[data-theme="dark"] .referral-code-box {
  background: #0b1120;
  border-color: #334155;
}

html[data-theme="dark"] .referral-code {
  color: #a89cff;
}

html[data-theme="dark"] .profile-note {
  background: #111827;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1200px) {
  .profile-content {
    padding: 45px 35px;
  }

  .profile-overview {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  body.host-layout .profile-content {
    padding: 40px 28px;
  }
}

@media (max-width: 900px) {
  .profile-content,
  body.host-layout .profile-content {
    width: 100%;
    margin-left: 0;
    padding: 32px 20px;
  }

  .profile-overview {
    grid-template-columns: 1fr;
  }

  .identity-card,
  .account-card {
    min-height: auto;
  }

  .referral-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .referral-action {
    width: 100%;
  }

  .referral-code-box {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .profile-content,
  body.host-layout .profile-content {
    padding: 30px 18px 50px;
  }

  .profile-header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 30px;
  }

  .profile-header h1 {
    font-size: 36px;
  }

  .edit-profile-btn {
    width: 100%;
  }

  .identity-card,
  .account-card {
    padding: 25px;
    border-radius: 20px;
  }

  .identity-card {
    align-items: center;
    text-align: center;
  }

  .avatar-wrapper {
    margin-bottom: 20px;
  }

  .referral-card {
    padding: 25px;
    border-radius: 20px;
  }

  .referral-info {
    align-items: flex-start;
  }

  .detail-content {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .detail-value {
    text-align: left;
  }

  .account-detail {
    min-height: 82px;
  }
}