/* Profile & avatar frames */
.profile-page { max-width: 920px; }
.profile-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.15rem 1.5rem;
  margin-bottom: 1rem;
}
.profile-hero-avatar-col {
  flex-shrink: 0;
  display: grid;
  justify-items: center;
  gap: .55rem;
  max-width: 11rem;
}
.profile-hero-avatar {
  position: relative;
  flex-shrink: 0;
  --frame-pad: 8px;
}
.profile-hero-avatar .avatar-ring {
  width: 112px;
  height: 112px;
}
.profile-hero-avatar .avatar-fallback {
  font-size: 2rem;
}
.avatar-admin-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 2;
  min-height: 1.35rem;
  padding: .35rem .48rem .38rem;
  border-radius: 3px;
  font-family: "Press Start 2P", Oxanium, monospace;
  font-size: .48rem;
  letter-spacing: .02em;
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  color: #e8fffe;
  background:
    linear-gradient(160deg, #b8fff8 0%, #4aedd9 38%, #1fa8c4 72%, #0d6f8a 100%);
  border: 2px solid #0a5a72;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    inset 0 -1px 0 rgba(10, 70, 90, .35),
    0 0 0 1px rgba(74, 237, 217, .45),
    1px 1px 0 rgba(8, 50, 70, .35);
  pointer-events: none;
  text-transform: none;
  text-shadow: 0 1px 0 rgba(8, 50, 70, .45);
}
.profile-form .field { margin-bottom: .55rem; }
.profile-upload-form { display: inline; }

/* Recovery key modal — light MC day theme */
.rk-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(30, 70, 110, .38);
  backdrop-filter: blur(5px);
}
.rk-modal-backdrop[hidden] { display: none !important; }
.rk-modal {
  width: min(560px, 100%);
  padding: 1.35rem 1.4rem 1.2rem;
  border-radius: 14px;
  border: 1px solid rgba(40, 90, 130, .22);
  background:
    linear-gradient(180deg, rgba(255,255,255,.97), rgba(232, 245, 255, .96));
  box-shadow:
    0 18px 48px rgba(30, 60, 90, .22),
    inset 0 1px 0 rgba(255,255,255,.85);
  color: #1a3350;
}
.rk-modal-title {
  margin: 0 0 .4rem;
  font-family: Oxanium, Nunito, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #1a3350;
}
.rk-modal-text {
  margin: 0 0 .9rem;
  color: #5a7390;
  line-height: 1.45;
  font-size: .95rem;
}
.rk-modal-key {
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
  padding: .95rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(40, 90, 130, .22);
  background: rgba(20, 50, 80, .06);
  color: #1a3350;
  cursor: pointer;
  user-select: all;
  line-height: 1.5;
  font-size: .95rem;
}
.rk-modal-key:hover,
.rk-modal-key.is-copied {
  border-color: rgba(47, 122, 40, .55);
  background: rgba(93, 189, 58, .12);
}
.rk-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1rem;
}
.rk-modal-status {
  min-height: 1.2rem;
  margin-top: .55rem;
  color: #2f7a28;
  font-size: .9rem;
}
.profile-hero-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
}
.profile-upload-btn {
  position: relative;
  cursor: pointer;
}
.profile-upload-btn.is-busy {
  opacity: .7;
  pointer-events: none;
}
.profile-hero-avatar-hint {
  margin: 0;
  text-align: center;
  line-height: 1.35;
}
.profile-hero-meta {
  min-width: 0;
  flex: 1 1 12rem;
}
.profile-hero-meta h2 {
  margin: 0 0 .2rem;
  font-family: Oxanium, Nunito, sans-serif;
  color: #1a3350;
  word-break: break-word;
}
.profile-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 860px) {
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .profile-frames,
  .profile-badges { grid-column: 1 / -1; }
}
.profile-card h3 {
  margin: 0 0 .45rem;
  font-family: Oxanium, Nunito, sans-serif;
  color: #1a3350;
}
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .65rem;
}
.recovery-box {
  display: grid;
  gap: .65rem;
}
.recovery-key {
  display: block;
  padding: .75rem .9rem;
  border-radius: 10px;
  background: rgba(20, 40, 70, .08);
  border: 1px solid rgba(40, 80, 120, .2);
  word-break: break-all;
  font-size: .95rem;
  color: #1a3350;
}

