:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #DBEAFE;
  --gold: #F59E0B;
  --purple: #7C3AED;
  --love: #EF4444;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  min-height: 100vh; /* fallback for browsers without dvh */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, var(--safe-t)) 20px max(20px, var(--safe-b));
}

/* Desktop: two-column shell with a brand panel. On mobile this collapses
   to just the auth card (panel is hidden via media query below). */
#page-shell {
  width: 100%;
  max-width: 380px;
  display: flex;
}

#auth-page {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  border: 1px solid var(--border);
}

.brand { text-align: center; margin-bottom: 28px; }

/* Logo image replaces the dove emoji */
.dove {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  margin: 0 auto 10px;
  object-fit: contain;
}
.brand-panel .dove {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  margin: 0 0 4px;
}

.brand h1 { color: var(--primary); font-size: 24px; font-weight: 700; letter-spacing: 0.5px; }
.tagline { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

form { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-top: 12px; }

.input-wrapper { position: relative; }

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  outline: none;
  background: var(--bg);
}
input:focus { border-color: var(--primary); }
input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.input-wrapper input[type="password"],
.input-wrapper input[data-pw] {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 8px;
}
.toggle-password:hover { color: var(--text-primary); }
.toggle-password:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.field-hint.error-hint { color: var(--love); }

button[type="submit"] {
  margin-top: 20px;
  padding: 13px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
}
@media (hover: hover) {
  button[type="submit"]:hover:not(:disabled) { background: var(--primary-hover); }
}
button[type="submit"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button[type="submit"]:disabled {
  background: #CBD5E1;
  color: #FFFFFF;
  cursor: not-allowed;
  opacity: 1;
}

.error {
  background: #FEF2F2;
  color: var(--love);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 8px;
}
.error.info {
  background: var(--primary-light);
  color: var(--primary-hover);
}
.hidden { display: none; }

.switch-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.switch-link a { color: var(--primary); font-weight: 600; text-decoration: none; }
@media (hover: hover) { .switch-link a:hover { text-decoration: underline; } }

.terms-check { margin-top: 16px; }

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.checkbox-label input {
  width: auto;
  margin-top: 3px;
  accent-color: var(--primary);
  min-width: 18px;
  min-height: 18px;
}

.checkbox-label a,
.legal-text a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
@media (hover: hover) {
  .checkbox-label a:hover, .legal-text a:hover { text-decoration: underline; }
}

.legal-text {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---------- Check-your-email state (post-registration) ---------- */
#check-email-card { text-align: center; }
#check-email-card .icon { font-size: 40px; margin-bottom: 12px; }
#check-email-card h2 { font-size: 18px; margin-bottom: 8px; }
#check-email-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
#check-email-card .masked-email { font-weight: 700; color: var(--text-primary); }
#check-email-card .actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
#resend-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}
#resend-btn:disabled { color: var(--text-secondary); cursor: not-allowed; }
.text-link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  min-height: 36px;
}
#resend-status { font-size: 12.5px; color: var(--primary); min-height: 16px; }
#resend-status.error { color: var(--love); }

/* ---------- Desktop brand panel ---------- */
.brand-panel { display: none; }

@media (min-width: 900px) {
  body { padding: 40px 20px; }
  #page-shell {
    max-width: 820px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15,23,42,.08);
  }
  .brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    background: linear-gradient(155deg, var(--primary), #1E40AF);
    color: #fff;
    padding: 48px 40px;
  }
  .brand-panel h2 { font-size: 26px; font-weight: 800; margin-top: 12px; letter-spacing: -.01em; }
  .brand-panel p { font-size: 14.5px; color: #DBEAFE; margin-top: 10px; line-height: 1.6; max-width: 30ch; }
  .brand-panel ul { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }
  .brand-panel li { font-size: 13.5px; color: #EFF6FF; display: flex; gap: 8px; }
  .brand-panel li::before { content: "✓"; font-weight: 700; color: var(--gold); flex-shrink: 0; }

  #auth-page {
    flex: 1;
    border: none;
    border-radius: 0;
    padding: 48px 44px;
    max-width: 420px;
  }
  #auth-page .brand { display: none; } /* panel already shows branding on desktop */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
/* ---------- Shared button-styled links (e.g. invite page CTAs) ---------- */
.btn-primary,
.btn-secondary {
  display: block;
  text-decoration: none;
  padding: 13px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  min-height: 48px;
  box-sizing: border-box;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}
@media (hover: hover) {
  .btn-primary:hover { background: var(--primary-hover); }
}
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
@media (hover: hover) {
  .btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
}