/* Компоненты интерфейса. */

/* ------------------------------ Кнопки и поля ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--duration-fast) ease, background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.btn:active:not(:disabled),
.icon-btn:active:not(:disabled),
.chip:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.45;
}

.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 86%, var(--text));
  border-color: transparent;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

.btn--small {
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
}

.btn--block {
  width: 100%;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  transition: transform var(--duration-fast) ease, background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--accent);
}

.icon-btn:disabled {
  opacity: 0.45;
}

.search__field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.3rem 0.3rem var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.search__field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search__field > .icon {
  color: var(--muted);
}

.search__input {
  flex: 1;
  min-width: 0;
  height: 2.4rem;
  border: 0;
  background: transparent;
  outline: none;
  /* 16px — iOS не увеличивает страницу при фокусе */
  font-size: max(1rem, 16px);
}

.search__input::placeholder {
  color: var(--muted);
}

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

.search__go {
  min-height: 2.4rem;
  border-radius: var(--r-pill);
}

.suggest {
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  z-index: 50;
  overflow: hidden;
  padding: var(--space-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.suggest__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border-radius: var(--r-md);
  text-align: left;
}

.suggest__item:hover,
.suggest__item[aria-selected="true"] {
  background: var(--accent-soft);
}

.suggest__points {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ------------------------------ Чипы и бейджи ------------------------------ */

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.chips--scroll {
  flex-wrap: nowrap;
  margin-bottom: 0;
  padding: 2px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

/* На телефоне ленту фильтров можно листать от края до края экрана */
@media (max-width: 639.98px) {
  .chips--scroll {
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
  }
}

/* На ПК фильтров мало — переносим на новую строку вместо прокрутки */
@media (min-width: 1024px) {
  .chips--scroll {
    flex-wrap: wrap;
    overflow: visible;
  }
}

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

.chips__label {
  color: var(--muted);
  font-size: var(--text-xs);
}

.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  max-width: 14rem;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  transition: transform var(--duration-fast) ease, background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.chip:hover {
  border-color: var(--accent-line);
}

.chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--league {
  border: 1px solid color-mix(in srgb, var(--league, var(--accent)) 55%, transparent);
  background: color-mix(in srgb, var(--league, var(--accent)) 14%, transparent);
}

.badge--league::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--league, var(--accent));
}

.badge--tone {
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  color: var(--tone);
}

/* ------------------------------ Карточки ------------------------------ */

.card {
  position: relative;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

@media (min-width: 1024px) {
  .card {
    padding: var(--space-5);
  }
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card--tint {
  background: linear-gradient(140deg, var(--accent-soft), transparent 60%), var(--surface);
}

.card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.card--flush > .card__head {
  margin: 0;
  padding: var(--space-4) var(--space-4) var(--space-3);
}

.card__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.card__title .icon {
  color: var(--accent);
}

.card__aside {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-xs);
}

.card__hint {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-xs);
}

.section-title {
  margin: var(--space-2) 0 calc(var(--space-1) * -1);
  font-size: var(--text-lg);
}

.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  color: var(--muted);
  text-align: center;
}

.empty .tee {
  width: 5rem;
  height: 5rem;
  color: var(--accent);
}

.empty__title {
  color: var(--text);
  font-size: var(--text-xl);
}

.empty p {
  max-width: 30rem;
}

/* Плашки «нет связи», «игрок не найден»: компактные, по ширине текста, с крестиком */
.notice {
  display: flex;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  width: fit-content;
  max-width: min(100%, 40rem);
  margin-bottom: var(--space-4);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--text-sm);
  animation: rise 260ms var(--ease-out);
}

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

.notice--error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.notice--warn > .icon {
  color: var(--warn);
}

.notice__close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.notice__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

@media (max-width: 479.98px) {
  .notice {
    flex-wrap: wrap;
    width: 100%;
  }
}

.skeleton {
  min-height: 6rem;
  border-radius: var(--r-lg);
  background: var(--surface);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton--tall {
  min-height: 15rem;
}

/* ------------------------------ Прогресс ------------------------------ */

.bar {
  display: block;
  width: 100%;
  height: 0.5rem;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}

.bar--thin {
  height: 0.3rem;
}

.bar--thick {
  height: 0.75rem;
}

.bar__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--tone, var(--accent));
  transform: scaleX(var(--share, 0));
  transform-origin: left center;
  animation: grow var(--duration-slow) var(--ease-out) backwards;
}

