/* Страницы входа и ошибок — Material 3 Expressive.
   Цвета приходят из js/theme.js (--md-*, светлая/тёмная тема); значения ниже — запасные для случая без JS. */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --md-surface: #0B0E13; --md-surface-container: #1B1D21; --md-surface-container-high: #262A2F; --md-surface-container-highest: #31353A;
  --md-on-surface: #E0E2E8; --md-on-surface-variant: #C1C7D3; --md-outline-variant: #414751;
  --md-primary: #AAC8FA; --md-on-primary: #0E3254; --md-primary-container: #244A75; --md-on-primary-container: #D3E4FF;
  --md-secondary-container: #3F4759; --md-on-secondary-container: #DBE2F9;
  --md-tertiary-container: #5B3E5C; --md-on-tertiary-container: #FCD7FB;
  --md-error-container: #8C1D18; --md-on-error-container: #F9DEDC; --md-error: #F2B8B5;
  --md-ease-spring: cubic-bezier(.34, 1.56, .64, 1); --md-ease-decel: cubic-bezier(.05, .7, .1, 1); --md-ease-shape: cubic-bezier(.2, 0, 0, 1);
  color-scheme: dark;
}
html[data-mode="light"] { color-scheme: light; }
html { min-height: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom));
  background: var(--md-surface); color: var(--md-on-surface); overflow-x: hidden; position: relative;
  font-family: 'Roboto Flex', 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif; font-optical-sizing: auto;
}
/* фоновые формы */
body::before, body::after { content: ""; position: fixed; z-index: 0; pointer-events: none; animation: morph 18s ease-in-out infinite; }
body::before { width: min(60vw, 560px); aspect-ratio: 1; left: -12vw; bottom: -18vw; background: var(--md-primary-container); opacity: .55; }
body::after { width: min(46vw, 420px); aspect-ratio: 1; right: -8vw; top: -10vw; background: var(--md-tertiary-container); opacity: .5; animation-delay: -7s; animation-direction: reverse; }
@keyframes morph {
  0%, 100% { border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%; transform: rotate(0); }
  33% { border-radius: 38% 62% 45% 55% / 58% 42% 58% 42%; transform: rotate(40deg); }
  66% { border-radius: 52% 48% 65% 35% / 40% 55% 45% 60%; transform: rotate(-30deg); }
}

.page { position: relative; z-index: 1; width: min(100%, 520px); display: grid; gap: 12px; animation: pageIn 480ms var(--md-ease-decel); }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* герой: крупная фигура с иконкой/кодом */
.hero {
  position: relative; min-height: 232px; padding: 60px 28px 24px; display: flex; align-items: center; justify-content: center; gap: 16px; overflow: hidden;
  border-radius: 56px 56px 20px 20px; background: var(--tone-bg); color: var(--tone-fg);
  transition: border-radius 600ms var(--md-ease-shape);
}
.page:hover .hero { border-radius: 20px 20px 56px 56px; }
.hero:has(.hero-code) { justify-content: space-between; }
.hero-shape { flex: 0 0 auto; width: 132px; height: 132px; display: grid; place-items: center; background: var(--tone-fg); color: var(--tone-bg); animation: morph 10s ease-in-out infinite; }
.hero-shape svg { width: 64px; height: 64px; }
.hero-code {
  font-size: clamp(3.75rem, 17vw, 6.25rem); line-height: 1; font-weight: 900; font-stretch: 125%; min-width: 0;
  letter-spacing: -.05em; font-variation-settings: 'opsz' 144; opacity: .9; user-select: none; font-variant-numeric: tabular-nums;
}
.hero-brand { position: absolute; left: 22px; top: 20px; display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-stretch: 108%; }
.hero-brand svg { width: 22px; height: 22px; }

.panel {
  padding: 28px 28px 24px; border-radius: 20px 20px 56px 56px; background: var(--md-surface-container); display: grid; gap: 10px;
  transition: border-radius 600ms var(--md-ease-shape);
}
.page:hover .panel { border-radius: 56px 56px 20px 20px; }
h1 { font-size: clamp(2rem, 8vw, 2.75rem); line-height: 1.02; font-weight: 800; font-stretch: 112%; letter-spacing: -.03em; font-variation-settings: 'opsz' 64; }
.lead { color: var(--md-on-surface-variant); font-size: 1rem; line-height: 1.5; max-width: 38ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.btn {
  height: 60px; padding: 0 22px; gap: 10px; border: 0; cursor: pointer; text-decoration: none; font: inherit; font-size: 1rem; font-weight: 700; font-stretch: 104%;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 30px; flex: 1 1 auto;
  transition: border-radius 400ms var(--md-ease-shape), transform 300ms var(--md-ease-spring), background 150ms;
}
.btn svg { width: 24px; height: 24px; flex-shrink: 0; }
.btn:hover { border-radius: 18px; }
.btn:active { border-radius: 12px; transform: scale(.97); }
.btn-primary { background: var(--md-primary); color: var(--md-on-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--md-primary) 90%, var(--md-on-primary)); }
.btn-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-tonal:hover { background: color-mix(in srgb, var(--md-secondary-container) 88%, var(--md-on-secondary-container)); }
.btn-wide { flex-basis: 100%; }
.only-5xx { display: none; }
body[data-class="5"] .only-5xx { display: inline-flex; }
:focus-visible { outline: 3px solid var(--md-primary); outline-offset: 3px; }

/* тона */
.tone-primary { --tone-bg: var(--md-primary-container); --tone-fg: var(--md-on-primary-container); }
.tone-secondary { --tone-bg: var(--md-secondary-container); --tone-fg: var(--md-on-secondary-container); }
.tone-tertiary { --tone-bg: var(--md-tertiary-container); --tone-fg: var(--md-on-tertiary-container); }
.tone-error { --tone-bg: var(--md-error-container); --tone-fg: var(--md-on-error-container); }

/* переключатель темы */
.theme-fab {
  position: fixed; z-index: 2; top: max(16px, env(safe-area-inset-top)); right: 16px; width: 48px; height: 48px; border: 0; cursor: pointer; display: grid; place-items: center;
  border-radius: 24px; background: var(--md-surface-container-high); color: var(--md-on-surface-variant);
  transition: border-radius 350ms var(--md-ease-shape), background 200ms, transform 300ms var(--md-ease-spring);
}
.theme-fab svg { width: 24px; height: 24px; grid-area: 1 / 1; transition: transform 500ms var(--md-ease-spring), opacity 200ms; }
.theme-fab .i-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
html[data-mode="light"] .theme-fab .i-moon { opacity: 0; transform: rotate(90deg) scale(.5); }
html[data-mode="light"] .theme-fab .i-sun { opacity: 1; transform: none; }
.theme-fab:hover { border-radius: 16px; background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.theme-fab:active { border-radius: 12px; transform: scale(.92); }

@media (max-width: 480px) {
  .hero { min-height: 200px; padding: 56px 20px 20px; border-radius: 44px 44px 16px 16px; }
  .panel { padding: 24px 22px 22px; border-radius: 16px 16px 44px 44px; }
  .hero-shape { width: 96px; height: 96px; }
  .hero-shape svg { width: 46px; height: 46px; }
  .btn { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
