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

:root {
  --bg: #f4f4f5;
  --card-bg: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #18181b;
  --accent-hover: #3f3f46;
  --input-bg: #fafafa;
  --focus-ring: rgba(24, 24, 27, 0.12);
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #dc2626;
  --radius-card: 14px;
  --radius-input: 7px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 20px rgba(0,0,0,0.07);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  -webkit-font-smoothing: antialiased;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 2.5rem 2.25rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 1rem;
  border: 2px solid var(--border);
}

.login-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.field-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.error-msg {
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-input);
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 0.875rem;
  line-height: 1.45;
}

.error-msg[hidden] {
  display: none;
}

.submit-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6875rem 1.25rem;
  border: none;
  border-radius: var(--radius-input);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  -webkit-font-smoothing: antialiased;
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  flex-shrink: 0;
}

.submit-btn.loading .btn-spinner {
  display: block;
  animation: spin 0.65s linear infinite;
}

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

@media (max-width: 480px) {
  body { padding: 0.75rem; }
  .login-card { padding: 1.75rem 1.25rem; }
}

@media (max-width: 360px) {
  .login-card { padding: 1.5rem 1rem; }
  /* Turnstile is 300px wide — scale it down so it fits */
  .turnstile-wrap {
    transform: scale(0.88);
    transform-origin: left center;
    margin-bottom: -8px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --card-bg: #1a1a1a;
    --border: #2a2a2a;
    --text: #fafafa;
    --text-muted: #a0a0a0;
    --accent: #fafafa;
    --accent-hover: #e0e0e0;
    --input-bg: #141414;
    --focus-ring: rgba(250,250,250,0.12);
    --error-bg: #2c1515;
    --error-border: #7f1d1d;
    --error-text: #f87171;
  }

  .submit-btn {
    color: #18181b;
  }

  .btn-spinner {
    border-color: rgba(24,24,27,0.35);
    border-top-color: #18181b;
  }
}
