/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /*
   * Exact Telegram "Night Blue" (tinted dark) palette
   * Source: Telegram-iOS DefaultDarkTintedPresentationTheme.swift
   * Accent: #2EA6FF
   */
  --tg-bg: #17212B;
  --tg-bg-secondary: #232E3C;
  --tg-bg-input: #101A24;
  --tg-separator: #344150;
  --tg-text: #F5F5F5;
  --tg-hint: #708499;
  --tg-link: #6AB3F3;
  --tg-accent: #2EA6FF;
  --tg-button: #5288C1;
  --tg-section-header: #6AB3F3;
  --tg-destructive: #EC3942;

  /* Premium gradient (from Telegram-Mac Appearance.swift) */
  --premium-blue: #6B93FF;
  --premium-purple: #976FFF;
  --premium-pink: #E46ACE;

  /* Star gold — luxury rich gold */
  --gold: #FFB800;
  --gold-bright: #FFCA28;
  --gold-deep: #E5A100;
  --gold-glow: rgba(255, 184, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, #0a1420 0%, #0e1a2a 30%, #0c1725 60%, #0e1422 100%);
  color: var(--tg-theme-text-color, var(--tg-text));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 50% at 10% 0%, rgba(46, 166, 255, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(151, 111, 255, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 50% 50%, rgba(46, 166, 255, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

@media (min-width: 600px) {
  body::before {
    background:
      radial-gradient(ellipse 80% 50% at 10% 0%, rgba(46, 166, 255, 0.22) 0%, transparent 55%),
      radial-gradient(ellipse 70% 50% at 90% 100%, rgba(151, 111, 255, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse 60% 40% at 50% 50%, rgba(46, 166, 255, 0.10) 0%, transparent 60%);
  }
}

/* ── State visibility ── */
.state {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes countUp {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes starGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 184, 0, 0.5)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 184, 0, 0.8)); }
}

@keyframes premiumGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Loading State ── */
.loading-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: fadeIn 0.4s ease-out;
}

.loading-video {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 20px;
  pointer-events: none;
}

.loading-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--tg-theme-text-color, var(--tg-text));
}

.loading-sub {
  font-size: 14px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  animation: pulse 2s ease-in-out infinite;
}

/* ── Refresh Toast — floating pill at top, no layout impact ── */
.refresh-banner {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  pointer-events: none;
  z-index: 2000;
  white-space: nowrap;
  animation: refreshSlideIn 0.25s ease-out;
}

@keyframes refreshSlideIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.refresh-banner--out {
  animation: refreshSlideOut 0.2s ease-in forwards;
}

@keyframes refreshSlideOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -10px); }
}

/* ── Search Toast — same pill, brighter since user-initiated ── */
.search-toast {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-purple));
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

/* Dim main content while searching for another user */
body.is-searching #page-home,
body.is-searching #page-leaderboard,
body.is-searching #page-settings {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.2s ease;
  filter: saturate(0.7);
}

/* ── Header ── */
.header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.4s ease-out;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}

/* When profile-rating is visible (viewing another user), hide inline search for space */
.header:has(#profile-rating:not(.hidden)) .search-row--inline {
  display: none;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tg-theme-button-color, var(--tg-button));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--tg-theme-button-text-color, #ffffff);
  flex-shrink: 0;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.user-name-link {
  color: var(--tg-theme-text-color, var(--tg-text));
  text-decoration: none;
}

.user-name-link:active {
  opacity: 0.7;
}

.user-name-arrow {
  color: var(--tg-theme-hint-color, var(--tg-hint));
  font-size: 20px;
  margin-left: 2px;
}

.user-username {
  font-size: 14px;
  font-weight: 400;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

/* ── Profile Rating ── */
.profile-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.profile-rating.hidden {
  display: none;
}

.rate-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--tg-theme-text-color, var(--tg-text));
  cursor: pointer;
  transition: all 0.15s;
}

.rate-btn:active {
  transform: scale(0.95);
}

.rate-btn.voted {
  border-color: var(--tg-accent);
  background: rgba(46, 166, 255, 0.15);
}

.profile-views {
  font-size: 12px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

/* ── Search Row ── */
.search-row {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  animation: fadeInUp 0.45s ease-out;
  position: relative;  /* anchor for .search-suggestions */
}

/* ── Typeahead suggestions dropdown ──────────────────────────────────────
 * Lives absolutely-positioned under each search input. Each row mirrors
 * a leaderboard mini-row (avatar + name/sub + total stars) so the dropdown
 * feels native to the rest of the app. Hidden by default via the [hidden]
 * attribute; JS toggles `el.hidden = false` when matches arrive. */
.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 360px;
  overflow-y: auto;
  background: var(--tg-theme-bg-color, #1c1d22);
  border: 1px solid rgba(151, 111, 255, 0.25);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 4px;
}

.ss-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.ss-item:hover,
.ss-item:active {
  background: rgba(151, 111, 255, 0.12);
}

.ss-avatar,
.ss-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-purple));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
}

.ss-info {
  flex: 1;
  min-width: 0;
}

.ss-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.ss-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.ss-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Inline variant: lives inside .header, compact, takes remaining right-side space */
.search-row--inline {
  flex: 1;
  padding: 0;
  margin-left: auto;
  min-width: 0;
  animation: none;
}

.search-row--inline .search-input {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.search-row--inline .search-btn {
  padding: 8px 10px;
  font-size: 14px;
  border-radius: 10px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid rgba(151, 111, 255, 0.15);
  border-radius: 12px;
  background: rgba(151, 111, 255, 0.08);
  color: var(--tg-theme-text-color, var(--tg-text));
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.search-input:focus {
  border-color: var(--premium-purple);
}

.search-input::placeholder {
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

.search-btn {
  padding: 10px 14px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-purple));
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}

.search-btn:active {
  opacity: 0.8;
  transform: scale(0.96);
}

/* ── Viewing Other User Banner ── */
.viewing-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 16px 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(107, 147, 255, 0.15), rgba(151, 111, 255, 0.10));
  border: 1px solid rgba(151, 111, 255, 0.25);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.viewing-banner.hidden {
  display: none;
}

.viewing-back {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
}

.viewing-back:active {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Totals Card — Telegram Premium gradient ── */
.totals-card {
  margin: 0 16px 12px;
  padding: 24px 20px;
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-purple), var(--premium-pink));
  background-size: 200% 200%;
  animation: fadeInUp 0.5s ease-out, premiumGradient 8s ease infinite;
  border-radius: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.totals-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}

.totals-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  position: relative;
}

/* Tap-affordance for the totals card — arrow next to the title hints
 * that you can tap the card to see the unique vs regular breakdown. */
.totals-title-arrow {
  display: inline-block;
  margin-left: 4px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  transform: translateY(-1px);
}

.totals-card--clickable {
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.totals-card--clickable:active {
  transform: scale(0.985);
  filter: brightness(0.95);
}

/* ── Portfolio breakdown modal — Unique vs Regular split ── */
.breakdown-list {
  margin-top: 12px;
  padding: 0 4px;
}

.breakdown-row {
  margin-bottom: 10px;
}

.breakdown-row--tappable {
  cursor: pointer;
  transition: transform 80ms ease, background 120ms ease;
}

.breakdown-row--tappable .breakdown-row-head {
  background: rgba(255, 255, 255, 0.06);
}

.breakdown-row--tappable:active .breakdown-row-head {
  background: rgba(255, 255, 255, 0.10);
  transform: scale(0.985);
}

.breakdown-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 14px 14px;
}

.breakdown-row-arrow {
  font-size: 18px;
  color: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.45));
  margin-left: 6px;
  flex-shrink: 0;
}

