:root {
  --ink: #0b1220;
  --ink-soft: #121a2b;
  --fog: #e8eef8;
  --text: #f4f7fc;
  --text-dim: rgba(244, 247, 252, 0.72);
  --muted: rgba(244, 247, 252, 0.58);
  --primary: #6571ff;
  --primary-hover: #7c85ff;
  --primary-deep: #4d58e0;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-text: #152033;
  --panel-muted: #5b6b84;
  --border: rgba(21, 32, 51, 0.12);
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #a16207;
  --warn-soft: #fef9c3;
  --radius: 20px;
  --font-display: "Sora", sans-serif;
  --font-body: "Figtree", sans-serif;
}

.dark {
  --panel: rgba(23, 26, 35, 0.92);
  --panel-text: #f1f5f9;
  --panel-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --danger: #f87171;
  --danger-soft: rgba(220, 38, 38, 0.16);
  --warn: #facc15;
  --warn-soft: rgba(250, 204, 21, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  min-height: 100vh;
}

.login-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px);
}

.login-atmosphere {
  position: absolute;
  inset: 0;
  /* Base wash only — the 3 marked blue lights are .login-orb (animated) */
  background: linear-gradient(160deg, #0b1220 0%, #10182b 45%, #0a101c 100%);
}

/* The three red-marked glows: left / top-right / bottom-right */
.login-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(28px);
  will-change: transform, opacity;
}
.login-orb-a {
  /* Left of brand copy — wider + brighter */
  width: min(78vw, 620px);
  height: min(68vw, 520px);
  left: -18%;
  top: 12%;
  background: radial-gradient(ellipse at 45% 45%,
    rgba(101, 113, 255, 0.92) 0%,
    rgba(101, 113, 255, 0.55) 28%,
    rgba(101, 113, 255, 0.22) 52%,
    transparent 72%);
  filter: blur(32px);
  animation:
    orbDriftA 16s ease-in-out infinite,
    orbBreath 10s ease-in-out -1.5s infinite;
}
.login-orb-b {
  /* Above / behind login card */
  width: min(48vw, 380px);
  height: min(48vw, 380px);
  right: -6%;
  top: -8%;
  background: radial-gradient(circle, rgba(124, 133, 255, 0.55) 0%, rgba(124, 133, 255, 0.2) 45%, transparent 72%);
  animation:
    orbDriftB 19s ease-in-out -5s infinite,
    orbBreath 12s ease-in-out -3s infinite;
}
.login-orb-c {
  /* Bottom-right under card */
  width: min(44vw, 340px);
  height: min(44vw, 340px);
  right: 12%;
  bottom: -10%;
  background: radial-gradient(circle, rgba(80, 90, 204, 0.5) 0%, rgba(80, 90, 204, 0.18) 48%, transparent 72%);
  animation:
    orbDriftC 17s ease-in-out -9s infinite,
    orbBreath 11s ease-in-out -6s infinite;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 78%);
  opacity: 0.7;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
}

.login-hero {
  max-width: 520px;
}

.login-eyebrow {
  margin: 0 0 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(165, 172, 255, 0.95);
  opacity: 0;
  transform: translateY(10px);
}

.login-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: #fff;
  text-wrap: balance;
  overflow: visible;
}

.login-brand-text {
  position: relative;
  display: inline-block;
  max-width: 100%;
  /* Room for glyph overhang (Sora "g") with tight tracking */
  padding: 0.04em 0.1em 0.08em 0.02em;
  margin: -0.04em -0.1em -0.08em -0.02em;
  opacity: 0;
  filter: blur(10px);
  transform: translateY(22px);
  clip-path: inset(0 105% 0 0);
  will-change: transform, opacity, filter, clip-path;
}

.login-brand-text::after {
  content: "";
  position: absolute;
  inset: -8% -12%;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.42) 50%,
    transparent 62%
  );
  background-size: 220% 100%;
  background-position: 120% 50%;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.login-lead {
  margin: 18px 0 0;
  max-width: 34ch;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text-dim);
  text-wrap: pretty;
  opacity: 0;
  transform: translateY(12px);
  filter: blur(4px);
  will-change: transform, opacity, filter;
}

