:root {
  --bg: #070b10;
  --panel: rgba(15, 22, 30, 0.84);
  --panel-solid: #111a24;
  --panel-raised: rgba(24, 34, 45, 0.92);
  --line: rgba(150, 180, 206, 0.12);
  --line-strong: rgba(150, 180, 206, 0.2);
  --text: #eef4f9;
  --muted: #8a9bac;
  --faint: #5f7184;
  --accent: #3cc8ff;
  --accent-deep: #1f8fd6;
  --accent-soft: rgba(60, 200, 255, 0.14);
  --in-bubble: #172230;
  --out-top: #1f86c9;
  --out-bottom: #1662a3;
  --online: #4fd98a;
  --danger: #ff6b7d;
  --danger-soft: rgba(255, 107, 125, 0.12);
  --gold-top: #ffd36b;
  --gold-bottom: #f0a53a;
  --radius-lg: 20px;
  --radius-bubble: 18px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(120% 60% at 50% 0%, rgba(31, 143, 214, 0.16), transparent 60%),
    url("/ghost-wallpaper.webp?v=20260906");
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, min(640px, 110vw);
  background-attachment: fixed, fixed;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  flex: 0 0 auto;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

/* ---------- шапка ---------- */

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(9, 14, 20, 0.78);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.app-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(150deg, rgba(60, 200, 255, 0.28), rgba(31, 143, 214, 0.08));
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.28), 0 6px 18px rgba(31, 143, 214, 0.22);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
  fill: var(--text);
}

.header-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.header-copy {
  min-width: 0;
  flex: 1;
}

.header-copy h1,
.header-copy p {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-copy h1 {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-copy p {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
  align-items: center;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  color: #c9f5dc;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(79, 217, 138, 0.1);
  box-shadow: inset 0 0 0 1px rgba(79, 217, 138, 0.22);
}

.status-pill i {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--online);
}

.status-pill i::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--online);
  opacity: 0;
  animation: ping 2.4s ease-out infinite;
}

.status-pill.offline {
  color: var(--muted);
  background: rgba(138, 155, 172, 0.1);
  box-shadow: inset 0 0 0 1px rgba(138, 155, 172, 0.2);
}

.status-pill.offline i {
  background: var(--muted);
}

.status-pill.offline i::after {
  display: none;
}