.breakdown-row-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.breakdown-row-label {
  flex: 1;
  min-width: 0;
}

.breakdown-row-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-theme-text-color, #fff);
}

.breakdown-row-sub {
  font-size: 12px;
  color: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.55));
  margin-top: 2px;
}

.breakdown-row-value {
  text-align: right;
  flex-shrink: 0;
}

.breakdown-row-stars {
  font-size: 15px;
  font-weight: 700;
  color: #ffd166;
}

.breakdown-row-fiat {
  font-size: 12px;
  color: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.55));
  margin-top: 2px;
}

.breakdown-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.breakdown-footer-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.55));
}

.breakdown-footer-value {
  text-align: right;
}

.breakdown-footer-stars {
  font-size: 18px;
  font-weight: 800;
  color: #ffd166;
}

.breakdown-footer-fiat {
  font-size: 13px;
  color: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.55));
  margin-top: 2px;
}

.totals-primary {
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 10px;
  position: relative;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}

.totals-primary .star-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: starGlow 2.5s ease-in-out infinite;
}

.totals-primary .totals-num {
  line-height: 1;
  display: inline-block;
}

.totals-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  text-align: center;
}

.totals-secondary {
  font-size: 17px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.totals-separator {
  color: rgba(255, 255, 255, 0.35);
  font-size: 17px;
}

/* ── Stats Row ── */
.stats-row {
  display: flex;
  margin: 0 16px 20px;
  gap: 8px;
  animation: fadeInUp 0.6s ease-out;
}

.stat-item {
  flex: 1;
  background: linear-gradient(135deg, rgba(107, 147, 255, 0.18) 0%, rgba(151, 111, 255, 0.15) 50%, rgba(228, 106, 206, 0.12) 100%);
  border: 1px solid rgba(151, 111, 255, 0.20);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat-clickable {
  cursor: pointer;
  border-color: rgba(151, 111, 255, 0.30);
}

.stat-clickable:active {
  transform: scale(0.96);
  background: linear-gradient(135deg, rgba(107, 147, 255, 0.28) 0%, rgba(151, 111, 255, 0.25) 50%, rgba(228, 106, 206, 0.22) 100%);
}

.stat-disabled {
  pointer-events: none;
  opacity: 0.55;
}

.stat-item:active {
  transform: scale(0.96);
}

.stat-value {
  /* Aggressive clamp: on 320px the font drops to 11px so 3-cell rows with
   * long numbers ("3,536 / 3,634") still fit on one line without ellipsis.
   * Max 20px preserves the wide look on desktop-class viewports. */
  font-size: clamp(11px, 3.2vw + 2px, 20px);
  font-weight: 700;
  letter-spacing: -0.4px;
  animation: countUp 0.5s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
.stat-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(9px, 2.4vw, 12px);
  letter-spacing: 0.2px;
}
.stat-item {
  min-width: 0;
  padding: 12px 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── View Tabs ── */
.view-tabs {
  display: flex;
  margin: 0 16px 12px;
  background: var(--tg-bg-secondary);
  border-radius: 12px;
  padding: 3px;
}

/* When hidden we still reserve the exact layout space (visibility instead of
 * display:none) so the profile doesn't "jump" as collections fetch resolves
 * and tabs toggle visible. The space is only fully collapsed on Home view
 * for own portfolio (handled by .view-tabs--collapsed below) where we know
 * collections won't appear. */
.view-tabs.hidden {
  visibility: hidden;
  pointer-events: none;
}

.view-tabs.view-tabs--collapsed {
  display: none;
}

.view-tab {
  flex: 1;
  padding: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  cursor: pointer;
  transition: all 0.2s;
}

.view-tab.active {
  background: linear-gradient(135deg, rgba(151, 111, 255, 0.25), rgba(107, 147, 255, 0.20));
  color: #fff;
}

/* ── Controls Row ── */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 8px;
  gap: 8px;
  animation: fadeInUp 0.65s ease-out;
}

.controls-row .section-header {
  padding: 0;
  animation: none;
  flex-shrink: 0;
  font-size: 11px;
}

.section-header {
  padding: 4px 20px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-theme-section-header-text-color, var(--tg-section-header));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: fadeInUp 0.65s ease-out;
}

.sort-buttons {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.sort-buttons::-webkit-scrollbar {
  display: none;
}

@media (min-width: 600px) {
  .sort-buttons {
    flex-wrap: wrap;
    gap: 6px;
  }
}

.sort-btn {
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(46, 166, 255, 0.15);
  border-radius: 8px;
  background: transparent;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.sort-btn.active {
  background: rgba(46, 166, 255, 0.20);
  border-color: var(--tg-accent);
  color: var(--tg-accent);
}

.sort-btn:active {
  transform: scale(0.95);
}

/* ── Active Filter Banner ── */
.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 8px 12px 8px 14px;
  background: rgba(151, 111, 255, 0.20);
  border: 1px solid rgba(151, 111, 255, 0.30);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  animation: fadeIn 0.15s ease-out;
}

.active-filter.hidden {
  display: none;
}

.active-filter-clear {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.active-filter-clear:active {
  background: rgba(255, 255, 255, 0.30);
}

/* ── Dropdown Panel (overlay) ── */
.dropdown-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--tg-theme-bg-color, var(--tg-bg));
  border-top: 1px solid rgba(46, 166, 255, 0.20);
  border-radius: 20px 20px 0 0;
  animation: slideUp 0.2s ease-out;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 24px);
  margin-bottom: 12px;
  margin-left: 8px;
  margin-right: 8px;
  border-radius: 20px;
  border: 1px solid rgba(46, 166, 255, 0.15);
}

.dropdown-panel.hidden {
  display: none !important;
}

.dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--tg-theme-bg-color, var(--tg-bg));
  z-index: 1;
}

.dropdown-search-wrap {
  padding: 0 16px 10px;
  position: sticky;
  top: 48px;
  background: var(--tg-theme-bg-color, var(--tg-bg));
  z-index: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dropdown-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--tg-theme-text-color, var(--tg-text));
  outline: none;
}

.dropdown-search:focus {
  border-color: var(--tg-accent);
}

.dropdown-search::placeholder {
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

.dropdown-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dropdown-collection-chips {
  display: flex;
  gap: 6px;
  padding: 4px 16px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.dropdown-collection-chips::-webkit-scrollbar {
  display: none;
}

.dropdown-col-chip {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.dropdown-col-chip.active {
  background: var(--tg-accent);
  border-color: var(--tg-accent);
  color: #fff;
}

.dropdown-title {
  font-size: 16px;
  font-weight: 700;
}

.dropdown-apply {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--tg-accent);
  color: #fff;
  cursor: pointer;
}

.dropdown-apply:active {
  opacity: 0.8;
}

.dropdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.4);
}

.dropdown-overlay.hidden {
  display: none !important;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:active {
  background: rgba(46, 166, 255, 0.1);
}

.dropdown-item.selected {
  background: rgba(46, 166, 255, 0.12);
}

.dropdown-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}

.dropdown-item.selected .dropdown-check {
  background: var(--tg-accent);
  border-color: var(--tg-accent);
  color: #fff;
}

.dropdown-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.dropdown-item-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dropdown-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item-right {
  font-size: 12px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  flex-shrink: 0;
  margin-left: 8px;
}

/* ── Filter Chips ── */
.filter-chips {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chips.hidden {
  display: none;
}

.filter-chip {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--tg-bg-secondary);
  color: var(--tg-theme-text-color, var(--tg-text));
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}

.filter-chip.active {
  background: var(--tg-accent);
  border-color: var(--tg-accent);
  color: #fff;
}

.filter-chip:active {
  transform: scale(0.95);
}

