/* Keep these palettes in step with NativeMemberProfileTheme.swift. */
[data-ed-profile-theme="signature"] {
  --edpt-bg: #F8F5FC; --edpt-surface: #FFFFFF; --edpt-raised: #F3EBFC;
  --edpt-text: #20142E; --edpt-muted: #665871; --edpt-accent: #6C25C9;
  --edpt-secondary: #B51C74; --edpt-border: #DAC9F0; --edpt-badge: #4D148C;
  --edpt-on-accent: #FFFFFF;
}
[data-ed-profile-theme="sunset"] {
  --edpt-bg: #FFF8F3; --edpt-surface: #FFFFFF; --edpt-raised: #FFF0E5;
  --edpt-text: #32170F; --edpt-muted: #805642; --edpt-accent: #A54310;
  --edpt-secondary: #B21B57; --edpt-border: #EBCBBC; --edpt-badge: #873408;
  --edpt-on-accent: #FFFFFF;
}
[data-ed-profile-theme="ocean"] {
  --edpt-bg: #F4F9FC; --edpt-surface: #FFFFFF; --edpt-raised: #E8F4FA;
  --edpt-text: #112C3B; --edpt-muted: #426579; --edpt-accent: #076C90;
  --edpt-secondary: #3152AD; --edpt-border: #BFDBE7; --edpt-badge: #06455D;
  --edpt-on-accent: #FFFFFF;
}
[data-ed-profile-theme="forest"] {
  --edpt-bg: #F6FAF4; --edpt-surface: #FFFFFF; --edpt-raised: #EDF5E8;
  --edpt-text: #193126; --edpt-muted: #52664F; --edpt-accent: #27673C;
  --edpt-secondary: #716014; --edpt-border: #C9DEC5; --edpt-badge: #19482A;
  --edpt-on-accent: #FFFFFF;
}
[data-ed-profile-theme="rose"] {
  --edpt-bg: #FFF5F8; --edpt-surface: #FFFFFF; --edpt-raised: #FCEAF1;
  --edpt-text: #371729; --edpt-muted: #795468; --edpt-accent: #A32D69;
  --edpt-secondary: #884CC0; --edpt-border: #EBCBDD; --edpt-badge: #711943;
  --edpt-on-accent: #FFFFFF;
}
[data-ed-profile-theme="midnight"] {
  --edpt-bg: #F2F4FA; --edpt-surface: #FAFBFF; --edpt-raised: #E9ECF7;
  --edpt-text: #1A2240; --edpt-muted: #596582; --edpt-accent: #3A4C93;
  --edpt-secondary: #7A38A3; --edpt-border: #CBD2E8; --edpt-badge: #222E66;
  --edpt-on-accent: #FFFFFF;
}

:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="signature"] {
  --edpt-bg: #10091D; --edpt-surface: #1D142E; --edpt-raised: #291D3B;
  --edpt-text: #FBF7FF; --edpt-muted: #D2C5E2; --edpt-accent: #C19AFF;
  --edpt-secondary: #FFA3CF; --edpt-border: #55406B; --edpt-on-accent: #10091D;
}
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="sunset"] {
  --edpt-bg: #170E09; --edpt-surface: #2B1C15; --edpt-raised: #3A261C;
  --edpt-text: #FFF7F0; --edpt-muted: #E7C5AF; --edpt-accent: #FFB078;
  --edpt-secondary: #FFABC5; --edpt-border: #6A4831; --edpt-on-accent: #170E09;
}
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="ocean"] {
  --edpt-bg: #07141C; --edpt-surface: #102934; --edpt-raised: #153A47;
  --edpt-text: #F2FCFF; --edpt-muted: #BEDAE7; --edpt-accent: #76D5F1;
  --edpt-secondary: #AAC4FF; --edpt-border: #365D6E; --edpt-on-accent: #07141C;
}
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="forest"] {
  --edpt-bg: #0B170E; --edpt-surface: #182A1C; --edpt-raised: #253B27;
  --edpt-text: #F7FFF3; --edpt-muted: #C5DABE; --edpt-accent: #A0D9A7;
  --edpt-secondary: #EDCE84; --edpt-border: #496444; --edpt-on-accent: #0B170E;
}
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="rose"] {
  --edpt-bg: #1B0C15; --edpt-surface: #311B27; --edpt-raised: #412638;
  --edpt-text: #FFF6FA; --edpt-muted: #E4C3D3; --edpt-accent: #F8A3C9;
  --edpt-secondary: #D1ADFF; --edpt-border: #72445F; --edpt-on-accent: #1B0C15;
}
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) [data-ed-profile-theme="midnight"] {
  --edpt-bg: #090D19; --edpt-surface: #161D31; --edpt-raised: #232D46;
  --edpt-text: #F5F7FF; --edpt-muted: #C7D0ED; --edpt-accent: #AEBFFF;
  --edpt-secondary: #D4ADFF; --edpt-border: #485A81; --edpt-on-accent: #090D19;
}