body.in-thread .status-pill {
  display: none;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  margin-left: -4px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.icon-button:active {
  background: rgba(255, 255, 255, 0.08);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.main-content {
  min-height: calc(100dvh - 64px);
}

.view,
.thread-view {
  padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- плашка о приватности ---------- */

.privacy-notice {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 2px 0 12px;
  padding: 12px 8px 12px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(31, 143, 214, 0.2), rgba(15, 22, 30, 0.86) 70%);
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.notice-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
}

.notice-icon svg,
.privacy-notice button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notice-copy {
  min-width: 0;
  flex: 1;
}

.notice-copy strong {
  display: block;
  font-size: 0.93rem;
}

.notice-copy p {
  margin: 2px 0 0;
  color: #b8c7d4;
  font-size: 0.84rem;
}

.privacy-notice button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.privacy-notice button:active {
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- поиск и список ---------- */

.search-field {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 40px;
  margin-bottom: 14px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.search-field:focus-within {
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.45);
}

.search-field svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.search-field input::placeholder {
  color: var(--faint);
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.list-caption {
  margin: 0 6px 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-list {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.chat-list:empty {
  display: none;
}

.chat-row {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.chat-row + .chat-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 78px;
  height: 1px;
  background: var(--line);
}

.chat-row:active {
  background: rgba(255, 255, 255, 0.05);
}

.chat-body {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.chat-top,
.chat-bottom {
  display: flex;
  min-width: 0;
  gap: 8px;
  align-items: center;
}

.chat-name {
  overflow: hidden;
  flex: 1;
  font-size: 0.99rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-time {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.chat-preview {
  overflow: hidden;
  flex: 1;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-count {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #04202d;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
}

.list-empty {
  margin: 28px 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

/* ---------- аватарки ---------- */

.avatar {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  background: linear-gradient(160deg, #72d5fd, #2a9ef1);
}

.av-0 { background: linear-gradient(160deg, #ff8e6e, #ff4f6a); }
.av-1 { background: linear-gradient(160deg, #ffcf70, #ff9d4d); }
.av-2 { background: linear-gradient(160deg, #9fa8ff, #6c5cff); }
.av-3 { background: linear-gradient(160deg, #9ee27f, #44c46a); }
.av-4 { background: linear-gradient(160deg, #5ff0d8, #20bfae); }
.av-5 { background: linear-gradient(160deg, #72d5fd, #2a9ef1); }
.av-6 { background: linear-gradient(160deg, #eaa8f7, #c862e6); }

/* ---------- переписка ---------- */

.thread-view {
  min-height: calc(100dvh - 64px);
  padding-right: 10px;
  padding-left: 10px;
}

/* короткая переписка прижата к низу, как в Telegram */
.message-list {
  display: flex;
  min-height: calc(100dvh - 120px - env(safe-area-inset-bottom));
  flex-direction: column;
  justify-content: flex-end;
}

.day-sep {
  align-self: center;
  margin: 14px 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  color: #dfe8ef;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(8, 13, 19, 0.62);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.day-sep:first-child {
  margin-top: 4px;
}

.message-row {
  display: flex;
  margin-top: 8px;
  padding: 0 8px;
}

.message-row.join-prev {
  margin-top: 2px;
}

.message-row.out {
  justify-content: flex-end;
}

.bubble {
  position: relative;
  max-width: min(80%, 540px);
  padding: 7px 11px 7px;
  border-radius: var(--radius-bubble);
  background: var(--in-bubble);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.message-row.out .bubble {
  background: linear-gradient(170deg, var(--out-top), var(--out-bottom));
}

/* углы внутри группы сообщений, как в Telegram */
.message-row.in.join-prev .bubble { border-top-left-radius: 6px; }
.message-row.in.join-next .bubble { border-bottom-left-radius: 6px; }
.message-row.out.join-prev .bubble { border-top-right-radius: 6px; }
.message-row.out.join-next .bubble { border-bottom-right-radius: 6px; }

/* хвостик у последнего сообщения группы */
.message-row:not(.join-next) .bubble:not(.bare):not(.media-only)::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 14px;
  height: 14px;
}

.message-row.in:not(.join-next) .bubble:not(.bare):not(.media-only) {
  border-bottom-left-radius: 4px;
}

.message-row.in:not(.join-next) .bubble:not(.bare):not(.media-only)::before {
  left: -7px;
  background: var(--in-bubble);
  -webkit-mask: radial-gradient(circle at 0 0, transparent 13.5px, #000 14px);
  mask: radial-gradient(circle at 0 0, transparent 13.5px, #000 14px);
}

.message-row.out:not(.join-next) .bubble:not(.bare):not(.media-only) {
  border-bottom-right-radius: 4px;
}

.message-row.out:not(.join-next) .bubble:not(.bare):not(.media-only)::before {
  right: -7px;
  background: var(--out-bottom);
  -webkit-mask: radial-gradient(circle at 100% 0, transparent 13.5px, #000 14px);
  mask: radial-gradient(circle at 100% 0, transparent 13.5px, #000 14px);
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.meta {
  position: relative;
  top: 7px;
  display: inline-flex;
  float: right;
  gap: 5px;
  align-items: center;
  margin: 0 -2px 0 12px;
  color: rgba(224, 236, 246, 0.58);
  font-size: 0.69rem;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.message-row.out .meta {
  color: rgba(236, 246, 255, 0.72);
}

.meta.block {
  position: static;
  display: flex;
  float: none;
  justify-content: flex-end;
  margin: 4px 0 0;
}

.meta-deleted {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  color: #ffb3bd;
  font-weight: 600;
}

.meta-deleted svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

/* удалённое сообщение — красная обводка */
.bubble.is-deleted {
  box-shadow: inset 0 0 0 1.5px rgba(255, 107, 125, 0.55), 0 1px 2px rgba(0, 0, 0, 0.28);
}

.message-row.in .bubble.is-deleted {
  background: linear-gradient(170deg, #2a1c25, #1f1a24);
}

.message-row.in:not(.join-next) .bubble.is-deleted:not(.bare):not(.media-only)::before {
  background: #1f1a24;
}

.bubble.with-media {
  padding: 3px;
}

.bubble.with-media .message-text {
  padding: 5px 8px 4px;
}

.bubble.with-media .meta.block {
  margin: 4px 6px 2px;
}

/* фото без подписи — время поверх фото */
.bubble.media-only {
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.message-row.out .bubble.media-only {
  background: transparent;
}

.meta.overlay {
  position: absolute;
  top: auto;
  right: 8px;
  bottom: 8px;
  float: none;
  margin: 0;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.message-media {
  display: block;
  width: 100%;
  max-width: 460px;
  max-height: 62vh;
  border-radius: 15px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
}

.bubble.media-only .message-media {
  border-radius: var(--radius-bubble);
}

/* фото целиком, с сохранением пропорций, как в Telegram */
.message-photo {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(56vh, 440px);
  min-width: 120px;
  min-height: 80px;
  object-fit: contain;
  cursor: zoom-in;
}

video.message-media {
  object-fit: contain;
  background: #000;
}

.media-placeholder,
.document-link {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  margin: 2px 0 4px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--text);
  font-size: 0.86rem;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.2);
}

.media-placeholder {
  color: rgba(226, 236, 244, 0.66);
}

.document-link:active {
  background: rgba(0, 0, 0, 0.32);
}

.media-placeholder.sticker-badge {
  display: inline-flex;
  min-height: auto;
  padding: 6px 12px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  color: #d1ecf9;
}

.sticker-img,
.sticker-video {
  width: auto;
  max-width: 170px;
  max-height: 170px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
}

/* стикеры и кружки — без пузыря */
.bubble.bare,
.message-row.out .bubble.bare {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.bubble.bare .meta {
  position: static;
  float: none;
  width: fit-content;
  margin: 4px auto 0;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
}

.message-row.out .bubble.bare .meta {
  margin-right: 0;
}

.message-row.in .bubble.bare .meta {
  margin-left: 0;
}

.empty-thread {
  margin: auto;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  background: rgba(8, 13, 19, 0.6);
}

.older-button,
.primary-button {
  display: block;
  min-height: 40px;
  margin: 0 auto 12px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
  background: rgba(8, 13, 19, 0.7);
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.primary-button {
  margin-top: 20px;
  padding: 11px 26px;
  color: #04202d;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 22px rgba(31, 143, 214, 0.3);
}

.older-button:disabled {
  opacity: 0.6;
}

/* ---------- состояния ---------- */

.state-view {
  display: grid;
  min-height: calc(100dvh - 64px);
  padding: 28px 24px;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.state-view.compact {
  min-height: 46vh;
}

.state-view h2,
.state-view p {
  margin: 0;
}

.state-view h2 {
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.state-view p {
  max-width: 320px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.93rem;
}

.state-icon,
.empty-ghost {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 22px;
  color: var(--danger);
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 125, 0.25);
}

.state-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.empty-ghost {
  color: var(--accent);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.empty-ghost svg,
.ghost-loader svg,
.paywall-badge svg {
  fill: rgba(255, 255, 255, 0.06);
  stroke: currentColor;
  stroke-width: 1.8;
}

.empty-ghost svg {
  width: 36px;
  height: 36px;
}

.ghost-loader {
  display: grid;
  width: 88px;
  height: 88px;
  margin-bottom: 10px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: radial-gradient(circle, rgba(60, 200, 255, 0.18), transparent 68%);
}

.ghost-loader svg {
  width: 58px;
  height: 58px;
  animation: float 1.8s ease-in-out infinite;
}

/* ---------- экран Plus ---------- */

.paywall-badge {
  position: relative;
  display: grid;
  width: 96px;
  height: 96px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 30px;
  color: var(--accent);
  background: linear-gradient(150deg, rgba(60, 200, 255, 0.24), rgba(15, 22, 30, 0.9));
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.3), 0 16px 40px rgba(31, 143, 214, 0.28);
}

.paywall-badge svg {
  width: 58px;
  height: 58px;
}

.paywall-star {
  position: absolute;
  right: -8px;
  bottom: -8px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  font-size: 1.15rem;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
  box-shadow: 0 0 0 4px var(--bg), 0 6px 16px rgba(240, 165, 58, 0.4);
}

.paywall-features {
  display: grid;
  width: min(100%, 320px);
  gap: 1px;
  margin: 20px 0 0;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  text-align: left;
  list-style: none;
  background: var(--line);
  box-shadow: inset 0 0 0 1px var(--line);
}

.paywall-features li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  font-size: 0.9rem;
  background: var(--panel-solid);
}

.paywall-features span {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  font-size: 0.95rem;
  background: var(--accent-soft);
}

.gold-button {
  position: relative;
  width: min(100%, 320px);
  min-height: 50px;
  margin-top: 22px;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  color: #3a2300;
  font-size: 1rem;
  font-weight: 750;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
  box-shadow: 0 10px 26px rgba(240, 165, 58, 0.32);
  cursor: pointer;
}

.gold-button::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-18deg);
  animation: shine 3.2s ease-in-out infinite;
}

.gold-button:active,
.primary-button:active,
.older-button:active {
  transform: scale(0.98);
}

/* ---------- просмотр фото ---------- */

.viewer {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  place-items: center;
  background: rgba(0, 0, 0, 0.94);
  cursor: zoom-out;
  animation: fade 0.18s ease-out;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.is-hidden {
  display: none !important;
}

/* ---------- видеокружки ---------- */

.video-note {
  position: relative;
  width: min(240px, 64vw);
  aspect-ratio: 1;
  margin: 4px;
  border-radius: 50%;
  cursor: pointer;
}

.video-note-video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.video-note-ring {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.video-note-ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.25s linear;
}

.video-note-play {
  position: absolute;
  inset: 0;
  display: grid;
  width: 56px;
  height: 56px;
  margin: auto;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.video-note-play::before {
  content: "";
  margin-left: 5px;
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent #fff;
}

.video-note.is-playing .video-note-play {
  opacity: 0;
}

.video-note-time {
  position: absolute;
  bottom: 10px;
  left: 50%;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.55);
  transform: translateX(-50%);
  pointer-events: none;
}

/* ---------- голосовые и аудио ---------- */

.voice-player {
  display: flex;
  gap: 10px;
  align-items: center;
  width: min(260px, 66vw);
  margin: 2px 0;
}

.voice-play {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #04202d;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  cursor: pointer;
}

.message-row.out .voice-play {
  color: var(--out-bottom);
  background: #eef8ff;
}

.voice-play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 3px;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent currentColor;
}

.voice-player.is-playing .voice-play::before {
  width: 4px;
  height: 15px;
  margin-left: -7px;
  border: 0;
  background: currentColor;
  box-shadow: 7px 0 0 currentColor;
}

.voice-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.voice-seek {
  padding: 7px 0;
  cursor: pointer;
}

.voice-track {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
}

.voice-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
}

.message-row.out .voice-fill {
  background: #eef8ff;
}

.voice-time {
  color: rgba(226, 238, 247, 0.7);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- заставка при открытии ---------- */

/* Логотип стоит ровно по центру экрана. Когда данные готовы, фон растворяется,
   а логотип перелетает на место значка в шапке (revealApp в app.js). */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

body.splashing {
  overflow: hidden;
}

.splash {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  /* страховка: если скрипт не загрузился, заставка сама уходит через 15 секунд */
  animation: splash-failsafe 0.01s linear 15s forwards;
}

.splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(55% 34% at 50% 50%, rgba(31, 143, 214, 0.24), transparent 72%),
    var(--bg);
}

.splash-stage {
  position: relative;
  display: grid;
  gap: 26px;
  justify-items: center;
}

.splash-logo {
  position: relative;
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 32px;
  background: linear-gradient(150deg, rgba(60, 200, 255, 0.3), rgba(31, 143, 214, 0.08));
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.34), 0 18px 48px rgba(31, 143, 214, 0.34);
  animation: logo-in 0.7s var(--ease-spring) both;
  will-change: transform;
}

.splash-ghost {
  width: 64px;
  height: 64px;
  color: var(--accent);
  fill: var(--text);
  animation: hover 2.4s ease-in-out 0.7s infinite;
}

/* мягкие волны от логотипа, пока грузятся данные */
.splash-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 1.5px rgba(60, 200, 255, 0.55);
  opacity: 0;
  animation: ring 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) 0.6s infinite;
}

.splash-ring.late {
  animation-delay: 1.8s;
}

.splash-copy {
  display: grid;
  gap: 8px;
  justify-items: center;
  animation: fade-up 0.5s var(--ease-out) 0.25s both;
}

.splash-title {
  color: transparent;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(120deg, #ffffff 35%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.splash-sub {
  color: var(--muted);
  font-size: 0.88rem;
}

.splash-bar {
  position: relative;
  width: 136px;
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(150, 180, 206, 0.14);
}

.splash-bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: bar 1.25s ease-in-out infinite;
}

/* раскрытие: фон и подписи уходят, логотип летит в шапку (Web Animations в app.js) */
.splash.reveal {
  pointer-events: none;
}

.splash.reveal::before {
  animation: fade-out 0.5s ease 0.06s both;
}

.splash.reveal .splash-copy {
  animation: fade-out 0.18s ease-out both;
}

.splash.reveal .splash-ring {
  display: none;
}

.splash.reveal .splash-logo,
.splash.reveal .splash-ghost {
  animation: none;
}

/* если лететь некуда (например, открыта сразу переписка) — логотип просто растворяется */
.splash.reveal.no-fly .splash-logo {
  animation: logo-out 0.42s var(--ease-out) both;
}

.brand-mark.waiting {
  visibility: hidden;
}

.brand-mark.land {
  animation: land 0.36s var(--ease-spring) both;
}

/* шапка после заставки только проявляется — сдвиг сбил бы точку приземления логотипа */
body.splashing .app-header {
  animation: none;
}

body.after-splash .app-header {
  animation: fade 0.4s ease-out 0.2s both;
}

@keyframes logo-in {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

@keyframes logo-out {
  to { transform: scale(1.18); opacity: 0; }
}

@keyframes hover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes ring {
  0% { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(1.75); opacity: 0; }
}

@keyframes bar {
  from { transform: translateX(-100%); }
  to { transform: translateX(240%); }
}

@keyframes land {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes fade-out {
  to { opacity: 0; }
}

@keyframes splash-failsafe {
  to { opacity: 0; visibility: hidden; }
}

/* ---------- нижние вкладки ---------- */

.tabbar {
  position: fixed;
  z-index: 20;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  width: min(calc(100% - 24px), 400px);
  height: 62px;
  padding: 5px;
  grid-template-columns: repeat(4, 1fr);
  border-radius: 24px;
  background: rgba(12, 18, 26, 0.84);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 16px 40px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.tabbar.enter {
  animation: tabbar-in 0.55s var(--ease-spring) 0.3s both;
}

.tab-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 10px) / 4);
  border-radius: 19px;
  background: linear-gradient(150deg, rgba(60, 200, 255, 0.26), rgba(31, 143, 214, 0.1));
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.32);
  transition: transform 0.4s var(--ease-spring);
}

.tabbar[data-active="earn"] .tab-indicator {
  transform: translateX(100%);
}

.tabbar[data-active="games"] .tab-indicator {
  transform: translateX(200%);
}

.tabbar[data-active="duels"] .tab-indicator {
  transform: translateX(300%);
}

.tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 19px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.12s ease;
}

.tab:active {
  transform: scale(0.95);
}

.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active svg {
  stroke: var(--accent);
}

.tab-badge {
  position: absolute;
  top: 3px;
  left: calc(50% + 8px);
  padding: 1px 6px;
  border-radius: 999px;
  color: #3a2300;
  font-size: 0.56rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
  box-shadow: 0 0 0 2px rgba(12, 18, 26, 0.9);
}

.tab-badge.new {
  color: #04121c;
  background: linear-gradient(150deg, #7fe3ff, var(--accent));
}

/* место под панель, чтобы она не закрывала низ экрана */
body.has-tabbar .view {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

body.has-tabbar .state-view {
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

@keyframes tabbar-in {
  from { transform: translate(-50%, 24px); opacity: 0; }
  to { transform: translateX(-50%); opacity: 1; }
}

/* ---------- заработок ---------- */

.earn-hero {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 20px;
  border-radius: 24px;
  background: linear-gradient(150deg, rgba(31, 143, 214, 0.34), rgba(15, 22, 30, 0.92) 64%);
  box-shadow: inset 0 0 0 1px rgba(60, 200, 255, 0.26), var(--shadow);
}

.earn-hero-glow {
  position: absolute;
  top: -70px;
  right: -50px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(60, 200, 255, 0.32), transparent 70%);
  pointer-events: none;
  animation: glow 5s ease-in-out infinite;
}

.earn-hero-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.earn-hero-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 17px;
  color: #ffffff;
  background: linear-gradient(145deg, #25f4ee, #1f8fd6 52%, #fe2c55);
  box-shadow: 0 10px 24px rgba(254, 44, 85, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.earn-hero-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.earn-hero-badge {
  padding: 6px 11px;
  border-radius: 999px;
  color: #3a2300;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
  box-shadow: 0 6px 18px rgba(240, 165, 58, 0.3);
}

.earn-hero h2 {
  position: relative;
  margin: 0;
  font-size: 1.34rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.earn-hero p {
  position: relative;
  margin: 8px 0 0;
  color: #b8c7d4;
  font-size: 0.92rem;
}

.earn-hero b,
.earn-card b,
.earn-steps b {
  color: var(--accent);
  font-weight: 700;
}

.earn-progress {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.earn-progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.86rem;
}

.earn-progress-top strong {
  color: var(--text);
  font-size: 1.3rem;
}

.earn-progress-track {
  position: relative;
  display: block;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(150, 180, 206, 0.14);
}

.earn-progress-track i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 12px rgba(60, 200, 255, 0.5);
  transition: width 0.8s var(--ease-out) 0.2s;
}

.earn-progress p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.section-title {
  margin: 24px 6px 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.earn-rewards {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.reward {
  position: relative;
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 18px 10px 14px;
  border-radius: 22px;
  text-align: center;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.reward.featured {
  background: linear-gradient(160deg, rgba(240, 165, 58, 0.16), rgba(15, 22, 30, 0.9) 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 211, 107, 0.4), 0 12px 30px rgba(240, 165, 58, 0.14);
}

.reward-tag {
  position: absolute;
  top: -9px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #3a2300;
  font-size: 0.66rem;
  font-weight: 800;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
}

.reward-count {
  color: transparent;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  background: linear-gradient(140deg, #ffffff 30%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.reward.featured .reward-count {
  background-image: linear-gradient(140deg, #fff3d1 20%, var(--gold-bottom));
}

.reward-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.reward-prize {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
  background: var(--accent-soft);
}

.reward.featured .reward-prize {
  color: #3a2300;
  background: linear-gradient(150deg, var(--gold-top), var(--gold-bottom));
}

.earn-note {
  margin: 10px 8px 0;
  color: var(--faint);
  font-size: 0.8rem;
  text-align: center;
}

.earn-card {
  padding: 16px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.earn-card p {
  margin: 0;
  color: #c9d6e1;
  font-size: 0.92rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.chips span {
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 650;
  background: var(--accent-soft);
}

.example {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 3px 0 0 var(--accent);
}

.example-label {
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* готовые комментарии: нажатие копирует */
.comment-hint {
  margin: 0 6px 10px;
  color: var(--faint);
  font-size: 0.8rem;
}

.comment-list {
  display: grid;
  gap: 8px;
}

.comment-item {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 0;
  border-radius: 16px;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--accent);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.comment-item:active {
  transform: scale(0.98);
}

.comment-text {
  font-size: 0.92rem;
  line-height: 1.4;
}

.comment-copy {
  justify-self: end;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.comment-item.is-copied {
  box-shadow: inset 0 0 0 1px rgba(79, 217, 138, 0.6), inset 3px 0 0 #4fd98a;
}

.comment-item.is-copied .comment-copy {
  color: #4fd98a;
}

.comment-in {
  animation: fade-up 0.36s var(--ease-out) var(--d, 0ms) both;
}

.comment-more {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  border-radius: 14px;
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
  cursor: pointer;
}

.copy-buffer {
  position: fixed;
  top: -1000px;
  opacity: 0;
}

.earn-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.earn-steps li {
  display: grid;
  gap: 13px;
  align-items: center;
  padding: 14px 16px;
  grid-template-columns: 32px minmax(0, 1fr);
  border-radius: 20px;
  font-size: 0.93rem;
  font-weight: 600;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.step-num {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #04202d;
  font-size: 0.9rem;
  font-weight: 800;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: 0 6px 16px rgba(31, 143, 214, 0.35);
}

.cta-button {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  margin-top: 18px;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  color: #04202d;
  font-size: 1.02rem;
  font-weight: 800;
  background: linear-gradient(150deg, #5fd6ff, var(--accent-deep));
  box-shadow: 0 12px 30px rgba(31, 143, 214, 0.38);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.cta-button::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-18deg);
  animation: shine 3.4s ease-in-out infinite;
}

.cta-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.cta-button:active {
  transform: scale(0.98);
}

.cta-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.cta-button:disabled::after {
  display: none;
}

.earn-foot {
  margin: 12px 10px 0;
  color: var(--faint);
  font-size: 0.78rem;
  text-align: center;
}

.link-button {
  margin-top: 16px;
  padding: 6px 10px;
  border: 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 650;
  background: transparent;
  cursor: pointer;
}

.link-button:active {
  opacity: 0.7;
}

/* разделы появляются по очереди */
.stagger-in > * {
  animation: fade-up 0.45s var(--ease-out) var(--d, 0ms) both;
}

@keyframes glow {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.85; }
  50% { transform: translate(-14px, 10px) scale(1.1); opacity: 1; }
}

/* ---------- анимации переходов ---------- */

:root {
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* шапка при открытии мини-аппа */
.app-header {
  animation: header-in 0.45s var(--ease-out) both;
}

.header-copy.swap,
.brand-mark.swap {
  animation: swap-in 0.32s var(--ease-out) both;
}

.header-avatar.swap {
  animation: pop 0.42s var(--ease-spring) both;
}

.state-view {
  animation: fade 0.3s ease-out both;
}

/* переход в переписку и обратно */
.enter-forward {
  animation: slide-in-right 0.34s var(--ease-out) both;
}

.enter-back {
  animation: slide-in-left 0.3s var(--ease-out) both;
}

/* первое открытие: плашка, поиск и чаты появляются по очереди */
.view.boot .privacy-notice { animation: fade-up 0.42s var(--ease-out) 40ms both; }
.view.boot .search-field { animation: fade-up 0.42s var(--ease-out) 90ms both; }
.view.boot .list-caption { animation: fade-up 0.42s var(--ease-out) 120ms both; }
.view.boot .chat-list { animation: fade 0.35s ease-out 100ms both; }

.chat-list.stagger .chat-row {
  animation: fade-up 0.42s var(--ease-out) var(--d, 0ms) both;
}

.chat-list.stagger .chat-row .avatar {
  animation: pop 0.5s var(--ease-spring) calc(var(--d, 0ms) + 50ms) both;
}

/* сообщения всплывают от своей стороны */
.message-row.in .bubble { transform-origin: 0 100%; }
.message-row.out .bubble { transform-origin: 100% 100%; }

.message-row.appear .bubble {
  animation: bubble-in 0.36s var(--ease-out) var(--d, 0ms) both;
}

.day-sep.appear {
  animation: fade 0.3s ease-out var(--d, 0ms) both;
}

.message-row.appear-soft,
.day-sep.appear-soft {
  animation: fade 0.35s ease-out both;
}

/* заготовки сообщений, пока грузится переписка */
.skeleton-row {
  display: flex;
  margin-top: 8px;
  padding: 0 8px;
  animation: fade 0.25s ease-out var(--d, 0ms) both;
}

.skeleton-row.out {
  justify-content: flex-end;
}

.skeleton-bubble {
  position: relative;
  height: 38px;
  overflow: hidden;
  border-radius: var(--radius-bubble);
  background: rgba(23, 34, 48, 0.88);
}

.skeleton-row.out .skeleton-bubble {
  background: rgba(31, 134, 201, 0.32);
}

.skeleton-bubble::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.08) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: sweep 1.3s ease-in-out infinite;
}

.skeleton-bubble.tall {
  height: 58px;
}

/* экран Plus собирается по очереди */
.paywall > * {
  animation: fade-up 0.45s var(--ease-out) both;
}

.paywall > :nth-child(1) { animation: pop 0.6s var(--ease-spring) 40ms both; }
.paywall > :nth-child(2) { animation-delay: 120ms; }
.paywall > :nth-child(3) { animation-delay: 170ms; }
.paywall > :nth-child(4) { animation-delay: 230ms; }
.paywall > :nth-child(5) { animation-delay: 300ms; }
.paywall > :nth-child(6) { animation-delay: 360ms; }

.chat-row,
.icon-button,
.gold-button,
.primary-button,
.older-button {
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.chat-row:active {
  transform: scale(0.985);
}

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

@keyframes swap-in {
  from { transform: translateX(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes slide-in-right {
  from { transform: translateX(32px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes slide-in-left {
  from { transform: translateX(-32px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes fade-up {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes sweep {
  to { transform: translateX(100%); }
}

/* ---------- анимации ---------- */

@keyframes float {
  0%, 100% { transform: translateY(0); opacity: 0.75; }
  50% { transform: translateY(-7px); opacity: 1; }
}

@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.8; }
  80%, 100% { transform: scale(1.8); opacity: 0; }
}

@keyframes rise {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shine {
  0%, 55% { left: -60%; }
  100% { left: 130%; }
}

@media (min-width: 700px) {
  .view,
  .thread-view {
    padding-right: 20px;
    padding-left: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* экран «Приложение не загрузилось» от сторожа запуска (boot.js) */
.boot-fail {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg, #070b10);
  color: var(--text, #eef4f9);
  text-align: center;
}

.boot-fail strong {
  font-size: 1.15rem;
}

.boot-fail p {
  max-width: 320px;
  margin: 0;
  color: var(--muted, #8a9bac);
  line-height: 1.4;
}

.boot-fail .primary-button {
  min-width: 200px;
}

/* облегчённый режим (Android и слабые телефоны, класс ставит boot.js): размытие под стеклом и
   неподвижный фон перерисовываются на каждой прокрутке и съедают видеокарту — даём плотную заливку */
html.lite *,
html.lite *::before,
html.lite *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.lite body {
  background-attachment: scroll, scroll;
}

html.lite .app-header {
  background: rgba(9, 14, 20, 0.97);
}

html.lite .tabbar {
  background: rgba(12, 18, 26, 0.98);
}

.boot-fail.is-slow {
  background: rgba(7, 11, 16, 0.92);
}