.filter-chip-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Group Grid Mode ── */
.lines-grid {
  padding: 0 16px 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.group-card {
  background: linear-gradient(135deg, rgba(107, 147, 255, 0.12) 0%, rgba(151, 111, 255, 0.08) 100%);
  border: 1px solid rgba(151, 111, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
  overflow: hidden;
}

.group-card:active {
  transform: scale(0.96);
}

.group-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  margin: 0 auto 8px;
  display: block;
  /* No mix-blend-mode — `lighten` was a workaround for asset backgrounds
   * on dark UI but ate dark interior pixels of the gift icons across all
   * tiers. Native compositing reads cleaner everywhere. */
}

/* Emoji-as-thumb variant for the synthetic "Regular" tile — same square
 * footprint as image thumbs but renders the gift emoji centered on a soft
 * gradient background instead of an asset jpg. */
.group-thumb--icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(46,166,255,0.12));
  border: 1px solid rgba(255,255,255,0.06);
}

.group-name {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.group-count {
  font-size: 10px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  margin-bottom: 4px;
}

.group-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--tg-accent);
}

.group-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--tg-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Lines List ── */
.lines-list {
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.line-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--tg-theme-secondary-bg-color, var(--tg-bg-secondary));
  border-left: 3px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
  animation: fadeInUp 0.4s ease-out backwards;
}

.line-item:first-child {
  border-radius: 12px 12px 0 0;
}

.line-item:last-child {
  border-radius: 0 0 12px 12px;
}

.line-item:only-child {
  border-radius: 12px;
}

.line-item:active {
  opacity: 0.7;
  transform: scale(0.98);
}

/* Value tiers — full-row gradient by total USD value */

/* $1000+ — Trophy Gold */
.line-item[data-tier="gold"] {
  border-left-color: #FFC940;
  background: linear-gradient(90deg,
    rgba(255, 227, 104, 0.32) 0%,
    rgba(246, 201, 30, 0.22) 35%,
    rgba(245, 217, 139, 0.16) 70%,
    rgba(245, 217, 139, 0.10) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 243, 176, 0.28), 0 0 14px rgba(255, 201, 64, 0.14);
}

/* $100–$999 — Purple (Premium) */
.line-item[data-tier="purple"] {
  border-left-color: var(--premium-purple);
  background: linear-gradient(90deg, rgba(151, 111, 255, 0.33) 0%, rgba(151, 111, 255, 0.17) 50%, rgba(151, 111, 255, 0.10) 100%);
}

/* $10–$99 — Blue (Accent) */
.line-item[data-tier="blue"] {
  border-left-color: var(--tg-accent);
  background: linear-gradient(90deg, rgba(46, 166, 255, 0.27) 0%, rgba(46, 166, 255, 0.15) 50%, rgba(46, 166, 255, 0.09) 100%);
}

/* Under $10 — Soft blue-grey */
.line-item[data-tier="common"] {
  border-left-color: rgba(106, 179, 243, 0.40);
  background: linear-gradient(90deg, rgba(106, 179, 243, 0.19) 0%, rgba(106, 179, 243, 0.11) 50%, rgba(106, 179, 243, 0.07) 100%);
}

/* ── Gift Thumbnail ── */
.line-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 12px;
  background: var(--tg-bg-secondary);
}

.line-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.line-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}

.line-count {
  font-size: 12px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  font-weight: 500;
}

.line-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.line-floor {
  font-size: 15px;
  font-weight: 700;
  color: var(--tg-theme-text-color, var(--tg-text));
}

.line-floor .star-sm {
  color: var(--gold);
  font-size: 14px;
}

.line-per-item {
  font-size: 12px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  font-weight: 500;
}

/* ── Error State ── */
.error-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  animation: fadeIn 0.4s ease-out;
}

.error-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tg-destructive);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
}

.error-text {
  font-size: 16px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  text-align: center;
  line-height: 1.5;
}

.btn-retry {
  padding: 14px 40px;
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-theme-button-text-color, #ffffff);
  background: var(--tg-theme-button-color, var(--tg-button));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-retry:active {
  opacity: 0.8;
  transform: scale(0.96);
}

/* ── Pages ── */
.page.hidden {
  display: none !important;
}

.page {
  padding-bottom: 70px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  padding: 20px 20px 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  padding: 0 20px 16px;
}

/* ── Leaderboard header: title + search on one row, subtitle + refresh
 *    hint on the next row. Both rows share the same horizontal padding
 *    (20px) so "Leaderboard" and "Top portfolios by value" line up
 *    visually in a single left column. */
.lb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 6px;
}

/* Rainbow gradient title — Telegram-Premium-style multi-stop background
 * that we mask through the text via background-clip. The animation
 * (`premiumGradient`) is the same one already used on the Portfolio Value
 * card, so the two headers feel related. */
.page-title--inline {
  padding: 0;
  flex-shrink: 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(
    100deg,
    #ff6ba8 0%,    /* pink */
    #ff9d6b 18%,   /* orange */
    #ffd166 36%,   /* gold */
    #5fe39a 56%,   /* green */
    #5ec1ff 74%,   /* sky blue */
    #976fff 92%    /* purple */
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  animation: premiumGradient 8s ease infinite;
}

.lb-subtitle-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 14px;
}

.page-subtitle--inline {
  padding: 0;
}

/* Inherit the same font as .page-subtitle so both halves of the row look
 * identical in size, weight, and colour. The grey is identical too — only
 * tabular-nums and right-alignment distinguish the timer visually. */
.leaderboard-refresh-hint {
  font-size: 13px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  padding: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  padding: 12px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--tg-theme-bg-color, var(--tg-bg));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.18s ease-out;
  /* On mobile when the soft keyboard opens, `position:fixed; bottom:0`
   * gets pushed up by the visual viewport collapse — looks ugly perched
   * above the keyboard. Slide the nav off-screen while any input is focused
   * (body.keyboard-open class added by app.js focus/blur listeners). */
}

body.keyboard-open .bottom-nav {
  transform: translateY(110%);
  pointer-events: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 24px;
  background: none;
  border: none;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  cursor: pointer;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--tg-accent);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* ── Leaderboard ── */
.leaderboard-list {
  padding: 0 16px 80px;
}

.lb-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(90deg, rgba(46,166,255,0.16) 0%, rgba(46,166,255,0.09) 50%, rgba(46,166,255,0.04) 100%);
  border-left: 3px solid rgba(46,166,255,0.35);
  margin-bottom: 2px;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.3s ease, border-color 0.3s ease;
}

.lb-item:first-child {
  border-radius: 12px 12px 0 0;
}

.lb-item:last-child {
  border-radius: 0 0 12px 12px;
  margin-bottom: 0;
}

.lb-item:only-child {
  border-radius: 12px;
}

.lb-item:active {
  opacity: 0.7;
}

/* Brand-new entry (under NEW_ENTRY_BADGE_SECONDS) — soft pink outline +
 * subtle inner glow so the row stands out without screaming. Animation
 * is a gentle pulse so fresh entries are easy to spot while scrolling. */
.lb-item--new {
  background: linear-gradient(90deg,
              rgba(255,180,210,0.18) 0%,
              rgba(255,180,210,0.10) 50%,
              rgba(255,180,210,0.05) 100%);
  border-left-color: rgba(255,130,190,0.70);
  box-shadow:
    inset 0 0 0 1px rgba(255,180,210,0.22),
    0 0 14px rgba(255,150,200,0.18);
  animation: lbNewPulse 3.2s ease-in-out infinite;
}

@keyframes lbNewPulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,180,210,0.20),
                        0 0 10px rgba(255,150,200,0.14); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255,180,210,0.35),
                        0 0 20px rgba(255,150,200,0.28); }
}

