@font-face {
  font-family: "Manzana Flag Emoji";
  src: url("./theme-flags.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0020-E007F;
}

.emoji-display, .theme-choice {
  font-family: "Manzana Flag Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.profile-section,
.profile-dialog { --profile-ink: #393e4b; --profile-soft: #62697a; --profile-coral: #9b4652; }
.profile-section [hidden], .profile-dialog [hidden], .rail-profile [hidden] { display: none !important; }

.profile-section {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(2.8rem, 8vh, 6rem) clamp(1rem, 6vw, 7rem) clamp(2.8rem, 8vh, 6rem) clamp(3rem, 11vw, 12rem);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 22% 10%, #e3e8f373, transparent 46%),
    radial-gradient(ellipse at 86% 88%, #fae4e961, transparent 40%),
    radial-gradient(circle, #a8b0c064 .8px, transparent 1.6px) 0 0 / clamp(19px, 1.86vw, 33px) clamp(19px, 1.86vw, 33px),
    #fdfdfe;
}

.profile-section::before,
.profile-section::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}
.profile-section::before {
  width: min(110vw, 120rem);
  height: 45%;
  left: -20%;
  top: 29%;
  border: 1px solid #c3c9d868;
  box-shadow: 0 16px 0 #fdfdffbb, 0 17px 0 #c9cfde57, 0 45px 0 #e4e7f047;
  border-radius: 50%;
  transform: rotate(-18deg);
}
.profile-section::after {
  width: min(53vw, 50rem);
  aspect-ratio: 1;
  right: -12%;
  bottom: -35%;
  border-radius: 50%;
  border: 1px solid #c9cfdc5c;
  background: repeating-radial-gradient(ellipse at 66% 50%, #fff0 0 15%, #a9b3ca38 15.15% 15.45%);
  mask-image: linear-gradient(#000, #0000 75%);
}
.profile-inner { width: min(100%, 67rem); }

.profile-gate {
  display: grid;
  justify-items: center;
  gap: .8rem;
  text-align: center;
  color: var(--profile-ink);
}
.profile-lock {
  width: clamp(13rem, min(40vw, 45vh), 27rem);
  margin: -.5rem auto -.3rem;
  filter: drop-shadow(0 12px 23px #737f9c20);
}
.profile-lock-body { filter: drop-shadow(0 5px 7px #5361833d); }
.profile-gate h2 {
  margin: 0;
  font-size: clamp(2.05rem, 5.2vw, 4.35rem);
  line-height: 1;
  letter-spacing: -.065em;
  text-wrap: balance;
}
.profile-gate p {
  margin: 0;
  font-size: clamp(.99rem, 2vw, 1.27rem);
  color: var(--profile-soft);
  line-height: 1.5;
  text-wrap: balance;
}
.profile-gate .profile-primary, .profile-gate .profile-actions { margin-top: .6rem; }
#profile-login { min-width: min(10rem, 100%); min-height: 3.1rem; font-size: 1rem; }
.profile-setup-icon { color: #a96d78; width: 6.5rem; margin-bottom: .4rem; }
.profile-first-login .profile-actions { justify-content: center; }

.profile-card {
  padding: clamp(.55rem, 1.65vw, 1.15rem);
  border: 1px solid #fff;
  border-radius: clamp(1.55rem, 3.3vw, 2.6rem);
  background: linear-gradient(143deg, #fffffff6, #f4f5faf6);
  box-shadow: 0 24px 65px #52627e20, 0 4px 13px #69758916;
}
.profile-banner {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 3;
  border: 1px solid #fff;
  border-radius: clamp(.95rem, 2.2vw, 1.88rem);
  background:
    radial-gradient(ellipse at 86% 84%, #f1cbd2 0, #fff0 45%),
    radial-gradient(ellipse at 18% 19%, #fafbff 0, #fff0 59%),
    radial-gradient(circle, #6f7d9c56 1px, transparent 1.4px) 0 0 / 15px 15px,
    linear-gradient(127deg, #ecedf5, #cdd5e6 65%, #e9dbe4);
}
.profile-banner::before {
  content: "";
  position: absolute;
  inset: -55% -13% 31% -18%;
  z-index: -1;
  border-radius: 50%;
  border: 1px solid #fff;
  transform: rotate(-13deg);
  box-shadow: 0 18px 0 #ffffff4a, 0 19px 0 #acb5c9a3, 0 29px 0 #e6e9f36f;
}
.profile-banner > img, .profile-banner > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-banner-edit { position: absolute; top: .75rem; right: .75rem; }

.profile-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(.75rem, 2.1vw, 1.75rem);
  padding: 0 clamp(.7rem, 3.3vw, 2.6rem);
  position: relative;
  margin-top: -.3rem;
}
.profile-avatar {
  display: grid;
  place-items: center;
  position: relative;
  width: clamp(5rem, 13vw, 10rem);
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 31% 26%, #fbf0f2, #e9d0d8 54%, #d5cfde);
  color: #9c6574;
  box-shadow: 0 8px 17px #69718d35;
}
.profile-identity .profile-avatar { margin-top: -26%; align-self: start; }
.profile-avatar > img, .profile-avatar > canvas, .rail-profile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.profile-avatar svg { width: 66%; }
.profile-avatar :is(img, canvas):not([hidden]) ~ svg, .rail-profile img:not([hidden]) + svg { display: none; }
.rail-profile[aria-current="location"] { box-shadow: 0 0 0 3px #ffeef055; }
.profile-username { padding-top: .9rem; min-width: 0; }
.profile-username h2 {
  margin: 0;
  color: var(--profile-ink);
  font-size: clamp(1.65rem, 5vw, 3.65rem);
  line-height: 1;
  overflow-wrap: anywhere;
  letter-spacing: -.058em;
}
.profile-username p {
  margin: .48rem 0 0;
  color: var(--profile-soft);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.profile-member-since { font-size: .78rem; }
.profile-emblem {
  display: grid;
  place-items: center;
  gap: .38rem;
  margin-top: .9rem;
  padding: .6rem .85rem;
  color: #774451;
  background: linear-gradient(145deg, #fff, #f1e2e8);
  border: 1px solid #fff;
  border-radius: 1rem;
  font-size: .72rem;
  white-space: nowrap;
  box-shadow: 0 3px 11px #9f7d9027;
  transition: transform .18s ease;
}
.profile-emblem:hover { transform: translateY(-2px); }
.profile-emblem-value { font-size: clamp(1.55rem, 4vw, 2.8rem); line-height: 1.1; }
.profile-member-actions {
  margin: clamp(1.15rem, 3vw, 2.1rem) clamp(.7rem, 3.3vw, 2.6rem) clamp(.6rem, 2.7vw, 1.65rem);
  padding-top: 1rem;
  border-top: 1px solid #cdd2de83;
}
.profile-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.profile-logout { margin-inline-start: auto; }
.profile-primary, .profile-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .56rem 1rem;
  border: 1px solid #fff;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  transition: transform .16s ease, box-shadow .18s ease, background .18s ease;
}
.profile-primary {
  background: linear-gradient(145deg, #ae5663, #8e3848);
  box-shadow: 0 4px 12px #88455236;
  color: #fff;
}
.profile-primary:hover { background: linear-gradient(145deg, #a94b59, #7f3141); box-shadow: 0 7px 14px #88455245; }
.profile-secondary {
  background: linear-gradient(155deg, #fffffff5, #eef0f6e8);
  color: #495064;
  box-shadow: 0 2px 8px #4f587425;
  cursor: pointer;
}
.profile-secondary:hover { background: #fff; box-shadow: 0 4px 10px #4f587435; }
.profile-primary:active, .profile-secondary:active { transform: scale(.97); }
.profile-primary:disabled, .profile-secondary:disabled { opacity: .55; cursor: wait; }
.profile-feedback { color: #8e3c4b; font-size: .86rem; line-height: 1.42; overflow-wrap: anywhere; }
.profile-feedback:empty { display: none; }
.profile-inner > .profile-feedback { text-align: center; margin: .9rem 0 0; }

.profile-dialog {
  width: min(30rem, calc(100% - 1.7rem));
  max-height: calc(100dvh - 1.7rem);
  padding: clamp(1.35rem, 4.2vw, 2.4rem);
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse at 86% 0%, #f5dce378, transparent 45%),
    linear-gradient(150deg, #fffffff9, #f5f7fdf5);
  border-radius: clamp(1.3rem, 3.8vw, 2.15rem);
  color: var(--profile-ink);
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transition: opacity .2s ease, transform .25s ease;
  transition: opacity .2s ease, transform .25s ease, overlay .25s allow-discrete, display .25s allow-discrete;
}
.profile-dialog[open] { animation: none; opacity: 1; transform: none; }
.profile-dialog:not([open]), .profile-dialog:not([open])::backdrop { pointer-events: none; }
.profile-dialog::backdrop {
  opacity: 0;
  backdrop-filter: blur(8px);
  transition: opacity .22s ease;
  transition: opacity .22s ease, overlay .25s allow-discrete, display .25s allow-discrete;
}
.profile-dialog[open]::backdrop { opacity: 1; }
@starting-style {
  .profile-dialog[open] { opacity: 0; transform: translateY(12px) scale(.98); }
  .profile-dialog[open]::backdrop { opacity: 0; }
}
.profile-dialog h2 {
  margin-bottom: .55rem;
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  line-height: 1.03;
  letter-spacing: -.055em;
}
.profile-dialog .profile-dialog-intro { margin-bottom: 1rem; color: var(--profile-soft); }
.profile-fields {
  display: grid;
  gap: .65rem;
}
.profile-fields > label, .profile-edit-status > label, .profile-crop legend {
  color: #484f61;
  font-size: .88rem;
  font-weight: 700;
}
.profile-fields input:not([type="range"], [type="file"]), #theme-search {
  width: 100%;
  min-height: 2.75rem;
  padding: .66rem .8rem;
  border: 1px solid #b9bfd0;
  border-radius: .75rem;
  background: #ffffffe0;
  color: var(--profile-ink);
}
.profile-secret-field { position: relative; }
.profile-secret-field input { padding-right: 3rem !important; }
.profile-secret-field button {
  position: absolute;
  inset: 0 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.75rem;
  border: 0;
  border-radius: .75rem;
  background: #fff0;
  color: #646b80;
}
.profile-secret-field button[aria-pressed="true"] { color: var(--profile-coral); }
.profile-secret-field svg { width: 1.25rem; }
.profile-fields > .profile-primary { margin-top: .24rem; }

.profile-editor { width: min(52rem, calc(100% - 1.7rem)); }
.crop-layout { display: grid; grid-template-columns: minmax(0, 1.58fr) minmax(0, 1fr); gap: .75rem; margin: .55rem 0 .2rem; }
.profile-crop {
  min-width: 0;
  margin: 0;
  padding: .7rem;
  border: 1px solid #d5d9e5;
  border-radius: .9rem;
  background: #ffffff65;
}
.profile-crop .profile-avatar { width: clamp(4.75rem, 12vw, 7.5rem); margin: 0 auto; }
.crop-controls { position: relative; display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: .55rem; }
.crop-controls label { font-size: .8rem; }
.crop-controls:has(input:focus-visible) label { outline: 2px solid #853238; outline-offset: 3px; }
.crop-file, .profile-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
  border: 0;
}
.profile-text-button {
  min-height: 2.25rem;
  padding: .2rem .4rem;
  border: 0;
  border-radius: .45rem;
  background: none;
  color: #8e3c4b;
  font-size: .8rem;
  text-decoration: underline;
}
.crop-adjustments { display: grid; gap: .15rem; margin-top: .45rem; }
.crop-adjustments label { display: grid; grid-template-columns: 7.3rem minmax(0, 1fr); align-items: center; gap: .35rem; font-size: .72rem; }
.crop-adjustments input { accent-color: #a35260; width: 100%; min-height: 1.75rem; }
.profile-edit-status { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .35rem .5rem; }
.profile-edit-status input, .profile-edit-status p { grid-column: 1 / -1; }
.profile-character-count { justify-self: end; color: var(--profile-soft); font-size: .75rem; }
.profile-status-preview {
  padding: .42rem .7rem;
  border-radius: .7rem;
  background: #e9ecf5a8;
  color: var(--profile-soft);
  font-size: .81rem;
  overflow-wrap: anywhere;
}
.profile-edit-theme { display: flex; align-items: center; gap: .65rem; }
.profile-edit-theme span { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; background: #f0e3e8; color: #864655; border-radius: .65rem; font-size: 1.36rem; }

.theme-dialog { width: min(39rem, calc(100% - 1.7rem)); }
.theme-preview {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.6rem;
  margin: .8rem 0 .65rem;
  padding: .37rem .7rem;
  border: 1px solid #fff;
  border-radius: .8rem;
  color: var(--profile-soft);
  background: linear-gradient(128deg, #f3e3e9, #edf0f8);
}
#theme-preview-emoji { display: grid; place-items: center; min-width: 2.45rem; font-size: 1.9rem; }
.theme-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .55rem; }
.theme-tabs button {
  padding: .55rem .72rem;
  border: 1px solid #dadde8;
  border-radius: 999px;
  background: #ffffffe0;
  color: #535a6d;
  font-size: .79rem;
}
.theme-tabs [aria-selected="true"] { color: #853b4a; border-color: #d3a3ae; background: #f3e3e8; font-weight: 700; }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.45rem, 1fr));
  max-height: min(31vh, 13rem);
  gap: .26rem;
  margin: .55rem 0;
  padding: .25rem;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}
.theme-choice {
  display: grid;
  place-items: center;
  min-height: 2.45rem;
  padding: .15rem;
  border: 1px solid #fff;
  border-radius: .55rem;
  background: #e9ecf56b;
  font-size: 1.25rem;
}
.theme-choice:hover { background: #f1e3e8; }
.theme-choice[aria-pressed="true"] { border-color: #a95366; background: #f0dce3; }
.theme-dialog .profile-actions { margin-top: .65rem; }

.stats-dialog { width: min(39rem, calc(100% - 1.7rem)); }
.member-stat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin: 1rem clamp(.7rem, 3.3vw, 2.6rem) 0;
  color: var(--profile-soft);
  font-size: .85rem;
}
.stat-badge {
  display: inline-block;
  max-width: 100%;
  padding: .3rem .65rem;
  border: 1px solid var(--stat-color, #62697a);
  border-radius: 999px;
  background: var(--stat-color, #62697a);
  color: var(--stat-text, #fff);
  font: inherit;
  font-weight: 700;
  overflow-wrap: anywhere;
}
button.stat-badge { min-height: 2.25rem; }
button.stat-badge:hover { filter: brightness(1.12); }
[data-group="radical-left"] { --stat-color: #81252d; }
[data-group="left"] { --stat-color: #287342; }
[data-group="center"] { --stat-color: #626976; }
[data-group="right"] { --stat-color: #245c9f; }
[data-group="far-right"] { --stat-color: #e4c435; --stat-text: #2c2408; }
[data-group="third-position"] { --stat-color: #754687; }
[data-group="libertarian"] { --stat-color: #c55f24; --stat-text: #211309; }
[data-group="anarchist"] { --stat-color: #19191d; }
.stats-section-title, .ideology-details h3 { margin: .35rem 0 0; font-size: 1rem; }
.stats-selection { color: var(--profile-soft); font-size: .9rem; }
.stats-options {
  max-height: min(41dvh, 19rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: .65rem;
  border: 1px solid #d3d8e4;
  border-radius: .8rem;
  background: #ffffff85;
}
.stats-options h4 { margin: .3rem 0 .45rem; font-size: .78rem; }
.stats-options ul { list-style: none; margin: 0 0 .65rem; padding: 0; }
.stats-options button {
  width: 100%;
  min-height: 2.5rem;
  padding: .35rem .55rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  text-align: left;
  color: #393e4b;
  background: #fff0;
}
.stats-options button:hover { background: #e8ebf3; }
.stats-options button[aria-pressed="true"] { border-color: var(--stat-color); background: #eceef5; font-weight: 700; }
.ideology-details { margin-top: .7rem; }
.ideology-details h3 { margin-top: .9rem; }
.ideology-details blockquote {
  margin: .35rem 0 0;
  padding: .5rem .7rem;
  border-left: 3px solid #ce8791;
  background: #f3e5ea;
  line-height: 1.5;
}

@media (max-width: 580px) {
  .profile-identity { grid-template-columns: minmax(0, 1fr) auto; gap: .45rem .65rem; }
  .profile-identity .profile-avatar { grid-area: 1 / 1; margin-top: -2.25rem; }
  .profile-emblem { grid-area: 1 / 2; align-self: start; margin-top: .6rem; }
  .profile-username { grid-column: 1 / -1; grid-row: 2; padding-top: .2rem; }
  .profile-banner-edit { top: .36rem; right: .36rem; min-height: 2rem; font-size: .74rem; }
  .crop-layout { grid-template-columns: 1fr; }
  .profile-member-actions .profile-logout { margin-inline-start: 0; }
}
