/* eGuard — стиль миниаппов в духе нативного Telegram (тема тянется из клиента). */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #007aff);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, var(--accent));
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --ok: #34c759;
  --sep: color-mix(in srgb, var(--hint) 24%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-secondary-bg-color, #000000);
    --card: var(--tg-theme-section-bg-color, #1c1c1e);
    --text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, #98989e);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* --- аватар чата --- */

.avatar {
  position: relative;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--av1, #82b1ff), var(--av2, #665fff));
  display: grid; place-items: center;
  color: #fff;
  font-weight: 600;
  flex: none;
}
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.avatar.sm { width: 46px; height: 46px; font-size: 20px; }
.avatar.xl { width: 96px; height: 96px; font-size: 40px; }

/* --- шапка (настройки) --- */

.header { display: flex; align-items: center; gap: 12px; padding: 6px 6px 0; }
.header > div:last-child { min-width: 0; }
.h-title {
  font-size: 19px; font-weight: 600; letter-spacing: -0.3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h-sub { font-size: 14px; color: var(--hint); margin-top: 1px; }

/* --- профиль чата (верификация) --- */

.profile {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 22px 12px 2px;
}
.p-title {
  font-size: 23px; font-weight: 700; letter-spacing: -0.4px;
  margin-top: 13px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.p-sub { font-size: 14.5px; color: var(--hint); margin-top: 4px; }

/* --- секции --- */

.sec {
  display: flex; flex-direction: column; gap: 7px;
}
.sec-label {
  font-size: 13px; font-weight: 400;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--hint);
  padding: 0 16px;
}

.card {
  background: var(--card);
  border-radius: 13px;
  overflow: hidden;
}

.row {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  padding: 11px 16px;
  min-height: 58px;
}
.row + .row::before {
  content: "";
  position: absolute; top: 0; right: 0; left: 58px;
  height: 0.5px;
  background: var(--sep);
}
.card.plain .row + .row::before { left: 16px; }

.icon-badge {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  color: #fff;
}
.icon-badge svg { width: 19px; height: 19px; }
.icon-badge.cf   { background: #ff9500; }
.icon-badge.star { background: #af52de; }

.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 16px; font-weight: 400; letter-spacing: -0.2px; }
.row-sub { font-size: 13px; color: var(--hint); margin-top: 2.5px; line-height: 1.35; }

/* выбираемые строки (режим) */

.sel { cursor: pointer; }
.sel:active { background: color-mix(in srgb, var(--hint) 10%, transparent); }
.sel .check {
  width: 22px; height: 22px; flex: none;
  color: var(--accent);
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.sel.on .check { opacity: 1; transform: none; }

/* --- переключатель (input + span.track: ::before на <input> не работает в iOS Safari) --- */

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0;
  cursor: pointer; z-index: 2;
}
.switch .track {
  position: absolute; inset: 0;
  border-radius: 100px;
  background: color-mix(in srgb, var(--hint) 32%, transparent);
  transition: background 0.22s ease;
}
.switch .track::before {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s cubic-bezier(0.24, 0.9, 0.36, 1.1);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:disabled + .track { opacity: 0.45; }

/* --- статусы в чек-листе --- */

.stat {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
}
.stat svg { width: 14px; height: 14px; }
.stat.ok   { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.stat.fail { background: color-mix(in srgb, var(--danger) 13%, transparent); }

/* --- кнопки --- */

.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 50px;
  border: none; border-radius: 12px;
  background: var(--accent); color: var(--accent-fg);
  font-family: inherit; font-size: 17px; font-weight: 600;
  text-align: center; text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); filter: brightness(0.92); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.ghost {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.btn-row {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 300px; margin-top: 20px;
}

/* --- баннеры-подсказки --- */

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 15px;
  border-radius: 13px;
  font-size: 13.5px; line-height: 1.45;
  background: var(--card);
}
.banner .b-ico { flex: none; line-height: 1.4; }
.banner.warn { box-shadow: inset 3px 0 0 #ff9500; }
.banner.info { box-shadow: inset 3px 0 0 var(--accent); }
.banner b { font-weight: 600; }

.foot-hint {
  font-size: 13.5px; color: var(--hint);
  line-height: 1.45; padding: 0 16px;
}

/* --- полноэкранные состояния --- */

.state {
  min-height: calc(100svh - 60px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 24px 20px;
}
.state h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.state p { color: var(--hint); font-size: 15px; line-height: 1.5; max-width: 320px; }
.state > .btn { max-width: 300px; margin-top: 18px; }

.mark { width: 90px; height: 90px; margin-bottom: 10px; }
.mark .ring  { stroke-dasharray: 277; stroke-dashoffset: 277; animation: dash 0.55s ease-out forwards; }
.mark .glyph { stroke-dasharray: 80;  stroke-dashoffset: 80;  animation: dash 0.4s 0.4s ease-out forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }

.pop { animation: pop 0.5s cubic-bezier(0.3, 1.45, 0.5, 1) both; }
@keyframes pop {
  from { transform: scale(0.45); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.glow { position: relative; }
.glow::before {
  content: "";
  position: absolute; inset: -28px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-c, transparent) 0%, transparent 68%);
  animation: glowpulse 2.4s ease-in-out infinite;
  z-index: -1;
}
.glow.g-ok   { --glow-c: color-mix(in srgb, var(--ok) 30%, transparent); }
.glow.g-fail { --glow-c: color-mix(in srgb, var(--danger) 24%, transparent); }
.glow.g-wait { --glow-c: color-mix(in srgb, var(--accent) 26%, transparent); }
@keyframes glowpulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

.spinner {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid var(--sep);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- капча --- */

.cf-holder {
  position: relative;
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
}
.cf-holder::before {
  content: "";
  position: absolute; top: 0; right: 0; left: 58px;
  height: 0.5px;
  background: var(--sep);
}
.cf-status {
  display: none;
  align-items: center; justify-content: center; gap: 9px;
  font-size: 14px; color: var(--hint); padding: 4px 0;
}
.cf-status.show { display: flex; }

/* --- появление --- */

.rise { animation: rise 0.32s ease both; }
.rise.d1 { animation-delay: 0.04s; }
.rise.d2 { animation-delay: 0.08s; }
.rise.d3 { animation-delay: 0.13s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- тост --- */

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(90px);
  background: rgba(22, 25, 31, 0.92);
  color: #fff;
  padding: 10px 19px;
  border-radius: 100px;
  font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.3, 0.9, 0.4, 1.1), opacity 0.25s ease;
  z-index: 50; white-space: nowrap;
}
.toast.show { transform: translateX(-50%); opacity: 1; }

.hidden { display: none !important; }

/* --- лендинг --- */

.blobs { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(76px); opacity: 0.13; }
.blob.b1 { width: 270px; height: 270px; left: -90px; top: -80px; background: var(--accent); }
.blob.b2 { width: 240px; height: 240px; right: -80px; top: 140px; background: #8b5cf6; }
.blob.b3 { width: 220px; height: 220px; left: 30%; bottom: -130px; background: #22b8cf; opacity: 0.09; }
