:root {
  --ink: #16181C; --mid: #5C6370; --line: rgba(22, 24, 28, .08); --ok: #13784A; --bad: #B42318;
  --font: "Onest", -apple-system, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: #F7F8FB; font: 400 17px/1.55 var(--font); min-height: 100vh; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--mid); }

/* Liquid Glass: мягкие цветные пятна за стеклом */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .75; animation: drift 26s ease-in-out infinite alternate; }
.bg i:nth-child(1) { width: 520px; height: 520px; left: -140px; top: -120px; background: #BFD8FF; }
.bg i:nth-child(2) { width: 460px; height: 460px; right: -160px; top: 180px; background: #E3D2FF; animation-delay: -8s; }
.bg i:nth-child(3) { width: 420px; height: 420px; left: 18%; top: 62%; background: #FFD9C7; animation-delay: -15s; }
.bg i:nth-child(4) { width: 380px; height: 380px; right: 8%; bottom: -160px; background: #C9F1E4; animation-delay: -4s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.08); } }
.glass {
  background: linear-gradient(160deg, rgba(255,255,255,.78), rgba(255,255,255,.48));
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), inset 0 -1px 0 rgba(255,255,255,.35), 0 12px 34px rgba(40, 52, 90, .10);
  -webkit-backdrop-filter: blur(26px) saturate(180%); backdrop-filter: blur(26px) saturate(180%);
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 460px; }

/* шапка */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; text-decoration: none; flex: none; }
.brand img { width: 38px; height: 38px; }
nav.links { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 999px; }
nav.links a { text-decoration: none; font-weight: 500; font-size: 15px; padding: 9px 14px; border-radius: 999px; color: var(--mid); white-space: nowrap; }
nav.links a:hover { color: var(--ink); }
nav.links a[aria-current="page"] { background: var(--ink); color: #fff; }
@media (max-width: 560px) {
  header.top { flex-wrap: wrap; }
  nav.links { order: 3; width: 100%; justify-content: space-between; }
  nav.links a { padding: 9px 10px; font-size: 14.5px; }
}

/* кнопки и поля */
.btn {
  appearance: none; border: 0; cursor: pointer; font: 600 16px/1 var(--font); color: var(--ink);
  padding: 15px 22px; border-radius: 999px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, background-color .12s ease, opacity .12s ease;
}
.btn.glass:hover { background: rgba(255,255,255,.88); }
.btn.solid { background: var(--ink); color: #fff; }
.btn.wide { width: 100%; padding: 17px; font-size: 17px; }
.btn.small { padding: 9px 14px; font-size: 14.5px; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

label.lbl { display: block; font-size: 14.5px; font-weight: 500; color: var(--mid); margin: 0 0 6px 6px; }
.field { width: 100%; font: 400 17px var(--font); color: var(--ink); padding: 15px 20px; border-radius: 999px; }
.field:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.hint { font-size: 14px; margin: 6px 0 0 8px; min-height: 1.2em; color: var(--mid); }
.hint.ok { color: var(--ok); } .hint.bad, .err { color: var(--bad); }
.err { font-size: 15px; margin-top: 10px; min-height: 1em; }

.card { border-radius: 28px; padding: 24px; margin-bottom: 14px; }
h1 { font-size: clamp(32px, 6.4vw, 54px); line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 16px; font-weight: 700; }
h2 { font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 12px; }
section { padding: 36px 0 6px; }
.note { color: var(--mid); font-size: 14.5px; margin: 8px 4px 0; }

/* код */
.code { border-radius: 28px; padding: 20px 20px 16px; overflow: auto; }
.code pre { margin: 0; font: 14px/1.65 var(--mono); white-space: pre; }
.code .k { color: #8A8F98; }
.code .key { background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { font: 500 14px var(--font); padding: 7px 14px; border-radius: 999px; border: 0; background: transparent; cursor: pointer; color: var(--mid); }
.tab[aria-selected="true"] { background: rgba(22,24,28,.07); color: var(--ink); }

/* шаги */
.steps { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; padding: 18px 20px 18px 62px; border-radius: 20px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 20px; top: 17px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; }
.steps a { font-weight: 600; }

/* цены */
table.prices { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 28px; overflow: hidden; }
.prices th, .prices td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.prices th { font-weight: 500; color: var(--mid); font-size: 14.5px; }
.prices tr:last-child td { border-bottom: 0; }
.prices td:first-child { font-weight: 600; }
.prices td:not(:first-child) { white-space: nowrap; }
@media (max-width: 520px) { .prices th, .prices td { padding: 12px 10px; font-size: 14.5px; } }

/* кабинет */
.row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ring { width: 88px; height: 88px; flex: none; }
.bal { font-size: 36px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip { font: 500 15px var(--font); padding: 9px 15px; border-radius: 999px; border: 0; cursor: pointer; background: rgba(22,24,28,.06); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.keys { list-style: none; margin: 14px 0 0; padding: 0; }
.keys li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.keys code { font: 14px var(--mono); color: var(--mid); }
.keys .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.newkey { margin-top: 12px; padding: 16px; border-radius: 18px; background: var(--ink); color: #fff; word-break: break-all; font: 15px var(--mono); }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 10px 14px; align-items: center; margin-top: 6px; }
.kv .l { color: var(--mid); font-size: 14.5px; }
.kv code { font: 15px var(--mono); word-break: break-all; }
.copy { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(22,24,28,.06); color: var(--ink); cursor: pointer; }
.copy.done { background: var(--ink); color: #fff; }

.seg { display: flex; padding: 4px; border-radius: 999px; margin-bottom: 18px; }
.seg button { flex: 1; border: 0; background: transparent; font: 600 15px var(--font); padding: 11px; border-radius: 999px; cursor: pointer; color: var(--mid); }
.seg button[aria-selected="true"] { background: var(--ink); color: #fff; }

footer { padding: 46px 0 40px; color: var(--mid); font-size: 14px; }

/* ---------- анимации ---------- */
:root { --spring: cubic-bezier(.34, 1.36, .64, 1); --ease: cubic-bezier(.22, .8, .24, 1); }
@view-transition { navigation: auto; }              /* плавный переход между страницами (Safari 18+, Chrome) */
::view-transition-old(root) { animation: vt-out .22s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px) scale(.995); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px) scale(.995); } }
header.top { view-transition-name: top; position: relative; z-index: 40; }

/* появление блоков снизу по очереди */
.pre { opacity: 0; }
.rise { opacity: 0; transform: translateY(14px) scale(.985); animation: rise .6s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 70ms + 40ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

/* кнопки: пружинка */
.btn, .chip, .tab, .copy, .seg button, nav.links a { transition: transform .35s var(--spring), background-color .2s ease, color .2s ease, opacity .2s ease, box-shadow .2s ease; }
.btn:hover:not([disabled]) { transform: translateY(-1px); }
.btn:active:not([disabled]), .chip:active, .copy:active, .tab:active, .seg button:active, nav.links a:active { transform: scale(.94); transition-duration: .08s; }
.field { transition: box-shadow .2s ease, background-color .2s ease; }
.hint, .err { transition: color .2s ease; }
.hint:not(:empty), .err:not(:empty) { animation: fade-in .3s var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(-3px); } }
.card.glass, .steps li, table.prices { transition: transform .4s var(--spring), box-shadow .3s ease; }
@media (hover: hover) { .steps li:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 16px 40px rgba(40,52,90,.14); } }

/* выделение в шапке перетекает между пунктами */
nav.links { position: relative; isolation: isolate; }
nav.links a[aria-current="page"] { background: transparent; color: var(--ink); font-weight: 600; }
nav.links .pill {
  position: absolute; z-index: -1; left: 0; top: 4px; height: calc(100% - 8px); border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(255,255,255,.62) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,1), inset 0 -1px 1px rgba(22,24,28,.05),
              0 0 0 .5px rgba(22,24,28,.08), 0 4px 14px rgba(40,52,90,.16);
  -webkit-backdrop-filter: blur(12px) saturate(190%); backdrop-filter: blur(12px) saturate(190%);
  transition: transform .5s var(--spring), width .5s var(--spring), opacity .2s ease;
}

/* меню аккаунта */
.me-wrap { position: relative; }
.me-btn { display: inline-flex; align-items: center; gap: 6px; }
.me-btn svg { transition: transform .35s var(--spring); }
.me-wrap.open .me-btn svg { transform: rotate(180deg); }
.menu { position: fixed; right: 16px; top: 70px; min-width: 230px; border-radius: 22px; padding: 6px; z-index: 1000; border: 1px solid rgba(255,255,255,.9);
  background: #fff; box-shadow: 0 18px 50px rgba(40,52,90,.18), inset 0 1px 0 #fff;
  opacity: 0; transform: translateY(-6px) scale(.96); transform-origin: top right; pointer-events: none; transition: opacity .18s ease, transform .35s var(--spring); }
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu .who { padding: 10px 14px 8px; font-size: 13.5px; color: var(--mid); }
.menu .who b { display: block; color: var(--ink); font-size: 16px; }
.menu a, .menu button { display: flex; white-space: nowrap; width: 100%; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; font: 500 15.5px var(--font); color: var(--ink); padding: 11px 14px; border-radius: 14px; cursor: pointer; text-decoration: none; transition: background-color .15s ease; }
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: rgba(22,24,28,.06); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 8px; }
.menu .danger { color: var(--bad); }

/* кольцо баланса и новые ключи */
#ringArc { transition: stroke-dashoffset 1.1s var(--ease), stroke .3s ease; }
.keys li { animation: rise .45s var(--ease) both; }
.newkey { animation: pop .5s var(--spring) both; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
.code pre { transition: opacity .2s ease; }
.code pre.swap { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-old(root), ::view-transition-new(root) { transition: none !important; animation: none !important; }
  .rise, .pre { opacity: 1; transform: none; }
}