/* Dark appearance owns the surfaces; profile themes only supply accents. */
html[data-ed-theme="dark"] :is(.edm-user-profile, .ed-professional-profile)[data-ed-profile-theme] {
  --edpt-bg: var(--ed-bg);
  --edpt-surface: var(--ed-app-surface);
  --edpt-raised: var(--ed-app-surface-raised);
  --edpt-text: var(--ed-app-text);
  --edpt-muted: var(--ed-app-muted);
  --edpt-border: var(--ed-app-border);
}

html[data-ed-theme="dark"] .ed-professional-profile[data-ed-profile-theme] {
  --ed-profile-hero-fallback: var(--ed-app-surface-raised);
  --ed-profile-menu-solid: var(--ed-app-surface-raised);
  --ed-profile-soft-strong: var(--ed-app-field);
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] :is(.edm-user-profile__mini-card, .edm-user-profile__event-card, .edm-user-profile__friend-card, .edm-feed-item) {
  border-color: var(--ed-app-border) !important;
  background: var(--ed-app-surface-raised) !important;
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] .edm-feed-media {
  border-color: var(--ed-app-border) !important;
  background: var(--ed-bg) !important;
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] :is(.edm-user-profile__pill, .edm-user-profile__look, .edm-user-profile__style-icon, .edm-user-profile__row-kicker, .edm-user-profile__event-chips span, .ed-visitor-profile-hero__chip) {
  border-color: var(--ed-app-border) !important;
  background: var(--ed-app-field) !important;
  color: var(--edpt-accent) !important;
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] :is(.edm-user-profile__avatar span, .edm-user-profile__mini-avatar, .edm-user-profile__friend-avatar) {
  background: var(--ed-app-field) !important;
  color: var(--edpt-accent) !important;
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] :is(.edm-feed-actions button, .edm-feed-action, .edm-user-profile__btn--soft) {
  border-color: var(--ed-app-border) !important;
  background: var(--ed-app-field) !important;
  color: var(--ed-app-muted) !important;
}

html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme] :is(.edm-feed-actions button, .edm-feed-action, .edm-user-profile__btn--soft):is(:hover, :focus-visible, .is-active, [aria-pressed="true"]) {
  border-color: var(--edpt-accent) !important;
  color: var(--edpt-accent) !important;
}

.edm-user-profile[data-ed-profile-theme],
body.ed-member-profile-page .edm-user-profile[data-ed-profile-theme],
html[data-ed-theme="dark"] .edm-user-profile[data-ed-profile-theme],
html[data-ed-theme="dark"] body.ed-member-profile-page .edm-user-profile[data-ed-profile-theme],
:is(html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) .edm-user-profile[data-ed-profile-theme] {
  --edm-user-profile-bg: var(--edpt-bg);
  --edm-user-profile-bg-soft: var(--edpt-bg);
  --edm-user-profile-surface: var(--edpt-surface);
  --edm-user-profile-surface-raised: var(--edpt-raised);
  --edm-user-profile-field: var(--edpt-surface);
  --edm-user-profile-glass: var(--edpt-surface);
  --edm-user-profile-text: var(--edpt-text);
  --edm-user-profile-muted: var(--edpt-muted);
  --edm-user-profile-border: var(--edpt-border);
  --edm-user-profile-border-strong: var(--edpt-border);
  --edm-user-profile-accent: var(--edpt-accent);
  --edm-user-profile-accent-strong: var(--edpt-accent);
  --edm-user-profile-accent-soft: var(--edpt-raised);
  --edm-user-profile-primary-soft: var(--edpt-raised);
  --edm-user-profile-primary-bg: var(--edpt-accent);
  --edm-user-profile-primary-hover: var(--edpt-secondary);
  --edm-user-profile-primary-text: var(--edpt-on-accent);
  --edm-user-profile-secondary: var(--edpt-secondary);
  --edm-user-profile-teal: var(--edpt-accent);
  --edm-ink: var(--edpt-text);
  --edm-muted: var(--edpt-muted);
  --edm-primary: var(--edpt-accent);
  --edm-surface-strong: var(--edpt-surface);
  --edm-line: var(--edpt-border);
  background: var(--edpt-bg) !important;
  color: var(--edpt-text) !important;
}

