:root {
  --ink: #f4f6fb;
  --muted: #9aa3b5;
  --line: rgba(255, 255, 255, 0.12);
  --panel: #07090f;
  --field: #141821;
  --primary: #225aeb;
  --accent: #fb735b;
  --wa: #25d366;
  --motion-instant: 80ms;
  --motion-fast: 120ms;
  --motion-normal: 240ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease: var(--ease-out);
  --font-display: "Gilda Display", Georgia, serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-control: 12px;
  --radius-surface: 14px;
  /* Match chat sidebar scrollbars (dark surface) */
  --scroll-size: 5px;
  --scroll-track: transparent;
  --scroll-thumb: color-mix(in srgb, white 18%, transparent);
  --scroll-thumb-hover: color-mix(in srgb, white 30%, transparent);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* Minimal scrollbars — same language as chat sidebar */
*::-webkit-scrollbar {
  width: var(--scroll-size);
  height: var(--scroll-size);
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

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

body {
  font-family: var(--font-ui);
  background: var(--panel);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
}

.auth__panel {
  display: flex;
  flex-direction: column;
  padding: max(1.5rem, env(safe-area-inset-top)) clamp(1.25rem, 4vw, 3.5rem)
    max(2rem, env(safe-area-inset-bottom));
  min-width: 0;
}

.auth__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.auth__brand:hover .auth__brand-name,
.auth__brand:focus-visible .auth__brand-name {
  color: color-mix(in srgb, var(--ink) 88%, var(--accent));
}

.auth__brand:focus-visible {
  outline: none;
  border-radius: 10px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent);
}

.auth__mark {
  width: 2rem;
  height: 2rem;
  display: block;
  flex-shrink: 0;
  border-radius: 0.55rem;
  object-fit: contain;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 8px 20px rgba(251, 115, 91, 0.2);
}

.auth__brand-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  line-height: 1;
  padding-top: 0.1em;
}

.auth__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100%, 24rem);
  margin: 0 auto;
  padding: 2rem 0 1rem;
  gap: 0;
}

.auth__head {
  margin-bottom: 0.25rem;
}

.auth__eyebrow {
  display: none;
}

.auth__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.95rem, 3.5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.auth__title--sm {
  font-size: clamp(1.55rem, 3vw, 1.95rem);
}

.auth__lead,
.auth__hint,
.auth__footnote,
.auth__sync-body {
  display: none !important;
}

.auth__intro {
  margin: var(--space-3) 0 0;
  max-width: 38ch;
  font-size: 1rem;
  line-height: 1.55;
  color: color-mix(in srgb, var(--ink) 78%, var(--muted));
}

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

/* Guest path — single primary action (#2) */
.auth__guest-block {
  margin-top: var(--space-6);
}

.auth__guest-block[hidden] {
  display: none !important;
}

.auth__primary--guest {
  margin-top: 0;
}

.auth__guest-note {
  margin: var(--space-3) 0 0;
  max-width: 38ch;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Claude-style OR separator between try vs link */
.auth__or {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: var(--space-6) 0;
  color: color-mix(in srgb, var(--muted) 88%, transparent);
  font-size: 0.75rem;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth__or::before,
.auth__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--line) 90%, transparent);
}

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

/* Sign-in — visually secondary unless link-only (#2, #12) */
.auth__signin-block {
  margin-top: 0;
  padding: var(--space-5) var(--space-4) var(--space-5);
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  background: color-mix(in srgb, white 3%, transparent);
}

body.is-link-only .auth__signin-block {
  margin-top: var(--space-6);
  padding: 0;
  border: 0;
  background: transparent;
}

.auth__signin-block[hidden] {
  display: none !important;
}

.auth__signin-head {
  margin-bottom: var(--space-4);
}

.auth__section-label {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
}

.auth__section-desc {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--muted);
}

.auth__divider {
  display: none !important;
}

