:root {
  --profile-bg: #f6f7f9;
  --profile-surface: #fff;
  --profile-ink: #282b31;
  --profile-ink-strong: #17191e;
  --profile-muted: #7c828e;
  --profile-muted-light: #a5aab3;
  --profile-line: #e9ebf0;
  --profile-primary: #7356dc;
  --profile-primary-deep: #5740b8;
  --profile-primary-soft: #f0edff;
  --profile-coral: #e27d6b;
  --profile-green: #14885a;
  --profile-gold: #b97924;
  --profile-shadow: 0 6px 20px rgba(47, 51, 67, .07);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--profile-bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  color: var(--profile-ink);
  background: var(--profile-bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF UI Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--profile-primary); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.profile-app {
  width: min(750px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--profile-bg);
}

.profile-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 62px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 15px 7px;
  border-bottom: 1px solid rgba(224, 226, 232, .9);
  background: rgba(246, 247, 249, .94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.profile-back, .profile-icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--profile-muted);
  background: transparent;
}

.profile-back:hover, .profile-icon-button:hover { color: var(--profile-ink); background: #fff; }
.profile-back svg, .profile-icon-button svg { width: 19px; height: 19px; }
.profile-header-title { min-width: 0; text-align: center; }
.profile-header-title span { display: block; color: var(--profile-primary); font-size: 8px; font-weight: 850; letter-spacing: .14em; line-height: 1; }
.profile-header-title h1 { margin: 4px 0 0; color: var(--profile-ink-strong); font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 700; line-height: 1; }

.profile-main {
  width: calc(100% - 30px);
  margin: 0 auto;
  padding: 15px 0 24px;
}

.profile-identity-card {
  position: relative;
  overflow: hidden;
  border: 1px solid #e5e2f6;
  border-radius: 12px;
  background: var(--profile-surface);
  box-shadow: var(--profile-shadow);
}

.profile-identity-glow {
  position: absolute;
  top: 0;
  right: 0;
  width: 42%;
  height: 8px;
  background: #d9d1ff;
  transform: skewX(-28deg) translateX(17%);
  pointer-events: none;
}

.profile-identity-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 126px;
  padding: 21px 17px 17px;
}

.profile-avatar {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 4px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #8062e6, #d17c91);
  box-shadow: 0 7px 16px rgba(88, 66, 175, .22);
}

