:root {
  color-scheme: light;
  --page: #f3effb;
  --panel: #ffffff;
  --field: #fbfaff;
  --line: #ded5ef;
  --line-soft: #ece6f6;
  --text: #272035;
  --muted: #716985;
  --faint: #9991aa;
  --primary: #7756c8;
  --primary-dark: #6544b7;
  --accent: #6d4fbd;
  --danger: #c74449;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }

.login-shell {
  width: min(450px, 100%);
}

.login-panel {
  padding: 34px 36px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 20px 55px rgba(75, 54, 120, .12);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 62px;
  height: 62px;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(83, 61, 127, .12);
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy { min-width: 0; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
}

h1 {
  margin: 0;
  color: #251e33;
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.welcome {
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.welcome p { margin: 0; }

.login-form { margin-top: 21px; }
.field { margin-bottom: 15px; }

.field > label {
  display: block;
  margin-bottom: 6px;
  color: #3e3651;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--field);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field input::placeholder { color: var(--faint); }

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(119, 86, 200, .13);
}

.field select {
  color: var(--text);
  cursor: pointer;
}

.field select:invalid { color: var(--faint); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 50px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: #f0ebfa;
  color: var(--primary);
  outline: none;
}

.password-toggle.is-visible { color: var(--primary); }

.form-options {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #554c68;
  font-size: 12px;
  cursor: pointer;
}

.remember input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b8accd;
  border-radius: 5px;
  background: #fff;
}

.checkmark::after {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  content: "";
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform .12s ease;
}

.remember input:checked + .checkmark {
  border-color: var(--primary);
  background: var(--primary);
}

.remember input:checked + .checkmark::after {
  transform: rotate(-45deg) translate(1px, -1px) scale(1);
}

.remember input:focus-visible + .checkmark {
  box-shadow: 0 0 0 3px rgba(119, 86, 200, .14);
}

.secure-note {
  color: var(--faint);
  font-size: 11px;
  text-align: right;
}

.form-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #edc3c6;
  border-radius: 7px;
  background: #fff6f6;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.login-button {
  width: 100%;
  min-height: 48px;
  margin-top: 17px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}

.login-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.login-button:active { transform: translateY(1px); }

.login-button:focus-visible {
  outline: 3px solid rgba(119, 86, 200, .2);
  outline-offset: 2px;
}

.login-button:disabled { opacity: .6; cursor: wait; }

.register-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}

.register-button:hover,
.register-button:focus-visible {
  border-color: #b9a7df;
  background: #faf8fe;
  outline: none;
}

.register-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.register-form {
  margin-top: 21px;
}

.register-form h2 {
  margin: 0 0 18px;
  color: #2d2640;
  font-size: 18px;
  line-height: 1.3;
}

.back-login-button {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.back-login-button:hover,
.back-login-button:focus-visible {
  background: #f7f4fc;
  color: var(--primary);
  outline: none;
}

.side-note { display: none; }

.noscript {
  position: fixed;
  right: 20px;
  bottom: 20px;
  margin: 0;
  color: var(--danger);
}

@media (max-width: 520px) {
  body {
    padding: 0;
    display: block;
    background: var(--panel);
  }

  .login-shell {
    width: 100%;
    min-height: 100vh;
  }

  .login-panel {
    min-height: 100vh;
    padding: 28px 20px calc(26px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
    border-radius: 12px;
  }

  h1 { font-size: 23px; }
  .welcome { margin-top: 25px; }
  .login-form { margin-top: 20px; }
  .register-form { margin-top: 20px; }
}