.lb-new-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(135deg, #ff7fbf, #ff4d94);
  border-radius: 6px;
  text-transform: uppercase;
  vertical-align: middle;
  box-shadow: 0 1px 4px rgba(255,77,148,0.4);
}

/* ── Top-3 tier backgrounds ──
 * End stops were 0.05–0.06 alpha — practically invisible at the right
 * edge, which made the row look "muddy" because the dark page bg bled
 * through. Bumped end alphas to stay near the start (≈ 0.18–0.22) so the
 * tint reads uniformly across the whole row.
 *
 * #1 also moved away from the olive `#E6B84E` end colour to a cleaner
 * champagne luxury gold (#E5C36F-ish) — same palette as the Group view's
 * gold tile, so #1 reads consistently across both surfaces. */
.lb-item[data-rank="1"] {
  /* Same warm-gold core as the Group view's gold tier (#FFD75F → #F8C446) —
   * refined yellow gold, not olive. End alpha kept ≥ 0.22 so the right edge
   * doesn't fade into dark. */
  background: linear-gradient(90deg,
    rgba(255,215,95,0.36) 0%,
    rgba(248,196,70,0.28) 50%,
    rgba(248,196,70,0.22) 100%);
  border-left: 4px solid #FFD75F;
  box-shadow:
    inset 0 1px 0 rgba(255,235,160,0.30),
    inset 0 0 0 1px rgba(255,205,80,0.22),
    0 0 12px rgba(255,205,80,0.18);
}

.lb-item[data-rank="2"] {
  background: linear-gradient(90deg,
    rgba(225,232,246,0.26) 0%,
    rgba(205,215,232,0.20) 50%,
    rgba(195,205,225,0.16) 100%);
  border-left: 4px solid #D2DCEC;
  box-shadow:
    inset 0 1px 0 rgba(240,245,255,0.22),
    inset 0 0 0 1px rgba(210,220,236,0.20),
    0 0 10px rgba(210,220,236,0.12);
}

.lb-item[data-rank="3"] {
  background: linear-gradient(90deg,
    rgba(224,151,100,0.28) 0%,
    rgba(212,135,85,0.22) 50%,
    rgba(200,118,70,0.18) 100%);
  border-left: 4px solid #D28352;
  box-shadow:
    inset 0 1px 0 rgba(245,205,170,0.20),
    inset 0 0 0 1px rgba(210,131,82,0.20),
    0 0 12px rgba(210,131,82,0.14);
}

.lb-rank {
  width: 28px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
  color: var(--tg-accent);
}

.lb-rank-1 {
  color: #F5D98B;
  text-shadow: 0 0 10px rgba(232,194,106,0.45), 0 1px 0 rgba(120,80,0,0.35);
}
.lb-rank-2 { color: #E6EDF8; text-shadow: 0 0 10px rgba(220,228,240,0.35); }
.lb-rank-3 { color: #E09460; text-shadow: 0 0 10px rgba(210,131,82,0.45); }

/* ── Tier-colored stats ── */
.lb-item[data-rank="1"] .lb-stars {
  background: linear-gradient(180deg, #F8E3A4 0%, #F5D98B 50%, #D9AF5A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 6px rgba(232,194,106,0.28));
}
.lb-item[data-rank="2"] .lb-stars { color: #E6EDF8; text-shadow: 0 0 8px rgba(220,228,240,0.22); }
.lb-item[data-rank="3"] .lb-stars { color: #E09460; text-shadow: 0 0 8px rgba(210,131,82,0.28); }

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.lb-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  /* No mix-blend-mode — `lighten` was erasing dark interior pixels of the
   * gift icon on every row (worst on tinted top-3, but visible on dark
   * default rows too once compared side-by-side). Render icons natively. */
}

.lb-info {
  flex: 1;
  min-width: 0;
}

.lb-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.lb-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lb-name .lb-new-badge {
  flex-shrink: 0;
}

.lb-gifts {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.1px;
}

.lb-value {
  text-align: right;
  flex-shrink: 0;
}

.lb-stars {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lb-ton {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1px;
}

/* Secondary text on top-3 rows: dimmer still, so the name clearly wins the hierarchy */
.lb-item[data-rank="1"] .lb-gifts,
.lb-item[data-rank="1"] .lb-ton,
.lb-item[data-rank="2"] .lb-gifts,
.lb-item[data-rank="2"] .lb-ton,
.lb-item[data-rank="3"] .lb-gifts,
.lb-item[data-rank="3"] .lb-ton {
  color: rgba(255, 255, 255, 0.32);
  font-weight: 500;
}

/* ── Settings ── */
.settings-list {
  padding: 16px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--tg-theme-secondary-bg-color, var(--tg-bg-secondary));
  margin-bottom: 2px;
}

.settings-item:first-child {
  border-radius: 12px 12px 0 0;
}

.settings-item:last-child {
  border-radius: 0 0 12px 12px;
  margin-bottom: 0;
}

.settings-link {
  cursor: pointer;
  transition: opacity 0.15s;
}

.settings-link:active {
  opacity: 0.7;
}

.settings-label {
  font-size: 14px;
  font-weight: 500;
}

/* ── Settings header with inline TON Connect button ─────────────────── */
/* "Settings" title on the left, Connect Wallet button (rendered by
 * @tonconnect/ui into #ton-connect-root) on the right — uses the empty
 * space next to the title instead of a dedicated row. */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 16px 8px;
}

.page-title--inline-tc {
  padding: 0;
  flex-shrink: 0;
}

.settings-header #ton-connect-root {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Top Contributors list on Settings page ─────────────────────────── */

.page-subtitle--section {
  margin: 20px 16px 2px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--tg-theme-text-color, #fff);
  opacity: 0.92;
}

.page-subtitle-hint {
  margin: 0 16px 10px;
  font-size: 12px;
  color: var(--tg-theme-hint-color, rgba(255,255,255,0.55));
}

.contributors-list {
  padding: 0 16px 16px;
  /* Reserve space for 3 rows so the section height is stable the moment
   * Settings is opened — prevents layout jumping as real data arrives. */
  min-height: 180px;
}

.contributors-loading, .contributors-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--tg-theme-hint-color, rgba(255,255,255,0.5));
}

/* Skeleton rows shown while the contributors list is loading. Same height
 * as real .contrib-item rows so there's no jump when real data replaces
 * the skeleton. The subtle pulse hints "still loading" without blinking.  */
.contrib-skeleton {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 2px;
  animation: contribSkeletonPulse 1.8s ease-in-out infinite;
}
.contrib-skeleton:first-child { border-radius: 12px 12px 0 0; }
.contrib-skeleton:last-child  { border-radius: 0 0 12px 12px; margin-bottom: 0; }
.contrib-skeleton-rank, .contrib-skeleton-avatar, .contrib-skeleton-text {
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
}
.contrib-skeleton-rank { width: 18px; height: 14px; flex-shrink: 0; }
.contrib-skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.contrib-skeleton-text { flex: 1; height: 14px; }

@keyframes contribSkeletonPulse {
  0%, 100% { opacity: 0.65; }
  50%      { opacity: 1.0;  }
}

.contrib-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--tg-theme-secondary-bg-color, rgba(255,255,255,0.04));
  margin-bottom: 2px;
}
.contrib-item:first-child { border-radius: 12px 12px 0 0; }
.contrib-item:last-child  { border-radius: 0 0 12px 12px; margin-bottom: 0; }
.contrib-item:only-child  { border-radius: 12px; }

.contrib-item--tappable {
  cursor: pointer;
  transition: opacity 0.15s;
}
.contrib-item--tappable:active { opacity: 0.7; }

