:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted-fg: #4a4a4a;
  --subtle-fg: #6b6b73;
  --divider-fg: #9a9aa3;
  --border: #e2e2e6;
  --border-hover: #d0d0d6;
  --surface: #ffffff;
  --surface-hover: #f7f7f9;
  --banner-bg: #f3f3f5;
  --btn-primary-bg: #0a0a0a;
  --btn-primary-fg: #ffffff;
  --focus-ring: rgba(10, 10, 10, 0.08);
  --error: #dc2626;
  --error-ring: rgba(220, 38, 38, 0.12);
}

[data-theme="dark"] {
  --bg: #0e0e10;
  --fg: #f5f5f7;
  --muted-fg: #b8b8bf;
  --subtle-fg: #8a8a93;
  --divider-fg: #6b6b73;
  --border: #2a2a2e;
  --border-hover: #3a3a3e;
  --surface: #18181c;
  --surface-hover: #1f1f24;
  --banner-bg: #18181c;
  --btn-primary-bg: #f5f5f7;
  --btn-primary-fg: #0a0a0a;
  --focus-ring: rgba(245, 245, 247, 0.12);
  --error: #f87171;
  --error-ring: rgba(248, 113, 113, 0.18);
}

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

html,
body {
  height: 100%;
}

body {
  font-family:
    "Geist",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  color: var(--fg);
  background: var(--bg);
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100vh;
}

.login-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14vh 24px 48px;
  overflow-y: auto;
}

.logo {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 8px;
  transition: opacity 0.15s ease;
}

.logo:hover {
  opacity: 0.75;
}

.logo img {
  width: 32px;
  height: 32px;
  display: block;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

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

.login-panel__inner {
  width: 100%;
  max-width: 360px;
}

.login-heading {
  text-align: center;
  margin-bottom: 56px;
}

.login-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
  line-height: 1.1;
}

.login-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted-fg);
  margin: 0;
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.honeypot {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.float-input {
  position: relative;
}

.login-form input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.login-form input[type="email"]:focus {
  outline: none;
  border-color: var(--fg);
}

.float-input label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--subtle-fg);
  background: transparent;
  pointer-events: none;
  transition:
    top 0.15s ease,
    font-size 0.15s ease,
    color 0.15s ease;
}

.float-input input:focus + label,
.float-input input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 12px;
  color: var(--fg);
  background: linear-gradient(to bottom, var(--bg) 50%, var(--surface) 50%);
}

.form-field.has-error input[type="email"] {
  border-color: var(--error);
}

.form-field.has-error input[type="email"]:focus {
  border-color: var(--error);
}

.form-field.has-error .float-input input:focus + label,
.form-field.has-error .float-input input:not(:placeholder-shown) + label {
  color: var(--error);
}

.field-error {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--error);
  line-height: 1.3;
}

.form-field.has-error .field-error {
  display: flex;
}

.field-error svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: var(--btn-primary-fg);
  background: var(--btn-primary-bg);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition:
    opacity 0.15s ease,
    transform 0.1s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary:not(:disabled):hover {
  opacity: 0.9;
}

.btn-primary:not(:disabled):active {
  transform: translateY(1px);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 36px 0;
  color: var(--divider-fg);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

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

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.2s ease;
}

.btn-oauth:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-oauth svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.login-help {
  margin-top: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--subtle-fg);
  line-height: 1.5;
}

.login-help a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}

.login-help a:hover {
  text-decoration: underline;
}

.login-banner {
  position: relative;
  overflow: hidden;
  background: var(--banner-bg);
}

.login-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-success {
  text-align: center;
}

.login-success__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 24px;
  border-radius: 14px;
  background: var(--surface-hover);
  color: var(--fg);
}

.login-success__icon svg {
  width: 28px;
  height: 28px;
}

.login-success .login-title {
  margin-bottom: 14px;
}

.login-success__email-line {
  margin-top: 18px;
  text-align: center;
}

.login-success__email {
  position: relative;
  display: inline-block;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  background: var(--surface-hover);
  border-radius: 8px;
  overflow: hidden;
  isolation: isolate;
}

.login-success__email::before {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-backdrop-filter: invert(1);
  backdrop-filter: invert(1);
  transform: translateX(-100%);
  animation: email-loading-sweep 3s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes email-loading-sweep {
  0%,
  18% {
    transform: translateX(-100%);
  }
  82%,
  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-success__email::before {
    animation: none;
  }
}

.login-success__hint {
  margin-top: 22px;
  color: var(--subtle-fg);
}

.login-success__expiry {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--subtle-fg);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.login-success__expiry [data-countdown] {
  font-weight: 700;
}

.login-success__expiry[data-expiring="true"] {
  color: var(--error);
}

.login-expired {
  text-align: center;
}

.login-expired__icon {
  color: var(--error);
}

.login-expired__button {
  margin-top: 28px;
}

.login-expired__error {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--error);
  line-height: 1.3;
}

.login-expired__error:not([hidden]) {
  display: flex;
}

.login-expired__error svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.login-expired__alt {
  margin-top: 16px;
  font-size: 14px;
  color: var(--subtle-fg);
}

.login-expired__alt a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}

.login-expired__alt a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .login-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .login-banner {
    display: none;
  }
}