.profile-avatar span { font-family: Georgia, "Times New Roman", serif; font-size: 32px; line-height: 1; }
.profile-avatar i { position: absolute; right: -3px; bottom: -2px; width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; color: #fff; background: var(--profile-primary); font-style: normal; }
.profile-avatar i svg { width: 12px; height: 12px; }
.profile-avatar:hover { transform: translateY(-1px); }

.profile-identity-copy { min-width: 0; }
.profile-eyebrow, .profile-kicker { margin: 0; color: var(--profile-primary); font-size: 8px; font-weight: 850; letter-spacing: .13em; line-height: 1.2; }
.profile-identity-copy h2 { margin: 6px 0 0; overflow: hidden; color: var(--profile-ink-strong); font-family: Georgia, "Times New Roman", serif; font-size: 26px; font-weight: 700; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
.profile-bio { display: -webkit-box; margin: 6px 0 0; overflow: hidden; color: var(--profile-muted); font-size: 11px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-device-badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; color: #6d7180; font-size: 9px; }
.profile-device-badge svg { width: 12px; height: 12px; color: var(--profile-green); }
.profile-edit-button { display: inline-flex; align-items: center; gap: 4px; min-height: 31px; padding: 0 10px; border: 1px solid #ded9f7; border-radius: 17px; color: var(--profile-primary-deep); background: #faf9ff; font-size: 10px; font-weight: 800; }
.profile-edit-button svg { width: 13px; height: 13px; }
.profile-edit-button:hover { border-color: #c9c0f1; background: var(--profile-primary-soft); }

.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #edeaf7; background: #fcfbff; }
.profile-stat { min-height: 65px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--profile-muted); background: transparent; }
.profile-stat + .profile-stat { border-left: 1px solid #edeaf7; }
.profile-stat strong { color: var(--profile-ink-strong); font-size: 20px; font-weight: 780; line-height: 1; }
.profile-stat span { font-size: 9px; font-weight: 700; }
.profile-stat:hover strong, .profile-stat:focus-visible strong { color: var(--profile-primary-deep); }

.profile-wallet-card {
  margin-top: 14px;
  padding: 15px 16px 12px;
  border: 1px solid #eadfca;
  border-radius: 11px;
  background: linear-gradient(112deg, #fffaf0 0%, #fffdf9 56%, #f8f5ff 100%);
  box-shadow: var(--profile-shadow);
}

.profile-wallet-heading, .profile-wallet-row, .profile-wallet-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.profile-section-label { min-width: 0; display: flex; align-items: center; gap: 9px; }
.profile-coin-icon { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #fff; background: linear-gradient(145deg, #e6a945, #c67a24); box-shadow: 0 6px 12px rgba(190, 117, 35, .2); }
.profile-coin-icon svg { width: 17px; height: 17px; }
.profile-section-label > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.profile-section-label small { color: #a18b6b; font-size: 8px; font-weight: 850; letter-spacing: .12em; }
.profile-section-label strong { margin-top: 3px; overflow: hidden; color: #5f421f; font-size: 14px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.profile-currency { padding: 5px 8px; border-radius: 999px; color: var(--profile-green); background: #e8f8ef; font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.profile-wallet-row { margin-top: 12px; }
.profile-wallet-amount { display: flex; align-items: baseline; gap: 6px; }
.profile-wallet-amount strong { color: #5f421f; font-size: 30px; line-height: 1; }
.profile-wallet-amount span { color: #a18b6b; font-size: 11px; font-weight: 750; }
.profile-recharge-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 12px; border-radius: 18px; color: #fff; background: var(--profile-green); font-size: 10px; font-weight: 850; box-shadow: 0 5px 11px rgba(20, 136, 90, .18); }
.profile-recharge-button:hover { background: #0b7149; }
.profile-recharge-button svg { width: 14px; height: 14px; }
.profile-wallet-foot { margin-top: 11px; padding-top: 10px; border-top: 1px solid #efe8da; color: #9a8b78; font-size: 9px; }
.profile-wallet-foot button { display: inline-flex; align-items: center; gap: 2px; padding: 3px 0; color: #896c43; background: transparent; font-size: 9px; font-weight: 800; }
.profile-wallet-foot button:hover { color: #614419; }
.profile-wallet-foot svg { width: 12px; height: 12px; }

.profile-section, .profile-menu-section { margin-top: 22px; }
.profile-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.profile-section-heading h2 { margin: 5px 0 0; color: var(--profile-ink-strong); font-size: 18px; font-weight: 780; line-height: 1.2; }
.profile-text-link { display: inline-flex; align-items: center; gap: 2px; padding: 4px 0; color: var(--profile-primary-deep); background: transparent; font-size: 10px; font-weight: 800; white-space: nowrap; }
.profile-text-link:hover { color: #3f2b99; }

.profile-reading-list, .profile-saved-list, .profile-transaction-list { margin-top: 11px; }
.profile-reading-list { display: grid; gap: 8px; }
.profile-reading-row { min-width: 0; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--profile-line); border-radius: 9px; background: var(--profile-surface); box-shadow: 0 3px 10px rgba(48, 54, 69, .035); }
.profile-reading-row:hover { border-color: #d9d1f6; background: #fcfbff; }
.profile-cover { width: 52px; aspect-ratio: 3 / 4; display: block; overflow: hidden; border-radius: 6px; background: #e9ebef; }
.profile-cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.profile-cover-art { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 6px; color: #fff; background: var(--profile-cover-bg, linear-gradient(145deg, #4e447e, #a777c8)); }
.profile-cover-art span { position: relative; z-index: 1; margin-bottom: 3px; overflow: hidden; color: rgba(255, 255, 255, .74); font-size: 5px; letter-spacing: .06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.profile-cover-art strong { position: relative; z-index: 1; display: -webkit-box; max-height: 27px; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 9px; line-height: 1.05; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-reading-copy { min-width: 0; }
.profile-reading-copy strong { display: -webkit-box; overflow: hidden; color: var(--profile-ink); font-size: 12px; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-reading-copy small { display: block; margin-top: 5px; overflow: hidden; color: var(--profile-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.profile-reading-progress { width: 52px; flex: 0 0 auto; }
.profile-reading-progress > span { display: block; color: var(--profile-primary-deep); font-size: 9px; font-weight: 800; text-align: right; }
.profile-progress-track { display: block; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 4px; background: #eceaf4; }
.profile-progress-track b { display: block; height: 100%; border-radius: inherit; background: var(--profile-primary); }

.profile-saved-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.profile-saved-list > .profile-empty { grid-column: 1 / -1; }
.profile-saved-item { min-width: 0; display: block; padding: 0; color: var(--profile-ink); background: transparent; text-align: left; }
.profile-saved-item .profile-cover { width: 100%; border-radius: 7px; box-shadow: 0 4px 10px rgba(43, 47, 60, .1); }
.profile-saved-item strong { display: -webkit-box; margin-top: 7px; overflow: hidden; color: var(--profile-ink); font-size: 10px; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.profile-saved-item:hover strong { color: var(--profile-primary-deep); }

.profile-transaction-list { overflow: hidden; border: 1px solid var(--profile-line); border-radius: 9px; background: var(--profile-surface); }
.profile-transaction-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 9px 11px; border-bottom: 1px solid #f0f1f4; }
.profile-transaction-row:last-child { border-bottom: 0; }
.profile-transaction-copy { min-width: 0; display: flex; flex-direction: column; }
.profile-transaction-copy strong { overflow: hidden; color: var(--profile-ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.profile-transaction-copy small { margin-top: 4px; color: var(--profile-muted-light); font-size: 9px; }
.profile-transaction-amount { flex: 0 0 auto; font-size: 11px; font-weight: 850; }
.profile-transaction-amount.positive { color: var(--profile-green); }
.profile-transaction-amount.negative { color: var(--profile-coral); }

.profile-menu-section { padding-bottom: 10px; }
.profile-menu-list { margin-top: 11px; overflow: hidden; border: 1px solid var(--profile-line); border-radius: 9px; background: var(--profile-surface); }
.profile-menu-row { width: 100%; min-width: 0; display: grid; grid-template-columns: 32px minmax(0, 1fr) 16px; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #f0f1f4; color: var(--profile-ink); background: var(--profile-surface); text-align: left; }
.profile-menu-row:last-child { border-bottom: 0; }
.profile-menu-row:hover { background: #fbfbfd; }
.profile-menu-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; }
.profile-menu-icon svg { width: 15px; height: 15px; }
.profile-menu-icon.purple { color: var(--profile-primary-deep); background: var(--profile-primary-soft); }
.profile-menu-icon.green { color: var(--profile-green); background: #e8f8ef; }
.profile-menu-icon.coral { color: #be604f; background: #fff0eb; }
.profile-menu-icon.red { color: #b35454; background: #fff0f0; }
.profile-menu-row > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.profile-menu-row strong { font-size: 11px; font-weight: 780; }
.profile-menu-row small { margin-top: 3px; overflow: hidden; color: var(--profile-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu-arrow { width: 15px; height: 15px; color: #abb0b9; }
.profile-menu-row.danger strong { color: #a24b4b; }

.profile-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 106px; padding: 16px; border: 1px dashed #dadde5; border-radius: 9px; color: var(--profile-muted); background: rgba(255, 255, 255, .55); text-align: center; }
.profile-empty-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: var(--profile-primary); background: var(--profile-primary-soft); }
.profile-empty-icon svg { width: 16px; height: 16px; }
.profile-empty strong { margin-top: 8px; color: var(--profile-ink); font-size: 11px; }
.profile-empty p { margin: 4px 0 0; font-size: 9px; line-height: 1.4; }
.profile-empty a { margin-top: 8px; color: var(--profile-primary-deep); font-size: 10px; font-weight: 800; }

.profile-bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 80; width: min(750px, 100%); height: 68px; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 auto; padding: 6px 8px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid #e5e7ec; background: rgba(255, 255, 255, .97); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.profile-bottom-item { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #969ba5; background: transparent; font-size: 10px; font-weight: 600; }
.profile-bottom-item img { width: 23px; height: 23px; object-fit: contain; opacity: .72; }
.profile-bottom-item.active { color: var(--profile-primary); font-weight: 800; }
.profile-bottom-item.active img { opacity: 1; }

/* wallet.js injects its checkout sheet and relies on these shared surfaces. */
.modal-layer { position: fixed; inset: 0; z-index: 220; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(26, 24, 38, .52); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 28px 22px 22px; border-radius: 14px; background: var(--profile-surface); box-shadow: 0 28px 65px rgba(29, 25, 52, .22); }
.modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #969ba5; background: transparent; }
.modal-close:hover { color: var(--profile-ink); background: #f1f2f5; }
.modal-close svg { width: 16px; height: 16px; }
.modal-kicker { margin: 0; color: var(--profile-primary); font-size: 8px; font-weight: 850; letter-spacing: .13em; line-height: 1.2; }

.profile-modal-layer { position: fixed; inset: 0; z-index: 240; display: grid; place-items: center; padding: 20px; }
.profile-modal-layer[hidden] { display: none; }
.profile-modal-backdrop { position: absolute; inset: 0; background: rgba(26, 24, 38, .52); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.profile-modal { position: relative; z-index: 1; width: min(100%, 430px); max-height: min(680px, calc(100dvh - 40px)); overflow: auto; padding: 27px 22px 21px; border-radius: 14px; background: #fff; box-shadow: 0 28px 65px rgba(29, 25, 52, .22); animation: profile-modal-in .22s ease-out both; }
@keyframes profile-modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.profile-modal-close { position: absolute; top: 10px; right: 10px; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: #969ba5; background: transparent; }
.profile-modal-close:hover { color: var(--profile-ink); background: #f1f2f5; }
.profile-modal-close svg { width: 16px; height: 16px; }
.profile-modal h2 { margin: 7px 0 20px; color: var(--profile-ink-strong); font-family: Georgia, "Times New Roman", serif; font-size: 28px; line-height: 1.05; }
.profile-form-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 7px; margin-top: 15px; color: var(--profile-ink); font-size: 11px; font-weight: 760; }
.profile-form-label input, .profile-form-label textarea { width: 100%; margin-top: 5px; padding: 10px 11px; border: 1px solid #e4e6eb; border-radius: 8px; outline: 0; color: var(--profile-ink); background: #fafbfc; font-size: 12px; resize: vertical; }
.profile-form-label input:focus, .profile-form-label textarea:focus { border-color: #bfb2f3; box-shadow: 0 0 0 3px rgba(115, 86, 220, .1); }
.profile-label-hint { color: var(--profile-muted-light); font-size: 9px; font-weight: 500; }
.profile-avatar-fieldset { margin: 17px 0 0; padding: 0; border: 0; }
.profile-avatar-fieldset legend { color: var(--profile-ink); font-size: 11px; font-weight: 760; }
.profile-avatar-options { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.profile-avatar-option { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 3px solid #fff; border-radius: 50%; color: #fff; box-shadow: 0 0 0 1px #dfe2e8; font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.profile-avatar-option.selected { box-shadow: 0 0 0 2px var(--profile-primary); }
.profile-avatar-option::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--profile-primary); opacity: 0; }
.profile-avatar-option.selected::after { opacity: 1; }
.profile-form-note { margin: 17px 0 0; color: var(--profile-muted); font-size: 9px; line-height: 1.4; }
.profile-form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 19px; }
.profile-secondary-button, .profile-primary-button { min-height: 40px; border-radius: 8px; font-size: 11px; font-weight: 800; }
.profile-secondary-button { color: var(--profile-muted); background: #f1f2f5; }
.profile-secondary-button:hover { color: var(--profile-ink); background: #e9ebef; }
.profile-primary-button { color: #fff; background: var(--profile-primary); box-shadow: 0 6px 14px rgba(115, 86, 220, .2); }
.profile-primary-button:hover { background: var(--profile-primary-deep); }

.toast { position: fixed; right: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 300; max-width: calc(100% - 40px); padding: 10px 15px; border-radius: 999px; color: #fff; background: rgba(34, 33, 43, .92); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(50%, 10px); transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(50%, 0); }
body.modal-open #profileToast { display: none; }

@media (max-width: 430px) {
  .profile-main { width: calc(100% - 24px); }
  .profile-identity-content { grid-template-columns: 67px minmax(0, 1fr) auto; gap: 9px; padding-inline: 13px; }
  .profile-avatar { width: 65px; height: 65px; }
  .profile-avatar span { font-size: 27px; }
  .profile-avatar i { width: 21px; height: 21px; }
  .profile-avatar i svg { width: 10px; height: 10px; }
  .profile-identity-copy h2 { font-size: 22px; }
  .profile-edit-button { width: 31px; height: 31px; justify-content: center; padding: 0; }
  .profile-edit-button span { display: none; }
  .profile-wallet-card { padding-inline: 13px; }
  .profile-saved-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .profile-menu-row { grid-template-columns: 30px minmax(0, 1fr) 15px; gap: 8px; padding-inline: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
