*, *::before, *::after { box-sizing: border-box; }

:root{
  --card-bg: rgba(16, 18, 22, 0.58);
  --card-border: rgba(255,255,255,0.14);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --error: #ff6b6b;
  --btn-bg: rgba(255,255,255,0.92);
  --btn-text: rgba(10, 12, 16, 0.92);
  --focus: rgba(255,255,255,0.30);
}

html, body { height: 100%; }

body{
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  overflow-x: hidden;

  /* Fallback gradient (shows immediately, stays behind images) */
  background: linear-gradient(135deg, #071a3a 0%, #5db0ff 100%);
}

/* Fullscreen background layer */
.bg{
  position: fixed;
  inset: 0;
  z-index: -2;
}
.bg img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;

  /* Fade-in + gentle de-blur */
  opacity: 0;
  filter: blur(10px) saturate(1.05) contrast(1.05);
  transform: scale(1.02);
  transition: opacity 550ms ease, filter 650ms ease;
}

/* Once loaded/decoded */
body.bg-ready .bg img{
  opacity: 1;
  filter: blur(0px) saturate(1.05) contrast(1.05);
}

.overlay{
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 20% 15%, rgba(0,0,0,0.12), rgba(0,0,0,0.60)),
    linear-gradient(to bottom, rgba(0,0,0,0.18), rgba(0,0,0,0.55));
}

.wrap{
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.card{
  width: min(420px, 100%);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.title{
  margin: 0 0 14px 0;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.field{ margin-top: 14px; }

label{
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input{
  width: 100%;
  box-sizing: border-box;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  outline: none;
}

input::placeholder{ color: rgba(255,255,255,0.40); }

input:focus{
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08);
}

.pwdRow{
  display: flex;
  gap: 10px;
  align-items: center;
}

.pwdRow input{ flex: 1; }

.ghost{
  flex: none;
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.88);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 72px;
}
.ghost:active{ transform: translateY(1px); }

.error{
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--error);
  min-height: 16px;
}

.btn{
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 650;
  cursor: pointer;
}

.btn:active{ transform: translateY(1px); }

.btn:disabled{
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.toast{
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.82);
  text-align: center;
  min-height: 18px;
}

/* Small screens: keep touch targets comfy */
@media (max-width: 360px){
  .card{ padding: 18px 16px 16px; }
  .ghost{ min-width: 64px; }
}