:root {
  --black: #080808;
  --charcoal: #141210;
  --maroon: #3a1116;
  --gold: #c9a96a;
  --gold-soft: rgba(201, 169, 106, 0.4);
  --ivory: #efe9dd;
  --muted: #8f887a;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--ivory);
  font-family: var(--sans);
  overflow-x: hidden;
}

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  animation: stage-in 1.2s ease both;
}

@keyframes stage-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 8%, rgba(58, 17, 22, 0.55), transparent 70%),
    radial-gradient(45% 35% at 50% 100%, rgba(201, 169, 106, 0.07), transparent 70%);
}

.shimmer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 18% 32%, rgba(239, 233, 221, 0.35), transparent 100%),
    radial-gradient(1px 1px at 74% 18%, rgba(239, 233, 221, 0.25), transparent 100%),
    radial-gradient(1.5px 1.5px at 62% 66%, rgba(201, 169, 106, 0.3), transparent 100%),
    radial-gradient(1px 1px at 30% 80%, rgba(239, 233, 221, 0.2), transparent 100%),
    radial-gradient(1px 1px at 88% 52%, rgba(201, 169, 106, 0.25), transparent 100%);
  animation: shimmer-drift 14s ease-in-out infinite alternate;
  opacity: 0.8;
}

@keyframes shimmer-drift {
  from { transform: translateY(-6px); opacity: 0.5; }
  to { transform: translateY(6px); opacity: 0.9; }
}

.panel {
  position: relative;
  width: 100%;
  max-width: 26.5rem;
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem) clamp(1.5rem, 4vw, 2.75rem);
  background: rgba(20, 18, 16, 0.66);
  border: 1px solid rgba(201, 169, 106, 0.18);
  border-radius: 2px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(239, 233, 221, 0.05);
}

.emblem {
  width: 108px;
  height: auto;
  margin: 0 auto 1.4rem;
  display: block;
  opacity: 0;
  filter: drop-shadow(0 0 18px rgba(201, 168, 106, 0.18));
  animation: emblem-in 1.6s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

@keyframes emblem-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.6rem;
}

.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 2.6rem);
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--ivory);
}

.divider {
  height: 1px;
  width: 72px;
  margin: 1.1rem auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform-origin: center;
}

.lede {
  font-size: 0.86rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 auto 1.8rem;
  max-width: 20.5rem;
}

.form {
  text-align: left;
}

.label {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem; /* prevents iOS zoom */
  font-weight: 300;
  color: var(--ivory);
  background: rgba(8, 8, 8, 0.55);
  border: 1px solid rgba(239, 233, 221, 0.14);
  border-radius: 2px;
  padding: 0.85rem 3rem 0.85rem 1rem;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  caret-color: var(--gold);
}

.field input::placeholder {
  color: rgba(143, 136, 122, 0.6);
}

.field input:focus-visible {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 1px rgba(201, 169, 106, 0.25), 0 0 24px rgba(201, 169, 106, 0.08);
}

.field input:-webkit-autofill {
  -webkit-text-fill-color: var(--ivory);
  -webkit-box-shadow: 0 0 0 1000px #100e0c inset;
  transition: background-color 9999s ease-out;
}

.toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 2px;
}

.toggle:hover { color: var(--gold); }
.toggle:focus-visible {
  outline: 1px solid var(--gold-soft);
  outline-offset: 2px;
  color: var(--gold);
}

.eye { width: 19px; height: 19px; }
.eye-hide { display: none; }
.toggle[aria-pressed='true'] .eye-show { display: none; }
.toggle[aria-pressed='true'] .eye-hide { display: block; }

.message {
  min-height: 1.2rem;
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  margin: 0.7rem 0 0.9rem;
  color: var(--muted);
}

.message.error { color: #d8a08f; }
.message.success { color: var(--gold); }

.submit {
  position: relative;
  width: 100%;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--black);
  background: linear-gradient(180deg, #d7bc85, var(--gold));
  border: 1px solid rgba(201, 169, 106, 0.6);
  border-radius: 2px;
  padding: 0.95rem 1rem;
  cursor: pointer;
  min-height: 3rem;
  transition: box-shadow 0.35s ease, transform 0.35s ease, opacity 0.3s ease;
}

.submit::after {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transition: left 0.7s ease;
}

.submit:hover:not(:disabled) {
  box-shadow: 0 8px 30px rgba(201, 169, 106, 0.22);
  transform: translateY(-1px);
}

.submit:hover:not(:disabled)::after { left: 130%; }

.submit:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: 3px;
}

.submit:disabled {
  opacity: 0.65;
  cursor: default;
}

.submit-loading { display: none; }
.submit.loading .submit-label { visibility: hidden; }
.submit.loading .submit-loading {
  display: flex;
  gap: 6px;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--black);
  animation: pulse 1s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.notice {
  font-size: 0.64rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: rgba(143, 136, 122, 0.75);
  margin: 1.6rem 0 0;
}

