:root {
  color-scheme: dark;
  --page: #050505;
  --panel: #080808;
  --field: #0d0d0e;
  --field-hover: #101011;
  --border: #1e1e20;
  --border-strong: #303033;
  --text: #f4f4f5;
  --muted: #8c8c93;
  --subtle: #5f5f65;
  --button: #f2f2f2;
  --button-hover: #ffffff;
  --button-text: #080808;
  --danger: #ff7b7b;
  --success: #a5dc8e;
  --focus: rgba(255, 255, 255, 0.13);
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f5f5f3;
  --panel: #ffffff;
  --field: #f7f7f6;
  --field-hover: #f1f1ef;
  --border: #dfdfdc;
  --border-strong: #c5c5c1;
  --text: #161616;
  --muted: #67676b;
  --subtle: #8d8d91;
  --button: #141414;
  --button-hover: #000000;
  --button-text: #ffffff;
  --danger: #c33b3b;
  --success: #39752f;
  --focus: rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition:
    color 180ms ease,
    background 180ms ease;
}

button,
input {
  font: inherit;
}

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

.topbar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
}

.brand-mark svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.brand-mark .moon {
  fill: var(--text);
  stroke: var(--panel);
  stroke-width: 0.8;
}

.theme-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.theme-toggle:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--panel);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.sun-icon,
:root[data-theme="light"] .moon-icon {
  display: none;
}

:root[data-theme="light"] .sun-icon {
  display: block;
}

.auth-shell {
  display: grid;
  width: 100%;
  place-items: center;
  padding: 42px 20px 64px;
}

.login-card {
  width: min(100%, 448px);
  padding: 38px 30px 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.16);
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.heading-group {
  margin-bottom: 29px;
  text-align: center;
}

.heading-group h1 {
  margin: 0 0 8px;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.heading-group p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sign-in-form {
  display: grid;
  gap: 20px;
}

.verification-copy {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.verification-copy strong {
  color: var(--text);
  font-weight: 650;
}

#two-factor-code {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.22em;
  text-align: center;
}

.verification-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.verification-actions button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.verification-actions button:hover,
.verification-actions button:focus-visible {
  color: var(--text);
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label,
.label-row {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-row a {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.label-row a:hover {
  color: var(--text);
}

.field-group input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  color: var(--text);
  background: var(--field);
  font-size: 13px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.field-group input:hover {
  border-color: var(--border-strong);
  background: var(--field-hover);
}

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

.field-group input::placeholder {
  color: var(--subtle);
}

.field-group input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent);
}

.password-wrap {
  position: relative;
}

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

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--subtle);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--text);
  background: var(--border);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 0;
}

.password-toggle svg {
  grid-area: 1 / 1;
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.password-toggle .eye-closed,
.password-toggle[aria-pressed="true"] .eye-open {
  display: none;
}

.password-toggle[aria-pressed="true"] .eye-closed {
  display: block;
}

.field-error {
  margin: 0 1px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.35;
}

.field-error:empty {
  display: none;
}

.remember-row {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-top: -3px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.remember-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.custom-checkbox {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--field);
}

.custom-checkbox svg {
  width: 11px;
  fill: none;
  stroke: var(--button-text);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  opacity: 0;
  transform: scale(0.75);
  transition: 120ms ease;
}

.remember-row input:checked + .custom-checkbox {
  border-color: var(--button);
  background: var(--button);
}

.remember-row input:checked + .custom-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.remember-row input:focus-visible + .custom-checkbox {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.submit-button {
  display: flex;
  width: 100%;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 3px;
  border: 0;
  border-radius: 7px;
  color: var(--button-text);
  background: var(--button);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.submit-button:hover {
  background: var(--button-hover);
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.submit-button:active {
  transform: translateY(0);
}

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

.button-loader {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid color-mix(in srgb, var(--button-text) 25%, transparent);
  border-top-color: var(--button-text);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.submit-button.is-loading .button-loader {
  display: block;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.78;
  transform: none;
}

.form-message {
  margin: -8px 0 0;
  color: var(--success);
  font-size: 11px;
  text-align: center;
}

.form-message.error {
  color: var(--danger);
}

.form-message:empty {
  display: none;
}

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 27px;
  padding-top: 23px;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 11px;
}

.security-note svg {
  width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.45;
}

.site-footer {
  padding: 20px 24px 26px;
  color: var(--subtle);
  font-size: 10px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

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

@media (max-width: 520px) {
  .topbar {
    padding: 20px;
  }

  .auth-shell {
    align-items: start;
    padding: 42px 16px;
  }

  .login-card {
    padding: 33px 22px 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
