:root {
  --paper: #f7f1e7;
  --ink: #171a17;
  --sage-wash: #e3e9e1;
  --sage-deep: #cbd8cf;
  --jade: #4a7c6f;
  --vermilion: #c8423c;
  --paper-deep: #ece3d6;
  --line: #d9cfc0;
  --muted: #6f6a62;
  --quiet: #91897f;
  --white-ink: #f4ede2;
  --danger: #a8332f;
  --serif: "Iowan Old Style", "Noto Serif CJK SC", "Songti SC", STSong, serif;
  --sans: "Avenir Next", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(200, 66, 60, 0.35);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.login-page {
  display: grid;
  grid-template-columns: minmax(440px, 1.16fr) minmax(460px, 0.84fr);
  min-height: 100svh;
}

.brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  overflow: hidden;
  padding: clamp(36px, 5vw, 72px);
  background: linear-gradient(135deg, #eef3ee 0%, var(--sage-wash) 48%, #c3d4ca 100%);
  color: var(--ink);
  border-right: 1px solid rgba(74, 124, 111, 0.22);
}

.brand-panel::after {
  content: "";
  position: absolute;
  right: clamp(28px, 6vw, 92px);
  top: 0;
  width: 1px;
  height: 32%;
  background: rgba(74, 124, 111, 0.24);
}

.brand-panel__top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.brand-lockup {
  display: grid;
  gap: 3px;
  place-items: center;
  width: clamp(300px, 31vw, 430px);
  max-width: calc(100% - 110px);
  padding: 8px 20px;
  background: var(--paper);
  border-left: 3px solid var(--vermilion);
}

.brand-lockup__primary {
  display: block;
  width: 100%;
  height: auto;
}

.brand-lockup__motto {
  color: var(--vermilion);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .34em;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-index {
  color: rgba(23, 26, 23, 0.42);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.brand-statement {
  position: relative;
  z-index: 1;
  margin: auto 0;
  max-width: 680px;
  padding: clamp(44px, 7vh, 88px) 0;
}

.brand-statement__eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 26px;
  color: #456a60;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.brand-statement__eyebrow::before {
  content: "";
  width: 34px;
  height: 2px;
  background: var(--vermilion);
}

.brand-statement h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 4.3vw, 64px);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.055em;
}

.brand-statement > p:last-child {
  max-width: 540px;
  margin: 28px 0 0;
  color: rgba(23, 26, 23, 0.64);
  font-size: 15px;
  line-height: 1.95;
}

.brand-footer {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: start;
  gap: 14px;
}

.brand-principles {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  color: rgba(23, 26, 23, 0.58);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.brand-principles span + span::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 18px 3px;
  border-radius: 50%;
  background: var(--jade);
}

.icp-record {
  color: rgba(23, 26, 23, 0.58);
  font-size: 11px;
  line-height: 1.6;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 160ms ease;
}

.icp-record:hover {
  color: var(--ink);
}

.icp-record--mobile {
  display: none;
}

.auth-main {
  display: grid;
  min-height: 100svh;
  overflow-y: auto;
  place-items: center;
  padding: clamp(32px, 5vw, 76px);
  background: var(--paper);
}

