/* ════════════════════════════════════════════════════════════════════
   Asadram — профиль, подарки, настройки

   Шапка профиля наконец держится: панель — flex-колонка, шапка стоит
   отдельным блоком с flex:none, а прокручивается только тело.
   position:sticky здесь не используется вовсе — именно он и не работал,
   когда у родителя стоял overflow:hidden.
   ════════════════════════════════════════════════════════════════════ */

.profile-panel {
  position: fixed;
  inset: 0;
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  will-change: transform;
}
.profile-panel.is-open { transform: none; }

@media (min-width: 901px) {
  .profile-panel {
    left: auto;
    width: 396px;
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
  }
}

/* ── Шапка: прибита сверху ──────────────────────────────────────── */
.profile-head {
  flex: none;
  position: relative;
  padding-top: var(--safe-top);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.profile-cover {
  position: relative;
  height: 132px;
  background: var(--accent-soft);
  background-size: cover;
  background-position: center;
}
.profile-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%,
              color-mix(in srgb, var(--bg) 88%, transparent));
}

.profile-bar {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
}
.profile-bar .icon-btn { color: #fff; background: rgba(0, 0, 0, .28); }
.profile-bar .icon-btn:hover { background: rgba(0, 0, 0, .42); }

.profile-identity {
  position: relative;
  z-index: 1;
  margin-top: -46px;
  padding: 0 var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  text-align: center;
}
.profile-identity .avatar { box-shadow: 0 0 0 4px var(--bg), var(--shadow-md); }

.profile-name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -.015em;
}
.profile-handle { font-size: var(--text-sm); color: var(--fg-muted); }
.profile-status { font-size: var(--text-sm); color: var(--fg-muted); }
.profile-status.is-online { color: var(--mint-600); font-weight: 600; }
[data-theme="dark"] .profile-status.is-online { color: var(--mint-500); }

.profile-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  width: 100%;
  max-width: 340px;
}
.profile-actions .btn { flex: 1; height: 40px; padding: 0 var(--sp-3); font-size: var(--text-sm); }

/* ── Тело: прокручивается только оно ────────────────────────────── */
.profile-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + var(--sp-6));
}

/* ── Статистика ─────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: var(--sp-4) var(--sp-4) 0;
  padding: 1px;
  background: var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stat {
  padding: var(--sp-3) var(--sp-2);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.stat:hover { background: var(--bg-hover); }
.stat .value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.stat .caption { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 2px; }

/* ── Блоки информации ───────────────────────────────────────────── */
.info-block { margin: var(--sp-4) var(--sp-4) 0; }
.info-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--sp-2);
}
.info-card {
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  overflow: hidden;
}
.info-line {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  transition: background var(--dur-fast) var(--ease-out);
}
.info-line:last-child { border-bottom: none; }
.info-line[role="button"] { cursor: pointer; }
.info-line[role="button"]:hover { background: var(--bg-hover); }
.info-line .ico { color: var(--fg-muted); }
.info-line .body { flex: 1; min-width: 0; }
.info-line .label { font-size: var(--text-xs); color: var(--fg-muted); margin: 0; font-weight: 500; }
.info-line .value { font-size: var(--text-base); overflow-wrap: anywhere; }
.info-line .trail { flex: none; color: var(--fg-faint); font-size: var(--text-sm); }

/* День рождения — с обратным отсчётом, а не просто датой */
.birthday-line .cake { font-size: 1.35rem; }
.birthday-line.is-today {
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--gold-500) 20%, transparent), transparent);
}
.birthday-countdown {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gold-500);
}

/* ════════════════════════════════════════════════════════════════════
   Вкладки: Подарки · Медиа · Файлы · Голосовые · Ссылки
   ════════════════════════════════════════════════════════════════════ */
.tabs {
  position: relative;
  display: flex;
  gap: var(--sp-1);
  margin-top: var(--sp-5);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-muted);
  white-space: nowrap;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab.is-active { color: var(--accent); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--sp-2);
  right: var(--sp-2);
  bottom: -1px;
  height: 2.5px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}
.tab .count {
  margin-left: 4px;
  font-size: var(--text-xs);
  opacity: .6;
  font-variant-numeric: tabular-nums;
}

.tab-panel { padding: var(--sp-4); min-height: 180px; }

/* ── Коллекция подарков ─────────────────────────────────────────── */
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--sp-2);
}

.gift-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-2) var(--sp-2);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-fast) var(--ease-out);
}
.gift-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.gift-tile:active { transform: scale(.97); }
.gift-tile img { width: 58px; height: 58px; object-fit: contain; }
.gift-tile .emoji { font-size: 2.6rem; line-height: 1; }
.gift-tile .price {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gold-500);
  font-variant-numeric: tabular-nums;
}

