:root {
  color-scheme: light;
  --bg: #F3F8FE;        /* панель формы на десктопе */
  --hero-bg: #E6F1FC;   /* фон картинки с графиком (его же читает canvas) */
  --hero-steel: 90, 120, 160; /* серые свечи и сетка графика */
  --surface: rgba(255, 255, 255, .88); /* поля */
  --stroke: rgba(40, 96, 160, .22);
  --ink: #0E2440;
  --sub-ink: #3F5B7D;
  --accent: 34, 150, 235; /* RGB-тройка: её же читает canvas с графиком */
  --error: #D93B40;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--hero-bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Телефон: картинка с графиком — фон на весь экран, форма поверх неё.
   Десктоп: форма слева, картинка справа. */
.page { display: flex; min-height: 100vh; min-height: 100dvh; }
.form-pane {
  position: relative; z-index: 1; flex: 1; display: flex;
  align-items: flex-start; justify-content: center;
  padding: 60px 16px 32px;
  padding-top: calc(60px + env(safe-area-inset-top));
}
.hero { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--hero-bg); }
.hero .seam, .hero-brand { display: none; }

@media (min-width: 1024px) {
  body { background: var(--bg); }
  .form-pane { align-items: center; padding: 64px 48px 56px; background: var(--bg); }
  .hero { position: relative; inset: auto; flex: 1; }
  .hero .seam, .hero-brand { display: block; }
}

/* ── Форма ────────────────────────────────────────────── */
.form { width: 100%; max-width: 344px; }
/* На телефоне заголовок и приветствие не показываем: над формой стоит название,
   а место нужно графику. Заголовок остаётся для программ чтения с экрана. */
