/* MAGIC VPN — общий слой оформления сайта, кабинета и мини-приложения [web2-1126].
   Тёмная тема, сетка и голубой акцент — как в приложении MAGIC VPN 2.0. */
:root {
  --bg: #0a0a0a;
  --surface: #17181b;      /* карточка на фоне страницы */
  --surface-2: #222327;    /* поля, сегменты, плашки внутри карточек */
  --surface-3: #2a2b30;    /* значки-пилюли, подложка сегмента */
  --card: linear-gradient(180deg, #1f2024 0%, #1c1d21 100%);   /* плитка внутри карточки — на ступень светлее */
  --card-solid: #1e1f23;
  --card-hover: #25262b;
  --card-m: #212226;       /* карточка на телефоне — прямо на фоне, как у их консоли */
  --hover: rgba(255, 255, 255, .05);
  --press: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .16);
  --text: #e1e3e6;
  --text-2: #b4b7bc;
  --muted: #8b8e95;
  --faint: #6c6f75;
  --accent: #2688eb;
  --accent-2: #5a9eff;
  --accent-soft: rgba(38, 136, 235, .15);
  --ok: #4bb34b;
  --ok-soft: rgba(75, 179, 75, .14);
  --warn: #ffa000;
  --warn-soft: rgba(255, 160, 0, .14);
  --bad: #ff5c5c;
  --bad-soft: rgba(230, 70, 70, .16);
  --grid: rgba(255, 255, 255, .035);
  --r-xs: 8px; --r-s: 10px; --r-m: 12px; --r-l: 16px; --r-xl: 22px;
  --shadow: 0 12px 30px rgba(0, 0, 0, .28);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-out: cubic-bezier(.25, .46, .45, .94);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  --spring: cubic-bezier(.22, 1, .36, 1);
  --t-spring: 600ms;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root { --spring: linear(0, .0279, .0987, .1954, .3052, .4183, .5277, .6288, .7188, .7962, .8609, .9133, .9543, .9853, 1.0077, 1.0228, 1.0322, 1.037, 1.0384, 1.0374, 1.0347, 1.031, 1.0267, 1.0224, 1.0182, 1.0143, 1.0108, 1.0079, 1.0054, 1.0034, 1); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
/* тёмные тонкие полосы прокрутки без стрелок */
html { scrollbar-color: #2c2d31 #0a0a0a; }
.modal__body, .chat, .palette__list, .side { scrollbar-width: thin; scrollbar-color: #34353a transparent; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  /* фон страницы рисует html; body прозрачный — иначе он закрывает слой сетки и свечения (.bgfx) */
  background: transparent; color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
.wave, .final__waves { max-width: none; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(38, 136, 235, .45); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── фон: сетка и два мягких свечения ─────────────────────── */
/* фон без сетки: глубокий градиент и мягкие свечения, медленно дрейфуют */
.bgfx { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background: radial-gradient(90% 60% at 50% -10%, rgba(38, 110, 235, .16), transparent 62%),
    radial-gradient(60% 50% at 100% 100%, rgba(52, 72, 200, .10), transparent 70%),
    linear-gradient(180deg, #08090c 0%, #0a0a0c 55%, #0b0c0f 100%); }
.bgfx i { position: absolute; border-radius: 50%; opacity: 0; filter: blur(8px);
  animation: glow-in 1.4s var(--ease) .15s forwards, glow-drift 32s ease-in-out 1.6s infinite alternate; }
.bgfx i:nth-child(1) { width: 820px; height: 820px; left: -340px; bottom: -380px; background: radial-gradient(circle, rgba(52, 140, 255, .24), transparent 66%); }
.bgfx i:nth-child(2) { width: 720px; height: 720px; right: -300px; top: -320px; background: radial-gradient(circle, rgba(70, 110, 255, .18), transparent 68%); animation-delay: .3s, 2s; }
.bgfx i:nth-child(3) { width: 600px; height: 600px; right: 12%; bottom: -380px; background: radial-gradient(circle, rgba(37, 126, 245, .13), transparent 68%); animation-delay: .5s, 4s; }
@keyframes glow-in { to { opacity: 1; } }
@keyframes glow-drift { 0% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(40px, -30px, 0) scale(1.08); } 100% { transform: translate3d(-20px, 24px, 0) scale(.96); } }

/* ── значки ───────────────────────────────────────────────── */
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic--s { width: 18px; height: 18px; }
.ic--l { width: 28px; height: 28px; }
.ic--xl { width: 44px; height: 44px; stroke-width: 1.5; }

/* ── кнопки ───────────────────────────────────────────────── */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--r-s);
  font-weight: 600; font-size: 15px; line-height: 1.2; text-align: center; white-space: nowrap;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .45s var(--ease-back), opacity .18s ease;
  user-select: none; text-decoration: none !important; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); transition-duration: .1s; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.is-busy { opacity: .8; pointer-events: none; }
.btn--primary { background: #fff; color: #0a0a0a; border-color: #fff; }
.btn--primary:hover { background: #ebedf0; }
.btn--accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--accent:hover { background: #3a95f0; }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--hover); }
.btn--danger { color: var(--bad); }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; border-radius: var(--r-xs); }
.btn--lg { min-height: 52px; padding: 12px 24px; font-size: 16px; border-radius: var(--r-m); }
.btn--block { display: flex; width: 100%; }
.btn .ic { width: 20px; height: 20px; }
/* загрузка: значок кнопки превращается в крутилку на своём месте; кнопка без значка — крутилка по центру вместо текста */
.btn.is-busy > .ic:first-child { stroke: transparent; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.is-busy:not(:has(> .ic)) { color: transparent !important; }
.btn.is-busy:not(:has(> .ic))::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  border: 2px solid var(--spin, #e1e3e6); border-right-color: transparent; animation: spin .8s linear infinite; }
.btn--primary { --spin: #0a0a0a; }
.btn--accent, .btn--glass { --spin: #fff; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--r-s);
  color: var(--muted); transition: background-color .15s, color .15s, transform .4s var(--ease-back); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.9); }

/* ── карточки, группы, ячейки ─────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .04); }
.card--pad { padding: 16px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 6px; box-shadow: var(--shadow); }
.group + .group, .card + .card, .group + .card, .card + .group { margin-top: 12px; }
.ghead { margin: 22px 4px 8px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ghead:first-child { margin-top: 2px; }
.gnote { margin: 8px 4px 0; font-size: 13px; color: var(--muted); text-align: center; text-wrap: balance; }

.cell { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 9px 12px;
  border-radius: var(--r-xs); text-align: left; color: var(--text); text-decoration: none !important;
  transition: background-color .15s ease; }
a.cell:hover, button.cell:hover, .cell.is-tap:hover { background: var(--hover); }
a.cell:active, button.cell:active, .cell.is-tap:active { background: var(--press); }
.cell + .cell::before { content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 1px; background: rgba(255, 255, 255, .06); }
.group--plain .cell + .cell::before, .cell.nosep::before { display: none; }
.cell__ic { display: inline-flex; color: var(--accent-2); flex: none; }
.cell__ic--box { width: 38px; height: 38px; border-radius: 10px; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--line); }
.cell__body { flex: 1; min-width: 0; }
.cell__title { display: block; font-size: 15.5px; line-height: 1.3; color: var(--text); overflow-wrap: anywhere; }
.cell__sub { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
.cell__sub b { font-weight: 500; }
.cell__after { flex: none; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.cell__chev { color: var(--faint); width: 18px; height: 18px; }
.cell--danger .cell__title { color: var(--bad); }
.cell--accent .cell__title { color: var(--accent-2); }
.cell.is-on { background: var(--hover); }

.t-ok { color: var(--ok) !important; }
.t-warn { color: var(--warn) !important; }
.t-bad { color: var(--bad) !important; }
.t-accent { color: var(--accent-2) !important; }
.t-muted { color: var(--muted) !important; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  line-height: 1.35; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill--ok { background: var(--ok-soft); color: #7fd77f; }
.pill--warn { background: var(--warn-soft); color: #ffc15c; }
.pill--bad { background: var(--bad-soft); color: #ff8a8a; }
.pill--accent { background: var(--accent); color: #fff; }
.pill--soft { background: var(--accent-soft); color: var(--accent-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 0 rgba(75, 179, 75, .5); animation: pulse 2.4s ease-out infinite; }
.dot--warn { background: var(--warn); animation: none; }
.dot--bad { background: var(--bad); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(75, 179, 75, .45); } 70% { box-shadow: 0 0 0 8px rgba(75, 179, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(75, 179, 75, 0); } }

/* ── поля, поле со ссылкой, переключатели ─────────────────── */
.field { display: block; width: 100%; min-height: 44px; padding: 10px 13px; border-radius: var(--r-s);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease; }
.field::placeholder { color: var(--faint); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(38, 136, 235, .18); }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.45; }
.label { display: block; margin: 0 2px 7px; font-size: 13px; color: var(--muted); }
.form-row + .form-row { margin-top: 12px; }
.linkfield { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 4px 4px 13px; border-radius: var(--r-s);
  background: var(--surface-2); border: 1px solid var(--line); }
.linkfield__v { flex: 1; min-width: 0; font: 500 14.5px/1.3 var(--font); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: all; cursor: text; }
.linkfield .icon-btn { width: 36px; height: 36px; color: var(--text-2); }
.mono { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.code-big { font: 700 28px/1.2 var(--mono); letter-spacing: 4px; color: var(--text); text-align: center; user-select: all; }

.switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: #3a3b3e; transition: background-color .25s ease; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .45s var(--ease-back); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch[aria-busy="true"] { opacity: .6; pointer-events: none; }

.radio { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #5d6064; transition: border .2s ease; }
.is-sel > .radio, .radio.is-sel { border: 7px solid var(--accent); }
.choice { cursor: pointer; }
.choice.is-dis { opacity: .5; cursor: not-allowed; }
.choice .chip { font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); }

/* сегменты: «Прокси | Туннель», выбор срока и т. п. — с плавающей подложкой */
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg__thumb { position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 9px; background: var(--surface-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); transition: transform .5s var(--spring), width .5s var(--spring); }
.seg button { position: relative; z-index: 1; flex: none; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: color .2s ease; white-space: nowrap; }
.seg button.is-on { color: var(--text); }
.seg--block { display: flex; width: 100%; }
.seg--block button { flex: 1; }

/* ── окно и шторка ────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px;
  visibility: hidden; pointer-events: none; }
.modal.is-open { visibility: visible; pointer-events: auto; }
.modal__mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .25s ease; }
.modal.is-open .modal__mask { opacity: 1; }
.modal__box { position: relative; width: 440px; max-width: 100%; max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: #1a1b1e; border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s ease, transform .5s var(--spring); }
.modal.is-open .modal__box { opacity: 1; transform: none; }
.modal__head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 54px; padding: 12px 52px;
  border-bottom: 1px solid var(--line); flex: none; }
.modal__title { font-size: 18px; font-weight: 600; text-align: center; }
.modal__close { position: absolute; right: -50px; top: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(40, 41, 44, .9);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; transition: transform .4s var(--ease-back), background-color .15s; }
.modal__close:hover { background: #3a3b3e; }
.modal__close:active { transform: scale(.88); }
.modal__body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.modal__grip { display: none; }
.modal__body > * + * { margin-top: 12px; }
.modal__body .group, .modal__body .card { background: var(--card); box-shadow: none; }
.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; min-width: 0; }
.btn-row > .btn { white-space: normal; }

@media (max-width: 899px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal__box { width: 100%; max-height: calc(100dvh - 56px - var(--safe-t)); border-radius: 18px 18px 0 0; border-bottom: 0;
    transform: translateY(100%); transition: transform .5s var(--spring); opacity: 1; padding-bottom: var(--safe-b); }
  .modal.is-open .modal__box { transform: translateY(var(--drag, 0px)); }
  .modal.is-drag .modal__box { transition: none; }
  .modal__grip { display: block; position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: rgba(255, 255, 255, .22); }
  .modal__head { justify-content: flex-start; padding: 14px 16px 12px 56px; border-bottom: 0; touch-action: none; }
  .modal__title { text-align: left; font-size: 20px; }
  .modal__close { right: auto; left: 10px; top: 10px; background: transparent; width: 38px; height: 38px; }
  .modal__body { padding: 4px 16px 18px; }
}

/* ── уведомления, загрузка, пустые экраны ─────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 120; max-width: min(92vw, 460px); padding: 11px 16px;
  border-radius: 12px; background: #222327; border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); color: var(--text); font-size: 14px;
  text-align: center; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .45s var(--spring); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--ok { border-color: rgba(75, 179, 75, .45); }
.toast--err { border-color: rgba(255, 92, 92, .5); }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid rgba(90, 158, 255, .22); border-top-color: var(--accent-2); animation: spin .8s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-xs); min-height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent); animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 18px 30px; gap: 8px; }
.empty__ic { color: var(--text-2); margin-bottom: 6px; }
.empty__title { font-size: 20px; font-weight: 700; }
.empty__text { color: var(--muted); max-width: 560px; text-wrap: balance; }
.empty .btn { margin-top: 10px; }
.note { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.note b { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 2px; }
.note--warn { background: rgba(71, 51, 21, .55); border-color: rgba(255, 160, 0, .28); }
.note--ok { background: rgba(46, 62, 43, .55); border-color: rgba(75, 179, 75, .3); }
.note--accent { background: rgba(28, 57, 84, .6); border-color: rgba(90, 158, 255, .3); }
.note__ic { flex: none; color: var(--warn); }
.note--ok .note__ic { color: var(--ok); }
.note--accent .note__ic { color: var(--accent-2); }
.qr { display: block; width: 240px; height: 240px; margin: 4px auto; padding: 10px; border-radius: 14px; background: #fff; }

/* появление по прокрутке: скрываем только то, что ниже первого экрана */
.rv-wait { opacity: 0; transform: translateY(22px); }
.rv-in { animation: rv-up var(--t-spring) var(--spring) both; animation-delay: var(--rv-d, 0ms); }
@keyframes rv-up { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

.paused *, .paused *::before, .paused *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .rv-wait { opacity: 1; transform: none; }
}

/* раскрывающиеся строки: подпись и номер слева, «+» справа превращается в «×»; рамка фокуса — по краю строки и только с клавиатуры */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:focus { outline: none; }
details > summary:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
/* текст в окнах подтверждения — по центру, крупнее и светлее */
.sheet-text { text-align: center; font-size: 15.5px; line-height: 1.55; color: var(--text-2); text-wrap: balance; }
.sheet-text b { color: var(--text); font-weight: 600; }
