/* ============================================================
   玉米code — authentication surface
   Continues the paper / ink / maize brand system.
   ============================================================ */

body[data-page="auth"] {
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

body[data-page="auth"] [hidden] {
  display: none !important;
}

.auth-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
  padding: 0 clamp(20px, 4.2vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.auth-header .brand {
  gap: 9px;
}

.auth-header .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.auth-header .brand-word {
  font-size: 20px;
}

.auth-header .brand-code {
  font-size: 12px;
}

.auth-header-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 12.5px;
  color: var(--muted);
}

.auth-header-nav a {
  text-decoration: none;
  transition: color 0.18s var(--ease);
}

.auth-header-nav a:hover {
  color: var(--ink);
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink) !important;
}

.auth-back:hover {
  border-color: var(--ink);
}

.auth-main {
  display: grid;
  grid-template-columns: minmax(420px, 44%) minmax(0, 1fr);
  height: calc(100dvh - 72px);
}

/* ---------------------------------------------------------- art panel */
.auth-art {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(34px, 4.6vw, 64px) clamp(30px, 4vw, 58px);
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
}

.auth-art-glow {
  position: absolute;
  left: 12%;
  top: 18%;
  width: 560px;
  height: 560px;
  display: none;
  pointer-events: none;
}

.auth-art-top {
  position: relative;
  font: 10px/1 var(--mono);
  letter-spacing: 0.24em;
  color: rgba(242, 243, 233, 0.4);
}

.auth-art-copy {
  position: relative;
  margin-top: clamp(46px, 8vh, 96px);
  max-width: 520px;
}

.auth-art-copy .eyebrow {
  color: rgba(242, 243, 233, 0.55);
}