.avatar-stage {
  --frame-pad: 5px;
  --frame-radius: 8px; /* square by default */
  position: relative;
  display: inline-flex;
  padding: var(--frame-pad);
  border-radius: var(--frame-radius);
  background: transparent;
  box-shadow: none;
  box-sizing: border-box;
  overflow: visible;
}
.avatar-stage.mini { --frame-pad: 5px; }
.avatar-stage.square { --frame-radius: 8px; }
.avatar-ring {
  width: 88px;
  height: 88px;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(160deg, #d9efff, #b8dcc0);
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.65);
  box-sizing: border-box;
}
.avatar-stage.mini .avatar-ring {
  width: 64px;
  height: 64px;
}
.avatar-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-fallback {
  font-family: Oxanium, Nunito, sans-serif;
  font-weight: 800;
  color: #1a4060;
  font-size: 1.35rem;
  letter-spacing: .02em;
}
.avatar-stage.mini .avatar-fallback { font-size: 1.05rem; }

/* Free / dynamic frames — class generated by /api/profile/frames/styles.css */
.avatar-stage.frame-none {
  background: rgba(255,255,255,.55);
  border: 2px solid rgba(40, 80, 120, .28);
  box-shadow: none;
  padding: 3px;
}

.avatar-stage.hh-fx-flash {
  filter: brightness(1.55) saturate(1.35) drop-shadow(0 0 12px #7dd3fc);
  transition: filter .08s linear;
}
.hh-fx-layer {
  position: absolute;
  inset: -28%;
  pointer-events: none;
  overflow: visible;
  z-index: 30; /* above custom ::before/::after crystals */
}
.hh-fx-bolt {
  position: absolute;
  width: 55%;
  height: 95%;
  opacity: 0;
  filter: drop-shadow(0 0 10px var(--hh-bolt-color, #dff6ff)) drop-shadow(0 0 18px #fff);
  transform-origin: top center;
  z-index: 31;
}
.hh-fx-bolt[data-from="tl"] { left: 8%; top: -8%; transform: rotate(-12deg) scale(.2); }
.hh-fx-bolt[data-from="tr"] { right: 6%; left: auto; top: -10%; transform: rotate(14deg) scale(.2); }
.hh-fx-bolt[data-from="top"] { left: 30%; top: -12%; transform: rotate(0deg) scale(.15); }
.hh-fx-bolt.is-on {
  opacity: 1;
  animation: hh-bolt-strike .38s ease-out forwards;
}
@keyframes hh-bolt-strike {
  0% { opacity: 0; transform: scaleY(.2) scaleX(.4); }
  18% { opacity: 1; transform: scaleY(1) scaleX(1); }
  55% { opacity: 1; }
  100% { opacity: 0; }
}
.hh-fx-ember {
  position: absolute;
  bottom: 8%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe08a 0%, #ff6a1a 55%, transparent 70%);
  animation: hh-ember-rise 1.2s ease-out forwards;
  box-shadow: 0 0 8px #ff8a3a, 0 0 14px #ffb347;
  z-index: 32;
}
@keyframes hh-ember-rise {
  0% { opacity: 0; transform: translateY(8px) scale(.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-42px) scale(.2); }
}
.hh-fx-aurora {
  position: absolute;
  inset: -10%;
  border-radius: inherit;
  background: conic-gradient(from 20deg, transparent, rgba(120,255,210,.35), transparent 40%, rgba(120,180,255,.3), transparent 75%);
  animation: hh-aurora-spin 2.2s linear forwards;
  mix-blend-mode: screen;
}
@keyframes hh-aurora-spin {
  0% { opacity: 0; transform: rotate(0deg) scale(.9); }
  25% { opacity: .9; }
  100% { opacity: 0; transform: rotate(120deg) scale(1.05); }
}

.frame-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: .85rem;
  margin-top: .75rem;
}
.frame-picker > form {
  display: contents;
}
.frame-option {
  display: grid;
  justify-items: center;
  gap: .4rem;
  padding: .85rem .55rem .7rem;
  border-radius: 10px;
  border: 2px solid rgba(40, 80, 120, .16);
  background: rgba(255,255,255,.78);
  cursor: pointer;
  font: inherit;
  color: #1a3350;
  min-height: 44px;
  width: 100%;
}
.frame-option:hover { border-color: rgba(40, 120, 80, .45); }
.frame-option.is-active {
  border-color: rgba(40, 140, 90, .6);
  background: rgba(90, 200, 140, .18);
  box-shadow: 0 0 0 2px rgba(90, 200, 140, .28);
}
.frame-option.is-locked { opacity: .78; }
.frame-option-name {
  font-weight: 750;
  font-size: .9rem;
  text-align: center;
}
.frame-option .avatar-stage.mini {
  --frame-pad: 6px;
}
.frame-option .avatar-stage.mini .avatar-ring {
  width: 72px;
  height: 72px;
}

.badge-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: .85rem;
  margin-top: .75rem;
}
.badge-picker > form { display: contents; }
.badge-option {
  display: grid;
  justify-items: center;
  gap: .4rem;
  padding: .85rem .55rem .7rem;
  border-radius: 10px;
  border: 2px solid rgba(40, 80, 120, .16);
  background: rgba(255,255,255,.78);
  cursor: pointer;
  font: inherit;
  color: #1a3350;
  min-height: 44px;
  width: 100%;
}
.badge-option:hover { border-color: rgba(40, 120, 80, .45); }
.badge-option.is-active {
  border-color: rgba(40, 140, 90, .6);
  background: rgba(90, 200, 140, .18);
  box-shadow: 0 0 0 2px rgba(90, 200, 140, .28);
}
.badge-option.is-locked { opacity: .78; }

.user-chip-badge {
  --badge-bg: #2f7a28;
  --badge-fg: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.2rem;
  padding: .22rem .42rem .26rem;
  border-radius: 4px;
  font-family: "Press Start 2P", Oxanium, monospace;
  font-size: .42rem;
  letter-spacing: .02em;
  line-height: 1.2;
  color: var(--badge-fg);
  background: var(--badge-bg);
  border: 1px solid color-mix(in srgb, var(--badge-bg) 70%, #000 30%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .28),
    0 1px 0 rgba(0, 0, 0, .12);
  white-space: nowrap;
  text-transform: none;
  vertical-align: middle;
}
.user-chip-badge.mini {
  min-height: 1.05rem;
  padding: .16rem .34rem .18rem;
  font-size: .36rem;
}
.user-chip-badge.is-admin {
  --badge-bg: #1f5f2a;
  --badge-fg: #e8ffe8;
}
.user-chip-badge.is-empty {
  --badge-bg: rgba(40, 80, 120, .12);
  --badge-fg: #5a7390;
  border-color: rgba(40, 80, 120, .22);
  box-shadow: none;
  font-family: Oxanium, Nunito, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: lowercase;
}
.user-chip-badge.is-active-chip {
  outline: 2px solid rgba(40, 140, 90, .55);
  outline-offset: 2px;
}
/* Badge sits on the bottom edge of the frame (not beside the avatar). */
.avatar-stage .avatar-frame-badge,
.avatar-frame-badge {
  position: absolute !important;
  left: auto;
  right: 2px;
  bottom: -3px;
  z-index: 5;
  pointer-events: none;
  max-width: calc(100% - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
  transform: none;
}
.avatar-stage.mini .avatar-frame-badge,
.avatar-frame-badge.mini {
  right: 1px;
  bottom: -4px;
  min-height: .95rem;
  padding: .12rem .28rem .14rem;
  font-size: .32rem;
  border-radius: 3px;
}
.profile-menu .avatar-frame-badge {
  right: 0;
  bottom: -3px;
}
.profile-hero-badge {
  right: 4px;
  bottom: -2px;
  min-height: 1.25rem;
  padding: .22rem .42rem .26rem;
  font-size: .42rem;
}
.profile-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .25rem 0 .45rem;
  min-height: 1.2rem;
}

/* Header chip / menu */
.profile-menu {
  position: relative;
  display: inline-flex;
}
.profile-menu-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem .35rem .2rem .2rem;
  border-radius: 10px;
  border: 1px solid rgba(40, 80, 120, .18);
  background: rgba(255,255,255,.62);
  color: #1a3350;
  user-select: none;
  min-height: 44px;
  box-sizing: border-box;
}
.profile-menu-summary::-webkit-details-marker { display: none; }
.profile-menu-summary::marker { content: ""; }
.profile-menu[open] .profile-menu-summary,
.profile-menu-summary:hover {
  border-color: rgba(40, 120, 80, .42);
  background: rgba(255,255,255,.88);
}
.profile-menu .avatar-stage { --frame-pad: 3px; }
.profile-menu .avatar-ring {
  width: 36px;
  height: 36px;
  border-width: 1px;
  border-radius: inherit;
}
.profile-menu .avatar-fallback { font-size: .72rem; }
.profile-menu-meta {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-width: 0;
}
.profile-menu-name-row {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
  max-width: 11rem;
}
.profile-menu-name {
  font-size: .86rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 7.5rem;
  color: #2f7a28;
}
.profile-menu-gear {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 6px;
  color: #3a556e;
  background: rgba(30, 60, 90, .08);
  flex-shrink: 0;
  transition: transform .2s ease, background .15s ease;
}
.profile-menu[open] .profile-menu-gear {
  color: #1a4060;
  background: rgba(93, 189, 58, .18);
  transform: rotate(28deg);
}

.profile-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 50;
  min-width: 12.5rem;
  padding: .35rem;
  border-radius: 10px;
  border: 1px solid rgba(40, 80, 120, .2);
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(236, 246, 255, .96));
  box-shadow: 0 10px 28px rgba(30, 55, 80, .18);
  display: grid;
  gap: .15rem;
  animation: profile-menu-in .16s ease-out;
}
@keyframes profile-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .profile-menu-panel { animation: none; }
  .profile-menu-gear { transition: none; }
  .profile-menu[open] .profile-menu-gear { transform: none; }
}
.profile-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  text-decoration: none;
  color: #1a3350;
  font-weight: 650;
  font-size: .9rem;
  min-height: 40px;
  box-sizing: border-box;
}
.profile-menu-item:hover {
  text-decoration: none;
  background: rgba(93, 189, 58, .14);
  color: #1a4060;
}
.profile-menu-item.is-danger {
  color: #9a2f2f;
  border-top: 1px solid rgba(40, 80, 120, .12);
  margin-top: .15rem;
  border-radius: 0 0 8px 8px;
}
.profile-menu-item.is-danger:hover {
  background: rgba(200, 70, 70, .12);
  color: #7a1f1f;
}

