/* ============================================================
   Profile screens — spec-locked mobile layout, theme aware
   Own profile / public profile / edit profile
   ============================================================ */

body.profile-shell { background: var(--bg); }
body.profile-shell #app { background: var(--bg); }
body.profile-shell .page { padding: 0; }
body.profile-shell .toast {
  background: var(--surface-2);
  border: 0;
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.pr-page {
  min-height: 100dvh;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}
.pr-page *,
.pr-page *::before,
.pr-page *::after { box-sizing: border-box; }
.pr-page button {
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pr-page button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Banner ===== */
.pr-banner {
  position: relative;
  width: 100%;
  height: 170px;
  background: var(--surface-2);
  overflow: hidden;
}
.pr-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pr-circle {
  position: absolute;
  top: 12px;
  z-index: 3;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform .14s ease, background .16s ease;
}
.pr-circle:active { transform: scale(.92); }
.pr-circle svg { width: 20px; height: 20px; }
.pr-settings { right: 16px; }
.pr-back { left: 16px; }
.pr-back svg { width: 22px; height: 22px; }

/* ===== Avatar rows ===== */
.pr-avatar-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  /* Only the avatar overlaps the banner. Action pills stay below it. */
  margin-top: 0;
  padding: 0 16px;
}
.pr-avatar {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  margin-top: -44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}
.pr-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pr-edit-btn {
  height: 36px;
  padding: 0 18px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: transform .14s ease, background .16s ease;
}
.pr-edit-btn:active { transform: scale(.96); background: var(--surface); }

/* ===== Identity ===== */
.pr-name {
  margin: 12px 16px 0;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.pr-id {
  display: flex;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 44px;
  margin: 2px 16px 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}
.pr-id span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pr-id svg { width: 14px; height: 14px; flex: 0 0 14px; margin-left: 5px; }
.pr-id:active { opacity: .6; }
.pr-bio {
  margin: 12px 16px 0;
  color: var(--text);
  font-size: 15px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.pr-bio[hidden] { display: none; }

/* ===== Stats (two items only) ===== */
.pr-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 16px 16px 0;
}
.pr-stat {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
}
.pr-stat b {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pr-stat.rep b { color: var(--gold); }
.pr-stat.followers b { color: var(--text); }
button.pr-stat::after {
  content: '';
  position: absolute;
  inset: -12px 0;
}
button.pr-stat:active { opacity: .65; }

/* ===== Collection ===== */
.pr-col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 16px 12px;
}
.pr-col-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}
.pr-col-count {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}
.pr-viewall {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.pr-viewall:active { opacity: .65; }

.pr-strip {
  display: flex;
  gap: 10px;
  padding: 0 16px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.pr-strip::-webkit-scrollbar { display: none; }
.pr-card {
  position: relative;
  flex: 0 0 104px;
  width: 104px;
  height: 150px;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  scroll-snap-align: start;
}
.pr-card img,
.pr-card .art-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pr-count {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 11px;
  background: rgba(0, 0, 0, .55);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.pr-card:active img { transform: scale(1.03); }
.pr-card img { transition: transform .3s ease; }

.pr-empty {
  margin: 0 16px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.45;
}
.pr-empty.is-center { text-align: center; }

/* ===== Public profile actions ===== */
.pr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}
.pr-action {
  position: relative;
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity .15s ease, transform .14s ease;
}
/* Keep a 44px touch target while the pill itself stays visually slim. */
.pr-action::after {
  content: '';
  position: absolute;
  inset: -2px 0;
}
.pr-action svg { width: 18px; height: 18px; flex: 0 0 18px; }
.pr-action[disabled] { opacity: .6; }
.pr-action:active { transform: scale(.97); }
.pr-follow { background: var(--accent); color: var(--on-accent); }
.pr-follow.is-on { background: var(--surface-2); color: var(--text); }
.pr-rep { background: var(--gold-soft); color: var(--gold); }
.pr-rep.is-on { background: var(--gold-fill); color: var(--on-gold); }
.pr-action-labels {
  display: inline-grid;
  align-items: center;
  justify-items: center;
}
.pr-action-label {
  grid-area: 1 / 1;
  white-space: nowrap;
  visibility: hidden;
}
.pr-action-label.is-active { visibility: visible; }

.pr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px;
}
.pr-grid .pr-card {
  flex: none;
  width: auto;
  height: 220px;
}
.pr-grid .pr-count {
  top: 10px;
  right: 10px;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 13px;
}

/* Pinned cards reuse the collection card, with a server-validated toggle
   layered above the artwork. */
.pr-card-wrap {
  position: relative;
  min-width: 0;
}
.pr-card-wrap .pr-card { width: 100%; }
.pr-pin-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 17px;
  background: rgba(0, 0, 0, .55);
  color: var(--on-accent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: transform .14s ease, background .14s ease;
}
.pr-pin-btn svg { width: 17px; height: 17px; }
.pr-pin-btn.is-on {
  background: var(--gold-fill);
  color: var(--on-gold);
}
.pr-pin-btn:active { transform: scale(.94); }
.pr-pin-btn:disabled { opacity: .55; }

/* ===== Loading / error ===== */
.pr-skel {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
}
.pr-skel::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skeleton-hi), transparent);
  animation: prShimmer 1.4s infinite;
}
@keyframes prShimmer { to { transform: translateX(100%); } }
.pr-skel-banner { height: 170px; border-radius: 0; }
.pr-skel-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 0;
  padding: 0 16px;
}
.pr-skel-avatar { width: 88px; height: 88px; margin-top: -44px; border-radius: 50%; border: 4px solid var(--bg); }
.pr-skel-edit { width: 104px; height: 36px; border-radius: 18px; margin-bottom: 4px; }
.pr-skel-line { height: 16px; margin: 12px 16px 0; }
.pr-skel-line.title { height: 26px; width: 48%; }
.pr-skel-line.short { width: 34%; height: 13px; }
.pr-skel-strip { display: flex; gap: 10px; padding: 0 16px; margin-top: 26px; overflow: hidden; }
.pr-skel-card { flex: 0 0 104px; width: 104px; height: 150px; }
.pr-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 90px 24px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}
.pr-retry {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}