.contrib-rank {
  width: 26px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--tg-theme-hint-color, rgba(255,255,255,0.55));
  flex-shrink: 0;
}
.contrib-rank--top {
  font-size: 18px;
}

.contrib-avatar-img, .contrib-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.contrib-info {
  flex: 1;
  min-width: 0;
}
.contrib-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-theme-text-color, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contrib-sub {
  font-size: 11px;
  color: var(--tg-theme-hint-color, rgba(255,255,255,0.55));
  margin-top: 2px;
}

.settings-value {
  font-size: 14px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

.settings-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--tg-theme-text-color, var(--tg-text));
  outline: none;
}

/* ── User Collections ── */
.collection-card {
  background: linear-gradient(135deg, rgba(151, 111, 255, 0.15), rgba(107, 147, 255, 0.10));
  border: 1px solid rgba(151, 111, 255, 0.15);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  position: relative;
}

.collection-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.collection-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.collection-gifts {
  font-size: 11px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

.collection-count {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--tg-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}

/* ── Empty state ── */
.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  font-size: 15px;
}

/* ── Regular (non-collectible) gifts section ── */
.regular-section {
  padding-top: 4px;
  margin-bottom: 32px;
}

.regular-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 20px 10px;
}

.regular-section-sub {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.48);
  text-transform: none;
  letter-spacing: 0.2px;
}

.regular-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Single column mirrors the collectibles list — at typical phone widths the
 * old 2-column grid squeezed each cell to ~140 px, which forced gift titles
 * to truncate to "Li…" and the count×price line to wrap onto two lines. */
.regular-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  min-width: 0;
}

.regular-item-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.regular-item-clickable:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.07);
}

.regular-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.regular-thumb--emoji {
  object-fit: contain;
  padding: 4px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(46, 166, 255, 0.10));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-list-thumb--emoji {
  object-fit: contain;
  padding: 4px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(46, 166, 255, 0.10));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-list-item-clickable {
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-list-item-clickable:active {
  background: rgba(255, 255, 255, 0.06);
}

.regular-emoji {
  font-size: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.regular-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.regular-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

/* "LIMITED" pill — shown next to the title for upgradeable LE StarGifts */
.limited-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffd166;
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 4px;
  vertical-align: middle;
  text-transform: uppercase;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.regular-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
  /* Keep "32 × 41,000 ⭐" on one row — it should never wrap */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.regular-right {
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.regular-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

/* ── Modal Overlay ──
 * Lighter dim + stronger blur so the underlying portfolio is faintly
 * visible behind the semi-transparent modal card. Together they read
 * as "same surface, peeled forward" rather than "solid black sheet". */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  overscroll-behavior: contain;
  touch-action: none;
}

body.modal-open { overflow: hidden; }

.modal-overlay.hidden {
  display: none !important;
}

/* ── Modal Card (slides up from bottom) ── */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

.modal-card {
  width: 100%;
  max-width: 480px;
  /* Semi-transparent dark surface — combined with the overlay's backdrop-blur
   * the underlying page peeks through. ~85 % alpha keeps text fully legible.
   * Local backdrop-filter handles iOS Safari quirk where overlay blur doesn't
   * propagate to the card's compositing layer. */
  background: rgba(20, 22, 30, 0.78);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  backdrop-filter: blur(28px) saturate(140%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px 20px 0 0;
  padding: 0 16px 20px;
  animation: slideUp 0.25s ease-out;
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.modal-card.closing {
  animation: slideDown 0.2s ease-in forwards;
}

/* ── Modal Card themed by value tier ──
 * Bottom half of each gradient was solid `--tg-theme-bg-color`; replaced
 * with the semi-transparent surface used on the default modal so themed
 * cards blend visually with the blurred overlay instead of looking
 * abruptly opaque at the fold line. */
.modal-card[data-tier="gold"] {
  background: linear-gradient(180deg, rgba(255,227,104,0.38) 0%, rgba(246,201,30,0.22) 25%, rgba(20,22,30,0.78) 55%);
  border-top: 2px solid #FFC940;
  box-shadow: inset 0 1px 0 rgba(255,243,176,0.38), 0 0 22px rgba(255,201,64,0.18);
}

.modal-card[data-tier="purple"] {
  background: linear-gradient(180deg, rgba(151,111,255,0.33) 0%, rgba(151,111,255,0.17) 25%, rgba(20,22,30,0.78) 55%);
  border-top: 2px solid rgba(151,111,255,0.60);
}

.modal-card[data-tier="blue"] {
  background: linear-gradient(180deg, rgba(46,166,255,0.27) 0%, rgba(46,166,255,0.15) 25%, rgba(20,22,30,0.78) 55%);
  border-top: 2px solid rgba(46,166,255,0.50);
}

.modal-card[data-tier="common"] {
  background: linear-gradient(180deg, rgba(106,179,243,0.19) 0%, rgba(106,179,243,0.11) 25%, rgba(20,22,30,0.78) 55%);
  border-top: 2px solid rgba(106,179,243,0.40);
}

/* ── Modal stat cards themed ── */
.modal-card[data-tier="gold"] .modal-stat {
  background: linear-gradient(135deg, rgba(255,184,0,0.32), rgba(229,161,0,0.18));
  border: 1px solid rgba(255,202,40,0.50);
}

.modal-card[data-tier="purple"] .modal-stat {
  background: linear-gradient(135deg, rgba(151,111,255,0.33), rgba(151,111,255,0.17));
  border: 1px solid rgba(151,111,255,0.40);
}

.modal-card[data-tier="blue"] .modal-stat {
  background: linear-gradient(135deg, rgba(46,166,255,0.27), rgba(46,166,255,0.15));
  border: 1px solid rgba(46,166,255,0.35);
}

.modal-card[data-tier="common"] .modal-stat {
  background: linear-gradient(135deg, rgba(106,179,243,0.19), rgba(106,179,243,0.11));
  border: 1px solid rgba(106,179,243,0.30);
}

/* ── Modal Close Button ── */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  color: #ffffff;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  z-index: 2;
}

.modal-close:active {
  opacity: 0.6;
}

/* ── Modal Hero Image ── */
.modal-hero {
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
}

.modal-hero-img {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  object-fit: cover;
  background: transparent;
}

/* ── Modal Collection & Model ── */
.modal-collection {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}

.modal-model {
  text-align: center;
  font-size: 13px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  margin-bottom: 10px;
}

/* ── Modal Body ── */
.modal-body {
  padding: 10px 0;
}

.modal-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-stat {
  background: var(--tg-theme-secondary-bg-color, var(--tg-bg-secondary));
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.modal-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.modal-stat-value {
  font-size: 16px;
  font-weight: 700;
}

.modal-usd {
  text-align: center;
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
}

.modal-card[data-tier="gold"] .modal-usd { color: var(--gold-bright); text-shadow: 0 0 18px rgba(255,184,0,0.7); }
.modal-card[data-tier="purple"] .modal-usd { color: var(--premium-purple); }
.modal-card[data-tier="blue"] .modal-usd { color: var(--tg-accent); }
.modal-card[data-tier="common"] .modal-usd { color: var(--tg-theme-text-color, var(--tg-text)); }

/* ── Modal Button ── */
.modal-btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-theme-button-text-color, #ffffff);
  background: var(--tg-theme-button-color, var(--tg-button));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
}

.modal-btn:active {
  opacity: 0.8;
}

/* ── Modal Gift Items List ── */
.modal-gift-items {
  max-height: 200px;
  overflow-y: auto;
  border-radius: 14px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-gift-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 2px;
  border-radius: 0;
  transition: all 0.15s;
}

.modal-card[data-tier="gold"] .modal-gift-item {
  background: linear-gradient(90deg, rgba(255,184,0,0.32) 0%, rgba(229,161,0,0.18) 50%, rgba(255,184,0,0.08) 100%);
  border-left: 3px solid var(--gold);
}
.modal-card[data-tier="purple"] .modal-gift-item {
  background: linear-gradient(90deg, rgba(151,111,255,0.33) 0%, rgba(151,111,255,0.17) 50%, rgba(151,111,255,0.10) 100%);
  border-left: 3px solid var(--premium-purple);
}
.modal-card[data-tier="blue"] .modal-gift-item {
  background: linear-gradient(90deg, rgba(46,166,255,0.27) 0%, rgba(46,166,255,0.15) 50%, rgba(46,166,255,0.09) 100%);
  border-left: 3px solid var(--tg-accent);
}
.modal-card[data-tier="common"] .modal-gift-item {
  background: linear-gradient(90deg, rgba(106,179,243,0.19) 0%, rgba(106,179,243,0.11) 50%, rgba(106,179,243,0.07) 100%);
  border-left: 3px solid rgba(106,179,243,0.40);
}

.modal-gift-item:first-child { border-radius: 12px 12px 0 0; }
.modal-gift-item:last-child { border-radius: 0 0 12px 12px; margin-bottom: 0; }
.modal-gift-item:only-child { border-radius: 12px; }
.modal-gift-item:active { opacity: 0.7; transform: scale(0.98); }

.mgi-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--tg-accent);
  min-width: 70px;
}

.mgi-backdrop {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  padding-left: 4px;
}

.mgi-stars {
  font-size: 13px;
  font-weight: 700;
  margin-right: 6px;
}

.mgi-arrow {
  font-size: 18px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  opacity: 0.5;
}

/* ── Fullscreen modal (Total view) ── */
.modal-fullscreen {
  max-height: 90vh;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-fullscreen .modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.total-modal-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, var(--tg-hint));
  text-align: center;
  padding: 12px 0 8px;
  flex-shrink: 0;
}

