:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-accent: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.16), transparent 45%),
               radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.12), transparent 45%);
  --card: #121a2f;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-accent);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.vote-shell {
  width: 100%;
  max-width: 430px;
}

.vote-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.25rem 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.vote-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  display: grid;
  place-items: center;
  margin-bottom: 1.25rem;
}

h1 {
  margin: 0 0 0.4rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.vote-subtitle {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.hint {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.field input[type="email"],
.field input[type="text"] {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  color: var(--text);
  background: rgba(15, 23, 42, 0.8);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.field input[type="email"]:focus-visible,
.field input[type="text"]:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.28);
}

#otp-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.35em;
  text-align: center;
  min-height: 48px;
}

.otp-step {
  margin-bottom: 1rem;
}

.otp-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: -0.4rem;
  margin-bottom: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0.2rem 0;
  color: #a5b4fc;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) {
  color: #c7d2fe;
  text-decoration: underline;
}

.link-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.feedback.info {
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
}

.error-msg {
  display: none;
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.45rem;
  line-height: 1.35;
}

:is(input:user-invalid, input.user-invalid-fallback) {
  border-color: var(--danger);
  background-color: var(--danger-bg);
}

:is(input:user-invalid, input.user-invalid-fallback) + .error-msg {
  display: block;
}

:is(input:user-valid, input.user-valid-fallback) {
  border-color: var(--success);
}

/* Off-screen honeypot field */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.vote-btn {
  width: 100%;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: background-color 0.18s ease, transform 0.1s ease, opacity 0.18s ease;
}

.vote-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.vote-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.vote-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.vote-btn.loading .btn-spinner {
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner {
    animation-duration: 3s;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.feedback {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.feedback.error {
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.result-panel {
  text-align: center;
  padding: 1rem 0 0.25rem;
}

.result-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: grid;
  place-items: center;
}

.result-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1.45rem;
  color: var(--text);
}

.result-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}