/* Свечение по редкости — легендарные видно сразу */
.gift-tile[data-rarity="rare"]::before,
.gift-tile[data-rarity="epic"]::before,
.gift-tile[data-rarity="legendary"]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
.gift-tile[data-rarity="rare"]::before { box-shadow: inset 0 0 0 1.5px var(--rarity-rare); }
.gift-tile[data-rarity="epic"]::before { box-shadow: inset 0 0 0 1.5px var(--rarity-epic); }
.gift-tile[data-rarity="legendary"]::before {
  box-shadow: inset 0 0 0 2px var(--rarity-legendary);
  background: radial-gradient(90% 70% at 50% 0%,
    color-mix(in srgb, var(--gold-500) 17%, transparent), transparent 65%);
}

/* Карточка подарка: кто, когда, сколько стоил */
.gift-detail { text-align: center; padding: var(--sp-2) 0 0; }
.gift-detail .hero {
  width: 152px;
  height: 152px;
  margin: 0 auto var(--sp-3);
  object-fit: contain;
  animation: gift-float 3.4s var(--ease-in-out) infinite;
}
.gift-detail .hero-emoji { font-size: 6rem; line-height: 1; margin-bottom: var(--sp-3); }
.gift-detail .name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.gift-detail .rarity-tag {
  display: inline-block;
  margin-top: var(--sp-1);
  padding: 2px var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.gift-detail[data-rarity="common"] .rarity-tag { background: color-mix(in srgb, var(--rarity-common) 20%, transparent); color: var(--rarity-common); }
.gift-detail[data-rarity="rare"] .rarity-tag { background: color-mix(in srgb, var(--rarity-rare) 20%, transparent); color: var(--rarity-rare); }
.gift-detail[data-rarity="epic"] .rarity-tag { background: color-mix(in srgb, var(--rarity-epic) 20%, transparent); color: var(--rarity-epic); }
.gift-detail[data-rarity="legendary"] .rarity-tag { background: color-mix(in srgb, var(--rarity-legendary) 22%, transparent); color: var(--gold-500); }

.gift-detail .rows {
  margin-top: var(--sp-4);
  text-align: left;
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  overflow: hidden;
}
.gift-detail .rows .info-line { background: transparent; }

/* ── Сетка медиа ────────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.media-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-xs);
  overflow: hidden;
  background: var(--bg-input);
  cursor: zoom-in;
}
.media-cell img, .media-cell video { width: 100%; height: 100%; object-fit: cover; }
.media-cell .play-mark {
  position: absolute;
  right: 5px;
  bottom: 5px;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6));
}

.file-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.file-row:last-child { border-bottom: none; }
.file-row .glyph {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.file-row .meta { flex: 1; min-width: 0; }
.file-row .fname { font-size: var(--text-sm); font-weight: 600; }
.file-row .fsub { font-size: var(--text-xs); color: var(--fg-muted); }

/* ════════════════════════════════════════════════════════════════════
   Настройки
   ════════════════════════════════════════════════════════════════════ */
.settings-group { margin: var(--sp-5) var(--sp-4) 0; }

.setting-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.setting-row:first-of-type { border-radius: var(--r-md) var(--r-md) 0 0; }
.setting-row:last-of-type { border-radius: 0 0 var(--r-md) var(--r-md); border-bottom: none; }
.setting-row:only-of-type { border-radius: var(--r-md); }
.setting-row:hover { background: var(--bg-hover); }
.setting-row .ico { color: var(--accent); }
.setting-row .body { flex: 1; min-width: 0; }
.setting-row .name { font-size: var(--text-base); font-weight: 500; }
.setting-row .sub { font-size: var(--text-xs); color: var(--fg-muted); }
.setting-row .trail { flex: none; color: var(--fg-faint); }

/* ── Выбор обоев ────────────────────────────────────────────────── */
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--sp-2);
}
.wallpaper-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--chat-bg);
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.wallpaper-tile:active { transform: scale(.95); }
.wallpaper-tile.is-active { box-shadow: inset 0 0 0 2.5px var(--accent); }
.wallpaper-tile .preview { position: absolute; inset: 0; background-repeat: repeat; }
.wallpaper-tile .caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 6px 5px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: var(--fg);
  background: linear-gradient(transparent, var(--bg));
}
.wallpaper-tile .tick {
  position: absolute;
  top: 5px; right: 5px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transform: scale(.5);
  transition: all var(--dur) var(--ease-spring);
}
.wallpaper-tile.is-active .tick { opacity: 1; transform: none; }

