/**
 * Ferom — UI компоненты Material You (Mobile-First)
 */

/* ─── Page headers (главные вкладки) ─── */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 10px;
}

.page-head__title {
  font-size: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
  color: var(--md-sys-color-on-surface);
}

.page-head__icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-primary);
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.page-head__icon-btn .material-symbols-rounded {
  font-size: 26px;
}

.page-head__icon-btn:active {
  background: color-mix(in srgb, var(--md-sys-color-primary) 12%, transparent);
  transform: scale(0.92);
}

/* ─── Navigation bars (подэкраны, чат) ─── */
.top-bar {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
  align-items: center;
  min-height: 52px;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
  background: var(--md-sys-color-surface);
}

.top-bar--chat {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 2px;
  padding-right: 16px;
  min-height: 56px;
}

.top-bar__slot {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.top-bar__slot--start {
  justify-content: flex-start;
}

.top-bar__slot--end {
  justify-content: flex-end;
}

.top-bar__title {
  font-size: 1.0625rem;
  font-weight: 600;
  text-align: center;
  color: var(--md-sys-color-on-surface);
  line-height: 1.2;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar__icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-primary);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.top-bar__icon-btn .material-symbols-rounded {
  font-size: 24px;
}

.top-bar__icon-btn:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.top-bar__text-btn {
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  background: transparent;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  white-space: nowrap;
}

.top-bar__text-btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.top-bar__text-btn:active:not(:disabled) {
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
}

.glass {
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 78%, transparent);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 45%, transparent);
}

/* ─── Плавающий Tab Bar ─── */
.floating-nav-wrap {
  position: fixed;
  bottom: calc(var(--floating-nav-margin) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: calc(var(--app-max-width) - 32px);
  z-index: 40;
  pointer-events: none;
  transition:
    transform 0.36s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.28s ease,
    visibility 0.36s;
}

.floating-nav {
  position: relative;
  display: flex;
  align-items: stretch;
  height: var(--floating-nav-height);
  padding: 4px;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 62%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow:
    0 8px 32px color-mix(in srgb, var(--md-sys-color-shadow) 22%, transparent),
    inset 0 1px 0 color-mix(in srgb, #fff 12%, transparent);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  pointer-events: auto;
  overflow: hidden;
}

.floating-nav__indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: calc(var(--md-sys-shape-corner-extra-large) - 4px);
  background: var(--md-sys-color-secondary-container);
  box-shadow: var(--md-sys-elevation-1);
  transition:
    transform 0.4s cubic-bezier(0.34, 1.4, 0.64, 1),
    width 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
  z-index: 0;
  will-change: transform, width;
}

.floating-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  position: relative;
  z-index: 1;
  min-width: 0;
  transition: color 0.25s ease, transform 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
  border-radius: calc(var(--md-sys-shape-corner-extra-large) - 4px);
}

.floating-nav__icon {
  font-size: 22px !important;
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.floating-nav__label {
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.floating-nav__item.active {
  color: var(--md-sys-color-on-secondary-container);
}

.floating-nav__item.active .floating-nav__icon {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  transform: scale(1.08) translateY(-1px);
}

.floating-nav__item[data-tab="wallet"] .floating-nav__icon {
  color: #ec4899;
}

.floating-nav__item[data-tab="wallet"].active .floating-nav__icon {
  color: #db2777;
}

.floating-nav__item:active:not(.active) {
  transform: scale(0.94);
}

.floating-nav__item:active.active {
  transform: scale(0.97);
}

.floating-nav__badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--md-sys-color-error) 40%, transparent);
  z-index: 2;
}

/* ─── FAB ─── */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  right: max(16px, calc(50% - var(--app-max-width) / 2 + 16px));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: var(--md-sys-shape-corner-large);
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 90%, transparent);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-3);
  z-index: 39;
  transition:
    transform 0.36s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.28s ease,
    visibility 0.36s,
    box-shadow 0.15s;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
}

.fab:active {
  transform: scale(0.92);
  box-shadow: var(--md-sys-elevation-1);
}

.fab .material-symbols-rounded {
  font-size: 24px;
}

/* ─── Auth ─── */
.auth-screen {
  justify-content: center;
  align-items: center;
  padding: 2rem 1.5rem;
  padding-top: calc(2rem + env(safe-area-inset-top, 0px));
}

