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

:root {
  --bg-base: #050506;
  --bg-raised: #0a0a0c;
  --bg-overlay: #131315;
  --bg-subtle: rgba(255,255,255,0.03);
  --bg-muted: rgba(255,255,255,0.06);

  --border-subtle: rgba(255,255,255,0.04);
  --border-default: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.1);

  --text-primary: #ededf0;
  --text-secondary: rgba(255,255,255,0.62);
  --text-tertiary: rgba(255,255,255,0.35);

  --red: #c8102e;
  --red-text: #f0566a;
  --red-surface: rgba(200,16,46,0.08);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.3);

  --transition-fast: 0.12s ease;
  --transition-base: 0.15s ease;
  --transition-slow: 0.25s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Vignette */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,0.35) 100%);
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Animations ── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes btn-shine {
  0% { left: -100%; }
  100% { left: 200%; }
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes field-focus-glow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(200,16,46,0.15); }
  50% { box-shadow: 0 0 0 3px rgba(200,16,46,0.25); }
}

/* ── Ambient glow behind card ── */

.auth-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 500px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(200,16,46,0.07) 0%, transparent 65%),
    radial-gradient(ellipse at 40% 60%, rgba(62,111,199,0.025) 0%, transparent 50%);
  pointer-events: none;
  animation: glow-breathe 8s ease-in-out infinite;
  z-index: 0;
}

/* ── Auth Card ── */

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 40px 36px 36px;
  background: rgba(14, 14, 17, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 64px rgba(0,0,0,0.5),
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: fadeInUp 0.5s ease;
}

/* Subtle top edge highlight */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  border-radius: 1px;
}

/* ── Brand ── */

.auth-brand {
  display: block;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.auth-brand span {
  font-weight: 400;
  color: var(--text-secondary);
}

.auth-title {
  text-align: center;
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
}

/* ── Form ── */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.field-input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--transition-base),
    background var(--transition-base),
    box-shadow var(--transition-base);
}

.field-input::placeholder {
  color: var(--text-tertiary);
}

/* ── Password toggle ── */

.field-password-wrap {
  position: relative;
}

.field-password-wrap .field-input {
  padding-right: 44px;
}

.field-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  border-radius: 4px;
  transition: color var(--transition-base), background var(--transition-base);
  padding: 0;
}

.field-eye:hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
}

.field-eye svg {
  width: 18px;
  height: 18px;
}

.field-eye .eye-closed {
  display: none;
}

.field-eye.showing .eye-open {
  display: none;
}

.field-eye.showing .eye-closed {
  display: block;
}

.field-input:hover {
  border-color: var(--border-strong);
  background: rgba(255,255,255,0.05);
}

.field-input:focus {
  border-color: rgba(200,16,46,0.4);
  background: rgba(255,255,255,0.06);
  animation: field-focus-glow 2s ease-in-out infinite;
}

/* ── Submit Button — liquid glass red ── */

.auth-submit {
  width: 100%;
  padding: 13px 24px;
  margin-top: 4px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(220,20,50,0.78) 0%, rgba(180,14,38,0.68) 100%);
  backdrop-filter: blur(12px) saturate(220%);
  -webkit-backdrop-filter: blur(12px) saturate(220%);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(200,16,46,0.2),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(255,255,255,0.05);
  transition:
    background var(--transition-base),
    box-shadow var(--transition-base),
    border-color var(--transition-base),
    transform var(--transition-fast);
}

/* Top specular highlight */
.auth-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  pointer-events: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* Shine sweep on hover */
.auth-submit::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 80%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transition: none;
  z-index: 2;
}

.auth-submit:hover {
  background:
    linear-gradient(180deg, rgba(230,22,55,0.85) 0%, rgba(190,16,42,0.75) 100%);
  border-color: rgba(255,255,255,0.25);
  box-shadow:
    0 8px 40px rgba(200,16,46,0.3),
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -1px 0 rgba(255,255,255,0.08);
}

.auth-submit:hover::after {
  animation: btn-shine 0.6s ease forwards;
}

.auth-submit:active {
  transform: scale(0.98);
}

.auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-submit:disabled:hover {
  background:
    linear-gradient(180deg, rgba(220,20,50,0.78) 0%, rgba(180,14,38,0.68) 100%);
  box-shadow:
    0 8px 32px rgba(200,16,46,0.2),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(255,255,255,0.05);
}

.auth-submit:disabled:hover::after {
  animation: none;
}

/* ── Error message ── */

.auth-error {
  display: none;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red-text);
  background: var(--red-surface);
  border: 1px solid rgba(200,16,46,0.15);
  border-radius: var(--radius-md);
  line-height: 1.5;
}

.auth-error.visible {
  display: block;
}

/* ── Footer links ── */

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-tertiary);
}

.auth-footer a {
  color: var(--text-secondary);
  transition: color var(--transition-base);
}

.auth-footer a:hover {
  color: var(--text-primary);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

/* ── Back to landing ── */

.auth-back {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color var(--transition-base);
  animation: fadeInUp 0.5s ease 0.15s both;
}

.auth-back:hover {
  color: var(--text-secondary);
}

.auth-back svg {
  width: 16px;
  height: 16px;
}

/* ── Password requirements ── */

.field-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: -2px;
}

/* ── Loading state ── */

.auth-submit.loading {
  pointer-events: none;
  opacity: 0.7;
}

.auth-submit.loading .btn-text {
  opacity: 0;
}

.auth-submit.loading .btn-spinner {
  display: block;
}

.btn-text {
  position: relative;
  z-index: 1;
}

.btn-spinner {
  display: none;
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  z-index: 1;
}

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