/* sonar — серый фон, одно чёрное действие, один шрифт. Сетка 8px. */
:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #e9e9e9;
  --ink: #0a0a0a;
  --muted: #6b6b70;
  --faint: #a3a3a8;
  --btn: #000000;
  --btn-ink: #ffffff;
  --warn: #c2410c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
  --r-sm: 14px;
  --r-lg: 24px;
  --gutter: 24px;
  --col: 400px;
  --top-h: 80px;
  --foot-h: 96px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c; --surface: #161618; --surface-2: #1f1f22; --ink: #f2f2f2;
    --muted: #9a9aa0; --faint: #5f5f66; --btn: #f2f2f2; --btn-ink: #000;
    --warn: #fb923c; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0c; --surface: #161618; --surface-2: #1f1f22; --ink: #f2f2f2;
  --muted: #9a9aa0; --faint: #5f5f66; --btn: #f2f2f2; --btn-ink: #000;
  --warn: #fb923c; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 8px; }

/* ---------- шапка ---------- */
.top { height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--gutter); }
.back { display: inline-flex; align-items: center; gap: 2px; height: 36px; padding: 0 14px 0 8px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 15px; font-weight: 500; text-decoration: none; }
.back:active { transform: scale(.97); }
:root[data-tg] .back { display: none; }
.logo { display: inline-flex; align-items: center; height: 40px; color: var(--ink); text-decoration: none; }
/* логотип — контуры, центр картинки = центр знака = середина букв; одинаково во всех браузерах */
.lockup { height: 22px; width: auto; max-width: 60vw; display: block; flex: none; }
.lockup .w-vpn { opacity: .38; }

main { flex: 1; width: 100%; display: flex; flex-direction: column; }

/* ---------- подвал ---------- */
.foot { padding: 24px var(--gutter); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 0; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }
.foot .dot { margin: 0 8px; color: var(--faint); }
.foot .copy { color: var(--faint); }