.auth-screen__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.auth-screen__logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-tertiary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: var(--md-sys-elevation-2);
}

.auth-screen__logo .material-symbols-rounded {
  font-size: 36px;
  color: var(--md-sys-color-on-primary);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

.auth-screen__title {
  font-size: 2rem;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.5px;
}

.auth-screen__subtitle {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
  margin-top: 0.25rem;
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form__submit {
  margin-top: 8px;
}

.verify-email-display {
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.verify-email-change-toggle {
  display: inline;
  margin-left: 6px;
  font-size: 0.875rem;
  vertical-align: baseline;
}

.verify-email-change {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.verify-email-change-save {
  width: 100%;
}

.email-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

.email-status-badge .material-symbols-rounded {
  font-size: 1rem;
}

.email-status-badge--verified {
  color: #16a34a;
}

.email-status-badge--pending {
  color: #d97706;
}

.tg-field__value--email {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.profile-email-status {
  display: block;
  margin-top: 4px;
}

.verify-email-code-input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
}

.auth-form__dev-hint {
  font-size: 0.875rem;
  color: var(--md-sys-color-tertiary);
  text-align: center;
  margin: 0;
}

.auth-form__hint-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 28%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 55%, var(--md-sys-color-surface-container-low));
  color: var(--md-sys-color-on-primary-container);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.auth-form__hint-chip:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 78%, var(--md-sys-color-surface-container-low));
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 42%, transparent);
}

.auth-form__hint-chip:active {
  transform: scale(0.99);
}

.auth-form__hint-chip-icon {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--md-sys-color-primary);
  font-variation-settings: 'FILL' 1, 'wght' 500;
}

.auth-form__hint-chip-text {
  flex: 1;
  line-height: 1.35;
}

.auth-form__hint-chip-chevron {
  flex-shrink: 0;
  font-size: 18px;
  opacity: 0.65;
}

.auth-switch {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
}

.auth-switch__link {
  background: none;
  border: none;
  color: var(--md-sys-color-primary);
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  padding: 0;
  margin-left: 4px;
  cursor: pointer;
}

.auth-switch__link:active {
  opacity: 0.7;
}

/* ─── Form fields (native) ─── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  padding-left: 4px;
}

.form-field__input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  font: inherit;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.65;
}

.form-field__input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent);
}

.form-field__hint {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  padding-left: 4px;
  margin: 0;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn--primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--md-sys-color-primary) 28%, transparent);
}

.btn--primary:disabled {
  opacity: 0.55;
  pointer-events: none;
  box-shadow: none;
}

.btn--primary:active:not(:disabled) {
  transform: scale(0.98);
}

/* ─── Main screen layout ─── */
#screen-main.active {
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

#screen-profile-setup.active {
  display: flex !important;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

.profile-setup {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem 2rem;
  -webkit-overflow-scrolling: touch;
}

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.tab-panel.active {
  display: flex;
  animation: tabEnter 0.32s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes tabEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Profile Setup ─── */
.profile-setup__avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-top: 0.5rem;
}

.avatar-picker {
  width: 104px;
  height: 104px;
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  position: relative;
  background: var(--md-sys-color-surface-container-high);
  border: 3px solid var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
}

.avatar-picker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-picker__edit {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
}

.avatar-picker__edit .material-symbols-rounded {
  font-size: 18px;
}

.avatar-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
}

.avatar-presets__item {
  width: 52px;
  height: 52px;
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
  padding: 0;
}

.avatar-presets__item.selected {
  border-color: var(--md-sys-color-primary);
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.avatar-presets__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-setup__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-setup__form .btn {
  margin-top: 8px;
}

/* ─── Chats sidebar (mobile + desktop) ─── */
#tab-chats.active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.chats-sidebar {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--md-sys-color-surface);
  position: relative;
  overflow: hidden;
}

.chats-sidebar__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
  background: var(--md-sys-color-surface);
  z-index: 2;
}

.chats-sidebar__title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--md-sys-color-on-surface);
  margin: 0;
}

.chats-sidebar__toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.chats-sidebar__icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.chats-sidebar__icon-btn .material-symbols-rounded {
  font-size: 24px;
}

.chats-sidebar__icon-btn:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
  color: var(--md-sys-color-primary);
}