/* ============================================================
   Edit profile (full screen)
   ============================================================ */
.pr-edit { padding-top: env(safe-area-inset-top, 0px); }
.pr-edit-bar {
  display: flex;
  align-items: center;
  padding: 12px 8px 8px;
}
.pr-edit-back {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  display: grid;
  place-items: center;
}
.pr-edit-back svg { width: 24px; height: 24px; }
.pr-edit-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}
.pr-save {
  min-width: 64px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pr-save:disabled { color: var(--text-muted); cursor: default; }
.pr-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: prSpin .7s linear infinite;
}
@keyframes prSpin { to { transform: rotate(360deg); } }

.pr-edit-banner-wrap {
  position: relative;
  margin: 8px 16px 0;
}
.pr-edit-banner {
  position: relative;
  height: 140px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface-2);
}
.pr-edit-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pr-banner-edit {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: grid;
  place-items: center;
}
.pr-banner-edit svg { width: 20px; height: 20px; }

.pr-edit-avatar-row {
  position: relative;
  z-index: 2;
  width: 84px;
  height: 84px;
  margin: -40px 0 0 32px;
}
.pr-edit-avatar {
  position: relative;
  width: 84px;
  height: 84px;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 32px;
  font-weight: 700;
}
.pr-edit-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pr-edit-avatar-ov {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  pointer-events: none;
}
.pr-edit-avatar-ov svg { width: 24px; height: 24px; }
.pr-edit-hint {
  margin: 10px 16px 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}
.pr-field { margin: 22px 16px 0; }
.pr-field + .pr-field { margin-top: 18px; }
.pr-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.pr-field-label,
.pr-counter {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}
.pr-input,
.pr-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
}
.pr-input {
  height: 52px;
  padding: 0 16px;
}
.pr-textarea {
  min-height: 128px;
  padding: 14px 16px;
  line-height: 1.45;
  resize: none;
}
.pr-input:focus,
.pr-textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: none;
}
.pr-input::placeholder,
.pr-textarea::placeholder { color: var(--text-muted); }

/* ===== Shared bottom sheets ===== */
.pr-sheet {
  background: var(--surface);
  border: 0;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -18px 50px -30px rgba(0, 0, 0, .9);
}
.pr-sheet-title {
  margin: 0;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.pr-sheet-body {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.45;
}
.pr-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}
.pr-sheet-action {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
}
.pr-sheet-danger { background: var(--danger-soft); color: var(--danger); }
.pr-sheet-cancel { background: var(--surface-2); color: var(--text); }
.pr-sheet-premium { background: var(--gold-fill); color: var(--on-gold); }
.pr-sheet-action:active { opacity: .8; }

/* Narrow screens: tighten padding and gaps first, then the label size, so the
   avatar and both pills always stay on one row without ever wrapping. */
@media (max-width: 389px) {
  .pr-avatar-row { gap: 10px; }
  .pr-actions { gap: 6px; }
  .pr-action { padding: 0 12px; }
}
@media (max-width: 374px) {
  .pr-avatar-row { gap: 8px; }
  .pr-action { gap: 4px; font-size: 13px; }
  .pr-action svg { width: 16px; height: 16px; flex: 0 0 16px; }
}
@media (max-width: 349px) {
  /* The artwork icons would push the row past the viewport on 320px screens;
     the labels alone keep the 44px targets readable. */
  .pr-action svg { display: none; }
}

/* ===== Premium card ===== */
.pr-premium-host { margin: 16px 16px 0; }
.pr-premium {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pr-premium-star { flex: 0 0 auto; display: inline-flex; }
.pr-premium-copy { flex: 1; min-width: 0; }
.pr-premium-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}
.pr-premium-sub {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.35;
}
.pr-premium-buy,
.pr-premium-change {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pr-premium-buy { background: var(--gold-fill); color: var(--on-gold); }
.pr-premium-change { background: var(--surface); color: var(--text); }
.pr-premium-buy:active,
.pr-premium-change:active { opacity: .78; }
.pr-premium-buy:disabled { opacity: .55; }

/* ===== Badge picker ===== */
.sheet.badge-picker-sheet {
  background: var(--surface);
  border: 0;
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  color: var(--text);
}
.badge-picker-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}
.badge-picker-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}
.badge-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.badge-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.badge-picker-row.is-active {
  border-color: var(--gold-border);
  background: var(--gold-soft);
}
.badge-picker-row:disabled { opacity: .6; }
.badge-picker-ic {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--gold);
}
.badge-picker-label { flex: 1; min-width: 0; }
.badge-picker-check {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