/* ---------- кнопки и ссылки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 52px; padding: 0 24px; border: 0; border-radius: var(--r-sm);
  background: var(--btn); color: var(--btn-ink); font-size: 16px; font-weight: 500;
  text-decoration: none; cursor: pointer; transition: opacity .15s, transform .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.985); }
.btn svg { width: 18px; height: 18px; }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.link-muted {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 4px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 14px; text-decoration: none;
}
.link-muted:hover { color: var(--ink); }

/* ---------- один экран — одно действие ---------- */
.solo {
  width: 100%; max-width: calc(var(--col) + 2 * var(--gutter)); margin: 0 auto; padding: 32px var(--gutter);
  flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center;
}
.solo h1, .solo .big { font-size: 32px; line-height: 1.15; font-weight: 500; letter-spacing: -.035em; margin: 0 0 8px; }
.solo .big { font-size: 48px; }
.solo .sub { color: var(--muted); font-size: 16px; margin-bottom: 32px; text-wrap: balance; }
.solo .after { margin-top: 16px; }
.solo .gap { margin-top: 40px; }
.price { margin-top: 16px; font-size: 14px; color: var(--muted); }
.price b { color: var(--ink); font-weight: 500; }
.demo { margin-bottom: 16px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.mini { margin-top: 24px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; }
.mini > span { display: inline-flex; align-items: center; }
.mini .dot { color: var(--faint); margin: 0 4px; }

/* ---------- вход ---------- */
.qr { width: 200px; height: 200px; margin: 0 auto 32px; }
.qr[hidden] { display: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr rect.on { fill: var(--ink); }
.help-body { margin-top: 8px; padding: 16px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; color: var(--muted); text-align: left; }
.help-body .cmd { all: unset; display: block; width: 100%; box-sizing: border-box; margin-top: 8px; cursor: pointer; }
.help-body .cmd:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 10px; }
.help-body code { display: block; padding: 12px; border-radius: 10px; background: var(--surface); color: var(--ink); font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; }
.chev { transition: transform .2s; }
[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ---------- вход по номеру ---------- */
.btn + .btn, .btn.gap-s { margin-top: 12px; }
.field { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 18px; border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow); cursor: text; text-align: left; }
.field:focus-within { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ink) 35%, transparent); }
.field-pre { flex: none; font-size: 18px; font-weight: 500; color: var(--muted); }
.field input { all: unset; flex: 1; min-width: 0; height: 100%; font-size: 18px; font-weight: 500; letter-spacing: .01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.field input::placeholder { color: var(--faint); font-weight: 400; }
.field-code input { text-align: center; letter-spacing: .4em; padding-left: .4em; font-size: 22px; }
.field-code input::placeholder { letter-spacing: 0; font-size: 17px; }
.ph-status { min-height: 20px; margin: 12px 0 16px; font-size: 14px; color: var(--muted); text-wrap: balance; }
.ph-status.is-bad { color: var(--warn); }
#login-phone .help { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#ph-again:disabled { cursor: default; opacity: .7; }

/* ---------- документы ---------- */
.doc { width: 100%; max-width: calc(720px + 2 * var(--gutter)); margin: 0 auto; padding: 16px var(--gutter) 0; }
.doc-nav { display: flex; gap: 4px; margin: 0 calc(-1 * var(--gutter)) 24px; padding: 0 var(--gutter); overflow-x: auto; scrollbar-width: none; }
.doc-nav::-webkit-scrollbar { display: none; }
.doc-nav a { flex: none; height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--muted); }
.doc-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.doc h1 { font-size: 32px; line-height: 1.15; font-weight: 500; letter-spacing: -.03em; margin: 0 0 8px; }
.doc .meta { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 32px; }
.doc h2 { font-size: 17px; font-weight: 500; margin: 32px 0 8px; }
.doc h2:first-child { margin-top: 0; }
.doc p, .doc li { font-size: 15px; line-height: 1.6; }
.doc p { margin-bottom: 8px; }
.doc ol, .doc ul { margin: 0 0 8px; padding-left: 24px; }
.doc li { margin-bottom: 4px; }
.doc .num { display: inline-block; min-width: 32px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc .todo { background: color-mix(in srgb, var(--warn) 14%, transparent); padding: 0 4px; border-radius: 4px; }

/* ---------- уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom)); z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: max-content; max-width: min(calc(100vw - 2 * var(--gutter)), var(--col));
  min-height: 44px; padding: 10px 20px; border-radius: var(--r-sm);
  background: var(--btn); color: var(--btn-ink); font-size: 15px; font-weight: 500; line-height: 1.35; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 600px) { .toast { min-height: 40px; padding: 9px 16px; font-size: 14px; bottom: calc(24px + env(safe-area-inset-bottom)); } }

/* ---------- живой логотип: сигнал расходится волнами ---------- */
.mark .m-dot { transform-box: fill-box; transform-origin: center; animation: m-dot 2.4s ease-in-out infinite; }
.mark .m-w1 { animation: m-wave 2.4s ease-out .25s infinite; }
.mark .m-w2 { animation: m-wave 2.4s ease-out .6s infinite; }
@keyframes m-dot { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.25); } 30% { transform: scale(1); } }
@keyframes m-wave { 0% { opacity: .12; } 18% { opacity: 1; } 55%, 100% { opacity: .12; } }