.chats-sidebar__icon-btn:active {
  transform: scale(0.92);
}

.chats-sidebar__icon-btn--compose {
  color: var(--md-sys-color-primary);
}

.chats-sidebar__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chats-sidebar__list {
  min-height: 100%;
}

.chats-sidebar__list .list-item {
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
}

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

.chats-sidebar__list .chat-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  padding: 48px 24px;
  text-align: center;
}

/* Mobile: крупный заголовок как раньше */
@media (max-width: 1023px) {
  .chats-sidebar__header {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 10px 20px;
  }

  .chats-sidebar__title {
    font-size: 2.125rem;
    letter-spacing: -0.04em;
  }

  .chats-sidebar__scroll {
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
}

/* Legacy aliases (если где-то остались) */
.chats-page {
  padding: 0;
  min-height: 0;
  background: transparent;
}

.chat-list-card .list-item {
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
}

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

.chat-list-card .list-item:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.chat-list-card .chat-list__empty {
  padding: 3rem 1.5rem;
  height: auto;
  min-height: 200px;
}

/* ─── Search sheet (поиск пользователей) ─── */
.search-sheet {
  position: fixed;
  inset: 0;
  left: 50%;
  width: 100%;
  max-width: var(--app-max-width);
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface);
  transform: translateX(100%) translateX(-50%);
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.36s;
  pointer-events: none;
  visibility: hidden;
}

.search-sheet.is-open {
  transform: translateX(-50%);
  pointer-events: auto;
  visibility: visible;
}

body.search-open {
  overflow: hidden;
}

.search-sheet__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
}

.search-sheet__back {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-primary);
}

.search-sheet__back:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.search-sheet__field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-high);
}

.search-sheet__field-icon {
  font-size: 22px !important;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}

.search-sheet__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
  outline: none;
  padding: 10px 0;
}

.search-sheet__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.75;
}

.search-sheet__input::-webkit-search-cancel-button {
  display: none;
}

.search-sheet__clear {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
}

.search-sheet__clear:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.search-sheet__clear .material-symbols-rounded {
  font-size: 20px;
}

.search-sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 calc(16px + env(safe-area-inset-bottom, 0px));
}

.search-sheet__hint {
  padding: 32px 24px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.search-sheet__body .user-results__item {
  margin: 0 16px 8px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 30%, transparent);
}

.search-sheet__body .user-results__item:last-child {
  margin-bottom: 0;
}

.search-sheet__status {
  padding: 24px 16px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
}

.search-sheet__status--error {
  color: var(--md-sys-color-error);
}

.user-results__action {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 0.8125rem;
  font-weight: 500;
}

.user-results__action:disabled {
  opacity: 0.5;
}

.user-results__action:active:not(:disabled) {
  transform: scale(0.96);
}

#tab-chats {
  background: var(--md-sys-color-surface-container-lowest);
}

.chats-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* Avatar upload button */
.avatar-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--md-sys-elevation-1);
}

.avatar-upload-btn:active {
  transform: scale(0.97);
}

.avatar-upload-btn .material-symbols-rounded {
  font-size: 20px;
}

.avatar-upload-hint {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}

.avatar-upload-hint--success {
  color: var(--md-sys-color-primary);
  font-weight: 500;
}

/* ─── Chat List ─── */
.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.chat-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  gap: 0.75rem;
  height: 100%;
}

.chat-list__empty .material-symbols-rounded {
  font-size: 56px;
  opacity: 0.35;
  color: var(--md-sys-color-primary);
}

.chat-list__empty p:first-of-type {
  font-size: 1.125rem;
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  min-height: 72px;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 50%, transparent);
}

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

.avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--md-sys-color-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--md-sys-color-on-primary-container);
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  overflow: visible;
}

.avatar-wrap--sm {
  width: 40px;
  height: 40px;
}

