:root {
  color-scheme: light;
  --paper: #fcfcf9;
  --ink: #18243b;
  --muted: #556177;
  --border: #aebacc;
  --accent: #234abf;
  --accent-hover: #1c3999;
  --error: #a02234;
  --well: #17387e;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

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

body { margin: 0; color: var(--ink); background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.login-page {
  display: grid;
  grid-template-columns: minmax(0, 54fr) minmax(0, 46fr);
  grid-template-areas: "art login";
  min-height: 100svh;
  padding: 18px;
}

.login-panel {
  grid-area: login;
  display: grid;
  place-items: center;
  padding: 48px clamp(36px, 6vw, 106px);
}

.login-content { width: min(100%, 392px); }

.wordmark {
  display: block;
  width: 132px;
  height: auto;
  margin-bottom: 40px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 3.2vw, 45px);
  font-weight: 750;
  letter-spacing: .02em;
  line-height: 1.2;
}

.intro {
  margin: 13px 0 32px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

.field + .field { margin-top: 19px; }

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 650;
}

.field input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
}

.field input::placeholder { color: #626e81; opacity: 1; }
.field input:hover { border-color: #7889a4; }

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-color: var(--accent);
}

.field input[aria-invalid="true"] {
  border-color: var(--error);
  outline-color: var(--error);
}

.field-error {
  margin: 7px 0 0;
  color: var(--error);
  font-size: 13px;
  line-height: 1.45;
}

.password-field { position: relative; }
.password-field input { padding-right: 75px; }

.reveal {
  position: absolute;
  inset: 4px 5px 4px auto;
  min-width: 57px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.reveal:hover { color: var(--accent); background: #edf1fe; }

.primary {
  display: block;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 16px;
  font-weight: 650;
}

.primary:hover { background: var(--accent-hover); }
.primary:active { background: #1b2f77; }
.primary:disabled { opacity: .72; cursor: wait; }

#login-form { position: relative; }
#login-form .primary { margin-top: 25px; }

.help {
  display: block;
  min-height: 44px;
  margin: 6px auto 0;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
}

.help:hover { text-decoration: underline; text-underline-offset: 3px; }

.feedback {
  position: absolute;
  inset: auto 0 auto;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.feedback[data-error] { color: var(--error); }

.illustration {
  grid-area: art;
  position: relative;
  isolation: isolate;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 22px;
  background: var(--well);
}

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  container-type: size;
}

.book {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 52% 55%;
  transform: scale(1.025);
  animation: breathing-frame 10s ease-in-out infinite;
}

.paper-plane {
  position: absolute;
  top: 0;
  left: 0;
  width: clamp(50px, 13.2cqw, 120px);
  aspect-ratio: 1.78;
  transform: translate3d(69cqw, 17cqh, 0) rotate(-13deg);
  filter: drop-shadow(1px 4px 3px #14265d55); /* taste-skill-ignore: shadow on the paper artwork */
  animation: flight 10s linear infinite;
}

.paper-plane > i { position: absolute; inset: 0; }
.wing-back {
  background: #ecdab1;
  clip-path: polygon(8% 35%, 100% 5%, 35% 72%);
}
.wing-fold {
  background: #b7a385;
  clip-path: polygon(31% 62%, 100% 5%, 35% 91%);
}
.wing-front {
  background: #fff4d8;
  clip-path: polygon(100% 5%, 64% 90%, 38% 67%);
}

@keyframes breathing-frame {
  0%, 100% { transform: scale(1.025); }
  50% { transform: scale(1.06) translate3d(-.45%, .4%, 0); }
}

@keyframes flight {
  0% { opacity: 0; transform: translate3d(3cqw, 39cqh, 0) rotate(-25deg) scale(.55); }
  7% { opacity: 1; }
  20% { opacity: 1; transform: translate3d(29cqw, 23cqh, 0) rotate(-25deg) scale(.84); }
  40% { opacity: 1; transform: translate3d(60cqw, 16cqh, 0) rotate(-12deg) scale(1); }
  53% { opacity: 1; transform: translate3d(80cqw, 11cqh, 0) rotate(-9deg) scale(.86); }
  65%, 100% { opacity: 0; transform: translate3d(102cqw, 1cqh, 0) rotate(-18deg) scale(.65); }
}

.help-dialog {
  width: min(calc(100% - 36px), 370px);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
}

.help-dialog::backdrop { background: #13244473; }
.help-dialog h2 { margin: 0; font-size: 23px; }
.help-dialog p { margin: 12px 0 25px; color: var(--muted); line-height: 1.5; }

@media (max-width: 820px) {
  .login-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "art" "login";
    padding: 12px;
  }

  .illustration {
    height: clamp(163px, 49vw, 238px);
    border-radius: 14px;
  }

  .book { object-position: 51% 55%; }
  .login-panel { align-items: start; padding: 29px 16px 38px; }
  .wordmark { width: 109px; margin-bottom: 23px; }
  .intro { margin-bottom: 24px; }
  .field + .field { margin-top: 16px; }
  #login-form .primary { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.book, .paper-plane) { animation: none; }
}

/* Management login reuses the confirmed book-and-plane composition. */
.login-page { min-height: calc(100svh - 60px); }
.admin-sign-in { display: flex; align-items: center; justify-content: center; padding: 12px 18px; text-decoration: none; }
.account-note { margin: 16px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
#staff-login-form .primary { margin-top: 25px; }
.login-feedback { min-height: 21px; margin: 10px 0 0; color: var(--error); font-size: 14px; line-height: 1.5; }
.backup-sign-in { display: inline-block; padding: 12px 0; color: var(--muted); font-size: 13px; text-underline-offset: 3px; }
