/* Демо-рамка: страница предпросмотра, «телефон», шапка и главная кнопка Telegram.
   Внутри настоящего Telegram (body.native) всё это скрывается — остаётся только .app */

:root {
  --demo-bg: #e7ebf0;
  --demo-text: #1c2430;
  /* значения по умолчанию; tg.js перезапишет их темой */
  --tg-theme-bg-color: #ffffff;
  --tg-theme-secondary-bg-color: #efeff4;
  --tg-theme-section-bg-color: #ffffff;
  --tg-theme-text-color: #000000;
  --tg-theme-hint-color: #8e8e93;
  --tg-theme-link-color: #2481cc;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-header-bg-color: #f7f7f7;
  --tg-theme-destructive-text-color: #ff3b30;
  --tg-theme-section-separator-color: #e1e1e6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--demo-bg);
  color: var(--demo-text);
  -webkit-font-smoothing: antialiased;
}
body.demo-dark { --demo-bg: #0b1118; --demo-text: #e6edf3; }

/* ── Панель демо ─────────────────────────────────────────── */
.demo-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 12px 24px;
}
.demo-brand { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.demo-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ea6ff; box-shadow: 0 0 0 4px rgba(46,166,255,.2); }
.demo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-btn {
  border: 1px solid rgba(0,0,0,.1); background: #fff; color: inherit;
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.demo-btn:hover { border-color: #2ea6ff; }
body.demo-dark .demo-btn { background: #17212b; border-color: #26323f; }

.stage { display: flex; justify-content: center; align-items: flex-start; gap: 40px; padding: 4px 24px 32px; }

.demo-notes { width: 280px; font-size: 14px; line-height: 1.5; padding-top: 24px; }
.demo-notes h3 { font-size: 15px; margin: 0 0 8px; }
.demo-notes ul { margin: 0; padding-left: 18px; }
.demo-notes li { margin-bottom: 8px; }
.demo-notes code { background: rgba(46,166,255,.15); padding: 1px 6px; border-radius: 4px; font-weight: 600; }

/* ── «Телефон» ───────────────────────────────────────────── */
.phone {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  width: 390px; height: min(844px, calc(100vh - 80px)); min-height: 620px;
  border-radius: 46px;
  background: var(--tg-theme-secondary-bg-color);
  box-shadow: 0 0 0 10px #0d0d0f, 0 0 0 11px #3a3a3c, 0 30px 70px rgba(0,0,0,.28);
}

.tg-chrome { flex-shrink: 0; background: var(--tg-theme-header-bg-color); }
.tg-status {
  height: 40px; display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 30px 4px 34px; font-size: 15px; font-weight: 600; color: var(--tg-theme-text-color);
}
.tg-status-icons { display: flex; align-items: flex-end; gap: 2px; }
.tg-status-icons i { width: 3px; background: currentColor; border-radius: 1px; }
.tg-status-icons i:nth-child(1) { height: 5px; }
.tg-status-icons i:nth-child(2) { height: 8px; }
.tg-status-icons i:nth-child(3) { height: 11px; }
.tg-status-icons b { width: 22px; height: 11px; border: 1.5px solid currentColor; border-radius: 3px; margin-left: 6px; position: relative; }
.tg-status-icons b::after { content: ''; position: absolute; inset: 1.5px 5px 1.5px 1.5px; background: currentColor; border-radius: 1px; }

.tg-header {
  height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px;
  border-bottom: .5px solid var(--tg-theme-section-separator-color);
}
.tg-hbtn {
  min-width: 96px; display: flex; align-items: center; gap: 4px; padding: 8px 10px;
  background: none; border: 0; font: inherit; font-size: 16px; cursor: pointer;
  color: var(--tg-theme-link-color);
}
#tgLeftIcon { font-size: 18px; line-height: 1; }
.tg-hmore { justify-content: flex-end; font-size: 24px; letter-spacing: 1px; }
.tg-htitle { text-align: center; line-height: 1.2; color: var(--tg-theme-text-color); }
.tg-htitle b { display: block; font-size: 16px; }
.tg-htitle small { font-size: 12px; color: var(--tg-theme-hint-color); }

/* ── Главная кнопка (MainButton) ─────────────────────────── */
.tg-mainbtn-wrap {
  flex-shrink: 0; padding: 8px 12px 26px;
  background: var(--tg-theme-secondary-bg-color);
}
.tg-mainbtn {
  width: 100%; height: 50px; border: 0; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color);
  font: inherit; font-size: 16px; font-weight: 600;
  transition: opacity .2s, transform .1s;
}
.tg-mainbtn:active { transform: scale(.985); }
.tg-mainbtn.is-disabled { opacity: .45; cursor: default; }
.mb-spin {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.tg-mainbtn.is-loading .mb-spin { display: block; }
.tg-mainbtn.is-loading .mb-text { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Настоящий Telegram: убираем всю имитацию ───────────── */
body.native { background: var(--tg-theme-secondary-bg-color); }
body.native .demo-bar, body.native .demo-notes, body.native .tg-chrome, body.native .tg-mainbtn-wrap { display: none !important; }
body.native .stage { display: block; padding: 0; }
body.native .phone {
  width: 100%; height: var(--tg-viewport-stable-height, 100vh); min-height: 0;
  border-radius: 0; box-shadow: none;
}

/* ── Узкий экран (демо открыли с телефона) ──────────────── */
@media (max-width: 560px) {
  body:not(.native) { display: flex; flex-direction: column; height: 100dvh; }
  .demo-bar { padding: 8px 12px; flex-shrink: 0; }
  .demo-brand { display: none; }
  .demo-actions { flex-wrap: nowrap; overflow-x: auto; }
  .demo-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .stage { padding: 0; display: block; flex: 1; min-height: 0; }
  .demo-notes { display: none; }
  .phone { width: 100%; height: 100%; min-height: 0; border-radius: 0; box-shadow: none; }
  .tg-status { display: none; }
  .tg-mainbtn-wrap { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