.form h1 { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.form .welcome { display: none; }
@media (min-width: 1024px) {
  .form h1 {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
    text-align: center; font-size: 24px; font-weight: 700; line-height: 1.1;
  }
  .form .welcome {
    display: block; margin: 6px 0 16px; text-align: center; font-size: 12px; font-weight: 500;
    color: var(--sub-ink); opacity: .7;
  }
}
.card {
  padding: 20px; border-radius: 20px;
  /* Полупрозрачная: на телефоне сквозь карточку светится график. */
  background: rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(var(--accent), .18);
  box-shadow: 0 0 32px 1px rgba(var(--accent), .1), 0 12px 30px -10px rgba(30, 90, 160, .3), inset 0 1px 0 #fff;
}
.field { position: relative; margin-bottom: 12px; }
.field[hidden], .remember[hidden], .or[hidden], .btn-google[hidden] { display: none; }
.field input {
  width: 100%; height: 50px; padding: 18px 14px 4px;
  border-radius: 14px; border: 1px solid var(--stroke);
  /* 16px: при меньшем размере iOS приближает страницу при фокусе. */
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: rgba(var(--accent), .86); box-shadow: 0 0 0 .4px rgba(var(--accent), .86); }
/* Плавающая подпись: стоит по центру, уезжает вверх при фокусе или заполнении. */
.field label {
  position: absolute; left: 14px; top: 15px; pointer-events: none;
  color: var(--sub-ink); font-weight: 600; font-size: 15px;
  transition: transform .15s, font-size .15s; transform-origin: left top;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label { transform: translateY(-10px); font-size: 11px; }

.remember { display: flex; align-items: center; gap: 8px; margin: -4px 0 0; font-size: 12px; font-weight: 500; color: var(--sub-ink); cursor: pointer; user-select: none; }
.remember input { width: 18px; height: 18px; margin: 3px; accent-color: var(--ink); cursor: pointer; }
.error { margin: 12px 0 0; font-size: 12px; font-weight: 500; color: var(--error); }
.error:empty { display: none; }

.btn-primary {
  width: 100%; height: 44px; margin-top: 16px; border: 0; border-radius: 14px;
  background: linear-gradient(180deg, #5CC6FF, #2A8BEA); color: #fff; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(34, 150, 235, .8);
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .92; }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-secondary {
  width: 100%; height: 44px; margin-top: 8px; border-radius: 14px;
  border: 1px solid rgba(var(--accent), .45); background: transparent; color: rgb(var(--accent));
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: rgba(var(--accent), .1); border-color: rgba(var(--accent), .7); }
.btn-secondary:disabled { opacity: .5; cursor: default; }

.or { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 12px; font-weight: 500; color: var(--sub-ink); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

.btn-google {
  width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px;
  border-radius: 14px; border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .85); color: var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 500; letter-spacing: .2px; cursor: pointer;
  transition: border-color .18s ease-out, box-shadow .18s ease-out, background .18s ease-out;
}
.btn-google:hover { border-color: rgba(var(--accent), .4); box-shadow: 0 0 18px rgba(var(--accent), .18); background: var(--surface); }
.btn-google:disabled { opacity: .5; cursor: default; }
.btn-google svg { width: 20px; height: 20px; }
/* Внутри Telegram эта кнопка — вход через Telegram: значок Google не нужен. */
.in-tg .btn-google svg { display: none; }

.links { display: flex; justify-content: flex-end; margin-top: 10px; }
.links a { padding: 8px 12px; border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.links a:hover { background: rgba(30, 80, 140, .06); }
.links a[hidden] { display: none; }

/* Телефон: компактная карточка, чтобы под ней оставалось место графику.
   «Запомнить» и «Забыли пароль?» стоят в одной строке, «Войти» и «Регистрация» — рядом. */
@media (max-width: 1023.98px) {
  .card {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; padding: 16px;
    grid-template-areas: "login login" "pass pass" "opts opts" "error error" "enter signup" "or or" "google google";
  }
  .card > .field { margin-bottom: 10px; }
  .card > .field:nth-child(1) { grid-area: login; }
  .card > .field:nth-child(2) { grid-area: pass; }
  .field input { height: 46px; padding: 17px 14px 3px; }
  .field label { top: 13px; }
  .field input:focus + label,
  .field input:not(:placeholder-shown) + label { transform: translateY(-9px); }

  .remember { grid-area: opts; justify-self: start; align-self: center; margin: 0; white-space: nowrap; }
  .links { grid-area: opts; justify-self: end; align-self: center; margin: 0; }
  .links a { padding: 6px 0 6px 8px; font-size: 12.5px; white-space: nowrap; }
  .links a:hover { background: none; }
  .error { grid-area: error; margin: 8px 0 0; }

  .btn-primary { grid-area: enter; margin-top: 12px; }
  .btn-secondary { grid-area: signup; margin-top: 12px; }
  .or { grid-area: or; margin: 8px 0; }
  .btn-google { grid-area: google; height: 46px; }
}
/* Совсем узкий экран: ссылка не помещается рядом с «Запомнить», уходит строкой ниже. */
@media (max-width: 359.98px) {
  .card { grid-template-areas: "login login" "pass pass" "opts opts" "forgot forgot" "error error" "enter signup" "or or" "google google"; }
  .links { grid-area: forgot; }
}

/* ── Выбор языка ──────────────────────────────────────── */
.lang { position: fixed; z-index: 10; top: calc(16px + env(safe-area-inset-top)); left: 16px; }
.lang-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 10px;
  border-radius: 20px; border: 1px solid rgba(var(--accent), .18);
  background: rgba(255, 255, 255, .7); color: var(--sub-ink);
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 1px; cursor: pointer;
}
.lang-btn:hover { background: rgba(255, 255, 255, .9); }
.lang-btn .flag { font-size: 14px; letter-spacing: 0; }
.lang-btn .chev { width: 16px; height: 16px; opacity: .6; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 180px; margin: 0; padding: 8px 0; list-style: none;
  border-radius: 14px; border: 1px solid rgba(var(--accent), .18); background: var(--surface);
  box-shadow: 0 12px 30px -10px rgba(30, 90, 160, .3);
}
.lang-menu[hidden] { display: none; }
.lang-menu li { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 16px; font-size: 14px; cursor: pointer; }
.lang-menu li:hover { background: rgba(30, 80, 140, .06); }
.lang-menu li .flag { font-size: 16px; }
.lang-menu li[aria-selected="true"] { color: rgb(var(--accent)); font-weight: 600; }
.lang-menu li[aria-selected="true"]::after { content: "✓"; margin-left: 4px; font-size: 12px; }

/* ── Картинка и название ──────────────────────────────── */
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Шов: цвет панели формы растворяется на левом краю картинки. */
.hero .seam { position: absolute; left: 0; top: 0; bottom: 0; width: 80px; pointer-events: none; background: linear-gradient(to right, var(--bg), transparent); }

.emblem { display: block; color: rgb(var(--accent)); }
.brand-name {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-weight: 600; text-transform: uppercase; line-height: 1.1; color: var(--ink);
}
.brand-caption { font-weight: 600; text-transform: uppercase; color: rgb(var(--accent)); }
.brand-tagline { color: var(--sub-ink); opacity: .72; }

/* Телефон: название по центру над формой. Отрицательный отступ гасит разрядку после последней буквы. */
.brand-top { display: flex; flex-direction: column; align-items: center; margin-bottom: 16px; text-align: center; }
.brand-top .emblem { width: 27px; height: 30px; margin-bottom: 8px; }
.brand-top .brand-name { font-size: 27px; letter-spacing: .3em; margin-right: -.3em; }
.brand-top .brand-caption { margin-top: 6px; font-size: 9.5px; letter-spacing: .32em; margin-right: -.32em; }
.brand-top .brand-tagline { margin-top: 6px; font-size: 11.5px; }

/* Десктоп: название в левом верхнем углу картинки. */
@media (min-width: 1024px) {
  .brand-top { display: none; }
  .hero-brand { position: absolute; top: 52px; left: 64px; right: 48px; }
  .hero-brand .emblem { width: 42px; height: 46px; margin-bottom: 26px; }
  .hero-brand .brand-name { font-size: clamp(40px, 4vw, 60px); letter-spacing: .3em; }
  .hero-brand .brand-caption { margin-top: 14px; font-size: 12px; letter-spacing: .38em; }
  .hero-brand .brand-rule { width: 64px; height: 1px; margin: 22px 0 16px; background: linear-gradient(to right, rgb(var(--accent)), rgba(var(--accent), 0)); }
  .hero-brand .brand-tagline { font-size: 14px; letter-spacing: .02em; }
}
.error.note { color: var(--sub-ink); }

/* Название Xtralite: гротеск, без разрядки; X — акцентным цветом */
.brand-name { display: inline-block; font-family: Inter, system-ui, sans-serif; font-weight: 700; text-transform: none; letter-spacing: -.015em !important; margin-right: 0 !important; }
.brand-name::first-letter { color: rgb(var(--accent)); }
.brand-top .brand-name { font-size: 30px; }
.brand-top .brand-caption { letter-spacing: .2em; margin-right: -.2em; }
@media (min-width: 1024px) {
  .hero-brand .brand-name { font-size: clamp(44px, 4.4vw, 64px); }
  .hero-brand .brand-caption { letter-spacing: .24em; }
}

/* Юрлицо под формой входа */
.legal-line { margin: 18px auto 0; max-width: 420px; font-size: 11px; line-height: 1.45; color: var(--sub-ink); opacity: .7; text-align: center; }
