:root {
  color-scheme: light;
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #fbfcfe;
  --surface-inset: #eef2f7;
  --header-bg: rgb(255 255 255 / 94%);
  --field-bg: #ffffff;
  --field-disabled: #f8fafc;
  --line-soft: #e9edf5;
  --line: #d9dee8;
  --line-strong: #c7cfdd;
  --text: #111827;
  --text-strong: #0f172a;
  --muted: #667085;
  --muted-strong: #475467;
  --text-inverse: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e6fffb;
  --accent-muted: #f0fdfa;
  --accent-line: #99f6e4;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --danger-line: #fecdca;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --warning-line: #fedf89;
  --success: #067647;
  --success-bg: #ecfdf3;
  --success-line: #abefc6;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-line: #bfdbfe;
  --focus-ring: rgb(15 118 110 / 12%);
  --shadow-soft: 0 1px 2px rgb(16 24 40 / 5%);
  --shadow-card: 0 12px 28px rgb(16 24 40 / 8%);
  --shadow-popover: 0 24px 56px rgb(16 24 40 / 24%);
  --backdrop: rgb(17 24 39 / 46%);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101816;
    --surface: #18201d;
    --surface-raised: #1d2724;
    --surface-soft: #202c28;
    --surface-muted: #151d1a;
    --surface-inset: #0e1513;
    --header-bg: rgb(24 32 29 / 92%);
    --field-bg: #121a17;
    --field-disabled: #1a2420;
    --line-soft: #25342f;
    --line: #30413a;
    --line-strong: #466057;
    --text: #edf5f1;
    --text-strong: #ffffff;
    --muted: #a8b8b1;
    --muted-strong: #c7d4cf;
    --text-inverse: #07110e;
    --accent: #5eead4;
    --accent-strong: #2dd4bf;
    --accent-soft: #123a35;
    --accent-muted: #0f2d29;
    --accent-line: #1f766d;
    --danger: #ffb4ab;
    --danger-bg: #3d1f1d;
    --danger-line: #7f3029;
    --warning: #fcd59f;
    --warning-bg: #3a2a13;
    --warning-line: #8a5a19;
    --success: #86efac;
    --success-bg: #12351f;
    --success-line: #277247;
    --info: #93c5fd;
    --info-bg: #152b4f;
    --info-line: #2f5f9f;
    --focus-ring: rgb(94 234 212 / 22%);
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 28%);
    --shadow-card: 0 16px 34px rgb(0 0 0 / 32%);
    --shadow-popover: 0 24px 56px rgb(0 0 0 / 44%);
    --backdrop: rgb(0 0 0 / 58%);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.auth-panel {
  width: min(100%, 420px);
  padding: 32px 0;
  background: var(--bg);
}

.brand {
  display: grid;
  justify-content: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
}

.brand-mark img {
  display: block;
  width: 48px;
  height: 48px;
}

.auth-brand span span {
  color: var(--accent);
}

.auth-heading {
  margin-top: 24px;
  text-align: center;
}

.auth-heading h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.auth-heading p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.auth-choice {
  display: grid;
  gap: 18px;
}

.auth-states {
  margin-top: 32px;
}

.auth-states .auth-form {
  margin-top: 0;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 600;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.primary-button {
  height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text-inverse);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.oauth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.oauth-button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.oauth-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.oauth-button-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.oauth-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.auth-divider span {
  display: block;
  height: 1px;
  background: var(--line);
}

.auth-divider strong {
  font-weight: 600;
  text-transform: uppercase;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.button-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-icon {
  width: 20px;
  height: 20px;
}

.auth-helper {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-message {
  min-height: 22px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.auth-message[data-type="error"] {
  color: var(--danger);
}

.auth-message[data-type="success"] {
  color: var(--success);
}

.password-meter {
  display: grid;
  gap: 7px;
}

.password-meter-bar {
  display: block;
  width: 100%;
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field-bg);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.password-meter-bar[data-strength="1"] {
  border-color: var(--danger-line);
  background: var(--danger);
}

.password-meter-bar[data-strength="2"],
.password-meter-bar[data-strength="3"] {
  border-color: var(--warning-line);
  background: var(--warning);
}

.password-meter-bar[data-strength="4"] {
  border-color: var(--success-line);
  background: var(--success);
}

.password-meter p,
.field-note {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.password-meter p[data-type="error"],
.field-note[data-type="error"] {
  color: var(--danger);
}

.password-meter p[data-type="warning"] {
  color: var(--warning);
}

.password-meter p[data-type="success"],
.field-note[data-type="success"] {
  color: var(--success);
}

.password-requirements {
  padding: 14px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-muted);
  color: var(--accent);
}

.password-requirements p {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.password-requirements ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.45;
}

.auth-state {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
}

.state-icon-loading {
  border: 4px solid var(--accent-line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.state-icon-success {
  background: var(--success-bg);
  border: 1px solid var(--success-line);
  color: var(--success);
}

.state-email-icon {
  width: 32px;
  height: 32px;
}

.state-icon-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger);
}

.state-alert-icon {
  width: 32px;
  height: 32px;
}

.state-copy {
  display: grid;
  gap: 8px;
}

.state-copy h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

.state-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.state-copy strong {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sent-email-address {
  display: block;
  font-size: 16px;
  line-height: 1.5;
}

.state-note {
  font-size: 14px;
}

.state-actions {
  display: grid;
  gap: 8px;
  width: 100%;
}

.auth-state > .primary-button {
  width: 100%;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  padding: 8px;
}

.text-button:hover {
  color: var(--accent-strong);
}

.text-button.muted {
  color: var(--muted);
}

.text-button.muted:hover {
  color: var(--text);
}

.resend-button,
.resend-button:hover {
  color: var(--info);
}

.message {
  min-height: 22px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.message[data-type="error"] {
  color: var(--danger);
}

.message[data-type="success"] {
  color: var(--success);
}

.message[data-type="hidden"] {
  color: transparent;
  margin-top: 0;
  min-height: 0;
}

.message:empty {
  margin-top: 0;
  min-height: 0;
}

.security-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-muted);
  color: var(--accent);
}

.security-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.security-title {
  margin: 0;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.security-copy {
  margin: 4px 0 0;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.45;
}

.back-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.back-home:hover {
  color: var(--accent);
}

.back-home-icon {
  width: 16px;
  height: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .auth-page {
    padding: 16px;
  }

  .auth-panel {
    padding: 24px 0;
  }

  .auth-heading h1 {
    font-size: 28px;
  }
}