/* ---------- телефон ---------- */
@media (max-width: 600px) {
  :root { --gutter: 16px; --top-h: 72px; }
  .solo h1 { font-size: 28px; }
  .solo .big { font-size: 44px; }
  .card { padding: 24px 20px; }
  .doc h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .mark .m-w2 { opacity: .45; }
}
[hidden] { display: none !important; }
.solo .big.big-text { font-size: 32px; }
@media (max-width: 600px) { .solo .big.big-text { font-size: 28px; } }
/* знак Telegram в кнопке: кружок цвета текста кнопки, самолётик — цвета самой кнопки (светлая/тёмная тема сами) */
.btn .tg { width: 22px; height: 22px; flex: none; margin-left: -4px; }
.btn .tg circle { fill: currentColor; }
.btn .tg .plane { fill: var(--btn); }
.btn-ghost .tg .plane { fill: var(--surface); }
/* подвал не прячется под нижней панелью Safari / полоской iPhone */
.foot { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- кабинет: устройства, оплаты ---------- */
.btn:disabled, .btn.is-busy { opacity: .55; cursor: progress; }
.btn.is-busy { opacity: .8; }
.spin { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-load { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.page-load .spin { width: 28px; height: 28px; border-width: 2.5px; }
.pay-wait { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; font-size: 14px; }
.pay-wait-acts { display: inline-flex; align-items: center; width: 100%; justify-content: center; }
.pay-wait-acts .dot { color: var(--faint); margin: 0 4px; }
.panel { margin-top: 32px; text-align: left; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 8px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.muted { color: var(--faint); font-weight: 400; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 8px 0 16px; border-top: 1px solid var(--surface-2); }
.rows > .row:first-child { border-top: 0; }
.row-empty { color: var(--faint); font-size: 14px; }
.row-main { all: unset; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 0; cursor: pointer; }
.row-main:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }
div.row-main { cursor: default; }
.row-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub, .row-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { flex: none; }
.row-input { flex: 1; min-width: 0; height: 40px; margin: 8px 0; padding: 0 12px; border: 1px solid var(--surface-2); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; outline: none; }
.row-input:focus { border-color: var(--ink); }
.row-act { flex: none; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; }
.row-act.is-primary { background: var(--btn); color: var(--btn-ink); }
.note { margin-top: 12px; }
.note .link-muted { font-size: 13px; min-height: 24px; text-align: center; }
.row-x { flex: none; width: 32px; height: 32px; border: 0; border-radius: 999px; background: none; color: var(--faint); font-size: 13px; cursor: pointer; }
.row-x:hover { color: var(--warn); background: var(--surface-2); }
.row-add { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 14px 16px; border-top: 1px solid var(--surface-2); font-size: 15px; font-weight: 500; cursor: pointer; }
.row-add::before { content: "+"; display: inline-block; width: 20px; color: var(--muted); }
.row-add:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 12px; }

/* ---------- кабинет: меню (Incy, поддержка, админка, выход) — такой же блок, как устройства ---------- */
.menu { padding: 4px 0; }
.menu-row { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 12px 0 16px; border-top: 1px solid var(--surface-2); font-size: 15px; font-weight: 500; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.menu > .menu-row:first-child, .menu > [hidden] + .menu-row:not([hidden]):nth-child(2) { border-top: 0; }
.menu-row[hidden] { display: none !important; }
.menu-row:active { background: var(--surface-2); }
.menu-row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 12px; }
.menu-ic { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu-t { flex: 1; min-width: 0; }
.menu-chev { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-badge { flex: none; height: 22px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--btn); color: var(--btn-ink); font-size: 12px; font-weight: 500; }
.menu-out, .menu-out .menu-ic { color: var(--warn); stroke: var(--warn); }

/* ---------- чат поддержки ---------- */
.chat-page, .admin { width: 100%; max-width: calc(560px + 2 * var(--gutter)); margin: 0 auto; padding: 24px var(--gutter); flex: 1; display: flex; flex-direction: column; }
.chat-page h1, .admin h1 { font-size: 32px; line-height: 1.15; font-weight: 500; letter-spacing: -.035em; margin: 0 0 4px; text-align: center; }
.chat-page .sub { color: var(--muted); text-align: center; margin-bottom: 24px; }
.chat { flex: 1; min-height: 280px; max-height: 60dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.chat-admin { max-height: 50dvh; border-radius: 0; box-shadow: none; }
.chat-empty { margin: auto; max-width: 280px; text-align: center; color: var(--faint); font-size: 14px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.4; }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-out { align-self: flex-end; background: var(--btn); color: var(--btn-ink); border-bottom-right-radius: 6px; }
.msg-in { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.msg-time { display: block; margin-top: 4px; font-size: 11px; opacity: .55; }
.composer { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
.composer.is-busy { opacity: .6; pointer-events: none; }
.composer textarea { flex: 1; min-height: 52px; max-height: 160px; resize: none; padding: 14px 16px; border: 0; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font: inherit; font-size: 16px; line-height: 1.5; }
.composer textarea:focus { outline: none; }
.composer textarea:focus-visible { outline: none; }
.send { flex: none; width: 52px; height: 52px; border: 0; border-radius: var(--r-sm); background: var(--btn); color: var(--btn-ink); cursor: pointer; display: grid; place-items: center; }
.send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- админка ---------- */
.admin { max-width: calc(720px + 2 * var(--gutter)); }
.admin h1 { margin-bottom: 24px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 24px; }
.stat { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border-radius: 999px; align-self: center; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.pane > .rows { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px 0; }
.pane .panel { margin-top: 0; }
.search { width: 100%; height: 48px; margin-bottom: 12px; padding: 0 16px; border: 0; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font: inherit; font-size: 16px; }
.search:focus { outline: none; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ink) 30%, transparent); }
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row-meta { display: none; }
}

/* ---------- чат одним блоком: лента + поле ввода внизу (поддержка и админка) ---------- */
.chat-card { flex: 1; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; padding: 0; }
.chat-card .chat { background: none; box-shadow: none; border-radius: 0; max-height: none; min-height: 320px; }
.chat-page .chat-card .chat { max-height: 62dvh; }
.chat-card .chat-admin { max-height: 58dvh; }
.chat-card .composer { margin: 0; padding: 8px; gap: 8px; border-top: 1px solid var(--surface-2); align-items: flex-end; }
.chat-card .composer textarea { min-height: 44px; padding: 11px 16px; border-radius: 22px; background: var(--surface-2); box-shadow: none; font-size: 16px; line-height: 1.4; }
.chat-card .send { width: 44px; height: 44px; border-radius: 50%; }
.chat-card .send svg { width: 20px; height: 20px; }
.chat-card .send:active { transform: scale(.94); }
.msg-out { border-bottom-right-radius: 8px; }
.msg-in { border-bottom-left-radius: 8px; }
.chat-head { justify-content: flex-start; gap: 4px; padding: 8px 12px 8px 6px; border-bottom: 1px solid var(--surface-2); }
.chat-back { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.chat-back:hover { background: var(--surface-2); }
.chat-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-title { font-size: 16px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- админка: списки ---------- */
.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--btn); color: var(--btn-ink); font-size: 11px; line-height: 18px; text-align: center; }
.row-side { flex: none; align-self: flex-start; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; padding: 12px 8px 0 0; }
.row-time { font-size: 12px; color: var(--faint); white-space: nowrap; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.pill { flex: none; height: 24px; margin-right: 8px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill-paid { background: var(--btn); color: var(--btn-ink); }
.pane > .rows { padding: 4px 0; }

/* ---------- внутри Telegram: чисто белый / чисто чёрный, шапка Telegram того же цвета — без шва ---------- */
:root[data-tg][data-theme="light"] { --bg: #ffffff; --surface: #f3f3f3; --surface-2: #e8e8ea; --shadow: none; }
:root[data-tg][data-theme="dark"] { --bg: #000000; --surface: #141416; --surface-2: #222226; --shadow: none; }

/* окно снизу (App Store: смена региона) */
.menu-sub { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.35; }
.menu-sub[hidden] { display: none; }
#app-get:has(.menu-sub:not([hidden])) { min-height: 64px; padding-top: 10px; padding-bottom: 10px; }
html.sheet-open, html.sheet-open body { overflow: hidden; }
.sheet {
  --pad: 20px;
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 460px; max-height: calc(100dvh - 24px);
  overflow: auto; overscroll-behavior: contain; padding: 0 var(--pad); border: 0; border-radius: 28px 28px 0 0;
  background: var(--surface); color: var(--ink); text-align: left;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, .04), 0 -16px 48px rgba(0, 0, 0, .14);
  animation: sheet-in .42s cubic-bezier(.16, 1, .3, 1);
  transition: transform .32s cubic-bezier(.16, 1, .3, 1);
}
.sheet:focus { outline: none; }
.sheet.is-dragging { transition: none; }
.sheet.is-closing { animation: sheet-out .26s cubic-bezier(.4, 0, 1, 1) forwards; }
.sheet::backdrop { background: rgba(0, 0, 0, .42); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade-in .3s ease; }
.sheet.is-closing::backdrop { animation: fade-out .26s ease forwards; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(105%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@media (min-width: 520px) {
  .sheet { inset: 0; margin: auto; height: fit-content; border-radius: 28px; box-shadow: 0 24px 64px rgba(0, 0, 0, .22); animation-name: pop-in; }
  .sheet.is-closing { animation-name: pop-out; }
  @keyframes pop-in { from { transform: translateY(12px) scale(.97); opacity: 0; } }
  @keyframes pop-out { to { transform: translateY(8px) scale(.98); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheet::backdrop, .sheet.is-closing, .sheet.is-closing::backdrop { animation: none; transition: none; } }

/* верх листа: за него тянут вниз */
.sheet-head { position: relative; padding: 8px 0 16px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.sheet.is-dragging .sheet-head { cursor: grabbing; }
.sheet-grab { width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 3px; background: var(--faint); opacity: .45; }
.sheet-x { all: unset; position: absolute; top: 12px; right: -6px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sheet-x:active { transform: scale(.92); }
.sheet-x:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sheet-x-ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.sheet-hero { display: flex; gap: 14px; align-items: flex-start; padding-right: 30px; }
.sheet-ic { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--btn); color: var(--btn-ink); }
.sheet-ic-svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sheet-title { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.25; letter-spacing: -.015em; }
.sheet-sub { margin: 3px 0 0; font-size: 14px; color: var(--muted); line-height: 1.4; }

/* шаги: номер в кружке, линия между ними */
.steps { list-style: none; counter-reset: st; margin: 0; padding: 0; }
.steps li { counter-increment: st; position: relative; padding: 0 0 12px 42px; font-size: 15px; line-height: 1.45; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 12.5px; top: 30px; bottom: 3px; width: 1px; background: var(--surface-2); }
.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::before { background: var(--btn); color: var(--btn-ink); }
.step-t { display: block; padding-top: 1px; }
.chip { display: inline; padding: 1px 7px; border-radius: 8px; background: var(--surface-2); font-weight: 600; white-space: nowrap; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

.sheet-tip { display: flex; gap: 10px; margin: 16px 0 0; padding: 11px 14px; border-radius: 16px; background: var(--surface-2); }
.sheet-tip p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.sheet-tip-ic { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: var(--muted); stroke-width: 1.9; stroke-linecap: round; }
.sheet .btn { width: 100%; }
.sheet-foot { position: sticky; bottom: 0; margin: 0 calc(-1 * var(--pad)); padding: 14px var(--pad) calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--surface) 12px); text-align: center; }
@media (min-width: 520px) { .sheet-foot { padding-bottom: 18px; } }
.sheet-help { display: inline-block; margin-top: 6px; font-size: 13px; min-height: 24px; line-height: 24px; }
@media (min-width: 520px) { .sheet-grab { visibility: hidden; height: 0; margin-bottom: 8px; } .sheet-head { cursor: default; } }

/* статус устройства в кабинете */
.dev-st { display: flex; align-items: center; gap: 8px; }
.dev-st b { font-weight: 600; color: var(--ink); }
.dev-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dev-st.is-on .dev-dot { background: #22a559; animation: dev-pulse 1.8s ease-out infinite; }
.dev-st.is-stale .dev-dot { background: #e6a700; box-shadow: 0 0 0 3px rgba(230, 167, 0, .18); }
@keyframes dev-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 165, 89, .55); }
  70% { box-shadow: 0 0 0 7px rgba(34, 165, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 165, 89, 0); }
}
@media (prefers-reduced-motion: reduce) { .dev-st.is-on .dev-dot { animation: none; box-shadow: 0 0 0 3px rgba(34, 165, 89, .16); } }
.dev-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* страница подключения: подтверждено сервером */
.c-ok { display: none; width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: #22a559; place-items: center; animation: ok-pop .45s cubic-bezier(.16, 1, .3, 1); }
#connect.is-done .c-ok { display: grid; }
.c-ok svg { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; animation: ok-draw .4s .15s ease-out forwards; }
@keyframes ok-pop { from { transform: scale(.6); opacity: 0; } }
@keyframes ok-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .c-ok, .c-ok svg { animation: none; stroke-dashoffset: 0; } }
.dev-when { padding-left: 0; }
