:root {
  --ink: #0d1728;
  --ink-soft: #1f2b3f;
  --muted: #6f7c8f;
  --muted-strong: #4d5c72;
  --canvas: #e9eef2;
  --surface: #f8fafb;
  --paper: #fffdf7;
  --line: #d8e0e7;
  --line-strong: #c4cfda;
  --cobalt: #2f5bff;
  --cobalt-dark: #2346c7;
  --coral: #e76f51;
  --mint: #b9e3d0;
  --danger: #b53d32;
  --white: #ffffff;
  --shadow: 0 20px 50px rgba(13, 23, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 91, 255, 0.28);
  outline-offset: 2px;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(310px, 38%) minmax(0, 1fr);
}

.brand-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(34px + env(safe-area-inset-top)) 9% calc(30px + env(safe-area-inset-bottom));
  color: #dce6f2;
  background: var(--ink);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-lockup,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup {
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-lockup strong,
.mobile-brand strong {
  display: block;
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-lockup small,
.mobile-brand small {
  display: block;
  margin-top: 4px;
  color: #8ea0b8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 7px;
  border-radius: var(--radius);
  background: var(--coral);
  transform: rotate(-4deg);
}

.brand-mark > span {
  height: 2px;
  display: block;
  border-radius: 4px;
  background: var(--ink);
}

.brand-mark > span:nth-child(2) {
  width: 75%;
}

.brand-mark > span:nth-child(3) {
  width: 50%;
}

.brand-statement {
  position: relative;
  max-width: 440px;
  margin: auto 0;
  padding: 3px 0 5px 24px;
}

.brand-statement::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--coral);
}

.brand-kicker,
.eyebrow {
  margin: 0 0 16px;
  color: #8ea0b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  color: var(--white);
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: 0;
}

.brand-copy {
  max-width: 390px;
  margin: 22px 0 0;
  color: #9eacc0;
  font-size: 14px;
  line-height: 1.85;
}

.privacy-stamp {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #c6d3e3;
}

.privacy-stamp svg {
  width: 20px;
  height: 20px;
  color: var(--mint);
}

.privacy-stamp strong,
.privacy-stamp small {
  display: block;
}

.privacy-stamp strong {
  font-size: 12px;
}

.privacy-stamp small {
  margin-top: 2px;
  color: #71839a;
  font-size: 11px;
}

.auth-main {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: calc(36px + env(safe-area-inset-top)) max(28px, 7vw) calc(36px + env(safe-area-inset-bottom));
  background: var(--surface);
}

.auth-surface {
  width: min(100%, 440px);
}

.mobile-brand {
  display: none;
}

.auth-header {
  margin-bottom: 0;
}

.auth-header .eyebrow {
  margin-bottom: 10px;
  color: var(--cobalt);
}

.auth-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 850;
  line-height: 1.25;
  letter-spacing: 0;
}

.auth-header p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.setup-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 20px 0 0;
  padding: 10px 12px;
  color: #644d13;
  background: #fff6d9;
  border: 1px solid #ead995;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
}

.setup-notice svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.auth-form {
  display: grid;
  gap: 19px;
  margin-top: 28px;
}

.field-group {
  min-width: 0;
}

.create-confirmation {
  min-width: 0;
  display: grid;
  gap: 16px;
  padding: 15px;
  background: #eef3ff;
  border: 1px solid #c9d5f2;
  border-radius: var(--radius);
}

.confirmation-intro {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #344664;
}

.confirmation-intro > svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  margin-top: 1px;
  color: var(--cobalt);
}

.confirmation-intro strong {
  display: block;
  color: var(--ink-soft);
  font-size: 13px;
}

.confirmation-intro p {
  margin: 4px 0 0;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.field-group > label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 750;
}

.input-control {
  min-width: 0;
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-control:focus-within {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(47, 91, 255, 0.12);
}

.input-control.has-error {
  border-color: var(--danger);
}

.input-control > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #8795a8;
  stroke-width: 1.8;
}

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

.input-control input::placeholder {
  color: #98a5b5;
}

.input-control input:disabled {
  cursor: wait;
}

.password-control input {
  font-variant-numeric: tabular-nums;
}

.visibility-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  margin-right: -6px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.visibility-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--canvas);
}

.visibility-button svg {
  width: 18px;
  height: 18px;
}

.field-hint,
.field-error {
  min-height: 18px;
  margin: 5px 1px 0;
  font-size: 11px;
  line-height: 1.55;
}

.field-hint {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
  font-weight: 650;
}

.field-hint + .field-error {
  min-height: 0;
  margin-top: 0;
}

.pin-progress {
  height: 4px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin: 7px 1px 0;
}

.pin-progress span {
  background: var(--line);
  border-radius: 2px;
  transition: background-color 120ms ease;
}

.pin-progress span.is-filled {
  background: var(--cobalt);
}

.form-message {
  margin-top: -3px;
  padding: 11px 12px;
  color: #7f2d27;
  background: #fff0ee;
  border: 1px solid #efc2bd;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.6;
}

.form-message.is-info {
  color: #344664;
  background: #eef3ff;
  border-color: #c9d5f2;
}

.submit-button {
  min-height: 50px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  padding: 0 18px;
  color: var(--white);
  background: var(--cobalt);
  border: 1px solid var(--cobalt);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 9px 22px rgba(47, 91, 255, 0.18);
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--cobalt-dark);
  border-color: var(--cobalt-dark);
  transform: translateY(-1px);
}

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

.submit-button:disabled {
  cursor: wait;
  color: #7c899a;
  background: #d9e0e7;
  border-color: #d9e0e7;
  box-shadow: none;
}

.submit-ready,
.submit-busy {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.submit-ready svg,
.submit-busy svg {
  width: 17px;
  height: 17px;
}

.submit-busy svg {
  animation: spin 800ms linear infinite;
}

.auth-footnote {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.auth-footnote svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-top: 2px;
}

.admin-entry {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 2px 0;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.admin-entry > svg {
  width: 18px;
  height: 18px;
  color: var(--muted-strong);
}

.admin-entry > svg:last-child {
  width: 16px;
  height: 16px;
  justify-self: end;
  transition: transform 160ms ease;
}

.admin-entry strong,
.admin-entry small {
  display: block;
}

.admin-entry strong {
  font-size: 12px;
}

.admin-entry small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.admin-entry:hover {
  color: var(--cobalt-dark);
}

.admin-entry:hover > svg:last-child {
  transform: translateX(2px);
}

.connection-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.connection-status.is-warning {
  padding: 8px 10px;
  color: #7a4513;
  background: #fff4d8;
  border: 1px solid #ead399;
  border-radius: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .auth-layout {
    min-height: 100svh;
    display: block;
  }

  .brand-panel {
    display: none;
  }

  .auth-main {
    min-height: 100svh;
    display: block;
    padding: calc(23px + env(safe-area-inset-top)) max(20px, 6vw) calc(28px + env(safe-area-inset-bottom));
  }

  .auth-surface {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
  }

  .mobile-brand {
    display: flex;
    margin-bottom: 46px;
  }

  .mobile-brand strong {
    color: var(--ink);
  }

  .mobile-brand small {
    color: var(--muted);
  }

  .auth-header h1 {
    font-size: 27px;
  }

  .auth-form {
    gap: 17px;
    margin-top: 24px;
  }

  .input-control {
    min-height: 52px;
  }

  .input-control input {
    height: 50px;
    font-size: 16px;
  }

  .submit-button {
    min-height: 52px;
  }
}

@media (max-width: 370px) {
  .auth-main {
    padding-left: 16px;
    padding-right: 16px;
  }

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

@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;
  }
}
