:root {
  color-scheme: dark;
  --bg: #050506;
  --bg-raised: #09090a;
  --panel: #101012;
  --panel-2: #171719;
  --panel-3: #202023;
  --text: #f6f6f7;
  --text-strong: #ffffff;
  --text-2: #b4b4bb;
  --muted: #898991;
  --line: #29292e;
  --line-strong: #3a3a40;
  --control-border: #4a4a51;
  --brand: var(--brand-accent, #ff1f2d);
  --brand-dark: var(--brand-accent-dark, #db101d);
  --brand-light: var(--brand-accent-soft, rgb(255 31 45 / 12%));
  --brand-glow: rgb(255 31 45 / 22%);
  --danger: #ff6670;
  --danger-soft: rgb(255 102 112 / 10%);
  --warning: #f4ba55;
  --warning-soft: rgb(244 186 85 / 10%);
  --info: #63b9eb;
  --info-soft: rgb(99 185 235 / 10%);
  --tg-blue: #229ed9;
  --tg-blue-ink: #ffffff;
  --qr-plate: #ffffff;
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-pill: 8px;
  --accent: var(--brand);
  --accent-strong: var(--brand-dark);
  --accent-deep: #ffffff;
  --accent-soft: var(--brand-light);
  --accent-glow: var(--brand-glow);
  --surface: var(--panel);
  --surface-strong: var(--panel-2);
  --bg-deep: var(--bg);
  --bg-soft: var(--bg-raised);
  --ink: var(--text);
  --ink-soft: var(--text-2);
  --muted-strong: var(--text-2);
  --shadow-card: 0 30px 80px rgb(0 0 0 / 32%);
  --shadow-button: 0 12px 28px var(--brand-glow);
  --scrim: rgb(0 0 0 / 72%);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f1ed;
  --bg-raised: #eceae5;
  --panel: #fffefa;
  --panel-2: #f3f1ed;
  --panel-3: #e8e5df;
  --text: #151517;
  --text-strong: #070708;
  --text-2: #4f4f55;
  --muted: #66666d;
  --line: #d9d6d0;
  --line-strong: #bebbb5;
  --control-border: #96928c;
  --brand-light: var(--brand-accent-soft, rgb(255 31 45 / 9%));
  --brand-glow: rgb(255 31 45 / 15%);
  --danger: #bf2430;
  --danger-soft: rgb(191 36 48 / 8%);
  --warning: #815a12;
  --warning-soft: rgb(129 90 18 / 9%);
  --info: #1b648f;
  --info-soft: rgb(27 100 143 / 9%);
  --shadow-card: 0 24px 70px rgb(20 18 16 / 10%);
  --scrim: rgb(14 12 12 / 46%);
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: "Onest", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

html { scrollbar-gutter: stable; }

body {
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  letter-spacing: -0.01em;
}

body::before {
  content: "";
  position: fixed;
  z-index: 0;
  right: -14vw;
  bottom: -4vh;
  width: min(72vw, 1050px);
  height: min(52vh, 520px);
  pointer-events: none;
  opacity: .58;
  background:
    linear-gradient(168deg, transparent 0 57%, var(--brand) 57.1% 57.35%, transparent 57.45%),
    linear-gradient(164deg, transparent 0 63%, rgb(255 31 45 / 75%) 63.1% 63.35%, transparent 63.45%),
    linear-gradient(172deg, transparent 0 70%, rgb(255 31 45 / 45%) 70.1% 70.28%, transparent 70.4%),
    linear-gradient(159deg, transparent 0 76%, rgb(255 31 45 / 28%) 76.1% 76.3%, transparent 76.4%);
  filter: drop-shadow(0 0 14px var(--brand-glow));
  transform: skewX(-10deg) rotate(-2deg);
}

body::after {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(115deg, transparent 48%, rgb(255 255 255 / 2%) 49%, transparent 50%),
    linear-gradient(35deg, transparent 49%, rgb(255 255 255 / 1.5%) 50%, transparent 51%);
  background-size: 19px 27px, 31px 37px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.ambient-bg { display: none !important; }

a { color: inherit; text-underline-offset: 4px; }
a:hover { color: var(--brand); }

button,
input,
textarea { font: inherit; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.hidden,
[hidden] { display: none !important; }

.lk-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1180px);
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 0;
  margin: 0 auto;
  padding: 0 28px calc(26px + env(safe-area-inset-bottom, 0px));
}

.brand-row {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(26px, 5vw, 62px);
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  text-decoration: none;
}

.brand-wordmark {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  flex: 0 1 auto;
  max-width: 380px;
  color: var(--text-strong);
  font-size: clamp(23px, 2.6vw, 36px);
  font-weight: 850;
  letter-spacing: -.075em;
  line-height: .85;
  white-space: nowrap;
}

.brand-wordmark b {
  max-width: 330px;
  overflow: hidden;
  text-overflow: ellipsis;
  font: inherit;
}

.brand-wordmark i {
  margin-left: .03em;
  color: var(--brand);
  font-style: normal;
}

.brand-wordmark small {
  position: absolute;
  right: 0;
  bottom: -1.18em;
  color: var(--brand);
  font-size: .25em;
  font-weight: 850;
  letter-spacing: -.02em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
}

.brand-name {
  max-width: 220px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-note {
  color: var(--brand);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .15em;
}

.brand-row__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.support-link {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
}

.theme-toggle {
  width: 42px;
  min-width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-2);
  background: var(--panel);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.theme-toggle svg[hidden] { display: none !important; }

.entry-grid {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(410px, 1.1fr);
  gap: 12px;
  align-items: stretch;
}

.auth-card,
.temporary-access {
  position: relative;
  height: 100%;
  padding: clamp(28px, 4.2vw, 50px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: linear-gradient(145deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
  box-shadow: 0 0 24px var(--brand-glow);
}

.auth-card__halo { display: none; }

.auth-card__head {
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 26px;
  text-align: left;
}

.auth-card__head::before,
.temporary-access::before {
  display: block;
  color: var(--brand);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.auth-card__head::before { content: "ЛИЧНЫЙ КАБИНЕТ / 01"; }

.auth-card__head h1 {
  margin: 12px 0 0;
  color: var(--text-strong);
  background: none;
  -webkit-text-fill-color: currentColor;
  font-size: clamp(36px, 5vw, 54px);
  font-weight: 780;
  letter-spacing: -.055em;
  line-height: .98;
}

.auth-card__head p {
  max-width: 470px;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: initial;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--bg-raised);
}

.mode-button {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.mode-button:hover { color: var(--text); background: var(--panel-2); }
.mode-button.active { color: #fff; background: var(--brand); box-shadow: 0 8px 24px var(--brand-glow); }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }

.field label {
  color: var(--text-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  color: var(--text);
  background: var(--bg-raised);
  font-size: 15px;
}

.field input::placeholder { color: var(--muted); }
.field input:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-light); outline: none; }

.password-shell { position: relative; }
.password-shell input { padding-right: 94px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  min-height: 38px;
  padding: 7px 10px;
  transform: translateY(-50%);
  border-radius: 5px;
  color: var(--brand);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.password-toggle:hover { color: var(--text); background: var(--brand-light); }

.password-generate,
.btn-secondary {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  color: var(--text);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.password-generate:hover,
.btn-secondary:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-light); }

.password-shell.field-error input { border-color: var(--danger); background: var(--danger-soft); box-shadow: 0 0 0 3px var(--danger-soft); }
.field-feedback { color: var(--danger); font-size: 13px; }

.cta-button,
.btn-primary {
  min-height: 52px;
  border: 1px solid var(--brand);
  border-radius: var(--radius-input);
  color: #fff;
  background: linear-gradient(180deg, #ff2b38, var(--brand-dark));
  box-shadow: var(--shadow-button);
  font-size: 14px;
  font-weight: 760;
}

.cta-button::before { display: none; }
.cta-button:hover,
.btn-primary:hover { color: #fff; background: var(--brand-dark); box-shadow: 0 14px 30px var(--brand-glow); transform: translateY(-1px); }
.cta-button:active,
.btn-primary:active { transform: translateY(0) scale(.99); }

.text-button {
  align-self: center;
  min-height: 38px;
  padding: 8px;
  color: var(--text-2);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover { color: var(--brand); }

.feedback {
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-2);
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.5;
}

.feedback.info { color: var(--info); border-color: var(--info); background: var(--info-soft); }
.feedback.warn { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }
.feedback.error { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 23px 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.telegram-card { display: flex; flex-direction: column; gap: 10px; padding: 0; border: 0; background: transparent; }
.telegram-card #telegram-widget-root { display: flex; justify-content: center; min-height: 0; width: 100%; }
.telegram-card #telegram-widget-root:empty { display: none; }

.telegram-fallback {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  color: var(--text);
  background: var(--bg-raised);
  text-align: left;
  text-decoration: none;
}

.telegram-fallback:hover { color: var(--text); border-color: var(--tg-blue); background: var(--info-soft); }
.telegram-fallback__icon { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--tg-blue); }
.telegram-fallback__text { display: flex; flex-direction: column; gap: 2px; }
.telegram-fallback__text strong { font-size: 13px; }
.telegram-fallback__text small,
.muted-hint { color: var(--muted); font-size: 11px; line-height: 1.4; }
.muted-hint { margin: 0; text-align: center; }

.proxy-first { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; padding: 13px; border: 1px solid rgb(244 186 85 / 30%); border-radius: var(--radius-input); color: var(--text); background: var(--warning-soft); }
.proxy-first p { margin: 0; color: var(--text-2); font-size: 12px; line-height: 1.45; }
.proxy-first__actions { display: flex; gap: 8px; }
.proxy-first__btn { flex: 1 1 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: var(--panel); font-size: 12px; font-weight: 700; text-align: center; text-decoration: none; }
.proxy-first__btn:hover { color: var(--brand); border-color: var(--brand); }
.proxy-first__btn--primary,
.proxy-first__btn--primary:hover { color: #fff; border-color: var(--tg-blue); background: var(--tg-blue); }

.google-auth { min-height: 0; }
.google-auth iframe { max-width: 100% !important; border-radius: 6px !important; }

.reset-sheet { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-input); color: var(--text); background: var(--bg-raised); }
.reset-sheet h3 { margin: 0 0 6px; }
.reset-sheet > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.temporary-access {
  border-left-color: rgb(255 31 45 / 42%);
  background:
    radial-gradient(circle at 110% 0%, var(--brand-light), transparent 42%),
    linear-gradient(145deg, var(--panel-2), var(--panel));
}

.temporary-access::before { content: "БЫСТРЫЙ СТАРТ / 02"; margin-bottom: 14px; }
.temporary-kicker { margin: 0 0 12px; color: var(--text-2); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }

.temporary-access h2 {
  max-width: 460px;
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(29px, 4.1vw, 43px);
  font-weight: 760;
  letter-spacing: -.05em;
  line-height: 1;
}

.temporary-lead { margin: 14px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.temporary-main { display: grid; grid-template-columns: 164px minmax(0, 1fr); gap: 18px; align-items: start; }

.temporary-qr { position: relative; width: 164px; aspect-ratio: 1; padding: 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--qr-plate); }
.temporary-qr svg { display: block; width: 100%; height: 100%; }
.temporary-qr__logo { position: absolute; inset: 50% auto auto 50%; width: 42px; height: 42px; padding: 4px; transform: translate(-50%, -50%); border: 3px solid var(--qr-plate); border-radius: 6px; background: var(--qr-plate); }
.temporary-qr__logo img { display: block; width: 100%; height: 100%; border-radius: 3px; }

.temporary-status { min-width: 0; min-height: 164px; display: flex; flex-direction: column; }
.temporary-status-label { margin: 0 0 5px; color: var(--text-2); font-size: 11px; }
.temporary-countdown { margin: 0 0 16px; color: var(--brand); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }

.temporary-key { display: block; width: 100%; margin-top: auto; padding: 10px 11px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; color: var(--text-2); background: var(--bg-raised); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 10px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; cursor: copy; user-select: all; }
.temporary-key:hover { color: var(--text); border-color: var(--brand); }

.temporary-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 20px; }
.temporary-action { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; padding: 11px 15px; border: 1px solid transparent; border-radius: var(--radius-input); font-size: 13px; font-weight: 750; text-align: center; text-decoration: none; }
.temporary-action--primary { color: #fff; border-color: var(--brand); background: linear-gradient(180deg, #ff2b38, var(--brand-dark)); box-shadow: var(--shadow-button); }
.temporary-action--primary:hover { color: #fff; background: var(--brand-dark); }
.temporary-action--secondary { color: var(--text); border-color: var(--line-strong); background: transparent; }
.temporary-action--secondary:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-light); }
.temporary-action[aria-disabled="true"],
.temporary-action:disabled { opacity: .5; pointer-events: none; }

.temporary-message { min-height: 20px; margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.temporary-notes { margin: 22px 0 0; padding: 18px 0 0 20px; border-top: 1px solid var(--line); }
.temporary-notes li { margin: 0 0 9px; padding-left: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.temporary-notes li::marker { color: var(--brand); font-weight: 800; }

.how-it-works { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 38px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.how-step { min-height: 118px; padding: 22px; }
.how-step:first-child { padding-left: 0; }
.how-step:last-child { padding-right: 0; }
.how-step + .how-step { border-left: 1px solid var(--line); }
.how-step strong { display: block; margin-bottom: 7px; color: var(--text); font-size: 13px; }
.how-step p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.lk-footer { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0; color: var(--muted); font-size: 10px; }
.lk-footer a { color: var(--muted); }

.auth-toast { position: fixed; z-index: 20; top: 18px; left: 50%; max-width: min(90vw, 420px); padding: 11px 14px; transform: translate(-50%, -140%); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); background: var(--panel-2); box-shadow: 0 18px 48px rgb(0 0 0 / 40%); font-size: 13px; transition: transform 180ms ease; }
.auth-toast:empty { display: none; }
.auth-toast.visible { transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .lk-shell { padding-inline: 18px; }
  .brand-row { margin-bottom: 24px; }
  .entry-grid { grid-template-columns: 1fr; }
  .auth-card,
  .temporary-access { height: auto; }
  body::before { width: 110vw; opacity: .38; }
}

@media (max-width: 620px) {
  .lk-shell { padding: 0 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .brand-row { min-height: 72px; margin-bottom: 12px; gap: 12px; }
  .brand { gap: 10px; }
  .brand-wordmark { max-width: 245px; font-size: 22px; }
  .brand-wordmark b { max-width: 220px; }
  .brand-copy { display: none; }
  .support-link { font-size: 10px; }
  .theme-toggle { width: 40px; min-width: 40px; height: 40px; }
  .entry-grid { gap: 10px; }
  .auth-card,
  .temporary-access { padding: 24px 18px; }
  .auth-card__head { margin-bottom: 22px; }
  .auth-card__head h1 { font-size: 38px; }
  .temporary-access h2 { font-size: 32px; }
  .temporary-main { grid-template-columns: 118px minmax(0, 1fr); gap: 13px; }
  .temporary-qr { width: 118px; }
  .temporary-status { min-height: 118px; }
  .temporary-countdown { font-size: 25px; }
  .temporary-actions { grid-template-columns: 1fr; }
  .how-it-works { grid-template-columns: 1fr; }
  .how-step,
  .how-step:first-child,
  .how-step:last-child { min-height: 0; padding: 16px 0; }
  .how-step + .how-step { border-top: 1px solid var(--line); border-left: 0; }
  .lk-footer { min-height: 58px; }
}

@media (max-width: 390px) {
  .support-link { display: none; }
  .temporary-main { grid-template-columns: 1fr; }
  .temporary-qr { width: min(100%, 210px); margin: 0 auto; }
  .temporary-status { min-height: 0; }
  .temporary-key { margin-top: 4px; }
  .proxy-first__actions,
  .row { flex-direction: column; }
}

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