.ed-professional-profile[data-ed-profile-theme],
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) .ed-professional-profile[data-ed-profile-theme] {
  --ed-profile-page: var(--edpt-bg);
  --ed-profile-surface: var(--edpt-surface);
  --ed-profile-surface-solid: var(--edpt-surface);
  --ed-profile-surface-soft: var(--edpt-raised);
  --ed-profile-text: var(--edpt-text);
  --ed-profile-heading: var(--edpt-text);
  --ed-profile-muted: var(--edpt-muted);
  --ed-profile-soft: var(--edpt-raised);
  --ed-profile-border: var(--edpt-border);
  --ed-profile-border-strong: var(--edpt-border);
  --ed-profile-accent: var(--edpt-accent);
  --ed-profile-purple: var(--edpt-accent);
  --ed-profile-purple-dark: var(--edpt-accent);
  --ed-profile-pink: var(--edpt-secondary);
  --ed-profile-on-primary: var(--edpt-on-accent);
  --ed-profile-hero-fallback: var(--edpt-badge);
  background: var(--edpt-bg);
}

.ed-professional-profile[data-ed-profile-theme] .ed-professional-profile__section-card {
  border-color: var(--edpt-border);
  background: var(--edpt-surface);
}

.edm-user-profile[data-ed-profile-theme] .edm-user-profile__card {
  border-color: var(--edpt-border) !important;
  background: var(--edpt-surface) !important;
}

/* Profile palettes are accents, not page-wide washes. */
html:not([data-ed-theme="dark"]):has(body.ed-member-profile-page, .ed-professional-profile[data-ed-profile-theme]) {
  --ed-profile-canvas: #F7F8FA;
  --ed-profile-ink: #202631;
  --ed-profile-neutral-muted: #626B76;
  --ed-profile-line: #E2E6EA;
  --ed-profile-line-strong: #CCD3DA;
  --ed-page-canvas: var(--ed-profile-canvas);
  --ed-color-body-bg: var(--ed-profile-canvas);
  background: var(--ed-profile-canvas) !important;
  background-image: none !important;
}

html:not([data-ed-theme="dark"]):has(body.ed-member-profile-page, .ed-professional-profile[data-ed-profile-theme]) :is(body, .site-main) {
  background: var(--ed-profile-canvas) !important;
  background-image: none !important;
}

html:not([data-ed-theme="dark"]) :is(.edm-user-profile, .ed-professional-profile)[data-ed-profile-theme] {
  background: var(--ed-profile-canvas) !important;
  background-image: none !important;
}