/* Author display rules beat UA [hidden]; force hide on every step shell */
.auth__guest-block[hidden],
.auth__signin-block[hidden],
.auth__head[hidden],
.auth__form[hidden],
.auth__modes[hidden],
.auth__otp[hidden],
.auth__sync[hidden],
.auth__title[hidden],
.auth__guest[hidden],
.auth__guest-note[hidden],
.auth__divider[hidden],
.auth__or[hidden],
.auth__error[hidden],
.auth__dev[hidden],
.auth__field[hidden],
.auth__legal[hidden] {
  display: none !important;
}

.auth__otp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.auth__modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin-top: 0;
  padding: 0.25rem;
  border-radius: 12px;
  background: color-mix(in srgb, white 4%, transparent);
  border: 1px solid var(--line);
}

.auth__mode {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.auth__mode.is-active {
  background: color-mix(in srgb, white 92%, transparent);
  color: #0b1220;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.auth__mode:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth__form {
  margin-top: var(--space-4);
  display: grid;
  gap: var(--space-4);
}

.auth__field {
  display: grid;
  gap: 0.4rem;
}

.auth__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--ink) 65%, var(--muted));
  letter-spacing: 0.01em;
}

.auth__hint {
  font-size: 0.72rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--muted) 90%, transparent);
}

.auth__field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 0.95rem;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.auth__phone {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  overflow: hidden;
  transition: border-color 160ms var(--ease);
}

.auth__phone:focus-within {
  border-color: transparent;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth__phone-prefix {
  display: grid;
  place-items: center;
  padding: 0 0.85rem;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.auth__phone input {
  border: 0;
  border-radius: 0;
  outline: none;
  min-height: 48px;
}

.auth__phone input:focus-visible {
  outline: none;
}

.auth__field input::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}

.auth__field input:hover {
  border-color: color-mix(in srgb, white 22%, transparent);
}

.auth__field input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: transparent;
}

.auth__error {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #ffb4a8;
}

.auth__primary {
  margin-top: var(--space-2);
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 0 color-mix(in srgb, white 18%, transparent) inset,
    0 8px 24px color-mix(in srgb, var(--primary) 28%, transparent);
  transition: transform var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease),
    box-shadow var(--motion-fast) var(--ease), opacity var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease);
}

/* Claude-style high-contrast CTA on dark — unmistakable primary (#2, #12) */
.auth__primary--solid {
  background: #f2f0ed;
  color: #0b1220;
  box-shadow: none;
}

.auth__primary--solid:hover {
  background: #fff;
  color: #0b1220;
  box-shadow: 0 8px 24px color-mix(in srgb, #000 28%, transparent);
}

.auth__primary--solid:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.auth__secondary {
  margin-top: var(--space-1);
  width: 100%;
  min-height: 48px;
  border: 1px solid color-mix(in srgb, var(--line) 100%, transparent);
  border-radius: var(--radius-control);
  background: color-mix(in srgb, white 2%, transparent);
  color: color-mix(in srgb, var(--ink) 90%, var(--muted));
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 550;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.auth__secondary:hover {
  border-color: color-mix(in srgb, white 28%, transparent);
  background: color-mix(in srgb, white 6%, transparent);
  color: var(--ink);
}

.auth__secondary:active {
  transform: translateY(1px);
}

.auth__secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.auth__secondary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth__divider::before,
.auth__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--line) 88%, transparent);
}

.auth__primary:hover {
  background: color-mix(in srgb, var(--primary) 90%, black);
  box-shadow: 0 1px 0 color-mix(in srgb, white 14%, transparent) inset,
    0 10px 28px color-mix(in srgb, var(--primary) 34%, transparent);
}

.auth__primary--solid:hover {
  background: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, #000 28%, transparent);
}

.auth__primary:active {
  transform: translateY(1px);
}

.auth__primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.auth__primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.auth__otp {
  margin-top: 1.15rem;
  display: grid;
  gap: 0.85rem;
  animation: authRise 400ms var(--ease) both;
}

.auth__otp-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.auth__otp-lead {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.auth__dev {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--accent) 80%, white);
}

.auth__text {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.35rem 0;
  justify-self: start;
}

.auth__text:hover {
  color: var(--ink);
}

.auth__text:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#otpCode {
  letter-spacing: 0.35em;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}


.auth__sync {
  margin-top: 1.15rem;
  display: grid;
  gap: 0.85rem;
  animation: authRise 400ms var(--ease) both;
}

