/* ─── Design tokens: dark (default) ─────────────────────────────── */
:root {
  --bg-top: #0d0f14;
  --bg-mid: #111318;
  --bg-bottom: #080a0e;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-highlight: rgba(255, 255, 255, 0.07);
  --card-shadow: 0 32px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --text-main: #e2e6f2;
  --text-soft: #6b7394;
  --field-bg: rgba(255, 255, 255, 0.05);
  --field-border: rgba(255, 255, 255, 0.1);
  --field-focus: #5b7cf5;
  --field-focus-glow: rgba(91, 124, 245, 0.18);
  --placeholder: rgba(255, 255, 255, 0.22);
  --button-top: #4c6ef5;
  --button-bottom: #3b5bdb;
  --button-hover-top: #6080f8;
  --button-hover-bottom: #4c6ef5;
  --button-glow: rgba(76, 110, 245, 0.32);
  --button-glow-hover: rgba(76, 110, 245, 0.48);
  --error-bg: rgba(220, 55, 35, 0.1);
  --error-border: rgba(220, 55, 35, 0.28);
  --error-text: #ff7a65;
  --toggle-bg: rgba(255, 255, 255, 0.07);
  --toggle-hover: rgba(255, 255, 255, 0.13);
  --toggle-color: #6b7394;
  --pw-btn-color: rgba(255, 255, 255, 0.3);
  --pw-btn-hover: rgba(255, 255, 255, 0.7);
  color-scheme: dark;
}

/* ─── Design tokens: light ───────────────────────────────────────── */
[data-theme="light"] {
  --bg-top: #f2f2f4;
  --bg-mid: #eaeaee;
  --bg-bottom: #e2e2e8;
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-border: rgba(0, 0, 0, 0.07);
  --card-highlight: rgba(255, 255, 255, 0.95);
  --card-shadow: 0 32px 64px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --text-main: #1c1f2e;
  --text-soft: #5a6080;
  --field-bg: #f4f4f6;
  --field-border: rgba(0, 0, 0, 0.12);
  --field-focus: #c42d82;
  --field-focus-glow: rgba(196, 45, 130, 0.14);
  --placeholder: rgba(0, 0, 0, 0.28);
  --button-top: #c42d82;
  --button-bottom: #9e2268;
  --button-hover-top: #d43590;
  --button-hover-bottom: #c42d82;
  --button-glow: rgba(196, 45, 130, 0.22);
  --button-glow-hover: rgba(196, 45, 130, 0.35);
  --error-bg: #fff2f0;
  --error-border: #f5b0a0;
  --error-text: #c03520;
  --toggle-bg: rgba(0, 0, 0, 0.06);
  --toggle-hover: rgba(0, 0, 0, 0.1);
  --toggle-color: #5a6080;
  --pw-btn-color: rgba(0, 0, 0, 0.3);
  --pw-btn-hover: rgba(0, 0, 0, 0.7);
  color-scheme: light;
}

/* ─── Base ───────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color: var(--text-main);
}

body {
  background:
    radial-gradient(ellipse 70% 50% at 15% 12%, rgba(91, 124, 245, 0.08), transparent),
    radial-gradient(ellipse 55% 45% at 85% 88%, rgba(140, 80, 220, 0.06), transparent),
    linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bottom) 100%);
  background-attachment: fixed;
}

/* ─── Layout ─────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* ─── Card ───────────────────────────────────────────────────────── */
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--card-border);
  border-top-color: var(--card-highlight);
  border-radius: 20px;
  background: var(--card-bg);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: var(--card-shadow);
  padding: 36px 32px 32px;
}

/* ─── Theme toggle ───────────────────────────────────────────────── */
.theme-toggle {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--toggle-bg);
  color: var(--toggle-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

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

/* ─── Brand ──────────────────────────────────────────────────────── */
.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  width: 160px;
  height: 160px;
  display: block;
  margin: 0 auto 10px;
}

.brand-kicker {
  margin: 0;
  font-size: 0.71rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
}

.brand h1 {
  margin: 8px 0 0;
  font-size: 1.38rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* ─── Error box ──────────────────────────────────────────────────── */
.login-error {
  display: none;
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 16px;
  color: var(--error-text);
}

.login-error.visible {
  display: block;
}

.login-error p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ─── Form ───────────────────────────────────────────────────────── */
.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  margin-top: 6px;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text-main);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.97rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form input::placeholder {
  color: var(--placeholder);
}

.login-form input:focus {
  border-color: var(--field-focus);
  box-shadow: 0 0 0 3px var(--field-focus-glow);
}

/* ─── Password wrapper ───────────────────────────────────────────── */
.pw-wrap {
  position: relative;
}

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

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--pw-btn-color);
  line-height: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}

.pw-toggle:hover {
  color: var(--pw-btn-hover);
}

.pw-toggle:focus-visible {
  outline: 2px solid var(--field-focus);
  border-radius: 4px;
  outline-offset: 1px;
}

/* ─── Login button ───────────────────────────────────────────────── */
#loginButton {
  display: block;
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--button-top), var(--button-bottom));
  color: #fff;
  font-size: 0.97rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 4px 16px var(--button-glow);
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.08s ease;
}

#loginButton:hover {
  background: linear-gradient(180deg, var(--button-hover-top), var(--button-hover-bottom));
  box-shadow: 0 6px 22px var(--button-glow-hover);
}

#loginButton:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px var(--button-glow);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 420px) {
  .login-card {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }

  .brand h1 {
    font-size: 1.25rem;
  }

  .brand-badge {
    width: 130px;
    height: 130px;
  }
}