.avatar-wrap--sm .avatar {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.avatar-wrap--xl {
  width: 120px;
  height: 120px;
}

.avatar-wrap--xl .tg-profile-header__avatar,
.avatar-wrap--xl .avatar {
  width: 120px;
  height: 120px;
}

.avatar-online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4caf50;
  border: 2.5px solid var(--md-sys-color-surface);
  z-index: 3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.avatar-wrap--sm .avatar-online-dot {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

.avatar-online-dot--lg {
  width: 18px;
  height: 18px;
  border-width: 3px;
  right: 4px;
  bottom: 4px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.avatar--xl {
  width: 108px;
  height: 108px;
  font-size: 2.5rem;
  border: 4px solid var(--md-sys-color-surface);
  box-shadow: var(--md-sys-elevation-2);
}

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

.list-item__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.list-item__title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.list-item__title .display-name-row {
  max-width: 100%;
}

.list-item__time {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}

.list-item__preview {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.list-item__badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 0.6875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-item--unread .list-item__title {
  font-weight: 700;
}

.list-item--unread .list-item__preview {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.list-item__avatar-wrap {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

.list-item__avatar-wrap .avatar-online-dot {
  right: 0;
  bottom: 0;
}

/* ─── Search ─── */
.search-section {
  padding: 8px 16px 12px;
  flex-shrink: 0;
  background: var(--md-sys-color-surface);
}

.search-section md-outlined-text-field {
  width: 100%;
}

.user-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.user-results__item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 50%, transparent);
}

.user-results__info {
  flex: 1;
  min-width: 0;
}

.user-results__name {
  font-weight: 500;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
}

.user-results__username {
  font-size: 0.875rem;
  color: var(--md-sys-color-primary);
  margin-top: 1px;
}

.user-results__item md-filled-tonal-button {
  flex-shrink: 0;
  --md-filled-tonal-button-container-height: 40px;
}

/* ─── Profile Page (Telegram-style) ─── */
.profile-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--md-sys-color-surface-container-lowest);
}

.profile-hero {
  position: relative;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 28px;
  margin-bottom: 8px;
  overflow: hidden;
}

.profile-hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.profile-hero__bg.cover-gradient--purple,
.tg-profile-header__bg.cover-gradient--purple {
  background: linear-gradient(145deg, #7c3aed 0%, #a855f7 45%, #c084fc 100%);
}

.cover-gradient--ocean,
.profile-hero__bg.cover-gradient--ocean,
.tg-profile-header__bg.cover-gradient--ocean {
  background: linear-gradient(145deg, #0369a1 0%, #0ea5e9 50%, #38bdf8 100%);
}

.cover-gradient--sunset,
.profile-hero__bg.cover-gradient--sunset,
.tg-profile-header__bg.cover-gradient--sunset {
  background: linear-gradient(145deg, #ea580c 0%, #f43f5e 55%, #fbbf24 100%);
}

.cover-gradient--forest,
.profile-hero__bg.cover-gradient--forest,
.tg-profile-header__bg.cover-gradient--forest {
  background: linear-gradient(145deg, #166534 0%, #22c55e 50%, #86efac 100%);
}

.cover-gradient--night,
.profile-hero__bg.cover-gradient--night,
.tg-profile-header__bg.cover-gradient--night {
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 45%, #6366f1 100%);
}

.cover-gradient--rose,
.profile-hero__bg.cover-gradient--rose,
.tg-profile-header__bg.cover-gradient--rose {
  background: linear-gradient(145deg, #be185d 0%, #ec4899 50%, #fda4af 100%);
}

.cover-gradient--aurora,
.profile-hero__bg.cover-gradient--aurora,
.tg-profile-header__bg.cover-gradient--aurora {
  background: linear-gradient(145deg, #06b6d4 0%, #8b5cf6 50%, #f472b6 100%);
}

.cover-gradient--fire,
.profile-hero__bg.cover-gradient--fire,
.tg-profile-header__bg.cover-gradient--fire {
  background: linear-gradient(145deg, #dc2626 0%, #f97316 50%, #facc15 100%);
}

.profile-hero__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 0%, rgba(255,255,255,0.18) 0%, transparent 60%);
}

.profile-hero__edit {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 8px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s ease, transform 0.15s ease;
}

.profile-hero__edit:active {
  background: rgba(255, 255, 255, 0.14);
  transform: scale(0.92);
}

.profile-hero__edit .material-symbols-rounded {
  font-size: 20px;
}

.profile-hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  width: 100%;
}

.profile-hero__name {
  font-size: 1.5rem;
  font-weight: 500;
  color: #fff;
  margin-top: 12px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.profile-hero__username {
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  width: 100%;
  text-align: center;
  margin-top: 2px;
  padding: 0 16px;
  box-sizing: border-box;
}

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

/* Gradient picker */
.gradient-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 8px 4px 4px;
}

.gradient-picker__item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--md-sys-shape-corner-large);
  border: 3px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.gradient-picker__item.selected {
  border-color: var(--md-sys-color-primary);
  transform: scale(1.05);
}

.gradient-picker__check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  opacity: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.gradient-picker__item.selected .gradient-picker__check {
  opacity: 1;
}

/* Wallet */
.wallet-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 8px;
}

.wallet-balance-card {
  margin: 12px 16px 20px;
  padding: 24px 20px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
}

.wallet-balance-card__label {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
}

.wallet-balance-card__amount {
  font-size: 2.25rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.5px;
}

.wallet-balance-card__hint {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 8px;
}

/* Privacy */
.privacy-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
}

.settings-row--static {
  cursor: default;
}

.settings-row--static:active {
  background: transparent;
}

/* Settings sections */
.settings-section {
  padding: 8px 16px 0;
}

.settings-section__title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 4px 6px;
}

.settings-card {
  background: color-mix(in srgb, var(--md-sys-color-surface) 82%, transparent);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-1);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 40%, transparent);
  transition: background 0.15s;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.settings-row--static {
  cursor: default;
}

.settings-row__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row__icon .material-symbols-rounded {
  font-size: 20px;
  color: #fff;
}

.settings-row__icon--blue { background: #4A90D9; }
.settings-row__icon--purple { background: #8B5CF6; }
.settings-row__icon--orange { background: #F59E0B; }
.settings-row__icon--red { background: #EF4444; }
.settings-row__icon--green { background: #22C55E; }
.settings-row__icon--teal { background: #14B8A6; }
.settings-row__icon--gold { background: linear-gradient(135deg, #f59e0b, #d97706); }

.settings-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.settings-row__label {
  font-size: 1rem;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
}

.settings-row__hint {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  min-width: 0;
}

.settings-row__hint--username {
  overflow: visible;
  white-space: normal;
  text-overflow: unset;
}

.settings-row--username {
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

.settings-row--username .settings-row__icon {
  margin-top: 0;
}

.settings-row--username .settings-row__chevron {
  margin-top: 0;
}

.settings-row__chevron {
  font-size: 20px !important;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
  opacity: 0.6;
}

.settings-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 24px 16px 0;
  padding: 14px;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  font-size: 1rem;
  font-weight: 500;
  transition: transform 0.15s, opacity 0.15s;
}

.settings-logout:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.settings-logout .material-symbols-rounded {
  font-size: 20px;
}

/* ─── Profile Edit Screen ─── */
.profile-edit-page {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 32px;
  -webkit-overflow-scrolling: touch;
}

#screen-profile-edit.active {
  display: flex !important;
  flex-direction: column;
  min-height: 100dvh;
}

.profile-edit-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.avatar-picker--lg {
  width: 120px;
  height: 120px;
}

.profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-edit-form md-outlined-text-field {
  width: 100%;
}

.profile-edit-form md-filled-button {
  width: 100%;
  margin-top: 8px;
  --md-filled-button-container-height: 52px;
}

/* ─── Legacy profile (removed) ─── */
.profile-view,
.profile-card,
.profile-card__name,
.profile-card__username,
.profile-edit-form,
.profile-actions {
  /* kept for compat */
}

/* ─── Chat Room ─── */
.chat-room {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface);
}

.chat-header__tap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 4px 0;
  margin: 0;
  border: none;
  background: transparent;
  text-align: left;
  border-radius: var(--md-sys-shape-corner-large);
  transition: background 0.15s ease;
}

.chat-header__tap:active {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.chat-header__info {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
}

.chat-header__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.chat-header__name .display-name-row {
  max-width: 100%;
}

.chat-header__status {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.chat-header__status--online {
  color: #4caf50;
  font-weight: 500;
}

.top-bar--chat .avatar--sm {
  box-shadow: 0 2px 8px color-mix(in srgb, var(--md-sys-color-shadow) 12%, transparent);
  border: 2px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 25%, transparent);
}

.chat-room__messages-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-date-float {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 45%, transparent);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--md-sys-color-shadow) 12%, transparent);
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.chat-date-float.hidden {
  opacity: 0;
}

.chat-date-divider {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.chat-date-divider span {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
}

.chat-room__messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--md-sys-color-primary) 6%, transparent), transparent 55%),
    var(--md-sys-color-surface-container-lowest);
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.chat-room__loading,
.chat-room__error {
  margin: auto;
  text-align: center;
  padding: 2rem;
}

.chat-room__empty {
  margin: auto;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
  padding: 2rem;
}

.chat-room__empty--official {
  max-width: min(92%, 360px);
  padding: 1rem 1rem 2rem;
}

.chat-official-bubble {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 75%, var(--md-sys-color-surface));
  border: 1px solid color-mix(in srgb, #1d9bf0 28%, transparent);
  text-align: left;
  box-shadow: var(--md-sys-elevation-1);
}

.chat-official-bubble__icon {
  flex-shrink: 0;
  font-size: 28px;
  color: #1d9bf0;
  font-variation-settings: 'FILL' 1;
  margin-top: 1px;
}

.chat-official-bubble__title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 6px;
}

.chat-official-bubble__text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface-variant);
}

