.modern-profile.profile-shell {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  background: var(--rd-page-bg, #e6e2da);
  color: var(--rd-text, #141210);
  font-family: var(--font-body, "Segoe UI", system-ui, sans-serif);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Публичный профиль: не подмешивать старую палитру profile.css (--profile-bg / синие кнопки) */
.public-profile-page.modern-profile.profile-shell {
  background: var(--rd-page-bg, #e6e2da) !important;
  color: var(--rd-text, #141210) !important;
}

.modern-profile .profile-layout {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.5vw, 28px) clamp(12px, 2.8vw, 30px) calc(20px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}

.modern-profile .profile-stage {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: clamp(14px, 2.2vw, 24px);
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-card, #faf8f4);
  box-shadow: none;
}

.modern-profile .profile-stage::before {
  display: none;
}

.modern-profile .tg-hero-top,
.modern-profile .tg-hero-main,
.modern-profile .tg-quick-grid {
  position: relative;
  z-index: 1;
}

.modern-profile .tg-hero-top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
}

.modern-profile .tg-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-pill, #ebe6dd);
  color: var(--rd-text, #141210);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modern-profile .tg-nav-title {
  text-align: center;
  color: var(--rd-text, #141210);
  font-size: clamp(15px, 1.7vw, 18px);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modern-profile .tg-hero-main {
  margin-top: clamp(12px, 1.8vw, 18px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(14px, 2.4vw, 22px);
  align-items: center;
}

.modern-profile .tg-avatar {
  width: clamp(96px, 11vw, 122px);
  height: clamp(96px, 11vw, 122px);
  margin: 0;
  border-radius: 22px;
  border: 2px solid var(--rd-border, #c9c2b6);
  background-color: var(--rd-pill-soft, #e0d9ce);
  box-shadow: none;
  color: var(--rd-text, #141210);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(33px, 3.8vw, 44px);
  font-weight: 700;
}

.modern-profile .profile-avatar-big.profile-avatar-img {
  background-size: cover;
  background-position: center;
  font-size: 0;
}

.modern-profile .profile-hero-copy {
  min-width: 0;
}

.modern-profile .tg-name-row {
  justify-content: flex-start;
  color: var(--rd-text, #141210);
  font-size: clamp(26px, 4.2vw, 42px);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.modern-profile .tg-handle {
  margin-top: 4px;
  color: var(--rd-muted, #5e594f);
  font-size: clamp(13px, 1.5vw, 15px);
}

.modern-profile .tg-status {
  margin-top: 8px;
  color: var(--rd-text, #141210);
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.36;
  word-break: break-word;
}

.modern-profile .profile-hero-tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modern-profile .profile-hero-tag {
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-pill, #ebe6dd);
  color: var(--rd-text, #141210);
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.modern-profile .profile-hero-tag-soft {
  background: var(--rd-pill-soft, #e0d9ce);
}

.modern-profile .tg-quick-grid {
  margin-top: clamp(14px, 2.2vw, 20px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.modern-profile .tg-quick-btn {
  min-height: 84px;
  border-radius: 16px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-pill-soft, #e0d9ce);
  color: var(--rd-text, #141210);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.modern-profile .tg-quick-btn > span:first-child {
  font-size: 20px;
  line-height: 1;
}

.modern-profile .profile-content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.modern-profile .profile-editor-card {
  grid-column: span 8;
}

.modern-profile .profile-status-card {
  grid-column: span 4;
}

.modern-profile .profile-usernames-card,
.modern-profile .profile-gifts-card,
.modern-profile .profile-info-card {
  grid-column: span 6;
}

.modern-profile .profile-full-width-card {
  grid-column: span 12;
}

.modern-profile .tg-section-card {
  border-radius: 22px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-card-2, #f3f0ea);
  box-shadow: none;
  padding: clamp(13px, 2vw, 18px);
  backdrop-filter: none;
}

.modern-profile .tg-section-card h3 {
  margin: 0 0 12px;
  color: var(--rd-muted, #5e594f);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.modern-profile .tg-field-grid,
.modern-profile .tg-pill-stack,
.modern-profile .tg-list {
  display: grid;
  gap: 10px;
}

.modern-profile .tg-field {
  display: grid;
  gap: 7px;
}

.modern-profile .tg-field > span {
  color: var(--rd-muted, #5e594f);
  font-size: 12px;
  font-weight: 700;
}

.modern-profile .tg-field input,
.modern-profile .tg-field textarea {
  width: 100%;
  border-radius: 13px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-pill, #ebe6dd);
  color: var(--rd-text, #141210);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.modern-profile .tg-field textarea {
  min-height: 90px;
  resize: vertical;
}

.modern-profile .tg-field input[readonly],
.modern-profile .tg-field input:disabled {
  color: var(--rd-muted, #5e594f);
  background: var(--rd-pill-soft, #e0d9ce);
}

.modern-profile .tg-pill,
.modern-profile .tg-list-item {
  border-radius: 14px;
  border: 1px solid var(--rd-border, #c9c2b6);
  background: var(--rd-pill-soft, #e0d9ce);
  color: var(--rd-text, #141210);
  padding: 11px 12px;
  font-size: 13px;
}

.modern-profile .tg-pill {
  font-weight: 700;
}

.modern-profile .tg-pill-orbs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modern-profile .tg-pill-orbs img {
  width: 15px;
  height: 15px;
}

.modern-profile .tg-username-item {
  width: 100%;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
}

.modern-profile .tg-meta {
  margin-top: 4px;
  color: var(--rd-muted, #5e594f);
  font-size: 12px;
}

.modern-profile .tg-empty {
  border: 1px dashed var(--rd-border, #c9c2b6);
  border-radius: 14px;
  background: var(--rd-pill, #ebe6dd);
  color: var(--rd-muted, #5e594f);
  font-size: 12px;
  padding: 12px;
}

.modern-profile .profile-error {
  margin: 10px 0 0;
}

.modern-profile .hidden-file,
.modern-profile .mobile-bottom-nav {
  display: none;
}

@media (max-width: 1024px) {
  .modern-profile .profile-editor-card,
  .modern-profile .profile-content-grid > * {
    grid-column: span 12;
  }
}

@media (max-width: 900px) and (hover: none), (max-width: 900px) and (pointer: coarse) {
  .modern-profile .profile-layout {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .modern-profile .tg-hero-main {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .modern-profile .tg-avatar {
    margin: 0 auto;
  }

  .modern-profile .tg-name-row {
    justify-content: center;
  }

  .modern-profile .profile-hero-tags {
    justify-content: center;
  }

  .modern-profile .mobile-bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    border-radius: 999px;
    border: 1px solid var(--rd-border, #c9c2b6);
    padding: 5px;
    overflow: hidden;
    background: var(--rd-card, #faf8f4);
    box-shadow: var(--rd-tabbar-shadow, var(--rd-shadow-soft), var(--rd-btn-bevel));
    z-index: 40;
  }

  .modern-profile .mobile-bottom-nav button:not(.active) {
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--rd-muted, #5e594f);
    min-height: 56px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.1;
  }

  .modern-profile .mobile-bottom-nav button img {
    width: 18px;
    height: 18px;
  }

  .modern-profile .mobile-bottom-nav button.active {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 56px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.1;
    font-weight: 800;
    background: color-mix(in srgb, var(--rd-nav-active, #e5dfd4) 92%, transparent);
    color: var(--rd-accent, #a63b00);
    box-shadow:
      var(--rd-btn-bevel, inset 0 1px 0 rgba(255, 255, 255, 0.14)),
      inset 0 0 0 1px color-mix(in srgb, var(--rd-border, #c9c2b6) 30%, transparent);
  }
}

/* Телефоны: одна строка из 4 кнопок (не сетка 2×2) — компактнее и предсказуемее */
@media (max-width: 640px) {
  .modern-profile .tg-quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .modern-profile .tg-quick-btn {
    min-height: 52px;
    padding: 8px 4px 10px;
    border-radius: 12px;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.15;
    justify-content: center;
  }

  .modern-profile .tg-quick-btn > span:first-child {
    font-size: 15px;
    line-height: 1;
  }

  .modern-profile .tg-quick-btn > span:last-child {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
    max-width: 100%;
    word-break: break-word;
  }
}

body.embed-panel.modern-profile .mobile-bottom-nav {
  display: none !important;
}

body.embed-panel.modern-profile .profile-layout {
  max-width: none;
  padding-bottom: 18px;
}

body.embed-panel.modern-profile.profile-shell {
  min-height: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .modern-profile .mobile-bottom-nav {
    display: none !important;
  }
}

body[data-theme="dark"].modern-profile.profile-shell,
body[data-theme="midnight"].modern-profile.profile-shell,
body[data-theme="graphite"].modern-profile.profile-shell {
  background: var(--rd-page-bg, #0f0d0b);
  color: var(--rd-text, #f2ede6);
}

body[data-theme="dark"].modern-profile .profile-stage,
body[data-theme="midnight"].modern-profile .profile-stage,
body[data-theme="graphite"].modern-profile .profile-stage {
  border-color: var(--rd-border, #3d3832);
  background: var(--rd-card, #1a1714);
}

body[data-theme="dark"].modern-profile .tg-section-card,
body[data-theme="midnight"].modern-profile .tg-section-card,
body[data-theme="graphite"].modern-profile .tg-section-card {
  border-color: var(--rd-border, #3d3832);
  background: var(--rd-card, #1a1714);
  box-shadow: none;
}

body[data-theme="dark"].modern-profile .tg-section-card h3,
body[data-theme="midnight"].modern-profile .tg-section-card h3,
body[data-theme="graphite"].modern-profile .tg-section-card h3 {
  color: var(--rd-muted, #9a9288);
}

body[data-theme="dark"].modern-profile .tg-field > span,
body[data-theme="midnight"].modern-profile .tg-field > span,
body[data-theme="graphite"].modern-profile .tg-field > span,
body[data-theme="dark"].modern-profile .tg-meta,
body[data-theme="midnight"].modern-profile .tg-meta,
body[data-theme="graphite"].modern-profile .tg-meta,
body[data-theme="dark"].modern-profile .tg-empty,
body[data-theme="midnight"].modern-profile .tg-empty,
body[data-theme="graphite"].modern-profile .tg-empty {
  color: var(--rd-muted, #9a9288);
}

body[data-theme="dark"].modern-profile .tg-field input,
body[data-theme="dark"].modern-profile .tg-field textarea,
body[data-theme="midnight"].modern-profile .tg-field input,
body[data-theme="midnight"].modern-profile .tg-field textarea,
body[data-theme="graphite"].modern-profile .tg-field input,
body[data-theme="graphite"].modern-profile .tg-field textarea {
  border-color: var(--rd-border, #3d3832);
  background: var(--rd-pill, #252220);
  color: var(--rd-text, #f2ede6);
}

body[data-theme="dark"].modern-profile .tg-pill,
body[data-theme="midnight"].modern-profile .tg-pill,
body[data-theme="graphite"].modern-profile .tg-pill,
body[data-theme="dark"].modern-profile .tg-list-item,
body[data-theme="midnight"].modern-profile .tg-list-item,
body[data-theme="graphite"].modern-profile .tg-list-item,
body[data-theme="dark"].modern-profile .tg-empty,
body[data-theme="midnight"].modern-profile .tg-empty,
body[data-theme="graphite"].modern-profile .tg-empty {
  border-color: var(--rd-border, #3d3832);
  background: var(--rd-pill, #252220);
  color: var(--rd-text, #f2ede6);
}

/* Публичный профиль пользователя: круглый аватар как в мессенджерах, чуть плотнее герой */
.public-profile-page.modern-profile .tg-avatar {
  border-radius: 50%;
}

.public-profile-page.modern-profile .profile-stage {
  background: var(--rd-card, #faf8f4);
}

.public-profile-page.modern-profile .tg-quick-btn:focus-visible {
  outline: 2px solid var(--rd-accent, #a63b00);
  outline-offset: 2px;
}
