:root {
  --bg-cream: #F5F3EE;
  --ink: #0B0F14;
  --primary: #FF5400;
  --primary-hover: #E04A00;
  --gray-200: #E5E5E5;
  --gray-400: #999999;
  --gray-500: #737373;
  --surface: #FFFFFF;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-color: var(--bg-cream);
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
/* Pinned while the screen scrolls (small phones, keyboard open); the status-bar inset lives here
   rather than on body so the bar still clears it once stuck (see ui-feedback.js stickyBar). */
.auth-header {
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  background: var(--bg-cream);
}
.auth-header.is-stuck { box-shadow: 0 1px 0 rgba(11, 15, 20, .08); }
.auth-back {
  background: none;
  border: none;
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  position: absolute;
  inset-inline-start: 8px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
}
.auth-back[hidden] {
  display: none !important;
}
.auth-close {
  background: none;
  border: none;
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  position: absolute;
  inset-inline-end: 8px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
}
/* Leaving the page: the tapped control spins until the next page paints (see ui-feedback.js). */
.auth-back.is-loading::after, .auth-close.is-loading::after { width: 18px; height: 18px; margin-block:-9px 0;margin-inline:-9px 0; }
.auth-page-title {
  font-weight: 700;
  font-size: 17px;
}

/* Main Content */
.auth-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 24px 40px;
  position: relative;
}

/* Screens */
.auth-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  animation: fade-in 0.3s ease-out;
}
.auth-screen[hidden] {
  display: none !important;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Brand */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  margin-top: 0;
}
.auth-logo {
  width: 92px;
  height: 92px;
  margin-bottom: 8px;
}
.auth-wordmark {
  font-weight: 800;
  font-size: 40px;
  letter-spacing: -0.04em;
}

/* Typography */
.auth-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-align: center;
}
.auth-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  margin: 0 0 32px;
  text-align: center;
  line-height: 1.4;
}

/* Forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* Input Groups */
.phone-input-group,
.input-group {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  height: 56px;
  padding: 0 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.phone-input-group:focus-within,
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 84, 0, 0.1);
}
.phone-input-group.is-invalid {
  border-color: #d92d20;
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.1);
}
.field-error {
  margin-block:-6px 0;margin-inline:4px 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #b42318;
}

/* Country Selector */
.country-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.country-flag {
  width: 27px;
  height: 18px;
  display: inline-flex;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.16); /* keeps the white half visible on the white field */
  flex-shrink: 0;
}
.country-flag svg { width: 100%; height: 100%; display: block; }
.country-select {
  appearance: none;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  padding-inline-end: 4px;
  font-family: inherit;
  cursor: pointer;
}
.country-select:focus {
  outline: none;
}
.input-divider {
  width: 1px;
  height: 24px;
  background-color: var(--gray-200);
  margin: 0 12px;
}

/* Inputs */
.phone-input,
.text-input {
  flex: 1;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink);
  font-family: inherit;
  min-width: 0;
  outline: none;
}
.phone-input::placeholder,
.text-input::placeholder {
  color: var(--gray-400);
}
.input-icon {
  width: 20px;
  height: 20px;
  color: var(--gray-500);
  margin-inline-end: 12px;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary);
  color: var(--ink);
  border: none;
  border-radius: 14px;
  height: 56px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}
.btn-primary:active {
  opacity: 0.9;
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--ink);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  height: 56px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  transition: background-color 0.2s;
  position: relative;
}
.btn-secondary:hover:not(:disabled) {
  background-color: #FAFAFA;
}
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-mail {
  width: 24px;
  height: 24px;
}

/* The hidden attribute must win over any display rule below (divider, alternatives, chips). */
[hidden] { display: none !important; }
#auth-email, #auth-password { padding-top:56px; }
#auth-email .auth-title, #auth-email .auth-subtitle,
#auth-password .auth-title, #auth-password .auth-subtitle { text-align:start; }
#auth-verify { padding-top:28px; }
#auth-verify .auth-title { font-size:34px; }
body[data-auth-variant="returning"] #auth-verify .verify-badge-container { justify-content:flex-start; }
body[data-auth-variant="returning"] #auth-verify .auth-title,
body[data-auth-variant="returning"] #auth-verify .auth-subtitle { text-align:start; }
#verify-form { flex:1; }
.otp-container input { min-width:0; }
.auth-message.is-error { color:#991b1b; background:#fff1ed; box-shadow:none; border:1px solid #f5c5b3; }
button:focus-visible { outline:2px solid var(--ink); outline-offset:3px; }
@media (max-width:360px) {
  .auth-content { padding-inline-start:16px; padding-inline-end:16px; }
  .auth-title { font-size:23px; }
  .otp-container { gap:6px; }
}
@media (prefers-reduced-motion:reduce) {
  .auth-screen { animation:none; }
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--gray-200);
}
.auth-divider span {
  padding: 0 16px;
}