.login-points {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-points li {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(10px);
}

/* Orchestrated entrance after page loader */
.login-hero.is-ready .login-eyebrow {
  animation: heroSoftRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0s both;
}
.login-hero.is-ready .login-brand-text {
  animation: brandReveal 0.88s cubic-bezier(0.22, 1, 0.36, 1) 0.04s both;
}
.login-hero.is-ready .login-brand-text::after {
  animation: brandShimmerSweep 1.05s ease 0.7s both;
}
.login-hero.is-ready .login-lead {
  animation: heroSoftRise 0.58s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both;
}
.login-hero.is-ready .login-points li:nth-child(1) {
  animation: heroSoftRise 0.48s cubic-bezier(0.22, 1, 0.36, 1) 0.52s both;
}
.login-hero.is-ready .login-points li:nth-child(2) {
  animation: heroSoftRise 0.48s cubic-bezier(0.22, 1, 0.36, 1) 0.6s both;
}
.login-hero.is-ready .login-points li:nth-child(3) {
  animation: heroSoftRise 0.48s cubic-bezier(0.22, 1, 0.36, 1) 0.68s both;
}

.login-panel {
  animation: riseIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.login-form {
  width: 100%;
  max-width: 420px;
  margin-left: auto;
  padding: 28px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--panel);
  color: var(--panel-text);
  border: 1px solid var(--border);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.login-form-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  box-shadow: 0 10px 24px rgba(101, 113, 255, 0.35);
  flex-shrink: 0;
  animation: markPulse 2.4s ease-in-out infinite;
}

.login-form-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.login-form-head p {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--panel-muted);
}

.login-hint {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-bottom: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    margin-bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.login-hint.is-visible {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-bottom: 14px;
  transform: translateY(0);
  pointer-events: auto;
}

.login-hint-inner {
  overflow: hidden;
  min-height: 0;
}

.login-hint-inner > span {
  --hint-radius: 12px;
  display: block;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--hint-radius);
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--danger) 10%, transparent);
  transform-origin: center center;
  will-change: clip-path;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  /* Keep corners blunt even while clipping */
  clip-path: inset(0 0 0 0 round var(--hint-radius));
}

.login-hint.is-warn .login-hint-inner > span {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--warn) 14%, transparent);
}

/*
  Close/open between the straight edges only:
  leave ~radius on each side so the visible shape stays a blunt capsule,
  never a sharp vertical cut through the rounded tips.
*/
@keyframes hintSqueeze {
  0% {
    clip-path: inset(0 0 0 0 round var(--hint-radius));
  }
  50% {
    clip-path: inset(0 calc(50% - var(--hint-radius)) 0 calc(50% - var(--hint-radius)) round var(--hint-radius));
  }
  100% {
    clip-path: inset(0 0 0 0 round var(--hint-radius));
  }
}

.login-hint-inner > span.is-squeeze {
  animation: hintSqueeze 0.7s ease;
}

.login-hint[hidden] { display: none !important; }

.field input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

.field input.is-invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 22%, transparent);
  transform: none;
}

/* Animate.css headShake (inputs only) */
@keyframes headShake {
  0% { transform: translateX(0); }
  6.5% { transform: translateX(-6px) rotateY(-9deg); }
  18.5% { transform: translateX(5px) rotateY(7deg); }
  31.5% { transform: translateX(-3px) rotateY(-5deg); }
  43.5% { transform: translateX(2px) rotateY(3deg); }
  50% { transform: translateX(0); }
}

.field input.animate__animated {
  animation-duration: 0.75s;
  animation-fill-mode: both;
}

.field input.animate__headShake {
  animation-name: headShake;
  animation-timing-function: ease-in-out;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--panel-text);
}

.field input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  background: color-mix(in srgb, var(--panel) 88%, #000 4%);
  color: var(--panel-text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field input::placeholder { color: color-mix(in srgb, var(--panel-muted) 80%, transparent); }

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(101, 113, 255, 0.16);
  transform: translateY(-1px);
}

.login-form.is-locked .field input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--panel) 82%, #000 8%);
  border-color: color-mix(in srgb, var(--border) 70%, var(--danger) 18%);
  transform: none;
  box-shadow: none;
}

.login-form.is-locked .btn-login:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

.login-form.is-locked .btn-login-label {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.btn-login {
  position: relative;
  width: 100%;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 12px 28px rgba(101, 113, 255, 0.28);
}

.btn-login:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-login:active { transform: translateY(0); }

.btn-login:disabled {
  opacity: 0.75;
  cursor: wait;
  transform: none;
}

.btn-login.loading .btn-login-label { opacity: 0; }
.btn-login.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes heroSoftRise {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes brandReveal {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(22px);
    clip-path: inset(0 105% 0 0);
  }
  62% {
    filter: blur(1px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: none;
    /* Negative inset keeps final "g"/descenders unclipped */
    clip-path: inset(-0.12em -0.14em -0.14em -0.06em);
  }
}


@keyframes brandShimmerSweep {
  from {
    opacity: 0;
    background-position: 120% 50%;
  }
  18% { opacity: 1; }
  to {
    opacity: 0;
    background-position: -40% 50%;
  }
}

@keyframes orbBreath {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

@keyframes orbDriftA {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(36px, -28px, 0) scale(1.12); }
}

@keyframes orbDriftB {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-32px, 24px, 0) scale(1.1); }
}

