:root {
  --brand: #432171;      /* фиолетовый логотипа TSG */
  --brand-deep: #2f1757;
  --brand-soft: #efeaf8;
  --ink: #1d1530;
  --muted: #6c6581;
  --line: #e8e4f0;
  --page: #f5f3f9;
  --surface: #ffffff;
  --wa: #1fa855;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; flex: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 3px solid #8b63e8; outline-offset: 2px; border-radius: 12px; }

.card { max-width: 460px; margin: 0 auto; padding-bottom: calc(28px + var(--safe-bottom)); }

/* Шапка — фиолетовая, как логотип */
.hero {
  position: relative;
  padding: calc(52px + var(--safe-top)) 24px 82px;
  background: linear-gradient(172deg, #4b2580 0%, var(--brand) 42%, var(--brand-deep) 100%);
  color: #fff;
  text-align: center;
}
.lang {
  position: absolute; top: calc(14px + var(--safe-top)); right: 14px;
  min-width: 48px; height: 36px; padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.32);
  font-size: 13px; font-weight: 600; letter-spacing: .06em;
  color: #fff;
}
.lang:active { background: rgba(255,255,255,.12); }

/* Логотип вместо имени — главное в шапке */
.logo { display: inline-flex; flex-direction: column; align-items: center; gap: 14px; }
.mark { width: 76px; height: 144px; color: #fff; }
.brand-text { font-size: 15px; color: rgba(255,255,255,.76); }
.role { margin: 30px 0 0; font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
.org { margin: 6px 0 0; font-size: 14.5px; color: rgba(255,255,255,.7); }

/* Три быстрых действия поверх края шапки */
.quick {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: -44px 16px 0;
}
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; padding: 14px 6px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(29,21,48,.06), 0 8px 24px -10px rgba(47,23,87,.28);
  font-size: 14px; font-weight: 600;
  transition: transform .15s ease;
}
.tile:active { transform: scale(.97); }
.tile-ico {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
}
.tile-wa .tile-ico { background: #e5f6ec; color: var(--wa); }

/* Главные кнопки */
.actions { display: grid; gap: 10px; margin: 18px 16px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 18px;
  border-radius: 16px;
  font-size: 16px; font-weight: 600;
  transition: transform .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 22px -12px rgba(67,33,113,.8); }
.btn-primary:active { background: var(--brand-deep); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-quiet svg { color: var(--brand); }
.btn.wide { width: 100%; }

/* Контакты строками */
.details {
  list-style: none;
  margin: 18px 16px 0; padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.details li { position: relative; display: flex; align-items: center; }
.details li + li::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; border-top: 1px solid var(--line); }
.detail {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 8px 12px 18px;
}
.detail > svg { color: var(--brand); }
.detail > svg.wa { color: var(--wa); }
.detail > span { min-width: 0; display: flex; flex-direction: column; }
.detail small { font-size: 12.5px; color: var(--muted); }
.detail b { font-weight: 500; font-size: 16px; overflow-wrap: anywhere; }
.copy {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-right: 6px;
  border-radius: 12px; color: var(--muted);
}
.copy svg { width: 20px; height: 20px; }
.copy:active { background: var(--brand-soft); color: var(--brand); }

.foot { margin: 22px 24px 0; color: var(--muted); font-size: 13.5px; }
.foot p { margin: 0; }
.install {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px; padding: 10px 0;
  color: var(--brand); font-weight: 600; font-size: 15px;
}
.install[hidden] { display: none; }

/* Нижние листы: QR и «Поделиться» */
.sheet {
  width: 100%; max-width: 480px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  color: var(--ink);
  max-height: 92svh;
}
.sheet[open] { animation: sheet-in .26s cubic-bezier(.2,.8,.2,1); }
.sheet::backdrop { background: rgba(22,12,42,.52); }
.sheet-body { padding: 18px 20px calc(22px + var(--safe-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 650; }
.x { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -8px; border-radius: 50%; color: var(--muted); }
.x:active { background: var(--page); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--page); }
.seg button { min-height: 42px; border-radius: 11px; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg button[hidden] { display: none; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(29,21,48,.12); }

.qr-box {
  width: min(78vw, 320px); aspect-ratio: 1;
  margin: 18px auto 0;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-hint { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.qr-who { margin: 4px 0 0; text-align: center; font-size: 15px; }

.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.share-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0; font-size: 13px; font-weight: 500; border-radius: 14px; }
.share-opt:active { background: var(--page); }
.so-ico { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.so-ico svg { width: 24px; height: 24px; }
.so-wa { background: #e5f6ec; color: var(--wa); }
.so-tg { background: #e6f2fb; color: #2a8bd4; }
.sheet .btn + .btn { margin-top: 10px; }
/* «Поделиться»: в браузере — ссылкой, в приложении — карточкой контакта */
.share-app { display: none; }
.in-app .share-web { display: none; }
.in-app .share-app { display: block; }
.share-hint { margin: 8px 4px 14px; font-size: 13.5px; color: var(--muted); text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 16px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #1d1530; color: #fff;
  font-size: 14.5px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { text-align: center; padding: 16px; }

/* Появление при открытии — коротко и один раз */
@media (prefers-reduced-motion: no-preference) {
  .hero > *, .quick, .actions, .details, .foot { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
  .hero > .role, .hero > .org { animation-delay: .06s; }
  .quick { animation-delay: .12s; }
  .actions { animation-delay: .17s; }
  .details { animation-delay: .22s; }
  .foot { animation-delay: .26s; }
}
@keyframes rise { from { transform: translateY(10px); } }   /* без прозрачности: если анимация не пойдёт, визитка всё равно видна */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* На компьютере — карточкой посередине */
@media (min-width: 520px) {
  body { padding: 40px 0; }
  .card {
    background: var(--page);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 30px 70px -30px rgba(47,23,87,.45), 0 0 0 1px rgba(47,23,87,.06);
  }
  .sheet { border-radius: 26px; margin: auto; }
}
