* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body.auth-page {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, hsl(var(--primary) / 0.09), transparent 28rem),
    radial-gradient(circle at 88% 92%, hsl(var(--primary) / 0.06), transparent 24rem),
    hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    linear-gradient(hsl(var(--foreground) / 0.025) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--foreground) / 0.025) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(25rem, 0.98fr);
  width: min(78rem, calc(100% - 2rem));
  min-height: 38rem;
  margin: max(1rem, 4vh) auto;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 1.5rem;
  background: hsl(var(--card));
  box-shadow: 0 2rem 5rem hsl(var(--foreground) / 0.11);
}

.auth-story {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(2.25rem, 5vw, 4.5rem);
  overflow: hidden;
  color: white;
  background:
    radial-gradient(circle at 82% 18%, rgba(255,255,255,0.17), transparent 17rem),
    linear-gradient(145deg, hsl(245 86% 54%), hsl(250 79% 42%));
}

.auth-story::after {
  content: "C";
  position: absolute;
  right: -2rem;
  bottom: -8rem;
  font-size: 28rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.12em;
  color: rgba(255, 255, 255, 0.055);
  pointer-events: none;
}

.auth-brand,
.auth-mobile-brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  color: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.auth-brand-mark {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0.5rem 1.5rem rgba(22, 15, 72, 0.18);
}

.auth-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-story-copy {
  position: relative;
  z-index: 1;
  max-width: 31rem;
  margin: 4rem 0;
}

.auth-eyebrow {
  display: inline-block;
  margin-bottom: 0.8rem;
  color: hsl(var(--primary));
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.auth-story .auth-eyebrow {
  color: rgba(255, 255, 255, 0.7);
}

.auth-story h1 {
  max-width: 31rem;
  margin: 0;
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  font-weight: 650;
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.auth-story-copy p {
  max-width: 27rem;
  margin: 1.5rem 0 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 1rem;
  line-height: 1.65;
}

.auth-pipeline {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-pipeline li {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.17);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.84rem;
}

.auth-pipeline li span {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
}

.auth-pipeline li strong {
  font-weight: 550;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 5vw, 4.5rem);
  background: hsl(var(--card));
}

.auth-mobile-brand {
  display: none;
  margin-bottom: 3rem;
}

.auth-mobile-brand .auth-brand-mark {
  border-color: hsl(var(--border));
  background: hsl(var(--background));
  box-shadow: none;
}

.dark .auth-mobile-brand .auth-brand-mark img {
  filter: invert(1);
}

.auth-panel-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.auth-panel-heading p {
  max-width: 26rem;
  margin: 0.85rem 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.92rem;
  line-height: 1.55;
}

.auth-form {
  margin-top: 2.25rem;
}

.auth-form-group {
  margin-bottom: 1.25rem;
}

.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.auth-form-label {
  display: block;
  margin-bottom: 0.48rem;
  color: hsl(var(--foreground));
  font-size: 0.79rem;
  font-weight: 600;
}

.auth-form-input {
  width: 100%;
  min-height: 3rem;
  padding: 0.78rem 0.9rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.7rem;
  outline: none;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.auth-form-input::placeholder {
  color: hsl(var(--muted-foreground) / 0.7);
}

.auth-form-input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.14);
}

.auth-password-wrap {
  position: relative;
}

.auth-password-input {
  padding-right: 3rem;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}

.auth-password-toggle:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.auth-password-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
}

.auth-link,
.auth-beta-note a,
.auth-footer a {
  color: hsl(var(--primary));
  font-weight: 550;
  text-decoration: none;
}

.auth-link {
  font-size: 0.76rem;
}

.auth-link:hover,
.auth-beta-note a:hover,
.auth-footer a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.auth-btn-primary {
  display: flex;
  width: 100%;
  min-height: 3.1rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 0.72rem;
  background: hsl(var(--primary));
  box-shadow: 0 0.7rem 1.7rem hsl(var(--primary) / 0.22);
  color: hsl(var(--primary-foreground));
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.auth-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0.9rem 2rem hsl(var(--primary) / 0.3);
}

.auth-btn-primary:disabled {
  opacity: 0.62;
  cursor: wait;
}

.auth-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.auth-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: auth-spin 700ms linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.auth-message {
  margin-top: 1.5rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid;
  border-radius: 0.7rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

.auth-message-success {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.09);
  color: #087f5b;
}

.auth-message-error {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.075);
  color: #b42318;
}

.dark .auth-message-success { color: #6ee7b7; }
.dark .auth-message-error { color: #fca5a5; }

.auth-beta-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 1.6rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.7rem;
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--muted-foreground));
  font-size: 0.72rem;
  line-height: 1.5;
}

.auth-install-button {
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.65rem;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.auth-install-button:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--muted-foreground));
}

.auth-install-button[hidden] {
  display: none;
}

.auth-beta-note p {
  margin: 0;
}

.auth-status-dot {
  flex: 0 0 auto;
  width: 0.48rem;
  height: 0.48rem;
  margin-top: 0.32rem;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.68rem;
}

.auth-footer-links {
  display: flex;
  gap: 1rem;
}

.auth-footer a {
  color: inherit;
}

.auth-theme-toggle {
  position: fixed;
  z-index: 2;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
  place-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card) / 0.92);
  box-shadow: 0 0.6rem 1.8rem hsl(var(--foreground) / 0.12);
  color: hsl(var(--foreground));
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.auth-theme-toggle:hover {
  border-color: hsl(var(--primary) / 0.5);
  color: hsl(var(--primary));
}

.auth-theme-toggle svg {
  width: 1.12rem;
  height: 1.12rem;
}

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

@media (max-width: 800px) {
  .auth-shell {
    display: block;
    width: min(31rem, calc(100% - 1.25rem));
    min-height: 0;
    margin: 0.65rem auto 4.5rem;
    border-radius: 1.15rem;
  }

  .auth-story {
    display: none;
  }

  .auth-panel {
    min-height: calc(100dvh - 5.8rem);
    padding: clamp(1.5rem, 7vw, 2.6rem);
  }

  .auth-mobile-brand {
    display: inline-flex;
  }

  .auth-footer {
    margin-top: 2.5rem;
  }
}

@media (max-width: 420px) {
  .auth-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

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