.auth__sync-lead {
  margin: 0;
  max-width: 34ch;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
}

.auth__sync .auth__primary {
  margin-top: 0.35rem;
}

.auth__sync-note {
  margin: 0.15rem 0 0;
  max-width: 36ch;
  font-size: 0.78rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--muted) 92%, transparent);
}

.auth__wa-link {
  justify-self: start;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 28%, transparent);
  padding-bottom: 0.1rem;
}

.auth__wa-link:hover {
  color: var(--ink);
  border-bottom-color: color-mix(in srgb, var(--ink) 35%, transparent);
}

.auth__wa-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.auth__wa-link[hidden] {
  display: none !important;
}

/* Legacy green WA button styles — keep unused, never promote again */
.auth__wa {
  display: none !important;
}

.auth__or {
  display: none !important;
}

.auth__hint {
  font-size: 0.72rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--muted) 90%, transparent);
}

.auth__footnote {
  margin: 1rem 0 0;
  max-width: 34ch;
  font-size: 0.7rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--muted) 85%, transparent);
}

.auth__guest {
  margin-top: auto;
  padding-top: 2.25rem;
  display: inline-block;
  width: fit-content;
  align-self: flex-start;
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 28%, transparent);
  padding-bottom: 0.1rem;
}

.auth__guest:hover {
  color: var(--ink);
  border-bottom-color: color-mix(in srgb, var(--ink) 40%, transparent);
}

.auth__guest:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.auth__legal {
  margin: var(--space-4) 0 0;
  max-width: 40ch;
  font-size: 0.72rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--muted) 88%, transparent);
}

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

.auth__visual {
  padding: 1.25rem 1.25rem 1.25rem 0.5rem;
  min-height: 100dvh;
}

.auth__visual-frame {
  position: relative;
  height: 100%;
  min-height: calc(100dvh - 2.5rem);
  border-radius: 28px;
  overflow: hidden;
  display: grid;
  place-items: end start;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: #101522;
}

.auth__visual-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  animation: authRise 700ms var(--ease) both;
}

.auth__visual-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 42%,
    color-mix(in srgb, #07090f 55%, transparent) 72%,
    color-mix(in srgb, #07090f 88%, transparent) 100%
  );
  pointer-events: none;
}

.auth__visual-line {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 12ch;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.6vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.auth__visual-copy,
.auth__visual-kicker,
.auth__visual-list {
  display: none !important;
}

@keyframes authRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth__visual-img,
  .auth__visual-copy,
  .auth__sync,
  .auth__otp,
  .auth__primary,
  .auth__secondary,
  .auth__mode {
    animation: none;
    transition: none;
  }
}

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

  .auth__panel {
    padding: max(1rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 1.5rem)
      max(1.75rem, env(safe-area-inset-bottom));
  }

  .auth__visual {
    order: -1;
    padding: 0.85rem 1rem 0;
    min-height: 0;
  }

  .auth__visual-frame {
    min-height: 168px;
    max-height: 200px;
    border-radius: 18px;
    padding: 1rem 1.15rem 1.1rem;
  }

  .auth__visual-img {
    object-position: center 18%;
  }

  .auth__visual-line {
    font-size: 1.35rem;
    max-width: 14ch;
  }

  .auth__body {
    width: 100%;
    max-width: 24rem;
    padding-top: 0.85rem;
    padding-bottom: 0.5rem;
  }

  .auth__guest-block {
    margin-top: 1.1rem;
  }

  .auth__or {
    margin: 1.25rem 0;
  }

  .auth__signin-block {
    margin-top: 0;
    padding: 1rem 0.9rem 1.1rem;
  }

  body.is-link-only .auth__signin-block {
    margin-top: 1.1rem;
    padding: 0;
  }
}

@media (max-width: 520px) {
  .auth__title {
    font-size: 1.9rem;
  }

  .auth__intro {
    font-size: 0.94rem;
  }

  .auth__primary {
    min-height: 50px;
    font-size: 0.98rem;
  }

  .auth__secondary {
    min-height: 44px;
    font-size: 0.9rem;
  }
}