.auth-card {
  width: min(100%, 440px);
  animation: enter-auth 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mobile-brand {
  display: none;
}

.auth-kicker {
  margin: 0 0 18px;
  color: var(--jade);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.auth-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 3vw, 46px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.045em;
}

.auth-subtitle {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.auth-rule {
  position: relative;
  width: 100%;
  height: 1px;
  margin: 32px 0;
  background: var(--line);
}

.auth-rule span {
  position: absolute;
  left: 0;
  top: -2px;
  width: 58px;
  height: 5px;
  background: var(--vermilion);
}

.auth-form[hidden] {
  display: none;
}

#currentPasswordField[hidden] {
  display: none;
}

.auth-form {
  display: grid;
  gap: 22px;
}

.field-group {
  display: grid;
  gap: 9px;
}

.field-group > label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.text-field {
  display: flex;
  align-items: stretch;
  min-height: 54px;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid var(--line);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.text-field:focus-within {
  background: rgba(255, 255, 255, 0.64);
  border-color: var(--jade);
  box-shadow: inset 3px 0 0 var(--jade);
}

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

.field-prefix {
  display: grid;
  place-items: center;
  min-width: 60px;
  color: var(--muted);
  font-size: 13px;
  border-right: 1px solid var(--line);
}

.text-field input {
  width: 100%;
  min-width: 0;
  padding: 0 16px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
}

.text-field input::placeholder {
  color: #9a9286;
}

.text-field input[readonly] {
  cursor: not-allowed;
  opacity: 0.62;
}

input:-webkit-autofill {
  animation-name: credential-autofill;
  animation-duration: 0.01s;
}

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

.password-toggle {
  flex: 0 0 auto;
  margin: 7px;
  padding: 0 10px;
  color: var(--jade);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.field-note {
  margin: 0;
  color: var(--quiet);
  font-size: 11px;
  line-height: 1.6;
}

.form-status {
  min-height: 20px;
  margin: -2px 0 -4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.form-status[data-tone="error"] {
  color: var(--danger);
}

.form-status[data-tone="success"] {
  color: var(--jade);
}

.primary-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 56px;
  padding: 0 17px 0 20px;
  overflow: hidden;
  color: #fff;
  background: var(--jade);
  border: 1px solid var(--jade);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--vermilion);
}

.primary-button:hover:not(:disabled) {
  background: #3f6f63;
  border-color: #3f6f63;
  transform: translateY(-1px);
}

.primary-button:active:not(:disabled) {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-arrow {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 400;
  transition: transform 150ms ease;
}

.primary-button:hover:not(:disabled) .button-arrow {
  transform: translateX(3px);
}

#loginButton {
  justify-content: center;
  padding-inline: 20px;
  border-radius: 5px;
  font-size: 16px;
  letter-spacing: 0.08em;
}

#loginButton::after {
  content: none;
}

.activation-form {
  gap: 20px;
}

.activation-intro {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 2px;
}

.activation-step {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
}

.activation-intro h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.activation-intro p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.account-chip {
  margin: 0;
  padding: 10px 13px;
  color: var(--muted);
  background: var(--paper-deep);
  border-left: 2px solid var(--jade);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.strength-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  height: 3px;
}

.strength-meter span {
  background: var(--line);
  transition: background 160ms ease;
}

.strength-meter[data-score="1"] span:nth-child(-n + 1),
.strength-meter[data-score="2"] span:nth-child(-n + 2) {
  background: var(--vermilion);
}

.strength-meter[data-score="3"] span:nth-child(-n + 3) {
  background: #9a7b42;
}

.strength-meter[data-score="4"] span:nth-child(-n + 4) {
  background: var(--jade);
}

.auth-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
  padding-top: 20px;
  color: var(--quiet);
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.auth-footer p {
  margin: 0;
  line-height: 1.6;
}

.security-mark {
  width: 7px;
  height: 7px;
  background: var(--jade);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(74, 124, 111, 0.13);
}

.noscript-message {
  padding: 12px;
  color: var(--danger);
  border: 1px solid var(--danger);
  font-size: 12px;
}

@keyframes enter-auth {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes credential-autofill {
  from { opacity: 0.99; }
  to { opacity: 1; }
}

@media (max-width: 960px) {
  .login-page {
    grid-template-columns: minmax(340px, 0.8fr) minmax(430px, 1.2fr);
  }

  .brand-panel {
    padding: 38px;
  }

  .brand-statement h1 {
    font-size: clamp(38px, 5.5vw, 54px);
  }

  .brand-principles {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .brand-principles span + span::before {
    display: none;
  }
}

@media (max-width: 760px) {
  .login-page {
    display: block;
  }

  .brand-panel {
    display: none;
  }

  .auth-footer {
    flex-wrap: wrap;
  }

  .icp-record--mobile {
    display: block;
    flex-basis: 100%;
    margin-left: 17px;
  }

  .auth-main {
    min-height: 100svh;
    padding: max(24px, env(safe-area-inset-top)) 28px max(24px, env(safe-area-inset-bottom));
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.2em;
  }

  .mobile-brand img {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 640px) {
  .auth-main {
    display: block;
    padding: max(18px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
  }

  .auth-card {
    max-width: none;
  }

  .mobile-brand {
    margin-bottom: 20px;
  }

  .auth-kicker {
    margin-bottom: 10px;
  }

  .auth-header h2 {
    font-size: 32px;
  }

  .auth-subtitle {
    margin-top: 10px;
    font-size: 13px;
  }

  .auth-rule {
    margin: 22px 0;
  }

  .auth-form {
    gap: 16px;
  }

  .text-field {
    min-height: 52px;
  }

  .primary-button {
    min-height: 54px;
  }

  .auth-footer {
    margin-top: 20px;
    padding-top: 15px;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .auth-main {
    place-items: start center;
    padding-top: 32px;
    padding-bottom: 32px;
  }

  .auth-rule {
    margin: 22px 0;
  }

  .auth-form {
    gap: 16px;
  }

  .auth-footer {
    margin-top: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