/* ── Portfolio value history chart (inside the breakdown modal) ──
 * Sits above the Unique / Regular rows. Fixed height so the modal
 * doesn't jump when data lands; the SVG scales width-to-parent. */
.pv-history {
  margin: 4px 0 14px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
}
.pv-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.pv-history-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pv-history-ranges {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  padding: 3px;
  border-radius: 999px;
}
.pv-range-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.pv-range-btn:active { background: rgba(255,255,255,0.06); }
.pv-range-btn--active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.pv-history-body {
  position: relative;
  min-height: 180px;
}
.pv-history-loading,
.pv-history-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
}
.pv-history-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.pv-history-current {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.pv-history-delta {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pv-history-delta--up   { color: #3ecb7a; }
.pv-history-delta--down { color: #ff5971; }
.pv-history-svg {
  width: 100%;
  height: 160px;
  display: block;
}
.pv-history-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.total-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.total-footer {
  flex-shrink: 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.total-footer-row {
  display: flex;
  justify-content: space-around;
  font-size: 15px;
  font-weight: 700;
  color: var(--tg-accent);
}

/* ── Modal Collection List ── */
.modal-collection-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 16px;
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, var(--tg-bg-secondary));
}

.modal-list-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-list-item:last-child {
  border-bottom: none;
}

.modal-list-thumb {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 10px;
}

.modal-list-emoji {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.05);
  line-height: 1;
}

.modal-list-info {
  flex: 1;
  min-width: 0;
}

.modal-list-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-list-sub {
  font-size: 11px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}

.modal-list-value {
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
}

.modal-list-stars {
  font-size: 13px;
  font-weight: 600;
}

.modal-list-ton {
  font-size: 11px;
  color: var(--tg-theme-hint-color, var(--tg-hint));
}


/* ── Portfolio (Profit) tab ─────────────────────────────────────────────── */
/* Summary card mirrors the Home totals-card footprint (same padding, same
 * rounded corners) so the Portfolio tab reads as a sibling surface, not an
 * alien layout. Purchase → Floor is a horizontal flex row; on very narrow
 * widths (iPhone SE, 320px) the arrow gets pushed to a new line — we keep
 * both sides at min-width:0 so text-overflow:ellipsis kicks in instead of
 * forcing horizontal scroll. */
.portfolio-card {
  /* Deeper, richer blue gradient — three stops with a darker middle so the
   * card has some dimensionality instead of a flat wash. Sits well against
   * the app's dark background without bleeding into the tiles below. */
  background:
    radial-gradient(circle at 15% 0%, rgba(130, 190, 255, 0.20) 0%, transparent 55%),
    radial-gradient(circle at 100% 120%, rgba(110, 80, 255, 0.22) 0%, transparent 60%),
    linear-gradient(135deg, #1f3b85 0%, #203a7d 30%, #2b2e70 60%, #3a2a7c 100%);
  border: 1px solid rgba(120, 170, 255, 0.28);
  border-radius: 18px;
  padding: 16px 18px 14px;
  margin: 0 16px 16px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 24px -8px rgba(70, 110, 240, 0.35),
    0 2px 10px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
/* Subtle highlight sweep at the top edge — reads as glass-like sheen. */
.portfolio-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 60%;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 18px 18px 0 0;
}
.portfolio-title--clickable {
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.portfolio-title--clickable:active { opacity: 0.7; }
.portfolio-title {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.portfolio-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portfolio-sub {
  flex-shrink: 0;
  opacity: 0.85;
}
.portfolio-sub-arrow {
  flex-shrink: 0;
  font-size: 10px;
  opacity: 0.7;
}
.portfolio-compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.portfolio-side {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}
.portfolio-side-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.portfolio-side-value {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portfolio-arrow {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.portfolio-secondary {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}
.portfolio-sec-chip {
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.portfolio-sec-chip .ps-label {
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.portfolio-star { color: #f5c33f; }
.portfolio-ton {
  /* Inline SVG of the TON brand mark — sized to the surrounding text
   * height (1.2em square) with a touch of negative vertical align so it
   * sits visually centred on the baseline of the digits next to it. */
  width: 1.2em;
  height: 1.2em;
  display: inline-block;
  vertical-align: -0.22em;
  margin-left: 2px;
  filter: drop-shadow(0 0 4px rgba(0, 152, 234, 0.3));
  flex-shrink: 0;
}
.portfolio-profit {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.portfolio-profit-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.portfolio-profit-value {
  font-size: 18px;
  font-weight: 800;
}
.portfolio-profit-pct {
  font-size: 13px;
  font-weight: 700;
}
.portfolio-profit--up .portfolio-profit-value,
.portfolio-profit--up .portfolio-profit-pct {
  color: #3ecb7a;
}
.portfolio-profit--down .portfolio-profit-value,
.portfolio-profit--down .portfolio-profit-pct {
  color: #ff5971;
}

/* ── Self-minted ratio chip on Portfolio card ──
 * Compact row below the PnL line showing "🎯 99% self-minted (3 535 / 3 536)".
 * Explains why PnL is gated: only self-minted gifts have a known purchase
 * basis. Transferred / marketplace gifts contribute 0 on both sides until
 * the user enters a custom price override. */
.portfolio-self-minted {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  letter-spacing: 0.02em;
}
.portfolio-self-minted[hidden] { display: none; }
.portfolio-self-minted .psm-icon { font-size: 13px; }
.portfolio-self-minted .psm-pct {
  font-weight: 700;
  color: #fff;
}
.portfolio-self-minted .psm-label { opacity: 0.75; }
.portfolio-self-minted .psm-count {
  opacity: 0.55;
  font-size: 11px;
  margin-left: 2px;
}
/* Clickable variant — shown only on the user's own portfolio. Subtle
 * hover/active affordance so it reads as "tap for details" without
 * competing with the PnL value visually. */
.portfolio-self-minted--clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  border-radius: 8px;
  padding-left: 10px;
  padding-right: 10px;
}
.portfolio-self-minted--clickable::after {
  content: '\203A';
  opacity: 0.45;
  font-size: 14px;
  margin-left: 2px;
}
.portfolio-self-minted--clickable:active {
  background: rgba(255,255,255,0.05);
}

/* ── Unpriced-gifts sheet ──
 * Opens from the self-minted chip. Lists collections whose non-self-minted
 * gifts lack a purchase-price override, grouped so one tap sets price for
 * the whole collection. Reuses the .pf-sheet bottom-sheet chrome. */
.pf-unpriced-sheet-inner {
  padding: 18px 16px 20px;
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pf-unpriced-body { position: relative; }
.pf-unpriced-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  padding-right: 32px;
}
.pf-unpriced-icon { margin-right: 2px; }
.pf-unpriced-sub {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255,255,255,0.62);
  padding-right: 32px;
}
.pf-unpriced-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.pf-unpriced-empty {
  padding: 20px 8px;
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
}
.pf-unpriced-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.pf-unpriced-row:active { background: rgba(255,255,255,0.09); }
.pf-unpriced-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
}
.pf-unpriced-meta { flex: 1; min-width: 0; }
.pf-unpriced-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-unpriced-override {
  margin-top: 2px;
  font-size: 11px;
  color: #e3d6ff;
  opacity: 0.85;
}
.pf-unpriced-badge {
  min-width: 28px;
  padding: 3px 8px;
  background: rgba(255, 160, 90, 0.22);
  color: #ffcca2;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.pf-unpriced-badge--done {
  background: rgba(70, 200, 120, 0.24);
  color: #b6f4cf;
}
.pf-unpriced-footnote {
  margin-top: 14px;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.4;
  text-align: center;
}

/* Mini chip on model tiles: "🎯 8/10" when partial, "🎯" when all self. */
.pf-tile-sm-chip {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.45);
  border-radius: 8px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.pf-tile-sm-chip--all {
  background: rgba(70, 200, 120, 0.28);
  color: #b6f4cf;
}
.pf-tile-sm-chip--override {
  background: rgba(155, 120, 255, 0.32);
  color: #e3d6ff;
}

/* Per-gift 🎯 badge in the detail modal's item list — small inline
 * icon after the gift number so users see which NFTs they minted. */
.pf-self-badge {
  display: inline-block;
  font-size: 11px;
  margin-left: 3px;
  opacity: 0.85;
  vertical-align: baseline;
}
.pf-sheet-item--self .pf-sheet-item-num {
  color: #b6f4cf;
}

/* ── Per-gift list: 2-column grid of compact tiles ──
 * Mirrors the Group view's 3-col .lines-grid layout but uses 2 columns so
 * each tile has horizontal room for the purchase → floor numbers plus a
 * profit badge. Tiles inherit the .group-card visual vocabulary (gradient
 * bg, rounded corners, scale-on-tap) so the two tabs feel like one family.
 */
.portfolio-list {
  padding: 0 16px 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.pf-tile {
  background: linear-gradient(135deg, rgba(107, 147, 255, 0.10) 0%,
                                      rgba(151, 111, 255, 0.06) 100%);
  border: 1px solid rgba(151, 111, 255, 0.12);
  border-radius: 12px;
  padding: 8px 8px 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s;
}
.pf-tile:active { transform: scale(0.97); }
/* Profit / loss tint — soft left-border accent + matching background wash
 * so profitable rows glow green and losers read slightly red without
 * overwhelming the tile. Mirrors .line-item[data-tier] conventions. */
.pf-tile--up {
  background: linear-gradient(135deg, rgba(62, 203, 122, 0.16) 0%,
                                      rgba(62, 203, 122, 0.06) 100%);
  border-color: rgba(62, 203, 122, 0.22);
}
.pf-tile--down {
  background: linear-gradient(135deg, rgba(255, 89, 113, 0.15) 0%,
                                      rgba(255, 89, 113, 0.05) 100%);
  border-color: rgba(255, 89, 113, 0.22);
}
.pf-tile-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  margin: 0 auto 6px;
  display: block;
  background: rgba(255, 255, 255, 0.04);
}
.pf-tile-name {
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.1px;
  margin-bottom: 4px;
}
.pf-tile-prices {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-tile-prices-arrow {
  color: rgba(255, 255, 255, 0.35);
  font-size: 9px;
}
.pf-tile-profit {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.pf-tile-profit-pct {
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}
.pf-tile--up .pf-tile-profit,
.pf-tile--up .pf-tile-profit-pct { color: #3ecb7a; }
.pf-tile--down .pf-tile-profit,
.pf-tile--down .pf-tile-profit-pct { color: #ff5971; }

/* Unpriced tiles: nothing computable (no self-minted, no user override).
 * Grey background + desaturated thumb signals "we don't know the cost
 * basis, so this doesn't feed into PnL yet." Clicking the self-minted
 * chip or the tile opens the price-input flow to fix that. */
.pf-tile--unpriced {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%,
                                      rgba(255, 255, 255, 0.015) 100%);
  border-color: rgba(255, 255, 255, 0.08);
}
.pf-tile--unpriced .pf-tile-thumb {
  filter: grayscale(0.9) opacity(0.55);
}
.pf-tile--unpriced .pf-tile-name { color: rgba(255, 255, 255, 0.75); }
.pf-tile--unpriced .pf-tile-profit,
.pf-tile--unpriced .pf-tile-profit-pct {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: lowercase;
}

.portfolio-footnote {
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 10px;
  padding: 0 20px 80px;
  line-height: 1.4;
}

/* Portfolio tab — larger, more tappable sort buttons (default .sort-btn is
 * 5px × 9px which reads too small next to the big summary card). We scope
 * via #page-portfolio so Home/Leaderboard sort buttons keep their compact
 * style. */
#page-portfolio .sort-btn {
  padding: 7px 14px;
  font-size: 12px;
  min-width: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#page-portfolio .sort-btn .dir-arrow {
  font-size: 9px;
  opacity: 0.85;
}

/* Portfolio drilldown bar */
.pf-drilldown-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 8px;
}
.pf-back-btn,
.pf-override-all-btn {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #fff;
  cursor: pointer;
}
.pf-override-all-btn {
  background: rgba(46,166,255,0.18);
  border-color: rgba(46,166,255,0.35);
  color: #6ab3f3;
}
.pf-back-btn:active,
.pf-override-all-btn:active { transform: scale(0.96); }
.pf-drilldown-spacer { width: 90px; }
.pf-drilldown-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-collection-tile {
  position: relative;
}
.pf-tile-chev {
  position: absolute;
  top: 8px;
  right: 10px;
  color: rgba(255,255,255,0.4);
  font-size: 18px;
  font-weight: 700;
}

/* Gift detail sheet overlay */
.pf-sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.pf-sheet-overlay.hidden { display: none; }
.pf-sheet {
  background: #1b2736;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 12px);
  animation: pfSheetUp 0.22s ease-out;
}
@keyframes pfSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pf-sheet-body { padding: 10px 18px 18px; position: relative; }
.pf-sheet-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.06);
  border: none;
  color: #fff;
  font-size: 18px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
.pf-sheet-hero {
  display: block;
  width: 120px; height: 120px;
  margin: 10px auto 12px;
  border-radius: 20px;
  object-fit: cover;
}
.pf-sheet-title {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}
.pf-sheet-count {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 14px;
}
.pf-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.pf-sheet-cell {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.pf-sheet-lbl {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.pf-sheet-val {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.pf-sheet--up { color: #3ecb7a !important; }
.pf-sheet--down { color: #ff5971 !important; }
.pf-custom-pill {
  font-size: 9px;
  background: rgba(46,166,255,0.25);
  color: #6ab3f3;
  padding: 2px 5px;
  border-radius: 5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-left: 4px;
  vertical-align: middle;
}
.pf-sheet-action {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
}
.pf-sheet-action:active { transform: scale(0.98); }
.pf-sheet-action--primary {
  background: var(--tg-accent, #2ea6ff);
  border-color: var(--tg-accent, #2ea6ff);
  color: #fff;
}

/* Blue variant of stats-row button — specifically for the Portfolio
 * shortcut on user profiles (self + viewed). Purple-family siblings
 * stay on their gradient; this one pops accent-blue so users can
 * immediately see "that\'s the PnL surface". */
.stats-row .stat-item--portfolio {
  background: linear-gradient(135deg, rgba(46, 166, 255, 0.20) 0%,
                                      rgba(46, 166, 255, 0.12) 100%);
  border-color: rgba(46, 166, 255, 0.35);
}
.stats-row .stat-item--portfolio:active {
  background: linear-gradient(135deg, rgba(46, 166, 255, 0.30) 0%,
                                      rgba(46, 166, 255, 0.18) 100%);
}
.stats-row .stat-item--portfolio .stat-label {
  color: rgba(46, 166, 255, 0.85);
}

/* Per-gift PnL clarifier: small tinted note under the totals grid */
.pf-sheet-pergift {
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin: -4px 0 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}
.pf-sheet-pergift b { font-weight: 700; }
.pf-sheet-pergift.pf-sheet--up b { color: #3ecb7a; }
.pf-sheet-pergift.pf-sheet--down b { color: #ff5971; }

/* Individual-gifts list inside the detail sheet — same visual vocabulary
 * as the Home-page modal-gift-items list: numbered rows, backdrop name,
 * per-item stars, chevron. */
.pf-sheet-items {
  margin: 4px 0 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  overflow: hidden;
}
.pf-sheet-items-title {
  padding: 8px 12px 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pf-sheet-item {
  display: grid;
  grid-template-columns: 60px 1fr auto 14px;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: #fff;
  text-decoration: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.pf-sheet-item:active { background: rgba(255,255,255,0.05); }
.pf-sheet-item-num { color: var(--tg-accent, #6ab3f3); font-weight: 700; font-size: 12px; }
.pf-sheet-item-bd { color: rgba(255,255,255,0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-sheet-item-stars { color: #f5c33f; font-weight: 600; font-size: 12px; }
.pf-sheet-item-arrow { color: rgba(255,255,255,0.35); font-weight: 700; }

/* Count pill for model tiles — shows how many individual gifts the
 * user owns for that (collection, model) combo. Top-right corner like
 * the Group view's .group-badge. */
.pf-tile-count {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(46, 166, 255, 0.28);
  color: #6ab3f3;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  min-width: 26px;
  text-align: center;
  letter-spacing: 0.02em;
  z-index: 2;
  pointer-events: none;
}
/* Tint the badge for up/down tiles so it reads in harmony */
.pf-tile--up .pf-tile-count {
  background: rgba(62, 203, 122, 0.25);
  color: #3ecb7a;
}
.pf-tile--down .pf-tile-count {
  background: rgba(255, 89, 113, 0.25);
  color: #ff5971;
}

/* Price-input modal (Stars ⇄ TON) */
.pf-price-sheet { max-width: 420px; }
.pf-price-body { padding: 18px 20px 20px; position: relative; }
.pf-price-title { text-align: center; font-size: 15px; font-weight: 700; color: #fff; padding: 0 24px 14px; line-height: 1.3; }
.pf-price-unit-toggle { display: flex; gap: 6px; margin-bottom: 12px; padding: 4px; background: rgba(255,255,255,0.04); border-radius: 10px; }
.pf-unit-btn { flex: 1; padding: 8px 10px; font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.55); background: transparent; border: none; border-radius: 8px; cursor: pointer; }
.pf-unit-btn.active { background: rgba(46, 166, 255, 0.22); color: #6ab3f3; }
.pf-price-input-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 10px 14px; margin-bottom: 6px; }
.pf-price-input { flex: 1; background: transparent; border: none; outline: none; color: #fff; font-size: 20px; font-weight: 700; min-width: 0; font-family: inherit; }
.pf-price-input::placeholder { color: rgba(255,255,255,0.25); }
.pf-price-unit-suffix { color: rgba(255,255,255,0.55); font-weight: 700; font-size: 14px; }
.pf-price-preview { text-align: center; font-size: 12px; color: rgba(255,255,255,0.6); min-height: 16px; padding: 6px 2px 14px; }
.pf-price-preview--hint { color: rgba(255,255,255,0.35); font-style: italic; }
.pf-price-actions { display: flex; gap: 8px; }
.pf-price-actions .pf-sheet-action { margin-top: 0; flex: 1; }

/* Currency cycle button — small caret hint next to the USD/TON/STARS label */
.portfolio-ccy-toggle { position: relative; padding: 2px 14px 2px 6px; border-radius: 6px; transition: background 0.15s; }
.portfolio-ccy-toggle:active { background: rgba(255,255,255,0.05); }
.portfolio-ccy-toggle::after { content: "▾"; position: absolute; right: 2px; top: 50%; transform: translateY(-45%); font-size: 9px; color: rgba(255,255,255,0.5); }

/* Global currency picker (opens from Settings) */
.ccy-picker-sheet { max-width: 420px; }
.ccy-picker-body { padding: 18px 20px 20px; }
.ccy-picker-title {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.7);
}
.ccy-picker-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ccy-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.ccy-opt:active { transform: scale(0.98); }
.ccy-opt.active {
  border-color: var(--tg-accent, #2ea6ff);
  background: rgba(46,166,255,0.14);
  color: var(--tg-accent, #2ea6ff);
}
.ccy-opt-sym {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
}
.ccy-opt.active .ccy-opt-sym {
  background: rgba(46,166,255,0.25);
  color: var(--tg-accent, #2ea6ff);
}

/* Primary-highlight variant for Settings items — Currency + Language.
 * Accent-tinted gradient + blue left-bar + bolder text so these sit
 * visually "above the fold" of the settings list. */
.settings-item--primary {
  /* Pink highlight — Currency + Language are the main personalization
   * settings, we want them to pop above the rest of the list. */
  background: linear-gradient(90deg,
    rgba(255, 90, 200, 0.20) 0%,
    rgba(255, 90, 200, 0.10) 60%,
    rgba(255, 90, 200, 0.04) 100%);
  border: 1px solid rgba(255, 90, 200, 0.35);
  border-left: 4px solid #ff5ac8;
  padding-left: 12px;
  box-shadow: 0 2px 10px rgba(255, 90, 200, 0.12);
}
.settings-item--primary .settings-label {
  color: #fff;
  font-weight: 700;
}
.settings-item--primary .settings-value {
  color: #ff80d5;
  font-weight: 700;
}
.settings-item--primary:active { transform: scale(0.99); }
/* ══ END Portfolio ══ */


/* ─── Mobile tap reliability (iOS / Telegram WebView) ─── */
/* tap-target-fix: disable tap-highlight flash + enable fast tap.
 * touch-action: manipulation lets the browser skip the 300ms double-tap
 * detection, so single tap fires immediately. */
#settings-currency-row,
#settings-language-row,
#portfolio-title-row {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 90, 200, 0.2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