.ring {
  flex: none;
}

.ring__track {
  stroke: var(--surface-2);
}

.ring__value {
  stroke: var(--tone, var(--accent));
  transition: stroke-dashoffset var(--duration-slow) var(--ease-out);
}

.ring__label {
  fill: var(--text);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 700;
}

/* ------------------------------ Герой профиля ------------------------------ */

.hero {
  position: relative;
  display: grid;
  gap: var(--space-4);
  height: 100%;
  padding: var(--space-5);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  z-index: -1;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  background: var(--glow);
  filter: blur(60px);
}

.hero__top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.hero__avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: clamp(4.5rem, 3rem + 6vw, 6.5rem);
  aspect-ratio: 1;
  border: 1px solid var(--accent-line);
  border-radius: 30%;
  background: var(--accent-soft);
  color: var(--accent);
}

.hero__avatar .tee {
  width: 74%;
  height: 74%;
}

.hero__name {
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.hero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.hero__points {
  align-self: end;
}

.hero__figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.hero__figure .num {
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
}

.hero__figure .muted {
  font-size: var(--text-sm);
}

.hero__share {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ------------------------------ Плитки метрик ------------------------------ */

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  height: 100%;
}

@media (min-width: 1024px) {
  .metrics {
    gap: var(--space-4);
  }
}

.metric {
  display: grid;
  align-content: space-between;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--duration) ease, transform var(--duration) var(--ease-out);
}

.metric:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
}

.metric__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric__label .icon {
  color: var(--accent);
}

.metric__value {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.1;
}

.metric__sub {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ------------------------------ Списки ------------------------------ */

.list > * + * {
  border-top: 1px solid var(--line);
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.45rem 0;
  font-size: var(--text-sm);
}

.kv__k {
  flex: none;
  max-width: 62%;
  color: var(--muted);
}

.kv__v {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

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

.item__title {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item__sub {
  color: var(--muted);
  font-size: var(--text-xs);
}

.item__side {
  flex: none;
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: right;
}

.item__mark {
  flex: none;
  width: 4px;
  height: 2rem;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.75;
}

.item__index {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.item--stacked {
  display: grid;
  gap: var(--space-2);
}

.item--stacked > .item__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Раскрывающиеся строки */

.fold__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 3.5rem;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  transition: background-color var(--duration-fast) ease;
}

.fold__head:hover {
  background: var(--surface-2);
}

.fold__chevron {
  flex: none;
  color: var(--muted);
  transition: transform var(--duration) var(--ease-out);
}

.fold__head[aria-expanded="true"] .fold__chevron {
  transform: rotate(180deg);
}

.fold__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration) var(--ease-out);
}

.fold__head[aria-expanded="true"] + .fold__panel {
  grid-template-rows: 1fr;
}

.fold__inner {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility var(--duration);
}

.fold__head[aria-expanded="true"] + .fold__panel > .fold__inner {
  visibility: visible;
}

.fold__content {
  padding: var(--space-1) var(--space-4) var(--space-4);
  border-top: 1px solid var(--line);
}

.more {
  width: 100%;
  border-radius: 0;
  border-top: 1px solid var(--line);
}

.thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 2;
  margin: var(--space-3) 0;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--surface-2);
  animation: pulse 1.4s ease-in-out infinite;
}

.thumb.is-loaded {
  animation: none;
}

@media (min-width: 1024px) {
  .thumb {
    max-width: 30rem;
  }
}

/* ------------------------------ Графики ------------------------------ */

.chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart__area {
  fill: var(--accent-soft);
}

.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart__grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart__dot {
  fill: var(--accent);
}

.chart__labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 5rem;
}

.bars__bar {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  opacity: 0.75;
  transform: scaleY(var(--share, 0));
  transform-origin: bottom;
  transition: opacity var(--duration-fast) ease;
}

.bars__bar:hover {
  opacity: 1;
}

.heatmap {
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: thin;
}

.heatmap__grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 0.8rem;
  grid-template-rows: repeat(7, 0.8rem);
  gap: 3px;
  width: max-content;
  margin-left: auto;
}

.heatmap__cell {
  border-radius: 3px;
  background: var(--surface-2);
}