.chat-official-bubble--sheet {
  margin: 0;
}

.message-bubble {
  max-width: 82%;
  padding: 10px 14px 8px;
  border-radius: 18px;
  font-size: 0.9375rem;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
  animation: message-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-bubble--mine {
  animation-name: message-in-mine;
}

@keyframes message-in-mine {
  from {
    opacity: 0;
    transform: translateY(10px) translateX(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message-row--mine {
  align-self: flex-end;
  align-items: flex-end;
}

.message-row--theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.message-row--mine .message-bubble {
  max-width: 100%;
}

.message-row--theirs .message-bubble {
  max-width: 100%;
}

.message-bubble__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.message-reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 0.8125rem;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
  color: var(--md-sys-color-on-surface);
  transition: transform 0.15s ease, background 0.15s ease;
  animation: reaction-pop 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.message-reaction--mine {
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 85%, transparent);
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent);
}

.message-reaction:active {
  transform: scale(0.92);
}

.message-reaction__count {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
}

@keyframes reaction-pop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.reaction-picker {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 8px;
}

.reaction-picker__btn {
  flex: 1;
  height: 52px;
  border: none;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container);
  font-size: 1.75rem;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1), background 0.15s ease;
}

.action-sheet__panel .reaction-picker__btn {
  background: var(--md-sys-color-surface-container);
}