.auth-art-copy h1 {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: clamp(44px, 4.6vw, 68px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.auth-art-copy > p:last-child {
  margin-top: 22px;
  max-width: 42ch;
  font-size: 14px;
  line-height: 1.9;
  color: rgba(242, 243, 233, 0.62);
}

.auth-ledger {
  position: relative;
  margin-top: clamp(28px, 5vh, 54px);
  max-width: 520px;
  border: 1px solid rgba(242, 243, 233, 0.14);
  border-top: 2px solid var(--maize);
  background: rgba(0, 0, 0, 0.22);
}

.auth-ledger-head,
.auth-ledger-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.14em;
  color: rgba(242, 243, 233, 0.46);
}

.auth-ledger-head {
  border-bottom: 1px solid rgba(242, 243, 233, 0.1);
}

.auth-ledger-head .ok {
  color: var(--sage);
}

.auth-ledger pre {
  margin: 0;
  padding: 16px;
  overflow: hidden;
  font: 11.5px/1.85 var(--mono);
  color: rgba(242, 243, 233, 0.78);
  white-space: pre-wrap;
}

.auth-ledger .tok-key { color: rgba(242, 200, 75, 0.75); }
.auth-ledger .tok-str { color: #b7cf9f; }
.auth-ledger .tok-num { color: #f7de96; }
.auth-ledger .tok-method { color: var(--maize); }

.auth-ledger-foot {
  border-top: 1px solid rgba(242, 243, 233, 0.1);
  letter-spacing: 0.08em;
}

.auth-art-foot {
  position: relative;
  display: flex;
  gap: 26px;
  margin-top: auto;
  padding-top: 30px;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.2em;
  color: rgba(242, 243, 233, 0.34);
}

.auth-watermark {
  position: absolute;
  right: -34px;
  bottom: -96px;
  font-family: var(--serif);
  font-size: 420px;
  line-height: 1;
  font-weight: 600;
  color: rgba(242, 200, 75, 0.05);
  pointer-events: none;
  user-select: none;
}

/* ---------------------------------------------------------- form panel */
.auth-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: var(--paper);
}

.auth-panel-inner {
  width: 100%;
  max-width: 496px;
  margin: auto;
  padding: clamp(34px, 5.4vw, 64px) clamp(22px, 4vw, 40px) 30px;
}

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

.auth-view {
  animation: auth-view-in 0.45s var(--ease) both;
}

.auth-kicker {
  font: 10px/1 var(--mono);
  letter-spacing: 0.24em;
  color: var(--maize-deep);
}

.auth-view h2 {
  margin-top: 14px;
  font-family: var(--serif);
  font-size: clamp(34px, 3.4vw, 44px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.auth-sub {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.demo-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(242, 200, 75, 0.1);
}

.demo-strip strong,
.demo-strip span {
  display: block;
}

.demo-strip strong {
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.demo-strip span {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.mini-btn {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 2px;
  font-size: 11px;
  color: var(--ink);
}

.mini-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.form-alert {
  margin-top: 18px;
  padding: 11px 14px;
  border: 1px solid rgba(138, 47, 29, 0.35);
  background: rgba(138, 47, 29, 0.06);
  color: #7c2c1c;
  font-size: 12px;
  line-height: 1.7;
}

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

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field label,
.field-top label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

.field label em {
  font-style: normal;
  color: var(--maize-deep);
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fbfbf6;
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.field input::placeholder {
  color: var(--muted-2);
}

.field input:hover {
  border-color: rgba(27, 30, 26, 0.48);
}

.field input:focus {
  outline: 0;
  border-color: var(--ink);
  background: #fffdf4;
  box-shadow: 0 0 0 3px rgba(242, 200, 75, 0.22);
}

.field.has-error input {
  border-color: #9a3a26;
  background: rgba(154, 58, 38, 0.04);
}

.field-hint {
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

.field-error {
  min-height: 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: #8a2f1d;
}

.field-error:empty {
  display: none;
}

.field-toggle {
  font-size: 10.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  border: 0;
  background: transparent;
  padding: 0;
}

.field-toggle:hover {
  color: var(--ink);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  margin-top: 2px;
  accent-color: var(--ink);
  flex: none;
}

.text-link {
  font-size: 11.5px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  border: 0;
  background: transparent;
  padding: 0;
}

.text-link:hover {
  color: var(--maize-deep);
}

.auth-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 50px;
  margin-top: 4px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.18s var(--ease), opacity 0.18s var(--ease);
}

.auth-submit:hover {
  background: var(--ink-3);
}

.auth-submit:disabled,
.auth-submit[aria-busy="true"] {
  opacity: 0.6;
  cursor: wait;
}

.auth-submit.is-loading .od-icon {
  animation: auth-arrow 0.9s linear infinite;
}

.auth-submit.as-link {
  margin-top: 20px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0 16px;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.18em;
  color: var(--muted-2);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.oauth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.oauth-btn {
  height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 2px;
  font-size: 11.5px;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.oauth-btn:hover {
  border-color: var(--ink);
  background: var(--paper-2);
}

.passkey-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.passkey-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.passkey-btn span {
  font: 8.5px/1 var(--mono);
  letter-spacing: 0.12em;
  color: var(--maize-deep);
  border: 1px solid rgba(138, 97, 16, 0.35);
  padding: 2px 4px;
}

.auth-switch {
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted);
}

.auth-switch a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-legal {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.75;
  color: var(--muted-2);
}

.policy-note {
  position: relative;
  margin-top: 22px;
  padding: 14px 16px 14px 18px;
  border: 1px solid rgba(138, 97, 16, 0.28);
  background: rgba(242, 200, 75, 0.13);
}

.policy-note::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 18px;
  width: 6px;
  height: 6px;
  background: var(--maize-deep);
}

.policy-note strong {
  display: block;
  padding-left: 16px;
  font-size: 11.5px;
}

.policy-note p {
  margin-top: 4px;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.strength {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 2px;
}

.strength i {
  height: 2px;
  background: var(--line);
  transition: background-color 0.2s var(--ease);
}

.strength[data-level="1"] i:nth-child(-n + 1) { background: #9a3a26; }
.strength[data-level="2"] i:nth-child(-n + 2) { background: #c08a20; }
.strength[data-level="3"] i:nth-child(-n + 3) { background: var(--sage); }
.strength[data-level="4"] i { background: var(--sage-deep); }

.auth-success {
  margin-top: 26px;
  padding: 26px 24px;
  border: 1px solid var(--line);
  background: #fbfbf6;
  text-align: center;
}

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

.success-mark {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--paper);
}

.auth-success h3 {
  margin-top: 14px;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
}

.auth-success p {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
}

.otp-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.otp-fieldset legend {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 10px;
}

.otp-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.otp-inputs input {
  width: 52px;
  height: 62px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fbfbf6;
  text-align: center;
  font: 24px/1 var(--mono);
  color: var(--ink);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.otp-inputs input:focus {
  outline: 0;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(242, 200, 75, 0.24);
}

.otp-inputs input.is-error {
  border-color: #9a3a26;
  background: rgba(154, 58, 38, 0.04);
}

.otp-gap {
  width: 12px;
  height: 1px;
  background: var(--line-strong);
  flex: none;
}

.otp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.otp-actions .text-link:disabled {
  color: var(--muted-2);
  text-decoration: none;
  cursor: default;
}

.auth-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px clamp(22px, 4vw, 40px) 22px;
  font: 9.5px/1.6 var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted-2);
}

.auth-panel-foot span:last-child {
  display: flex;
  gap: 16px;
}

.auth-panel-foot a {
  color: var(--muted);
  text-decoration: none;
}

.auth-panel-foot a:hover {
  color: var(--ink);
}

.auth-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  transform: translate(-50%, 16px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.6;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.auth-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes auth-view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes auth-arrow {
  to { transform: translateX(4px); }
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .auth-main {
    grid-template-columns: minmax(380px, 42%) minmax(0, 1fr);
  }

  .auth-ledger {
    display: none;
  }

  .auth-art-copy {
    margin-top: 40px;
  }
}

@media (max-width: 900px) {
  body[data-page="auth"] {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .auth-main {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: calc(100dvh - 72px);
  }

  .auth-art {
    min-height: 210px;
    padding: 30px 24px;
  }

  .auth-art-copy {
    margin-top: 24px;
  }

  .auth-art-copy h1 {
    font-size: 36px;
  }

  .auth-art-copy > p:last-child,
  .auth-art-foot,
  .auth-watermark {
    display: none;
  }

  .auth-panel {
    overflow: visible;
    background: var(--paper);
  }

  .auth-panel-inner {
    margin: 0 auto;
    padding: 34px 24px 24px;
  }

  .auth-panel-foot {
    padding: 18px 24px 26px;
  }
}

@media (max-width: 560px) {
  .auth-header {
    height: 62px;
    padding: 0 18px;
  }

  .auth-header-nav a:not(.auth-back) {
    display: none;
  }

  .auth-header-nav {
    gap: 12px;
  }

  .auth-main {
    min-height: calc(100dvh - 62px);
  }

  .auth-art {
    min-height: 172px;
    padding: 24px 20px;
  }

  .auth-art-top {
    font-size: 9px;
  }

  .auth-art-copy {
    margin-top: 18px;
  }

  .auth-art-copy .eyebrow {
    display: none;
  }

  .auth-art-copy h1 {
    margin-top: 0;
    font-size: 29px;
    line-height: 1.14;
  }

  .auth-panel-inner {
    padding: 28px 20px 22px;
  }

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

  .otp-inputs input {
    width: 44px;
    height: 56px;
    font-size: 21px;
  }

  .otp-gap {
    width: 6px;
  }

  .auth-panel-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 20px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-view,
  .auth-submit.is-loading .od-icon {
    animation: none;
  }

  .auth-toast {
    transition: opacity 0.01s linear;
  }
}
