:root {
  color-scheme: light;
  --page: #f7f7f8;
  --surface: #fff;
  --ink: #18181b;
  --label: #27272a;
  --muted: #606068;
  --border: #e5e5e5;
  --line: #e4e4e7;
  --primary: #18181b;
  --primary-hover: #303036;
  --focus: #71717a;
  --subtle: #f4f4f5;
  --focus-fill: #71717a1f;
  --card-shadow: 0 1px 3px #18181b1a, 0 1px 2px -1px #18181b1a;
  font: 15px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--page);
}

.app-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 25px;
  border-radius: 4px;
  background: var(--primary);
  color: var(--surface);
  font-size: 17px;
}

.login-area {
  display: grid;
  place-items: center;
  padding: clamp(20px, 6vh, 64px) 16px;
  position: relative;
  isolation: isolate;
  overflow: clip;
}

.login-area::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: clamp(900px, 100%, 1680px);
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  background: url('/account/login-schedule.webp') center / 100% 100% no-repeat;
  /* Hide the header and fade the chart away from the form and viewport edges. */
  mask-image:
    linear-gradient(to right, transparent, #000 12% 26%, transparent 44% 56%, #000 74% 88%, transparent),
    linear-gradient(to bottom, transparent 13%, #000 21% 79%, transparent 98%);
  mask-composite: intersect;
  filter: grayscale(1) brightness(.72) blur(.3px);
  opacity: .58;
  pointer-events: none;
}

.login-card {
  --inset: 24px;
  width: min(100%, 384px);
  min-width: 0;
  padding: 24px var(--inset);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.login-heading h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
}

.login-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 20px; }

.notice {
  margin: 18px 0 0;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 4px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
}

.login-form { display: grid; gap: 24px; margin-block-start: 24px; }
.notice + .login-form { margin-block-start: 16px; }
.code-form { display: grid; gap: 24px; }
.code-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 20px; }
.field { display: grid; gap: 10px; }
.field-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
}

label { color: var(--label); font-size: 14px; line-height: 20px; font-weight: 500; }
input, button { font: inherit; }
button { cursor: pointer; }

.link {
  min-height: 20px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  line-height: 20px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.link:hover, .login-footer .link { text-decoration: underline; }

input:not([type="hidden"]), :is(.password, .code-field) {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

input:not([type="hidden"]) {
  min-height: 36px;
  padding: 4px 12px;
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}

#username, #email, .password, .code-field {
  --field-shadow: 0 1px 2px #18181b0d;
  box-shadow: var(--field-shadow);
}
input::placeholder { color: var(--muted); opacity: 1; }
:is(#username, #email, .password, .code-field):hover { border-color: var(--muted); }

:is(#username, #email):focus, :is(.password, .code-field):focus-within {
  --field-shadow: 0 0 0 3px var(--focus-fill);
  border-color: var(--focus);
  outline: none;
}

:is(.password, .code-field) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
:is(.password, .code-field) input { min-height: 34px; border: 0; outline: 0; }
.code-field input:disabled { opacity: 1; }

/* Chrome 的自动填充背景优先于普通背景色。 */
:is(#username, #password, #email):is(:autofill, :-webkit-autofill) {
  box-shadow: inset 0 0 0 100px var(--surface);
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
}

:is(#username, #email):is(:autofill, :-webkit-autofill) {
  box-shadow: inset 0 0 0 100px var(--surface), var(--field-shadow);
}

:is(.password, .code-field) button {
  min-height: 28px;
  margin-inline-end: 2px;
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

:is(.password, .code-field) button:hover { background: var(--subtle); color: var(--ink); }
:is(.password, .code-field) button:focus-visible { outline-offset: -1px; }
.code-field button { color: var(--primary); }

.login-actions { display: grid; gap: 12px; }

.login-actions > button {
  width: 100%;
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.submit { background: var(--primary); color: #fff; }
.submit:hover { background: var(--primary-hover); }
.submit:active { background: var(--ink); }

.login-actions > :is(.qr-placeholder, .submit):disabled {
  border-color: var(--border);
  background: var(--subtle);
  color: #71717a;
  cursor: not-allowed;
}

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

.login-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 5px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.login-footer .link { color: inherit; }

.account-help {
  width: min(400px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px #18181b24;
}

.account-help::backdrop { background: #18181b4d; }
.account-help h2 { margin: 0; font-size: 18px; font-weight: 600; }
.account-help p { margin: 9px 0 20px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.account-help form { display: flex; justify-content: flex-end; }

.close-help {
  min-height: 34px;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.close-help:hover { background: var(--subtle); }

@media (max-width: 680px) {
  .login-area {
    align-items: start;
    padding-block-start: clamp(24px, 12vh, 90px);
    padding-block-start: clamp(24px, 12svh, 90px);
  }
  .login-area::before {
    content: none;
  }
}