@media (max-width: 860px) {
  .profile-menu-name { display: none; }
  .profile-menu-summary { padding: .15rem; gap: .25rem; min-height: 0; }
  .profile-menu .avatar-ring {
    width: 32px;
    height: 32px;
  }
  .profile-bar .profile-notif {
    width: 1.45rem;
    height: 1.45rem;
    font-size: .85rem;
  }
}

/* Admin frames */
.admin-frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .85rem;
  margin: 1rem 0 1.5rem;
}
.admin-frame-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .55rem .75rem;
  align-items: center;
  padding: .85rem;
  border-radius: 10px;
  border: 2px solid rgba(40, 80, 120, .14);
  background: rgba(255,255,255,.72);
}
.admin-frame-card.is-editing {
  border-color: rgba(40, 140, 90, .55);
  box-shadow: 0 0 0 2px rgba(90, 200, 140, .22);
}
.admin-frame-card.is-off { opacity: .62; }
.admin-frame-card-main { display: grid; gap: .15rem; }
.admin-frame-card-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.admin-frame-help { margin: .75rem 0 1rem; padding: .85rem 1rem; }
.admin-frame-help summary { cursor: pointer; font-weight: 750; color: #1a3350; }
.admin-frame-help-list { margin: .55rem 0 0; padding-left: 1.1rem; display: grid; gap: .35rem; }
.admin-frame-editor { margin-top: 1rem; }
.admin-frame-preview-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: .75rem 0 1rem;
}
.admin-frame-preview-hint {
  display: grid;
  gap: .35rem;
  max-width: 28rem;
}
.admin-frame-live-preview {
  flex-shrink: 0;
  min-width: 96px;
  min-height: 96px;
}
.admin-frame-form { display: grid; gap: .75rem; max-width: 720px; }
.admin-frame-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .65rem;
}
.admin-frame-form-actions { margin-top: .25rem; }
.admin-frame-texture-form {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(40, 80, 120, .14);
  display: grid;
  gap: .65rem;
  max-width: 480px;
}
.admin-frame-js-spec {
  margin-top: .75rem;
  padding-top: .55rem;
  border-top: 1px dashed rgba(40, 80, 120, .18);
}
.admin-frame-js-spec summary {
  cursor: pointer;
  font-weight: 700;
  color: #1a4060;
}
.admin-frame-js-sample {
  margin: .55rem 0;
  padding: .65rem .75rem;
  border-radius: 8px;
  background: rgba(20, 40, 60, .08);
  border: 1px solid rgba(40, 80, 120, .16);
  font-size: .78rem;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre;
  color: #1a3350;
}
.admin-frame-js-input textarea,
textarea.admin-frame-js-input {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem;
}