.reaction-picker__btn:active {
  transform: scale(1.2);
  background: color-mix(in srgb, var(--md-sys-color-primary-container) 70%, transparent);
}

.user-profile__write {
  margin: 16px 16px 0;
  width: calc(100% - 32px);
}

.tg-profile-header__main .avatar-wrap {
  margin: 0 auto;
}

.message-bubble__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-bubble--mine {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
}

.message-bubble--theirs {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-bottom-left-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 28%, transparent);
}

.message-bubble__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}

.message-bubble__time {
  font-size: 0.6875rem;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.message-bubble--theirs .message-bubble__time {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 1;
}

.message-row--highlight .message-bubble {
  animation: message-highlight 1.2s ease;
}

@keyframes message-highlight {
  0%, 40% {
    filter: brightness(1.15);
    transform: scale(1.02);
  }
  100% {
    filter: none;
    transform: none;
  }
}

.chat-room__input {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  margin: 0 12px 12px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
  box-shadow: var(--md-sys-elevation-1);
}

.chat-input__attach,
.chat-input__mic {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.chat-input__attach:active,
.chat-input__mic:active {
  transform: scale(0.94);
}

.chat-input__mic--active,
.chat-input__mic:active {
  background: color-mix(in srgb, var(--md-sys-color-error) 14%, transparent);
  color: var(--md-sys-color-error);
  transform: scale(1.08);
}

.chat-room__input--hidden {
  display: none;
}

.chat-voice-recording {
  --slide: 0px;
  display: grid;
  grid-template-columns: auto minmax(72px, auto) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-radius: 28px;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 30%, transparent);
  box-shadow: var(--md-sys-elevation-2);
  transform: translateX(var(--slide));
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: none;
}

.chat-voice-recording--cancel {
  background: color-mix(in srgb, var(--md-sys-color-error-container) 88%, transparent);
  border-color: color-mix(in srgb, var(--md-sys-color-error) 35%, transparent);
}

.chat-voice-recording__cancel {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--md-sys-color-error) 12%, transparent);
  color: var(--md-sys-color-error);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-voice-recording--cancel .chat-voice-recording__cancel {
  opacity: 1;
  transform: scale(1);
}