/* ── Выбор акцента ──────────────────────────────────────────────── */
.accent-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.accent-dot {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  position: relative;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.accent-dot:active { transform: scale(.88); }
.accent-dot.is-active { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px currentColor; }
.accent-dot .tick { color: #fff; opacity: 0; }
.accent-dot.is-active .tick { opacity: 1; }

/* ── Экран авторизации ──────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
}
.auth-card {
  width: min(408px, 100%);
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  background: var(--bg-raised);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto var(--sp-4);
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: var(--accent);
  color: #fff;
  font-size: 2.1rem;
  font-weight: var(--weight-bold);
}
.auth-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  text-align: center;
  letter-spacing: -.02em;
}
.auth-sub {
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  margin: var(--sp-2) 0 var(--sp-6);
}
.auth-links { margin-top: var(--sp-5); text-align: center; font-size: var(--text-sm); color: var(--fg-muted); }

/* ── Приветственный экран ───────────────────────────────────────── */
.welcome {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: var(--sp-6);
  background: var(--bg);
}
.welcome .mark {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -.035em;
  color: var(--fg);
}
.welcome .tagline {
  color: var(--fg-muted);
  font-size: var(--text-md);
  margin: var(--sp-2) 0 var(--sp-8);
  max-width: 30ch;
}
.welcome .actions { display: flex; flex-direction: column; gap: var(--sp-3); width: min(320px, 100%); }

/* ── Страница ошибки ────────────────────────────────────────────── */
.error-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: var(--sp-6);
}
.error-code {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 17vw, 6rem);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

/* ════════════════════════════════════════════════════════════════════
   Круглые действия, бейдж уровня, галочка
   ════════════════════════════════════════════════════════════════════ */

/* ── Круглые кнопки ──────────────────────────────────────────────── */
.profile-actions.is-round {
  display: flex;
  justify-content: center;
  gap: var(--sp-4, 16px);
  margin-top: var(--sp-4, 16px);
  flex-wrap: wrap;
}

.round-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.round-action-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-input, rgba(255, 255, 255, .08));
  color: var(--fg, #e6edf3);
  /* Мягкая тень снизу даёт объём — кнопка выглядит «жидкой»,
     а не плоским кружком */
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28),
              inset 0 1px 0 rgba(255, 255, 255, .07);
  transition: transform .22s cubic-bezier(.34, 1.56, .64, 1),
              background .2s, box-shadow .2s;
}

.round-action:hover .round-action-circle {
  transform: translateY(-2px) scale(1.05);
  background: var(--bg-raised, rgba(255, 255, 255, .13));
}

/* Нажатие вминает кнопку — отклик чувствуется на телефоне */
.round-action:active .round-action-circle {
  transform: scale(.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

.round-action.is-primary .round-action-circle {
  background: var(--accent, #5B5BF5);
  color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent, #5B5BF5) 45%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, .22);
}

.round-action-label {
  font-size: 11.5px;
  color: var(--fg-muted, #8b98a5);
  white-space: nowrap;
}

.round-action.is-primary .round-action-label {
  color: var(--fg, #e6edf3);
}

/* ── Статус с уровнем ────────────────────────────────────────────── */
.profile-status-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
}

/* Восьмиугольный бейдж уровня — как на присланном образце */
.level-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-display, inherit);
  color: var(--bg, #05070a);
  background: var(--fg-soft, #c3ced9);
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%,
                     70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

/* ── Синяя галочка ───────────────────────────────────────────────── */
.profile-name .verified,
.verified-badge {
  width: 19px;
  height: 19px;
  flex: none;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #3b8cff;
  color: #fff;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(59, 140, 255, .45);
}

.profile-name .verified svg,
.verified-badge svg {
  width: 100%;
  height: 100%;
  stroke-width: 3.2;
}

/* ── Эмодзи для статуса ──────────────────────────────────────────── */
.mood-emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.mood-emoji {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg-input, rgba(255, 255, 255, .07));
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1),
              border-color .18s, background .18s;
}

.mood-emoji:hover { transform: scale(1.12); }
.mood-emoji:active { transform: scale(.9); }

.mood-emoji.is-active {
  border-color: var(--accent, #5B5BF5);
  background: color-mix(in srgb, var(--accent, #5B5BF5) 18%, transparent);
}

.mood-emoji.is-more,
.mood-emoji.is-clear {
  color: var(--fg-muted, #8b98a5);
  font-size: 20px;
  font-weight: 600;
}

/* ── Полная клавиатура эмодзи ────────────────────────────────────── */
.emoji-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  padding-bottom: var(--sp-3, 12px);
}

.emoji-pick {
  aspect-ratio: 1;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.emoji-pick:hover {
  background: var(--bg-input, rgba(255, 255, 255, .08));
  transform: scale(1.15);
}

/* ── Палитра оформления ──────────────────────────────────────────── */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 10px;
}

.palette-dot {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 -18px 24px -18px rgba(0, 0, 0, .8);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1),
              border-color .2s;
}

.palette-dot:hover { transform: scale(1.08); }
.palette-dot:active { transform: scale(.94); }

.palette-dot.is-active {
  border-color: #fff;
  transform: scale(1.06);
}

/* Галочка на выбранном — видна на любом цвете за счёт тени */
.palette-dot.is-active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}
