*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #05060a;
  --bg-deep: #070913;
  --surface: rgba(13, 17, 27, 0.78);
  --surface-strong: rgba(16, 22, 35, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --surface-soft-2: rgba(255, 255, 255, 0.08);

  --border: rgba(120, 145, 255, 0.14);
  --border-strong: rgba(89, 225, 255, 0.28);

  --text: #f2f6ff;
  --text-muted: #a9b4d0;
  --text-soft: #7f8aa6;

  --accent: #59e1ff;
  --accent-2: #6d7cff;
  --accent-3: #8d63ff;

  --success: #30d17b;
  --danger: #ff6d86;
  --warning: #ffb95a;

  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 22px 50px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 40px 90px rgba(0, 0, 0, 0.5);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;

  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 16%, rgba(109, 124, 255, 0.18), transparent 22%),
    radial-gradient(circle at 88% 14%, rgba(89, 225, 255, 0.14), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(141, 99, 255, 0.08), transparent 22%),
    linear-gradient(180deg, #04050a 0%, #090c14 48%, #04050a 100%);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black 38%, transparent 100%);
  opacity: 0.24;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 28%, rgba(89, 225, 255, 0.09), transparent 16%),
    radial-gradient(circle at 78% 18%, rgba(109, 124, 255, 0.1), transparent 18%);
  filter: blur(28px);
  opacity: 0.9;
}

.header-left {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  gap: 30px !important;
  padding: 42px 56px 30px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  background:
    linear-gradient(135deg, rgba(10, 15, 25, 0.74) 0%, rgba(16, 24, 40, 0.72) 55%, rgba(10, 15, 27, 0.76) 100%) !important;
  overflow: hidden !important;
}


.header-left::before {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  background:
    radial-gradient(circle at 16% 35%, rgba(89, 225, 255, 0.16), transparent 24%),
    radial-gradient(circle at 84% 18%, rgba(109, 124, 255, 0.16), transparent 22%) !important;
  pointer-events: none !important;
}

.header-left::after {
  content: "" !important;
  position: absolute !important;
  left: 56px !important;
  right: 56px !important;
  bottom: 0 !important;
  height: 1px !important;
  background: linear-gradient(90deg, transparent, rgba(89, 225, 255, 0.45), transparent) !important;
}

.header-logo {
  width: 190px;
  max-width: 42%;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  filter:
    drop-shadow(0 12px 30px rgba(0, 0, 0, 0.4))
    drop-shadow(0 0 18px rgba(89, 225, 255, 0.08));
}

.header-text {
  position: relative;
  z-index: 1;
  text-align: left;
}

.header-text h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: #f8fbff;
}

.header-text h2 {
  margin: 0;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #dbe5ff;
}

.header-text h3 {
  margin: 10px 0 0;
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--text-muted);
  max-width: 42ch;
}

.lang-switcher {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}

.lang-switcher button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
}

.lang-switcher .lang-current {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  min-height: 44px;
  padding: 10px 16px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)) !important;
  color: var(--text) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition) !important;
}

.lang-switcher .lang-current:hover {
  transform: translateY(-1px);
  border-color: rgba(89, 225, 255, 0.34) !important;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(89, 225, 255, 0.18);
}

.lang-current .lang-flag {
  position: static;
  display: inline-block;
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 3px;
  margin: 0;
  flex-shrink: 0;
}

.lang-current .lang-label {
  display: inline-block;
}

.lang-current .lang-arrow {
  font-size: 10px;
  opacity: 0.8;
  margin-left: 2px;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  padding: 8px;
  min-width: 170px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 13, 20, 0.94);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  z-index: 50;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}

.lang-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.lang-dropdown button {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 11px 12px !important;
  color: var(--text) !important;
  font-size: 14px !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  line-height: 1.3 !important;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.lang-dropdown button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  transform: translateX(2px);
}

.lang-dropdown img.lang-flag {
  display: inline-block !important;
  position: static !important;
  width: 18px !important;
  height: 12px !important;
  object-fit: cover !important;
  border-radius: 3px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}

.lang-dropdown button span {
  display: inline-block !important;
}

.login-shell {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(6, 9, 15, 0.46), rgba(5, 7, 12, 0.62));
}

.card {
  position: relative;
  width: min(1100px, calc(100% - 48px));
  margin: auto;
  padding: 32px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(18, 23, 34, 0.88), rgba(10, 14, 22, 0.96));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(89, 225, 255, 0.08), transparent 18%),
    radial-gradient(circle at bottom left, rgba(109, 124, 255, 0.08), transparent 22%);
  pointer-events: none;
}