.chat-voice-recording__slide {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0.72;
}

.chat-voice-recording--cancel .chat-voice-recording__slide {
  color: var(--md-sys-color-error);
  opacity: 1;
}

.chat-voice-recording__slide .material-symbols-rounded {
  font-size: 1.1rem;
}

.chat-voice-recording__wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 28px;
  min-width: 0;
  overflow: hidden;
}

.chat-voice-recording__bar {
  width: 3px;
  height: calc(var(--h, 0.3) * 100%);
  border-radius: 999px;
  background: var(--md-sys-color-primary);
  opacity: 0.55;
  transition: height 0.08s linear, opacity 0.15s ease;
}

.chat-voice-recording__bar--live {
  height: calc(var(--live, var(--h, 0.3)) * 100%);
  opacity: 1;
}

.chat-voice-recording--cancel .chat-voice-recording__bar {
  background: var(--md-sys-color-error);
}

.chat-voice-recording__time {
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
  min-width: 2.6rem;
  text-align: right;
}

.chat-voice-recording__mic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--md-sys-color-error) 14%, transparent);
  color: var(--md-sys-color-error);
  animation: voice-mic-pulse 1.2s ease infinite;
}

.chat-voice-recording__mic .material-symbols-rounded {
  font-size: 1.35rem;
}

@keyframes voice-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error) 28%, transparent); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.message-bubble--image,
.message-bubble--voice {
  padding: 8px 10px 6px;
}

.message-bubble--image .message-bubble__footer,
.message-bubble--voice .message-bubble__footer {
  padding: 2px 2px 0;
  margin-top: 2px;
}

.message-bubble__image-btn {
  display: block;
  border: none;
  padding: 0;
  background: transparent;
  border-radius: 14px;
  overflow: hidden;
  max-width: min(72vw, 280px);
  cursor: pointer;
  position: relative;
}

.message-bubble__image-btn--pending {
  cursor: default;
}

.message-bubble__upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.38);
  border-radius: inherit;
}

.message-bubble__upload-overlay--failed {
  background: rgba(0, 0, 0, 0.5);
}

.message-bubble__upload-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  animation: photo-upload-spin 0.75s linear infinite;
}

.message-bubble__upload-retry {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.message-bubble__status--pending {
  opacity: 0.7;
}

.message-bubble__status--failed {
  color: var(--md-sys-color-error);
}

.message-row--pending {
  opacity: 0.96;
}

@keyframes photo-upload-spin {
  to { transform: rotate(360deg); }
}

.chat-photo-compose {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface);
}

.chat-photo-compose.hidden {
  display: none;
}

.chat-photo-compose__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  flex-shrink: 0;
}

.chat-photo-compose__back {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-photo-compose__title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

.chat-photo-compose__spacer {
  width: 40px;
  flex-shrink: 0;
}

.chat-photo-compose__stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background:
    radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent), transparent 60%),
    var(--md-sys-color-surface-container-low);
}

.chat-photo-compose__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 8px 32px color-mix(in srgb, var(--md-sys-color-shadow) 18%, transparent);
}

.chat-photo-compose__footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-highest) 92%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 35%, transparent);
}

.chat-photo-compose__caption {
  flex: 1;
  min-width: 0;
  border: none;
  background: color-mix(in srgb, var(--md-sys-color-surface) 80%, transparent);
  border-radius: 22px;
  padding: 12px 16px;
  font: inherit;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
  outline: none;
}

.chat-photo-compose__caption::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.chat-photo-compose__send {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--md-sys-color-primary) 30%, transparent);
}

.chat-room__input.hidden {
  display: none;
}

.message-bubble__image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  vertical-align: top;
}

.message-bubble__caption {
  margin-top: 6px;
  padding: 0 4px;
}

.message-voice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 210px;
  max-width: min(72vw, 280px);
}

.message-voice__play {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: inherit;
  transition: transform 0.15s ease, background 0.15s ease;
}