@keyframes orbDriftC {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(28px, -22px, 0) scale(1.14); }
}

@keyframes markPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 10px 24px rgba(101, 113, 255, 0.35); }
  50% { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(101, 113, 255, 0.45); }
}

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

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .login-hero {
    text-align: left;
    max-width: none;
  }
  .login-form {
    margin: 0;
    max-width: none;
  }
  .login-brand {
    font-size: clamp(2.3rem, 11vw, 3.4rem);
  }
}

@media (max-width: 520px) {
  .login-page { padding: 16px; }
  .login-form { padding: 22px 18px; }
  .login-points { gap: 8px; }
  .login-points li { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .login-hero,
  .login-panel,
  .login-orb,
  .login-mark,
  .login-eyebrow,
  .login-brand-text,
  .login-brand-text::after,
  .login-lead,
  .login-points li {
    animation: none !important;
  }
  .login-eyebrow,
  .login-brand-text,
  .login-lead,
  .login-points li {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
  }
  .login-brand-text::after { display: none !important; }
  .login-orb {
    opacity: 0.65 !important;
    transform: none !important;
  }
  .field input:focus,
  .btn-login:hover {
    transform: none;
  }
}


/* Theme toggle — glass capsule + sliding switch */
.login-theme {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(12, 16, 28, 0.42);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.login-theme-caption {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(244, 247, 252, 0.88);
  white-space: nowrap;
  user-select: none;
}

.theme-switcher-wrapper {
  display: inline-flex;
  align-items: center;
  margin: 0;
  user-select: none;
  height: 28px;
}
.theme-switcher-wrapper .theme-switcher-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.theme-switcher-label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  line-height: 0;
  height: 100%;
}
.theme-switcher-wrapper .box {
  --ts-track: rgba(255, 255, 255, 0.88);
  --ts-ball: #6571ff;
  --ts-icon: #1f2937;
  width: 56px;
  height: 28px;
  background-color: var(--ts-track);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  transition: background-color 0.28s ease, box-shadow 0.28s ease;
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.08),
    0 1px 2px rgba(15, 23, 42, 0.08);
}
.theme-switcher-wrapper .box .ball {
  width: 22px;
  height: 22px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), transparent 45%),
    var(--ts-ball);
  border-radius: 50%;
  position: absolute;
  left: 3px;
  top: 3px;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.28s ease;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(79, 88, 224, 0.45);
}
.theme-switcher-wrapper .box .icons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 7px;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.theme-switcher-wrapper .box .icons .link-icon,
.theme-switcher-wrapper .box .icons svg {
  width: 14px !important;
  height: 14px !important;
  color: var(--ts-icon);
  stroke-width: 2.25;
  transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-switcher-wrapper .box.light .ball,
html:not(.dark) .theme-switcher-wrapper .box .ball {
  transform: translateX(0);
}
.theme-switcher-wrapper .box.light .icons .lucide-sun,
html:not(.dark) .theme-switcher-wrapper .box .icons .lucide-sun {
  opacity: 0;
  transform: scale(0.85);
}
.theme-switcher-wrapper .box.light .icons .lucide-moon,
html:not(.dark) .theme-switcher-wrapper .box .icons .lucide-moon {
  opacity: 1;
  color: #111827;
}

.theme-switcher-wrapper .box.dark,
html.dark .theme-switcher-wrapper .box {
  --ts-track: #1b2434;
  --ts-ball: #94a3b8;
  --ts-icon: #fbbc06;
  background-color: var(--ts-track);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.25);
}
.theme-switcher-wrapper .box.dark .ball,
html.dark .theme-switcher-wrapper .box .ball {
  transform: translateX(28px);
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), transparent 45%),
    var(--ts-ball);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.theme-switcher-wrapper .box.dark .icons .lucide-sun,
html.dark .theme-switcher-wrapper .box .icons .lucide-sun {
  opacity: 1;
  color: #fbbc06;
  transform: scale(1);
}
.theme-switcher-wrapper .box.dark .icons .lucide-moon,
html.dark .theme-switcher-wrapper .box .icons .lucide-moon {
  opacity: 0;
  transform: scale(0.85);
}

.theme-switcher-wrapper .theme-switcher-input:focus-visible + .theme-switcher-label .box {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.theme-switcher-wrapper .theme-switcher-label:active .box .ball {
  transform: scale(0.96);
}
html.dark .theme-switcher-wrapper .theme-switcher-label:active .box .ball {
  transform: translateX(28px) scale(0.96);
}

@media (max-width: 520px) {
  .login-theme {
    top: 12px;
    right: 12px;
    gap: 10px;
    padding: 7px 10px 7px 12px;
  }
  .login-theme-caption {
    font-size: 0.78rem;
  }
}