#statusBadge,
.badge {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #dceaff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

#statusBadge::before,
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 109, 134, 0.42);
}

#loginForm,
#loginFieldset {
  width: 100%;
}

.login-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 12px;
}

.login-grid .field {
  width: 100%;
}

.login-grid input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.025));
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
}

.login-grid input::placeholder {
  color: var(--text-soft);
}

.login-grid input:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.035));
}

.login-grid input:focus {
  border-color: rgba(89, 225, 255, 0.55);
  box-shadow:
    0 0 0 4px rgba(89, 225, 255, 0.12),
    0 0 0 1px rgba(89, 225, 255, 0.18);
  background: rgba(17, 24, 36, 0.96);
}

.login-grid input:disabled {
  opacity: 0.64;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0;
}

button {
  min-height: 54px;
  padding: 0 22px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
}

button[type="submit"],
#connectBtn,
.actions button:not(.secondary) {
  color: #051018;
  background: linear-gradient(135deg, #7bedff 0%, #59e1ff 38%, #6d7cff 100%);
  box-shadow:
    0 14px 30px rgba(78, 173, 255, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.3);
}

button[type="submit"]:hover,
#connectBtn:hover,
.actions button:not(.secondary):hover {
  transform: translateY(-1px);
  box-shadow:
    0 18px 36px rgba(78, 173, 255, 0.28),
    0 0 0 1px rgba(89, 225, 255, 0.26);
}

button[type="submit"]:active,
#connectBtn:active,
.actions button:not(.secondary):active {
  transform: translateY(0);
}

.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.14);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.hint {
  margin-top: 12px;
  opacity: 0.92;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

.error-msg {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#updateSpinner,
.update-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(4, 6, 10, 0.76);
  backdrop-filter: blur(10px);
  z-index: 10;
  pointer-events: all;
  border-radius: inherit;
}

#updateSpinner.show,
.update-spinner.show {
  display: flex;
}

#updateSpinner p,
.update-spinner p {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 20px rgba(89, 225, 255, 0.12);
}

#loginCard.is-updating {
  filter: saturate(0.95);
}

.closure-banner {
  background: linear-gradient(135deg, rgba(25, 16, 10, 0.98), rgba(39, 23, 9, 0.96));
  color: #f5eadc;
  border-bottom: 1px solid rgba(255, 185, 90, 0.16);
  padding: 16px 20px;
  font-family: inherit;
}

.closure-content {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 6px;
}

.closure-content strong {
  color: var(--warning);
  font-size: 1.03rem;
}

.closure-content p {
  color: rgba(245, 234, 220, 0.82);
  font-size: 0.95rem;
  margin: 0;
}

.closure-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #fff3dd;
}

.closure-divider {
  width: 100%;
  height: 1px;
  margin: 6px 0;
  background: linear-gradient(90deg, transparent, rgba(255,185,90,0.32), transparent);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px #121927 inset;
  transition: background-color 9999s ease-in-out 0s;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .login-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
    justify-content: stretch;
  }

  .actions button,
  #connectBtn {
    width: 100%;
  }

  .card {
    width: min(760px, calc(100% - 32px));
  }
}

@media (max-width: 768px) {
  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
    padding: 76px 20px 22px;
  }

  .header-left::after {
    left: 20px;
    right: 20px;
  }

  .header-logo {
    width: 150px;
    max-width: 60%;
  }

  .header-text h1 {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .header-text h2 {
    font-size: 1rem;
  }

  .header-text h3 {
    font-size: 0.94rem;
    max-width: none;
  }

  .lang-switcher {
    top: 14px;
    right: 14px;
  }

  .lang-switcher .lang-current {
    min-height: 40px;
    padding: 8px 14px !important;
  }

  .login-shell {
    padding: 12px;
  }

  .card {
    width: calc(100% - 24px);
    padding: 20px;
    border-radius: 18px;
  }

  .login-grid input {
    min-height: 52px;
  }
}

@media (max-width: 480px) {
  .header-left {
    align-items: center;
    text-align: center;
    padding: 72px 16px 20px;
  }

  .header-text {
    text-align: center;
  }

  .header-logo {
    max-width: 72%;
  }

  .card {
    width: calc(100% - 20px);
    padding: 16px;
  }

  .badge,
  #statusBadge {
    font-size: 0.8rem;
  }

  .lang-current .lang-label {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}