* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at -8% -12%, #ffffff 0%, rgba(255, 255, 255, 0) 58%),
    radial-gradient(900px 560px at 112% 108%, #e6eeff 0%, rgba(230, 238, 255, 0) 64%),
    linear-gradient(165deg, #f4f7ff 0%, #eef3ff 42%, #f9fbff 100%);
  color: #1e2430;
  overflow: hidden;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid #d9e4fa;
  border-radius: 24px;
  box-shadow:
    0 28px 62px rgba(46, 77, 144, 0.14),
    0 2px 0 rgba(255, 255, 255, 0.8) inset;
  backdrop-filter: blur(8px);
  padding: 32px;
  overflow: auto;
  position: relative;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(90deg, #5d89f7, #69c8ff, #9b8bff);
  opacity: 0.9;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  letter-spacing: 0.01em;
  color: #152238;
}

.sub {
  margin: 9px 0 20px;
  color: #5e6b84;
  font-size: 0.93rem;
  line-height: 1.5;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px;
  border-radius: 999px;
  border: 1px solid #dbe5f8;
  background: rgba(241, 246, 255, 0.8);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #44536d;
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.tab.active {
  border-color: #c6d7fb;
  background: rgba(255, 255, 255, 0.95);
  color: #1d3f8d;
  box-shadow: 0 6px 12px rgba(57, 89, 152, 0.14);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.form {
  display: grid;
  gap: 10px;
}

label {
  color: #415470;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input {
  border: 1px solid #cfdaef;
  background: rgba(255, 255, 255, 0.94);
  color: #172135;
  border-radius: 12px;
  padding: 12px 13px;
  font: inherit;
  outline: none;
  transition: border-color 170ms ease, box-shadow 170ms ease, transform 170ms ease;
}

input::placeholder {
  color: #8b98b1;
}

input:focus {
  border-color: #5f87d8;
  box-shadow: 0 0 0 3px rgba(95, 135, 216, 0.18), 0 8px 20px rgba(55, 88, 151, 0.12);
  transform: translateY(-1px);
}

.input-shell,
.password-field {
  position: relative;
}

.input-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: #6e7f9c;
  line-height: 0;
  pointer-events: none;
  z-index: 1;
}

.input-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.input-shell input,
.password-field input {
  width: 100%;
  box-sizing: border-box;
  padding-top: 12px;
  padding-bottom: 12px;
  padding-right: 13px;
  padding-left: 38px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #5b6f90;
  border-radius: 8px;
  padding: 4px;
  line-height: 0;
  cursor: pointer;
  z-index: 1;
}

.password-toggle:hover {
  color: #2a4d9a;
}

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

.pw-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .pw-icon-eye-off {
  display: none;
}

.password-toggle.is-visible .pw-icon-eye {
  display: none;
}

.password-toggle.is-visible .pw-icon-eye-off {
  display: block;
}

button:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

button[type="submit"] {
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #2f6ffa 0%, #4f84ff 52%, #5e93ff 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 13px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 14px 26px rgba(49, 94, 195, 0.28);
}

button[type="submit"]:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

button[type="submit"]:active {
  transform: translateY(1px);
}

button[type="submit"]:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  filter: saturate(0.92);
  transform: none;
}

button[type="submit"].is-loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 999px;
  vertical-align: -1px;
  animation: submitSpin 0.8s linear infinite;
}

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

.error {
  min-height: 20px;
  margin: 5px 0 0;
  color: #c1254b;
  font-size: 0.85rem;
}

.error.success {
  color: #1b7f43;
}

.form-actions {
  min-height: 24px;
}

.form-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c7d7fa;
  background: #f4f8ff;
  color: #2150ad;
  text-decoration: none;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.form-action-link:hover {
  background: #ebf3ff;
}

@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  .auth-shell {
    display: block;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }

  .auth-card {
    max-width: none;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    padding: calc(20px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  }

  .auth-card::before {
    border-radius: 0;
  }

  .sub {
    font-size: 0.91rem;
    margin-bottom: 14px;
  }

  .tab {
    padding: 10px 10px;
    font-size: 0.88rem;
  }

  label {
    font-size: 0.82rem;
  }

  input {
    font-size: 16px;
    padding: 12px;
  }

  button[type="submit"] {
    font-size: 0.94rem;
    padding: 12px;
  }
}

@media (max-height: 680px) {
  .auth-shell {
    place-items: start center;
  }

  .auth-card {
    margin-top: 8px;
  }
}