.heatmap__cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heatmap__cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--surface-2)); }
.heatmap__cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--surface-2)); }
.heatmap__cell[data-level="4"] { background: var(--accent); }

.heatmap__legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
}

.heatmap__legend .heatmap__cell {
  width: 0.8rem;
  height: 0.8rem;
}

/* ------------------------------ Карты и планировщик ------------------------------ */

.chance {
  display: grid;
  flex: none;
  place-items: center;
}

.range {
  flex: 1 1 12rem;
  min-width: 0;
  height: 2rem;
  accent-color: var(--accent);
}

/* ------------------------------ ИИ-помощник ------------------------------ */

.assistant {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-3);
  height: 100%;
}

.assistant__log {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 20rem;
  min-height: 6rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.assistant__hints {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--space-2);
}

.msg {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: rise 260ms var(--ease-out) backwards;
}

.msg--user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
}

.msg--bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--surface-2);
}

.msg--error {
  align-self: flex-start;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.msg--typing {
  display: flex;
  gap: 5px;
  align-items: center;
  align-self: flex-start;
  min-height: 2.3rem;
  background: var(--surface-2);
}

.msg--typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1s ease-in-out infinite;
}

.msg--typing i:nth-child(2) { animation-delay: 150ms; }
.msg--typing i:nth-child(3) { animation-delay: 300ms; }

.assistant__form {
  display: flex;
  gap: var(--space-2);
}

.field {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  outline: none;
  font-size: max(1rem, 16px);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.field:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field::placeholder {
  color: var(--muted);
}

/* ------------------------------ Задания ------------------------------ */

.quest {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--duration-fast) ease, opacity var(--duration) ease, transform var(--duration-fast) ease;
}

.quest:hover {
  border-color: var(--accent-line);
}

.quest:active {
  transform: scale(0.985);
}

.quest__check {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--line-strong);
  border-radius: 9px;
  color: transparent;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.quest[aria-pressed="true"] {
  opacity: 0.66;
}

.quest[aria-pressed="true"] .quest__check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.quest[aria-pressed="true"] .item__title {
  text-decoration: line-through;
}

.quest .item__title {
  white-space: normal;
}

.questhead__rank {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.questhead__rank .bar {
  --tone: var(--league);
}

/* ------------------------------ Диалоги ------------------------------ */

.sheet {
  width: min(100%, 44rem);
  max-width: 100%;
  max-height: min(92dvh, 46rem);
  margin: auto auto 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-in 320ms var(--ease-out);
}

.sheet::backdrop {
  background: rgb(0 0 0 / 55%);
  backdrop-filter: blur(3px);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(24px); }
}

@media (min-width: 720px) {
  .sheet {
    margin: auto;
    border-radius: var(--r-xl);
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .sheet {
    max-height: 100dvh;
    margin: auto;
    border-radius: var(--r-lg);
  }
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.sheet__title {
  font-size: var(--text-lg);
}

.sheet__head .icon-btn {
  margin-left: auto;
}

.sheet__body {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet__section > h3 {
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Выбор темы */

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr));
  gap: var(--space-3);
}

.theme-card {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--duration-fast) ease, transform var(--duration-fast) ease;
}

.theme-card:hover {
  transform: translateY(-2px);
}

.theme-card[aria-checked="true"] {
  border-color: var(--accent);
}

.theme-card__preview {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--bg);
}

.theme-card__preview i {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
}

.theme-card__preview i:first-child {
  width: 46%;
  background: var(--accent);
}

.theme-card__preview i:nth-child(2) {
  height: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.theme-card__preview i:last-child {
  width: 70%;
}

.theme-card__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-1) var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
}

.theme-card__label .icon {
  color: var(--accent);
  opacity: 0;
}

.theme-card[aria-checked="true"] .theme-card__label .icon {
  opacity: 1;
}

.option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3rem;
  padding: var(--space-2) 0;
  cursor: pointer;
}

.option__text {
  flex: 1;
}

.option__text small {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

.switch {
  position: relative;
  flex: none;
  width: 2.9rem;
  height: 1.7rem;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  appearance: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.7rem - 6px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--text);
  transition: transform var(--duration) var(--ease-out);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  background: var(--accent-ink);
  transform: translateX(1.2rem);
}

.check {
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  margin: 0;
  accent-color: var(--accent);
}

