:root {
  color-scheme: light;
  --page: #d8d8d8;
  --gradient-low: #adb0b2;
  --gradient-mid: #d9d9d9;
  --gradient-high: #f6f6f6;
  --gradient-glow: #ffffffb8;
  --gradient-shade: #6c6c6c45;
  --panel: #fff;
  --glass: #ffffffa8;
  --surface-border: #ffffffbc;
  --shadow: 0 18px 56px #1e1e1e26, inset 0 1px #ffffff9c;
  --logo-shadow: 0 2px 5px #0003;
  --ink: #1b1e20;
  --muted: #525965;
  --placeholder: #646c76;
  --border: #aeb4bb;
  --focus: #2156b5;
  --field: #ffffffa8;
  --field-active: #f0f0f0;
  --subtle: #f7f8f9;
  --hover: #f0f2f3;
  --link: #364256;
  --error-bg: #fff3f2;
  --error-border: #e5b6b3;
  --error-ink: #861e16;
  --primary: #24292c;
  --primary-hover: #3b4145;
  --primary-ink: #fff;
  --switch-track: #777;
  --switch-thumb: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

:root[data-app-theme="dark"] {
  color-scheme: dark;
  --page: #1b1b1b;
  --gradient-low: #0c0c0c;
  --gradient-mid: #222;
  --gradient-high: #4a4a4a;
  --gradient-glow: #ffffff24;
  --gradient-shade: #0009;
  --panel: #222;
  --glass: #181818b8;
  --surface-border: #ffffff38;
  --shadow: 0 18px 56px #0006, inset 0 1px #ffffff14;
  --logo-shadow: 0 0 5px #ffffff50;
  --ink: #f0f2f4;
  --muted: #bec5cc;
  --placeholder: #a6afb8;
  --border: #707a84;
  --focus: #90b8ff;
  --field: #141414bd;
  --field-active: #303030;
  --subtle: #252a30;
  --hover: #30373e;
  --link: #c1d8ff;
  --error-bg: #392224;
  --error-border: #a95a60;
  --error-ink: #ffd4d6;
  --primary: #f0f2f4;
  --primary-hover: #dbe1e7;
  --primary-ink: #1b1e20;
  --switch-track: #e0e0e0;
  --switch-thumb: #242424;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; isolation: isolate; }
[hidden] { display: none !important; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(ellipse at 24% 32%, var(--gradient-glow), transparent 47%),
    radial-gradient(ellipse at 76% 68%, var(--gradient-shade), transparent 49%),
    linear-gradient(128deg, var(--gradient-low), var(--gradient-high) 32%, var(--gradient-mid) 60%, var(--gradient-low));
  background-size: 145% 145%, 155% 155%, 200% 200%;
  animation: gradient-drift 24s ease-in-out infinite alternate;
}

@keyframes gradient-drift {
  from { background-position: 0% 12%, 100% 75%, 0% 35%; }
  to { background-position: 100% 88%, 0% 15%, 100% 65%; }
}

.login-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 76px 20px 36px;
}

.login-panel {
  width: min(100%, 480px);
  min-width: 0;
  padding: clamp(24px, 4vw, 36px);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-header {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

.login-brand {
  display: block;
  min-width: 0;
  padding: 4px 7px;
  border-radius: 6px;
}

.login-brand img {
  display: block;
  width: clamp(168px, 55vw, 224px);
  max-width: 100%;
  height: auto;
  max-height: 88px;
  object-fit: contain;
  filter: drop-shadow(var(--logo-shadow));
}

.login-theme {
  position: absolute;
  inset-block-start: max(18px, env(safe-area-inset-top));
  inset-inline-end: max(20px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 6px 10px 6px 13px;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-panel, .login-theme {
    background: var(--glass);
    -webkit-backdrop-filter: blur(24px);
    backdrop-filter: blur(24px);
  }
}

.theme-track {
  display: inline-block;
  width: 36px;
  height: 20px;
  padding: 2px;
  border-radius: 999px;
  background: var(--switch-track);
}

.theme-track::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-thumb);
  transition: transform .18s ease-out;
}

.login-theme[aria-checked="true"] .theme-track::after { transform: translateX(16px); }

.login-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(2.375rem, 6vw, 3.125rem);
  line-height: 1.03;
  letter-spacing: -.055em;
  font-weight: 760;
}

.login-intro, .login-help { color: var(--muted); line-height: 1.55; }
.login-intro { margin: 0 0 28px; font-size: 1.05rem; }
.login-help { margin: 20px 0 0; font-size: .875rem; }
.login-form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field label { font-size: .925rem; font-weight: 680; }

.field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 14px;
}

.field input::placeholder { color: var(--placeholder); }
.field input:focus {
  outline: none;
  background: var(--field-active);
}
.password-field { position: relative; }
.password-field input { padding-right: 72px; }
.password-toggle {
  position: absolute;
  inset: 4px 5px 4px auto;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  cursor: pointer;
}

.password-toggle:hover { background: var(--hover); }
.login-verification { margin-top: 4px; min-width: 0; min-height: 65px; }
#login-turnstile[data-size="compact"] { min-height: 140px; }
.field-hint { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }

.text-button {
  justify-self: start;
  padding: 3px 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--link);
  font-size: .84rem;
  text-decoration: underline;
  cursor: pointer;
}

.security-question-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 105px);
  gap: 12px;
  align-items: center;
  padding: 6px 6px 6px 13px;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: var(--subtle);
  font-size: .9rem;
}
.security-question-entry input { min-height: 40px; padding: 6px 10px; }
.form-error {
  padding: 11px 13px;
  margin: 0 0 18px;
  border: 1px solid var(--error-border);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-ink);
  font-size: .9rem;
  line-height: 1.45;
}
.login-form .form-error { margin: 0; }

.sign-in {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 51px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.sign-in:hover { background: var(--primary-hover); }
.sign-in:disabled { opacity: .65; cursor: default; }
.sign-in[aria-busy="true"] { opacity: 1; cursor: progress; background: var(--primary); }
.sign-in-loading { display: inline-flex; align-items: center; gap: 9px; }

.sign-in-spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: sign-in-spin .7s linear infinite;
}

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

@media (max-width: 480px) {
  .login-layout { padding: 70px 16px 20px; }
  .login-panel { padding: 16px; }
  .login-header { margin-bottom: 20px; }
  .login-intro { margin-bottom: 22px; }
  .login-form { gap: 16px; }
  .login-help { margin-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .sign-in-spinner { animation: none; }
  .theme-track::after { transition: none; }
}

@media (forced-colors: active) {
  .field input:focus-visible { outline: 2px solid Highlight; }
  .theme-track { border: 1px solid ButtonText; }
  .theme-track::after { background: ButtonText; }
}
