:root {
  --orange: #F26B3A;
  --orange-dark: #D85726;
  --navy: #13153A;
  --text: #2A2A35;
  --muted: #6B6B78;
  --bg: #FAF7F3;
  --card: #FFFFFF;
  --border: #E5E1DA;
  --border-strong: #C9C5BC;
  --error: #B91C1C;
  --error-bg: #FEF2F2;
  --success: #15803D;
  --success-bg: #F0FDF4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(19, 21, 58, 0.04), 0 8px 24px rgba(19, 21, 58, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: clamp(15px, 0.875rem + 0.25vw, 17px);
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  width: 100%;
  max-width: 480px;
}

.logo {
  display: block;
  max-width: 260px;
  height: auto;
  margin: 0 auto 1.75rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.lede {
  margin: 0 0 1.75rem;
  color: var(--muted);
  text-align: center;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--navy);
  margin-bottom: 0.4rem;
}

input[type="email"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input[type="email"]:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 107, 58, 0.18);
}

button {
  font-family: inherit;
  cursor: pointer;
}

#submit {
  margin-top: 1.1rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--orange);
  color: #fff;
  /* 1.25rem @ 700 puts the button text in WCAG "large text" territory
     (≥14pt bold), so the 3:1 contrast of white-on-brand-orange passes AA. */
  font-size: 1.25rem;
  font-weight: 700;
  transition: background-color 120ms ease, transform 80ms ease;
}

#submit:hover:not(:disabled) { background: var(--orange-dark); }
#submit:active:not(:disabled) { transform: translateY(1px); }
#submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(242, 107, 58, 0.35);
}
#submit:disabled { opacity: 0.55; cursor: not-allowed; }

#loader {
  margin: 1.5rem auto 0;
}
#loader[hidden] { display: none; }

#error:empty { display: none; }
#error {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  font-size: 0.9rem;
  white-space: pre-line;
}

#error.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.hint {
  margin: 1.75rem 0 0;
  font-size: 0.825rem;
  color: var(--muted);
  text-align: center;
}

.hint a {
  color: var(--orange-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Spinner — recolored for light card */
.lds-ellipsis {
  display: block;
  position: relative;
  width: 80px;
  height: 20px;
}
.lds-ellipsis div {
  position: absolute;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
  animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.lds-ellipsis div:nth-child(1) { left: 8px;  animation: lds-ellipsis1 0.6s infinite; }
.lds-ellipsis div:nth-child(2) { left: 8px;  animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(3) { left: 32px; animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(4) { left: 56px; animation: lds-ellipsis3 0.6s infinite; }
@keyframes lds-ellipsis1 { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes lds-ellipsis3 { 0% { transform: scale(1); } 100% { transform: scale(0); } }
@keyframes lds-ellipsis2 { 0% { transform: translate(0, 0); } 100% { transform: translate(24px, 0); } }

/* Dialog (terms of use) */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(720px, 92vw);
  max-height: min(86vh, 820px);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: inherit;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(19, 21, 58, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-wrap {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.dialog-body {
  overflow-y: auto;
  padding: 1.75rem 1.75rem 0.5rem;
  flex: 1 1 auto;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}

#agree, #exit {
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

#agree {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
#agree:hover { background: var(--orange-dark); border-color: var(--orange-dark); }

#exit {
  background: transparent;
  color: var(--navy);
  border-color: var(--border-strong);
}
#exit:hover { background: var(--bg); }

#agree:focus, #exit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(242, 107, 58, 0.35);
}

/* Reset the wall of Google-Docs-export styling inside the dialog. */
.dialog-body h1,
.dialog-body h2,
.dialog-body h3,
.dialog-body h4 {
  color: var(--navy);
  font-family: inherit;
  line-height: 1.3;
  margin: 1.4em 0 0.55em;
}
.dialog-body h1 { font-size: 1.25rem; margin-top: 0; }
.dialog-body h2 { font-size: 1.05rem; }
.dialog-body h3 { font-size: 0.98rem; }
.dialog-body h4 {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.dialog-body p,
.dialog-body li {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}
.dialog-body ul,
.dialog-body ol { padding-left: 1.4em; }
.dialog-body li { margin-bottom: 0.45em; }
.dialog-body sup a { color: var(--muted); }