/* Entrance sequence */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.r1 { animation-delay: 0.55s; }
.r2 { animation-delay: 0.75s; }
.r3 { animation-delay: 0.95s; transform: scaleX(0); animation-name: expand; }
.r4 { animation-delay: 1.1s; }
.r5 { animation-delay: 1.3s; }
.r6 { animation-delay: 1.55s; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes expand {
  to { opacity: 1; transform: scaleX(1); }
}

/* Access-granted exit */
.stage.granted .panel {
  animation: lift 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.45s forwards;
}
.stage.granted .divider {
  animation: gleam 0.9s ease forwards;
}

@keyframes lift {
  to { opacity: 0; transform: translateY(-26px); }
}

@keyframes gleam {
  0% { width: 72px; opacity: 1; }
  100% { width: 100%; opacity: 0.9; }
}

@media (max-height: 620px) {
  .emblem { width: 80px; margin-bottom: 1rem; }
  .lede { margin-bottom: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .stage,
  .reveal,
  .emblem,
  .shimmer,
  .stage.granted .panel,
  .stage.granted .divider {
    animation: none !important;
  }
  .reveal { opacity: 1; transform: none; }
  .emblem { opacity: 1; transform: none; }
  .submit::after { display: none; }
  .stage.granted .panel { opacity: 0; transition: opacity 0.3s ease; }
}


html[data-theme="classic"] {
  --black: #faf8f5;
  --charcoal: #fcfbf8;
  --maroon: #8a303e;
  --gold: #c9a96a;
  --gold-soft: rgba(201, 169, 106, 0.4);
  --ivory: #1b1b1b;
  --muted: #5c5852;
}

html {
  transition: background-color 0.4s cubic-bezier(0.22, 1, 0.36, 1), color 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel, .field input, .submit, .theme-toggle, .theme-toggle-slider {
  transition: background-color 0.4s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.4s cubic-bezier(0.22, 1, 0.36, 1), color 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  height: 2rem;
  width: 140px;
  align-items: center;
  border-radius: 9999px;
  padding: 0.25rem;
  border: 1px solid rgba(201, 169, 106, 0.2);
  background: rgba(20, 18, 16, 0.66);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  outline: none;
}

html[data-theme="classic"] .theme-toggle {
  background: rgba(250, 248, 245, 0.8);
  border: 1px solid rgba(201, 169, 106, 0.4);
}

.theme-toggle-slider {
  position: absolute;
  left: 0.25rem;
  top: 0.25rem;
  bottom: 0.25rem;
  width: calc(50% - 0.25rem);
  border-radius: 9999px;
  background: linear-gradient(to bottom, rgba(201, 169, 106, 0.15), rgba(201, 169, 106, 0.02));
  border: 1px solid rgba(201, 169, 106, 0.4);
  transform: translateX(100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

html[data-theme="classic"] .theme-toggle-slider {
  transform: translateX(0);
}

.theme-toggle-label {
  position: relative;
  z-index: 10;
  width: 50%;
  text-align: center;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.theme-toggle .classic-label { color: #8f887a; }
.theme-toggle .signature-label { color: #efe9dd; font-weight: 500; }

html[data-theme="classic"] .theme-toggle .classic-label { color: #1b1b1b; font-weight: 500; }
html[data-theme="classic"] .theme-toggle .signature-label { color: #8f887a; font-weight: 400; }

html[data-theme="classic"] .panel {
  background: rgba(252, 251, 248, 0.85);
  border: 1px solid rgba(201, 169, 106, 0.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

html[data-theme="classic"] .field input {
  background: rgba(250, 248, 245, 0.55);
  border: 1px solid rgba(201, 169, 106, 0.25);
  color: #1b1b1b;
}

html[data-theme="classic"] .field input:-webkit-autofill {
  -webkit-text-fill-color: #1b1b1b;
  -webkit-box-shadow: 0 0 0 1000px #fcfbf8 inset;
}

html[data-theme="classic"] .submit {
  color: #faf8f5;
  background: linear-gradient(180deg, #d7bc85, #b79a5b);
}

html[data-theme="classic"] .submit-loading .dot {
  background: #faf8f5;
}

html[data-theme="classic"] .glow {
  background: radial-gradient(60% 45% at 50% 8%, rgba(201, 169, 106, 0.15), transparent 70%),
              radial-gradient(45% 35% at 50% 100%, rgba(201, 169, 106, 0.1), transparent 70%);
}

html[data-theme="classic"] .shimmer {
  background-image:
    radial-gradient(1px 1px at 18% 32%, rgba(201, 169, 106, 0.2), transparent 100%),
    radial-gradient(1px 1px at 74% 18%, rgba(201, 169, 106, 0.15), transparent 100%),
    radial-gradient(1.5px 1.5px at 62% 66%, rgba(201, 169, 106, 0.25), transparent 100%),
    radial-gradient(1px 1px at 30% 80%, rgba(201, 169, 106, 0.15), transparent 100%),
    radial-gradient(1px 1px at 88% 52%, rgba(201, 169, 106, 0.2), transparent 100%);
}

html[data-theme="classic"] .divider {
  background: linear-gradient(90deg, transparent, rgba(201, 169, 106, 0.5), transparent);
}