/* Alternatives */
.auth-alternatives {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Legal text */
.auth-legal {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* Help text */
.auth-help {
  font-size: 14px;
  color: var(--gray-500);
  text-align: center;
  margin: 16px 0 0;
  line-height: 1.4;
}

/* Bottom action */
.auth-bottom-action {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
}
.btn-text {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 15px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  font-family: inherit;
  padding: 8px;
}
.btn-text:hover {
  color: var(--ink);
}

/* Verify Screen */
.verify-badge-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.badge-status {
  background-color: var(--primary);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
}
.badge-status.returning {
  background-color: var(--ink);
  color: white;
}
.verify-subtitle {
  margin-bottom: 40px;
}
.btn-link {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}

.otp-container {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}
.otp-container input {
  width: 64px;
  height: 72px;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  background: var(--surface);
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  padding: 0;
}
/* If there are 6 inputs, they need to be smaller */
.otp-container[data-length="6"] input {
  width: 48px;
  height: 60px;
  font-size: 24px;
}
.otp-container input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.resend-text {
  text-align: center;
  font-size: 15px;
  color: var(--gray-500);
  margin: 0 0 32px;
}
.btn-link-subtle {
  background: none;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.mt-auto {
  margin-top: auto;
}
.mt-3 {
  margin-top: 12px;
}
.mt-4 {
  margin-top: 16px;
}

/* Email sent icon */
.icon-sent {
  width: 64px;
  height: 64px;
  background-color: rgba(255, 84, 0, 0.1);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px auto 32px;
}
.icon-sent svg {
  width: 32px;
  height: 32px;
}

/* Status overlays */
.auth-message {
  text-align: center;
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 14px;
  font-weight: 500;
  display: none;
  margin-bottom: 24px;
}
.auth-message:not(:empty) {
  display: block;
  animation: fade-in 0.3s ease-out;
}
.auth-state {
  text-align: center;
  font-size: 15px;
  color: var(--gray-500);
  padding: 24px;
}
.auth-notice {
  margin: 0 0 16px;
}
.btn-retry {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* Password visibility toggle */
.btn-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-inline-end: -8px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--gray-500, #6b7280);
  cursor: pointer;
}
.btn-eye:hover { color: var(--ink); }

/* "Add your number" step (after an e-mail code, or securing an older account): a plain
   step of the sign-up, not the branded first screen. */
#auth-phone[data-mode="add"] { padding-top: 8px; }
#auth-phone[data-mode="add"] .auth-title,
#auth-phone[data-mode="add"] .auth-subtitle { text-align:start; }
#auth-phone[data-mode="add"] .auth-subtitle { margin-bottom: 20px; }
.add-step { display: flex; flex-direction: column; gap: 28px; margin-bottom: 20px; }
.step-track {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--gray-400); letter-spacing: 0.01em;
}
.step-track li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.step-track li + li::before { content: ""; width: 18px; height: 1px; background: var(--gray-200); margin-inline-end: 2px; }
.step-dot {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--gray-200); color: var(--gray-400); font-size: 11px; font-weight: 800; background: var(--surface);
}
.step-track li.is-done { color: var(--ink); }
.step-track li.is-done .step-dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.step-track li.is-current { color: var(--ink); }
.step-track li.is-current .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.add-step-icon {
  width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: #FFE9DE; color: var(--primary);
}
.auth-chip {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin: 0 0 24px; padding: 8px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--gray-200); color: var(--ink); font-size: 13px; font-weight: 700;
}
.auth-chip ph-icon { color: var(--primary); flex-shrink: 0; }
.auth-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.add-step-note { justify-content: flex-start; text-align:start; margin: 16px 0 0; line-height: 1.45; }
.auth-eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
#auth-phone[data-mode="add"] .auth-title { font-size: 28px; }
@media (max-width: 360px) { #auth-phone[data-mode="add"] .auth-title { font-size: 24px; } }
