/* Оболочка приложения: экран, нижнее меню, типовые блоки страниц. */

.shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--felt-hi), var(--felt) 45%, var(--felt-lo) 100%),
    var(--felt-lo);
}

.shell.is-hidden {
  display: none;
}

.shell__view {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-t);
}

/* ── нижнее меню ────────────────────────────────────────────────────── */

.shell__nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 6px 6px calc(6px + var(--safe-b));
  background: linear-gradient(180deg, rgba(6, 26, 19, 0.85), rgba(6, 26, 19, 0.98));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.shell__tab {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}

.shell__tab.is-active {
  color: var(--brass-hi);
  background: rgba(214, 175, 105, 0.12);
}

.shell__icon {
  position: relative;
  font-size: 20px;
  line-height: 1;
}

.shell__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.shell__badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 17px;
  padding: 1px 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

/* ── страница ───────────────────────────────────────────────────────── */

.page {
  width: min(560px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 12px 16px 24px;
}

.page__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 2px;
}

.page__titles {
  flex: 1;
  min-width: 0;
}

.page__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--brass-hi);
}

.page__subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.page__body {
  display: grid;
  gap: 14px;
}

/* ── приветственный блок ────────────────────────────────────────────── */

.hero {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 18px 0 6px;
  text-align: center;
}

.hero__cards {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.hero__card {
  display: grid;
  place-items: center;
  width: 34px;
  height: 46px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: linear-gradient(158deg, #fffdf7, #ece3d2);
  color: var(--ink);
  font-size: 19px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transform: rotate(calc((var(--i) - 1.5) * 6deg)) translateY(calc(abs(var(--i) - 1.5) * 2px));
}

.hero__card.is-red {
  color: var(--suit-red);
}

.whoami {
  display: flex;
  align-items: center;
  gap: 12px;
}

.divider {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  opacity: 0.6;
}

/* ── список-меню (категории настроек) ───────────────────────────────── */

.menu-list {
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
}

.menu-list__item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  color: inherit;
  text-align: left;
  transition: background 0.15s;
}

.menu-list__item:active {
  background: rgba(214, 175, 105, 0.14);
}

.menu-list__icon {
  font-size: 20px;
}

.menu-list__text {
  flex: 1;
  display: grid;
  gap: 2px;
  font-size: 15px;
}

.menu-list__text span {
  font-size: 12.5px;
}

.menu-list__chevron {
  color: var(--muted);
  font-size: 22px;
}

/* ── аватар ─────────────────────────────────────────────────────────── */

.avatar {
  --avatar-size: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, #3d7f63, #1d5340);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-size: calc(var(--avatar-size) * 0.5);
  line-height: 1;
  overflow: hidden;
}

.avatar--photo {
  background: #0e3527;
}

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

.profile-card {
  flex-direction: row;
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-card__avatar {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
}

.profile-card__edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #3a2a0d;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.profile-card__id {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 15px;
}

.profile-card__id span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.profile-card__id .chip {
  justify-self: start;
}

/* ── кадрирование ───────────────────────────────────────────────────── */

.crop__stage {
  position: relative;
  justify-self: center;
  width: 260px;
  height: 260px;
  overflow: hidden;
  border-radius: 16px;
  background: #0b2c20;
  touch-action: none;
  cursor: grab;
}

.crop__stage:active {
  cursor: grabbing;
}

.crop__image {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Круглая рамка поверх: сразу видно, каким аватар станет. */
.crop__mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 16px;
  box-shadow: inset 0 0 0 2000px rgba(6, 26, 19, 0.55);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 49.5%, #000 50%);
  mask: radial-gradient(circle at 50% 50%, transparent 49.5%, #000 50%);
}

.crop__zoom {
  width: 100%;
  accent-color: var(--brass);
}

/* ── чат ────────────────────────────────────────────────────────────── */

.panel--chat {
  gap: 8px;
}

.chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
}

.chat__list {
  min-height: 140px;
  max-height: 34vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  -webkit-overflow-scrolling: touch;
}

.chat__empty,
.chat__system {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.chat__line {
  justify-self: start;
  max-width: 88%;
  padding: 7px 11px;
  border-radius: 12px 12px 12px 4px;
  background: rgba(255, 255, 255, 0.08);
}

.chat__line.is-mine {
  justify-self: end;
  border-radius: 12px 12px 4px 12px;
  background: rgba(214, 175, 105, 0.2);
}

.chat__meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  color: var(--muted);
}

.chat__meta b {
  color: var(--brass-hi);
}

.chat__text {
  font-size: 13.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat__form {
  display: flex;
  gap: 8px;
}

.chat__input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  -webkit-user-select: text;
  user-select: text;
}

.chat__input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.chat__send {
  flex: 0 0 auto;
  width: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #3a2a0d;
  font-size: 16px;
}

/* Выдвижной чат за столом. */
.chat-drawer {
  position: absolute;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 20;
  width: min(360px, 88vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, #164634, #0d3628);
  border-left: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
  animation: drawer-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.chat-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-drawer .chat__list {
  max-height: none;
}

.hud__actions {
  display: flex;
  gap: 8px;
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

@media (min-width: 720px) {
  .shell__nav {
    justify-content: center;
    grid-auto-columns: minmax(120px, 160px);
  }
}
