:root {
  --auth-shell-bg: rgba(255, 255, 255, 0.78);
  --auth-shell-border: rgba(157, 46, 197, 0.14);
  --auth-card-bg: rgba(255, 255, 255, 0.8);
  --auth-story-bg:
    linear-gradient(160deg, rgba(255, 255, 255, 0.72) 0%, rgba(239, 229, 255, 0.9) 58%, rgba(228, 243, 255, 0.88) 100%);
  --auth-story-card-bg: rgba(255, 255, 255, 0.56);
  --auth-story-card-border: rgba(157, 46, 197, 0.14);
  --auth-story-pill-bg: rgba(255, 255, 255, 0.66);
  --auth-story-pill-border: rgba(157, 46, 197, 0.18);
  --auth-subtle-border: rgba(157, 46, 197, 0.14);
  --auth-input-bg: rgba(255, 255, 255, 0.74);
  --auth-input-border: rgba(157, 46, 197, 0.18);
  --auth-placeholder: #8e84af;
  --auth-accent-soft: rgba(157, 46, 197, 0.1);
  --auth-accent-glow: rgba(124, 58, 237, 0.16);
  --auth-shadow: 0 28px 70px rgba(92, 51, 143, 0.16);
  --auth-shell-highlight: rgba(255, 255, 255, 0.55);
  --auth-button-shadow: 0 18px 30px rgba(94, 90, 238, 0.24);
  --auth-button-bg: linear-gradient(135deg, #8f49dc 0%, #5f86ff 100%);
  --auth-button-bg-hover: linear-gradient(135deg, #7d3fd4 0%, #4d79fb 100%);
}

html[data-theme="dark"] {
  --auth-shell-bg: rgba(10, 17, 30, 0.82);
  --auth-shell-border: rgba(161, 96, 235, 0.14);
  --auth-card-bg: rgba(12, 20, 33, 0.72);
  --auth-story-bg:
    linear-gradient(160deg, rgba(18, 26, 40, 0.96) 0%, rgba(33, 22, 51, 0.96) 58%, rgba(9, 31, 47, 0.98) 100%);
  --auth-story-card-bg: rgba(255, 255, 255, 0.05);
  --auth-story-card-border: rgba(161, 96, 235, 0.18);
  --auth-story-pill-bg: rgba(255, 255, 255, 0.06);
  --auth-story-pill-border: rgba(161, 96, 235, 0.18);
  --auth-subtle-border: rgba(161, 96, 235, 0.18);
  --auth-input-bg: rgba(255, 255, 255, 0.05);
  --auth-input-border: rgba(161, 96, 235, 0.16);
  --auth-placeholder: #7f8da4;
  --auth-accent-soft: rgba(161, 96, 235, 0.12);
  --auth-accent-glow: rgba(161, 96, 235, 0.24);
  --auth-shadow: 0 36px 90px rgba(0, 0, 0, 0.34);
  --auth-shell-highlight: rgba(255, 255, 255, 0.04);
  --auth-button-shadow: 0 20px 34px rgba(47, 76, 168, 0.32);
  --auth-button-bg: linear-gradient(135deg, #9a58ea 0%, #5d88ff 100%);
  --auth-button-bg-hover: linear-gradient(135deg, #ab6bfa 0%, #7094ff 100%);
}

body {
  overflow-x: hidden;
}

.auth-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at top left, rgba(157, 46, 197, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(84, 152, 255, 0.14), transparent 28%),
    linear-gradient(135deg, #fcfbff 0%, #f3eeff 48%, #edf8ff 100%);
}

html[data-theme="dark"] .auth-page {
  background:
    radial-gradient(circle at top left, rgba(161, 96, 235, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(84, 152, 255, 0.14), transparent 30%),
    linear-gradient(135deg, #0b1220 0%, #10192a 50%, #0d1f31 100%);
}

.auth-decor {
  position: absolute;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.8;
  pointer-events: none;
}

.auth-decor-primary {
  width: 360px;
  height: 360px;
  top: -110px;
  left: -80px;
  background:
    radial-gradient(circle at 40% 40%, rgba(163, 103, 235, 0.32), transparent 58%);
}

.auth-decor-secondary {
  width: 320px;
  height: 320px;
  right: -100px;
  bottom: -120px;
  background:
    radial-gradient(circle at 40% 40%, rgba(95, 134, 255, 0.28), transparent 56%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(360px, 0.95fr);
  border: 1px solid var(--auth-shell-border);
  border-radius: 28px;
  background: var(--auth-shell-bg);
  box-shadow: var(--auth-shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.auth-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--auth-shell-highlight);
  pointer-events: none;
}

.auth-story,
.auth-card {
  position: relative;
  padding: clamp(28px, 4vw, 42px);
}

.auth-story {
  display: grid;
  align-content: space-between;
  gap: 26px;
  background: var(--auth-story-bg);
}

.auth-story::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 48%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04));
  pointer-events: none;
}

.auth-card {
  display: grid;
  align-content: center;
  gap: 26px;
  background:
    linear-gradient(180deg, var(--auth-card-bg), rgba(255, 255, 255, 0.02));
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.auth-brand {
  position: relative;
  z-index: 1;
  width: fit-content;
  color: var(--text);
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo-dark {
  display: none;
}

html[data-theme="dark"] .brand-logo-light {
  display: none;
}

html[data-theme="dark"] .brand-logo-dark {
  display: block;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-name {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-tagline {
  color: var(--muted);
  font-size: 0.92rem;
}

.story-copy-wrap,
.story-grid,
.story-points {
  position: relative;
  z-index: 1;
}

.story-kicker,
.mode-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--auth-story-pill-border);
  background: var(--auth-story-pill-bg);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story-title {
  margin: 14px 0 12px;
  font-size: clamp(2.2rem, 4vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  max-width: 12ch;
}

.story-copy {
  margin: 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.story-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--auth-story-card-border);
  background: var(--auth-story-card-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.05);
}

.story-card-wide {
  grid-column: 1 / -1;
}

.story-card-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.story-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.95rem;
}

.story-points {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.story-points li {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--auth-story-pill-border);
  background: var(--auth-story-pill-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
}

.auth-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.back-link,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--auth-subtle-border);
  background: var(--auth-story-pill-bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  backdrop-filter: blur(8px);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.theme-toggle {
  cursor: pointer;
}

.back-link:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(157, 46, 197, 0.28);
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.14);
}

.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(157, 46, 197, 0.14);
  box-shadow: inset 0 0 0 1px rgba(157, 46, 197, 0.14);
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 4px 10px rgba(60, 25, 99, 0.18);
  transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-track {
  background: rgba(95, 134, 255, 0.24);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb {
  transform: translateX(20px);
  background: #dbe7ff;
}

.auth-card-head {
  display: grid;
  gap: 14px;
}

.title {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.65rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.helper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.field[hidden],
.story-card[hidden],
.story-points li[hidden] {
  display: none !important;
}

.field label,
.field-head {
  font-size: 0.95rem;
  font-weight: 700;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--auth-input-border);
  background: var(--auth-input-bg);
  color: var(--text);
  outline: none;
  appearance: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

input::placeholder {
  color: var(--auth-placeholder);
}

input:hover,
select:hover {
  border-color: rgba(157, 46, 197, 0.24);
}

input:focus,
select:focus {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 4px var(--ring),
    0 10px 26px var(--auth-accent-glow);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus {
  background: rgba(255, 255, 255, 0.08);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--auth-input-bg) inset;
  transition: background-color 5000s ease-in-out 0s;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 2px),
    calc(100% - 16px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

.phone-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.82fr) minmax(0, 1.18fr);
  gap: 12px;
}

.error {
  min-height: 18px;
  color: #c94444;
  font-size: 0.82rem;
  line-height: 1.45;
}

.error:empty {
  min-height: 0;
}

.status-banner {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  line-height: 1.6;
}

.status-banner[data-tone="info"] {
  color: #2c4e88;
  background: rgba(95, 134, 255, 0.12);
  border-color: rgba(95, 134, 255, 0.24);
}

.status-banner[data-tone="success"] {
  color: #165d37;
  background: rgba(46, 160, 67, 0.12);
  border-color: rgba(46, 160, 67, 0.22);
}

.status-banner[data-tone="error"] {
  color: #9f2a2a;
  background: rgba(201, 68, 68, 0.12);
  border-color: rgba(201, 68, 68, 0.2);
}

.submit-stack {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease,
    filter 0.16s ease;
}

.auth-btn-solid {
  color: #fff;
  background: var(--auth-button-bg);
  box-shadow: var(--auth-button-shadow);
}

.auth-btn-solid:hover {
  transform: translateY(-1px);
  background: var(--auth-button-bg-hover);
  filter: saturate(1.04);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

.form-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 22px;
  border-top: 1px solid var(--auth-subtle-border);
  color: var(--muted);
}

.link-btn {
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.16s ease;
}

.link-btn:hover {
  opacity: 0.8;
}

.auth-shell-single {
  grid-template-columns: 1fr;
  width: min(560px, 100%);
}

a:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

.auth-card.shake {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-2px);
  }
  40% {
    transform: translateX(2px);
  }
  60% {
    transform: translateX(-2px);
  }
  80% {
    transform: translateX(2px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-story,
  .auth-card {
    padding: 28px;
  }

  .story-title {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .auth-page {
    padding: 14px;
  }

  .auth-shell {
    border-radius: 22px;
  }

  .auth-story,
  .auth-card {
    padding: 22px 18px;
  }

  .auth-story {
    gap: 18px;
  }

  .auth-story::after {
    inset: 14px;
    border-radius: 18px;
  }

  .auth-brand {
    gap: 12px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .brand-copy {
    gap: 1px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .brand-tagline {
    font-size: 0.84rem;
  }

  .story-copy-wrap {
    display: grid;
    gap: 10px;
  }

  .story-kicker,
  .mode-pill {
    padding: 7px 10px;
    font-size: 0.72rem;
  }

  .story-title {
    margin: 0;
    font-size: clamp(1.85rem, 9vw, 2.35rem);
    line-height: 1.04;
    letter-spacing: -0.04em;
  }

  .story-copy {
    font-size: 0.96rem;
    line-height: 1.62;
  }

  .auth-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .back-link,
  .theme-toggle {
    flex: 1 1 180px;
    justify-content: center;
  }

  .story-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .story-card-wide {
    grid-column: auto;
  }

  .story-card {
    padding: 15px 16px;
    border-radius: 16px;
    box-shadow: none;
  }

  .story-card-label {
    margin-bottom: 8px;
    font-size: 0.86rem;
  }

  .story-card p {
    font-size: 0.91rem;
    line-height: 1.55;
  }

  .story-points {
    gap: 8px;
  }

  .story-points li {
    width: 100%;
    text-align: center;
    padding: 9px 12px;
    font-size: 0.88rem;
  }

  .auth-card-head {
    gap: 12px;
  }

  .title {
    font-size: clamp(1.85rem, 8.2vw, 2.3rem);
  }

  .subtitle {
    font-size: 0.96rem;
    line-height: 1.62;
  }

  .switch {
    padding-top: 18px;
  }

  .phone-grid {
    grid-template-columns: 1fr;
  }

  .helper-row {
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .auth-page {
    padding: 10px;
  }

  .auth-shell {
    border-radius: 20px;
  }

  .auth-story,
  .auth-card {
    padding: 18px 14px;
  }

  .auth-story {
    gap: 16px;
  }

  .auth-story::after {
    inset: 10px;
    border-radius: 16px;
  }

  .story-title {
    font-size: clamp(1.7rem, 10vw, 2rem);
  }

  .story-copy {
    font-size: 0.92rem;
    line-height: 1.56;
  }

  .story-card {
    padding: 13px 14px;
  }

  .story-card p {
    font-size: 0.89rem;
  }

  .brand-name {
    font-size: 0.96rem;
  }

  .brand-tagline {
    font-size: 0.8rem;
  }

  .back-link,
  .theme-toggle {
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.92rem;
  }

  .title {
    font-size: clamp(1.72rem, 9vw, 2.05rem);
  }

  .subtitle,
  .form-note {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-link,
  .theme-toggle,
  .auth-btn,
  input,
  select,
  .theme-toggle-thumb {
    transition: none;
  }

  .auth-card.shake {
    animation: none;
  }
}