html:not([data-ed-theme="dark"]) .edm-user-profile[data-ed-profile-theme] {
  --edm-user-profile-bg: var(--ed-profile-canvas);
  --edm-user-profile-bg-soft: var(--ed-profile-canvas);
  --edm-user-profile-surface: #FFFFFF;
  --edm-user-profile-surface-raised: #FFFFFF;
  --edm-user-profile-field: #FFFFFF;
  --edm-user-profile-text: var(--ed-profile-ink);
  --edm-user-profile-muted: var(--ed-profile-neutral-muted);
  --edm-user-profile-border: var(--ed-profile-line);
  --edm-user-profile-border-strong: var(--ed-profile-line-strong);
  --edm-user-profile-accent-soft: color-mix(in srgb, var(--edpt-accent) 8%, #FFFFFF);
  --edm-user-profile-primary-soft: var(--edm-user-profile-accent-soft);
  --edm-user-profile-shadow: 0 14px 34px rgba(31, 40, 53, .06);
  --edm-user-profile-shadow-soft: 0 6px 20px rgba(31, 40, 53, .045);
  --edm-ink: var(--ed-profile-ink);
  --edm-muted: var(--ed-profile-neutral-muted);
  --edm-surface-strong: #FFFFFF;
  --edm-line: var(--ed-profile-line);
}

html:not([data-ed-theme="dark"]) .ed-professional-profile[data-ed-profile-theme] {
  --ed-profile-page: var(--ed-profile-canvas);
  --ed-profile-surface: #FFFFFF;
  --ed-profile-surface-solid: #FFFFFF;
  --ed-profile-surface-soft: #FFFFFF;
  --ed-profile-text: var(--ed-profile-ink);
  --ed-profile-heading: var(--ed-profile-ink);
  --ed-profile-muted: var(--ed-profile-neutral-muted);
  --ed-profile-soft: color-mix(in srgb, var(--edpt-accent) 8%, #FFFFFF);
  --ed-profile-border: var(--ed-profile-line);
  --ed-profile-border-strong: var(--ed-profile-line-strong);
}

html:not([data-ed-theme="dark"]) .edm-user-profile[data-ed-profile-theme] .edm-user-profile__card,
html:not([data-ed-theme="dark"]) .ed-professional-profile[data-ed-profile-theme] .ed-professional-profile__section-card {
  border-color: var(--ed-profile-line) !important;
  background: #FFFFFF !important;
}

html:not([data-ed-theme="dark"]) .edm-user-profile[data-ed-profile-theme] :is(.edm-feed-actions button, .edm-feed-action, .edm-user-profile__btn--soft) {
  border-color: var(--ed-profile-line) !important;
  background: #FFFFFF !important;
  color: var(--ed-profile-neutral-muted) !important;
}

html:not([data-ed-theme="dark"]) .edm-user-profile[data-ed-profile-theme] :is(.edm-feed-actions button, .edm-feed-action, .edm-user-profile__btn--soft):is(:hover, :focus-visible, .is-active) {
  border-color: color-mix(in srgb, var(--edpt-accent) 30%, var(--ed-profile-line)) !important;
  background: var(--edm-user-profile-accent-soft) !important;
  color: var(--edpt-accent) !important;
}

html:not([data-ed-theme="dark"]) .edm-user-profile[data-ed-profile-theme] :is(.edm-user-profile__event-chips span, .edm-user-profile__style-world-chips span) {
  border-color: var(--ed-profile-line) !important;
  background: #FFFFFF !important;
  color: var(--ed-profile-neutral-muted) !important;
}

html[data-ed-theme="dark"] body.ed-member-profile-page .edm-user-profile[data-ed-profile-theme] .edm-user-profile__btn--primary {
  background: var(--edpt-accent) !important;
  color: var(--edpt-on-accent) !important;
}
html[data-ed-theme="dark"] body.ed-member-profile-page .edm-user-profile[data-ed-profile-theme] .edm-user-profile__btn--primary:is(:hover, :focus-visible) {
  background: var(--edpt-secondary) !important;
}
html[data-ed-theme="dark"] body.ed-member-profile-page .edm-user-profile[data-ed-profile-theme] .edm-user-profile__btn--secondary {
  border-color: var(--edpt-border) !important;
  background: var(--edpt-surface) !important;
  color: var(--edpt-text) !important;
}

.ed-profile-theme-picker {
  width: 100%;
  border: 1px solid var(--edpt-border);
  border-radius: 8px;
  background: var(--edpt-surface);
  color: var(--edpt-text);
  overflow: hidden;
}
.ed-profile-theme-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.ed-profile-theme-picker > summary::-webkit-details-marker { display: none; }
.ed-profile-theme-picker > summary:focus-visible,
.ed-profile-theme-picker button:focus-visible,
.ed-profile-theme-picker input:focus-visible + .ed-profile-theme-picker__choice-art {
  outline: 3px solid var(--edpt-accent);
  outline-offset: 2px;
}
.ed-profile-theme-picker__current,
.ed-profile-theme-picker__swatches,
.ed-profile-theme-picker__choice-art {
  display: flex;
  align-items: center;
}
.ed-profile-theme-picker__current { gap: 12px; }
.ed-profile-theme-picker__current strong { color: var(--edpt-accent); }
.ed-profile-theme-picker__swatches i,
.ed-profile-theme-picker__choice-art i {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--edpt-border);
}
.ed-profile-theme-picker__swatches i + i,
.ed-profile-theme-picker__choice-art i + i { margin-left: -5px; }
.ed-profile-theme-picker__swatches i:nth-child(1),
.ed-profile-theme-picker__choice-art i:nth-child(1) { background: var(--edpt-accent); }
.ed-profile-theme-picker__swatches i:nth-child(2),
.ed-profile-theme-picker__choice-art i:nth-child(2) { background: var(--edpt-secondary); }
.ed-profile-theme-picker__swatches i:nth-child(3),
.ed-profile-theme-picker__choice-art i:nth-child(3) { background: var(--edpt-badge); }
.ed-profile-theme-picker__chevron { font-size: 1.4rem; transition: transform 160ms ease; }
.ed-profile-theme-picker[open] .ed-profile-theme-picker__chevron { transform: rotate(180deg); }
.ed-profile-theme-picker form { border-top: 1px solid var(--edpt-border); padding: 18px; }
.ed-profile-theme-picker fieldset { margin: 0; padding: 0; border: 0; }
.ed-profile-theme-picker legend { margin-bottom: 12px; color: var(--edpt-text); font-weight: 700; }
.ed-profile-theme-picker__choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ed-profile-theme-picker__choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--edpt-border);
  border-radius: 8px;
  background: var(--edpt-raised);
  cursor: pointer;
}
.ed-profile-theme-picker__choice:has(input:checked) { border: 2px solid var(--edpt-accent); padding: 11px; }
.ed-profile-theme-picker__choice[data-theme-choice="signature"] { --ed-choice-accent: #6C25C9; --ed-choice-secondary: #B51C74; --ed-choice-badge: #4D148C; }
.ed-profile-theme-picker__choice[data-theme-choice="sunset"] { --ed-choice-accent: #A54310; --ed-choice-secondary: #B21B57; --ed-choice-badge: #873408; }
.ed-profile-theme-picker__choice[data-theme-choice="ocean"] { --ed-choice-accent: #076C90; --ed-choice-secondary: #3152AD; --ed-choice-badge: #06455D; }
.ed-profile-theme-picker__choice[data-theme-choice="forest"] { --ed-choice-accent: #27673C; --ed-choice-secondary: #716014; --ed-choice-badge: #19482A; }
.ed-profile-theme-picker__choice[data-theme-choice="rose"] { --ed-choice-accent: #A32D69; --ed-choice-secondary: #884CC0; --ed-choice-badge: #711943; }
.ed-profile-theme-picker__choice[data-theme-choice="midnight"] { --ed-choice-accent: #3A4C93; --ed-choice-secondary: #7A38A3; --ed-choice-badge: #222E66; }
.ed-profile-theme-picker__choice-art i:nth-child(1) { background: var(--ed-choice-accent); }
.ed-profile-theme-picker__choice-art i:nth-child(2) { background: var(--ed-choice-secondary); }
.ed-profile-theme-picker__choice-art i:nth-child(3) { background: var(--ed-choice-badge); }
.ed-profile-theme-picker__choice input { position: absolute; right: 10px; top: 10px; margin: 0; accent-color: var(--edpt-accent); }
.ed-profile-theme-picker__choice-copy { display: grid; gap: 2px; min-width: 0; padding-right: 14px; }
.ed-profile-theme-picker__choice-copy strong { color: var(--edpt-text); font-size: .94rem; }
.ed-profile-theme-picker__choice-copy small { color: var(--edpt-muted); font-size: .78rem; line-height: 1.3; }
.ed-profile-theme-picker__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ed-profile-theme-picker__actions button {
  min-height: 40px;
  border: 1px solid var(--edpt-border);
  border-radius: 8px;
  padding: 7px 15px;
  background: var(--edpt-surface);
  color: var(--edpt-text);
  cursor: pointer;
}
.ed-profile-theme-picker__actions button[type="submit"] { border-color: var(--edpt-accent); background: var(--edpt-accent); color: var(--edpt-on-accent); }
.ed-profile-theme-picker__actions button:disabled { opacity: .55; cursor: not-allowed; }
.ed-profile-theme-picker__status { min-height: 1.3em; margin: 8px 0 0; color: var(--edpt-muted); font-size: .85rem; }
.ed-profile-theme-picker__status[data-error="true"] { color: #b42332; }
:is(html[data-ed-theme="dark"], html[data-theme="dark"], body.dark, body.dark-mode, body.ed-dark-mode) .ed-profile-theme-picker__status[data-error="true"] { color: #ffb4bd; }
@media (max-width: 720px) {
  .ed-profile-theme-picker__choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .ed-profile-theme-picker__choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .ed-profile-theme-picker__chevron { transition: none; }
}