.message-voice__play:active {
  transform: scale(0.94);
}

.message-bubble--mine .message-voice__play {
  background: color-mix(in srgb, #fff 20%, transparent);
  color: #fff;
}

.message-voice__play .material-symbols-rounded {
  font-size: 1.5rem;
}

.message-voice__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.message-voice__waveform {
  position: relative;
  display: block;
  width: 100%;
  height: 28px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.message-voice__waveform-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.message-voice__bar {
  flex: 1;
  max-width: 3px;
  min-height: 4px;
  height: calc(var(--h, 0.4) * 100%);
  border-radius: 999px;
  background: currentColor;
  opacity: 0.3;
  transform-origin: center bottom;
  transition: opacity 0.1s linear, transform 0.1s linear;
}

.message-voice--playing .message-voice__bar {
  opacity: 0.34;
}

.message-voice__bar--played {
  opacity: 0.92;
}

.message-voice__bar--active {
  opacity: calc(0.34 + 0.58 * var(--partial, 0.5));
  transform: scaleY(calc(0.72 + 0.28 * var(--partial, 0.5)));
}

.message-bubble--mine .message-voice__bar {
  opacity: 0.36;
}

.message-bubble--mine .message-voice--playing .message-voice__bar {
  opacity: 0.4;
}

.message-bubble--mine .message-voice__bar--played,
.message-bubble--mine .message-voice__bar--active {
  opacity: 1;
}

.message-voice__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 1rem;
}

.message-voice__time {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.82;
}

.message-voice__speed {
  border: none;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  color: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}

.message-voice__audio {
  display: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.image-lightbox__close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inventory-item__icon.market-card__preview--theme {
  padding: 0;
  overflow: hidden;
}

.inventory-item__icon.market-card__preview--theme .theme-preview-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.chat-input__field {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--md-sys-color-on-surface);
  outline: none;
  padding: 10px 4px;
  max-height: 120px;
}

.chat-input__field::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.chat-input__send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--md-sys-color-primary) 28%, transparent);
  transition: transform 0.15s ease;
}

.chat-input__send:active {
  transform: scale(0.94);
}

.chat-input__send .material-symbols-rounded {
  font-size: 22px;
}

/* ─── Snackbar ─── */
.snackbar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  max-width: min(calc(var(--app-max-width) - 32px), calc(100vw - 32px));
  width: max-content;
  padding: 14px 16px;
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font-size: 0.875rem;
  z-index: 300;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s;
  pointer-events: none;
  box-shadow: var(--md-sys-elevation-2);
}

.snackbar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.snackbar--chat {
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* ─── Material Web: привязка к теме Ferom ─── */
md-outlined-text-field {
  --md-outlined-text-field-container-shape: 4px;
  --md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary);
  --md-outlined-text-field-focus-label-text-color: var(--md-sys-color-primary);
  --md-outlined-text-field-input-text-color: var(--md-sys-color-on-surface);
  --md-outlined-text-field-label-text-color: var(--md-sys-color-on-surface-variant);
  --md-outlined-text-field-outline-color: var(--md-sys-color-outline);
  --md-outlined-text-field-input-text-font: var(--md-ref-typeface-plain);
}

md-filled-button {
  --md-filled-button-container-color: var(--md-sys-color-primary);
  --md-filled-button-label-text-color: var(--md-sys-color-on-primary);
  --md-filled-button-container-shape: var(--md-sys-shape-corner-full);
}

md-outlined-button {
  --md-outlined-button-outline-color: var(--md-sys-color-outline);
  --md-outlined-button-label-text-color: var(--md-sys-color-primary);
  --md-outlined-button-container-shape: var(--md-sys-shape-corner-full);
}

md-text-button {
  --md-text-button-label-text-color: var(--md-sys-color-primary);
}

md-filled-tonal-button {
  --md-filled-tonal-button-container-color: var(--md-sys-color-secondary-container);
  --md-filled-tonal-button-label-text-color: var(--md-sys-color-on-secondary-container);
  --md-filled-tonal-button-container-shape: var(--md-sys-shape-corner-full);
}

/* Disabled state на кнопках при загрузке */
md-filled-button[disabled],
md-outlined-button[disabled] {
  opacity: 0.6;
  pointer-events: none;
}
