:root {
  --color-sky: #48bed6;
  --color-paper: #fff6e4;
  --color-paper-muted: #e9d9b9;
  --color-ink: #132b3f;
  --color-ink-muted: #496071;
  --color-primary: #142e49;
  --color-primary-hover: #1b3b5d;
  --color-primary-active: #0f2439;
  --color-accent: #b63d2e;
  --color-accent-hover: #a83328;
  --color-accent-active: #8f2d24;
  --color-danger: #9f2f2a;
  --color-success: #2f7656;
  --color-hairline: rgba(19, 43, 63, 0.2);
  --font-display:
    "Arial Rounded MT Bold", "Microsoft YaHei", sans-serif;
  --font-text:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui,
    sans-serif;
  --ease-crafted: cubic-bezier(0.28, 0.11, 0.32, 1);
  color-scheme: light;
  font-family: var(--font-text);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow-x: hidden;
  color: var(--color-ink);
  background: var(--color-sky);
}

button,
input {
  font: inherit;
}

.login-shell {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-items: center;
  isolation: isolate;
  padding: clamp(16px, 4vw, 64px);
}

.workshop-scene {
  position: fixed;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(
      90deg,
      rgba(72, 190, 214, 0.04) 0%,
      rgba(72, 190, 214, 0.04) 44%,
      rgba(19, 43, 63, 0.18) 100%
    ),
    url("/assets/login-workshop.png") center / cover no-repeat;
}

.workshop-scene::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 246, 228, 0.04),
    rgba(19, 43, 63, 0.08)
  );
  content: "";
}

.login-tablet {
  position: relative;
  display: flex;
  width: min(100%, 520px);
  min-height: min(780px, calc(100svh - 32px));
  margin-left: min(34vw, 490px);
  padding: clamp(32px, 5vw, 64px);
  flex-direction: column;
  justify-content: center;
  border: 1px solid rgba(255, 246, 228, 0.18);
  border-radius: 24px;
  color: var(--color-paper);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025), rgba(0, 0, 0, 0.025)),
    var(--color-primary);
  box-shadow:
    0 24px 64px rgba(19, 43, 63, 0.28),
    inset 0 1px rgba(255, 246, 228, 0.18);
}

.login-tablet::before {
  position: absolute;
  z-index: -1;
  inset: 12px -10px -12px 10px;
  border-radius: 24px;
  background: var(--color-primary-active);
  box-shadow: 0 8px 0 rgba(19, 43, 63, 0.18);
  content: "";
}

.tablet-hinge {
  position: absolute;
  left: -28px;
  width: 48px;
  height: 88px;
  border: 1px solid rgba(255, 246, 228, 0.14);
  border-radius: 8px;
  background: var(--color-primary-hover);
  box-shadow:
    inset 0 0 0 4px rgba(15, 36, 57, 0.32),
    0 4px 0 rgba(19, 43, 63, 0.28);
}

.tablet-hinge::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ba8d3f;
  box-shadow:
    inset 0 2px 0 rgba(255, 246, 228, 0.32),
    0 2px 0 rgba(15, 36, 57, 0.5);
  content: "";
  transform: translate(-50%, -50%);
}

.tablet-hinge-top {
  top: 96px;
}

.tablet-hinge-bottom {
  bottom: 80px;
}

.login-header {
  margin-bottom: 32px;
  text-align: center;
}

.brand {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 2.25rem);
  line-height: 1.05;
}

form {
  display: grid;
  gap: 24px;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  font-size: 1rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--color-hairline);
  border-radius: 12px;
  outline: none;
  color: var(--color-ink);
  background: var(--color-paper);
  box-shadow: 0 4px 0 rgba(19, 43, 63, 0.18);
  transition:
    border-color 180ms var(--ease-crafted),
    box-shadow 180ms var(--ease-crafted);
}

input:focus-visible,
button:focus-visible {
  outline: 4px solid #f07a52;
  outline-offset: 3px;
}

input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.password-control {
  position: relative;
}

.password-control input {
  padding-right: 64px;
}

.visibility-button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  place-items: center;
  color: var(--color-ink);
  background: transparent;
  cursor: pointer;
}

.visibility-button span {
  position: relative;
  width: 24px;
  height: 16px;
  border: 2px solid currentcolor;
  border-radius: 50%;
}

.visibility-button span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentcolor;
  content: "";
  transform: translate(-50%, -50%);
}

.primary-button,
.secondary-button {
  min-height: 56px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background-color 180ms var(--ease-crafted),
    transform 180ms var(--ease-crafted),
    box-shadow 180ms var(--ease-crafted);
}

.primary-button {
  border: 0;
  color: var(--color-paper);
  background: var(--color-accent);
  box-shadow: 0 4px 0 rgba(19, 43, 63, 0.28);
}

.primary-button:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
}

.primary-button:active {
  background: var(--color-accent-active);
  box-shadow: 0 1px 0 rgba(19, 43, 63, 0.28);
  transform: translateY(2px);
}

.secondary-button {
  border: 2px solid var(--color-paper);
  color: var(--color-paper);
  background: transparent;
}

.secondary-button:hover {
  background: var(--color-primary-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.form-message {
  min-height: 24px;
  margin: -8px 0;
  color: #ffd7cb;
  font-weight: 700;
}

.form-message[data-kind="success"] {
  color: #bfe9cf;
}

.launch-state {
  text-align: center;
}

.launch-state p {
  margin: 0 0 24px;
  font-weight: 700;
}

.loading-track {
  position: relative;
  height: 16px;
  margin-bottom: 24px;
  overflow: hidden;
  border: 2px solid rgba(255, 246, 228, 0.48);
  border-radius: 8px;
  background: var(--color-primary-active);
}

.loading-track span {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 42%;
  border-radius: 4px;
  background: var(--color-accent);
}

@media (max-width: 1100px) {
  .workshop-scene {
    background-position: 40% center;
  }

  .login-tablet {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .login-shell {
    align-items: end;
    padding: 16px;
  }

  .workshop-scene {
    background-position: 27% center;
  }

  .workshop-scene::after {
    background: rgba(19, 43, 63, 0.28);
  }

  .login-tablet {
    display: block;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 32px 24px;
  }

  .tablet-hinge {
    display: none;
  }
}

@media (max-width: 390px) {
  .login-shell {
    padding: 8px;
  }

  .login-tablet {
    padding: 24px 16px;
    border-radius: 16px;
  }

  .login-tablet::before {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .login-tablet {
    animation: tablet-enter 320ms var(--ease-crafted) both;
  }

  .loading-track span {
    animation: loading-sweep 1.2s linear infinite;
  }

  @keyframes tablet-enter {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes loading-sweep {
    from {
      transform: translateX(-110%);
    }
    to {
      transform: translateX(245%);
    }
  }
}