.seg {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.seg__item {
  min-height: 2.5rem;
  padding: 0 var(--space-2);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.seg__item[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgb(0 0 0 / 18%);
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0 var(--space-4);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.actions > .btn {
  flex: 1 1 10rem;
}

/* ------------------------------ Уведомления и жест обновления ------------------------------ */

.toasts {
  position: fixed;
  inset: auto 0 calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3)) 0;
  z-index: 90;
  display: grid;
  justify-items: center;
  padding: 0 var(--space-4);
  pointer-events: none;
}

@media (min-width: 1024px) {
  .toasts {
    bottom: var(--space-5);
  }
}

.toast {
  max-width: 30rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  animation: rise 260ms var(--ease-out);
}

.toast--error {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--danger);
}

.toast--good {
  border-color: color-mix(in srgb, var(--good) 55%, transparent);
}

.pull {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 0.5rem);
  left: 50%;
  z-index: 60;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  opacity: var(--pull-opacity, 0);
  transform: translate(-50%, var(--pull-y, -3rem)) rotate(var(--pull-turn, 0deg));
  pointer-events: none;
}

/* ------------------------------ Мелочи ------------------------------ */

.tee__glint {
  fill: var(--surface);
}

.hero__id {
  min-width: 0;
}

.chart {
  height: 11rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: var(--space-3);
  max-width: 62rem;
  margin: var(--space-4) auto 0;
}

.feature {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: var(--text-sm);
  transition: border-color var(--duration) ease, transform var(--duration) var(--ease-out);
}

.feature:hover {
  border-color: var(--accent-line);
  transform: translateY(-3px);
}

.feature .icon {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--accent);
}

.feature h3 {
  font-size: var(--text-md);
}

.assistant .card__aside {
  color: inherit;
}

.suggest__item {
  cursor: pointer;
}

/* ------------------------------ Правки по результатам проверки вёрстки ------------------------------ */

.item__title,
.item__sub {
  display: block;
}

.hero__name {
  font-size: clamp(1.35rem, 1rem + 1.5vw, 2rem);
  overflow-wrap: break-word;
}

.hero__figure .num {
  font-size: clamp(2rem, 1.4rem + 2vw, 2.9rem);
}

.hero__share {
  font-size: var(--text-lg);
}

.metric__value {
  font-size: clamp(1.05rem, 0.75rem + 1.5vw, 1.7rem);
}

.card:not(.card--flush) .list > .item {
  padding-inline: 0;
}

@media (max-width: 380px) {
  .brand__tag {
    display: none;
  }

  .topbar {
    gap: var(--space-2);
  }

  .topbar__actions {
    gap: var(--space-1);
  }

  .icon-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .metric {
    padding: var(--space-3);
  }
}

.hero > *,
.hero__top > * {
  min-width: 0;
}

.hero__avatar {
  min-width: 4.5rem;
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 1023.98px) {
  .grid > .lg-stretch {
    align-self: stretch;
  }

  .hero__avatar {
    width: 4.5rem;
  }
}

/* ------------------------------ Вкладка «Карты»: ровные ряды и детали карты ------------------------------ */

.lg-stretch > .card {
  height: 100%;
}

.kv--block {
  display: grid;
  gap: var(--space-2);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 0.2rem 0.55rem;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.map-link {
  margin-top: var(--space-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-2);
  pointer-events: auto;
}

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

/* ------------------------------ Тема «По аватарке» ------------------------------ */

.theme-card--loading {
  min-height: 7.2rem;
  animation: pulse 1.4s ease-in-out infinite;
}

.theme-card--media .theme-card__preview {
  background: linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--accent) 22%, var(--bg)));
}

.theme-card__preview--empty {
  display: grid;
  place-items: center;
  min-height: 4.6rem;
  color: var(--muted);
}

.theme-card:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

/* ------------------------------ Задания: тип, прогресс, правила ------------------------------ */

.quest__kind {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.35em;
  vertical-align: -0.12em;
  color: var(--accent);
}

.quest__progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.quest__progress .bar {
  flex: 1;
}

.quest__count {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.quest__xp {
  flex: none;
}

.quest--auto .quest__check {
  border-color: var(--good);
  background: var(--good);
}

.quest-streak {
  margin-left: auto;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
}

.quest-rules {
  display: grid;
  gap: var(--space-2);
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: var(--text-sm);
  list-style: disc;
}

.quest-rules li::marker {
  color: var(--accent);
}
