:root {
  --paper: #f6f0e5;
  --card: #fffdf8;
  --ink: #183c31;
  --ink-2: #294f43;
  --muted: #76847e;
  --faint: #a3ada7;
  --line: rgba(29, 70, 56, 0.13);
  --green: #2caf79;
  --green-deep: #178b61;
  --orange: #f28b5f;
  --danger: #c65b49;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 90% 8%, rgba(242, 139, 95, 0.13), transparent 25rem),
    radial-gradient(circle at 7% 82%, rgba(44, 175, 121, 0.12), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.auth-header {
  display: flex;
  width: min(1180px, calc(100% - 44px));
  min-height: 78px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: #80e4b5;
  font-family: "STZhongsong", serif;
  font-size: 21px;
}

.auth-brand > span:last-child {
  display: flex;
  flex-direction: column;
}

.auth-brand strong {
  font-family: "STZhongsong", "Songti SC", serif;
  font-size: 19px;
}

.auth-brand small {
  color: var(--faint);
  font-size: 7px;
  letter-spacing: 0.13em;
}

.back-home {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--ink-2);
  font-size: 11px;
  text-decoration: none;
}

.auth-layout {
  display: grid;
  width: min(1180px, calc(100% - 44px));
  min-height: calc(100vh - 108px);
  margin: 0 auto 30px;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.82fr);
  gap: 22px;
}

.auth-story {
  position: relative;
  min-height: 650px;
  overflow: hidden;
  padding: clamp(38px, 5vw, 72px);
  border-radius: 30px;
  background:
    linear-gradient(145deg, #173f33 0%, #205c47 58%, #1a4638 100%);
  box-shadow: 0 28px 70px rgba(23, 58, 46, 0.2);
  color: #fff;
}

.auth-story .eyebrow,
.auth-card .eyebrow,
.terms-overlay .eyebrow {
  color: #80e4b5;
  font-family: ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.auth-story h1 {
  position: relative;
  z-index: 2;
  margin: 17px 0 16px;
  font-family: "STZhongsong", "Songti SC", serif;
  font-size: clamp(40px, 5vw, 66px);
  font-weight: 500;
  line-height: 1.17;
  letter-spacing: -0.04em;
}

.auth-story > p {
  position: relative;
  z-index: 2;
  max-width: 430px;
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  line-height: 1.8;
}

.eyebrow {
  color: var(--green-deep);
}

.story-points {
  position: relative;
  z-index: 3;
  display: grid;
  width: min(390px, 100%);
  gap: 8px;
  margin-top: 28px;
}

.story-points span {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.story-points b {
  color: #f3d36b;
  font-family: ui-monospace, monospace;
  font-size: 9px;
}

.story-orbit {
  position: absolute;
  border: 1px solid rgba(126, 225, 180, 0.16);
  border-radius: 50%;
}

.orbit-a {
  right: -170px;
  bottom: -120px;
  width: 430px;
  height: 430px;
}

.orbit-b {
  right: -105px;
  bottom: -55px;
  width: 295px;
  height: 295px;
  background: rgba(255, 230, 154, 0.06);
}

.story-paper {
  position: absolute;
  right: 5%;
  bottom: 8%;
  display: flex;
  width: 160px;
  height: 210px;
  padding: 22px;
  flex-direction: column;
  gap: 11px;
  border-radius: 12px;
  box-shadow: 0 22px 46px rgba(6, 28, 20, 0.26);
}

.paper-one {
  background: #f9dcb9;
  transform: rotate(8deg);
}

.paper-one i {
  height: 4px;
  border-radius: 99px;
  background: rgba(24, 60, 49, 0.28);
}

.paper-one i:first-child {
  width: 35%;
  height: 10px;
  background: #183c31;
}

.paper-two {
  right: 17%;
  bottom: 15%;
  background: #bdebd6;
  transform: rotate(-8deg);
}

.paper-two b {
  margin-top: 20px;
  color: rgba(24, 60, 49, 0.72);
  font-family: Georgia, serif;
  font-size: 30px;
}

.paper-two span {
  height: 5px;
  border-radius: 99px;
  background: rgba(24, 60, 49, 0.18);
}

.story-caption {
  position: absolute;
  z-index: 4;
  bottom: 25px;
  left: 30px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.story-caption strong {
  font-size: 11px;
}

.story-caption small {
  color: rgba(255, 255, 255, 0.48);
  font-size: 9px;
}

.auth-card {
  align-self: center;
  padding: 24px 28px 28px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 25px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 25px 65px rgba(36, 69, 57, 0.13);
  backdrop-filter: blur(18px);
}

.auth-tabs {
  display: grid;
  padding: 4px;
  grid-template-columns: 1fr 1fr;
  border-radius: 11px;
  background: #eceee7;
}

.auth-tabs button {
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tabs button.active {
  background: #fff;
  box-shadow: 0 5px 15px rgba(28, 65, 51, 0.09);
  color: var(--ink);
}

#register-panel,
#login-panel {
  padding-top: 22px;
}

#register-panel h2,
#login-panel h2 {
  margin: 8px 0 5px;
  font-family: "STZhongsong", "Songti SC", serif;
  font-size: 30px;
}

.auth-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 11px;
}

.auth-notice {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid rgba(44, 175, 121, 0.2);
  border-radius: 9px;
  background: #ecf9f1;
  color: var(--green-deep);
  font-size: 11px;
  cursor: pointer;
}

.invite-detected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #e8f7ee;
  color: var(--green-deep);
  font-size: 10px;
}

.invite-detected strong {
  font-size: 10px;
}

#register-form,
#login-form {
  display: grid;
  gap: 12px;
}

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

.auth-field > span {
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
}

.auth-field > span small {
  color: var(--faint);
  font-weight: 400;
}

.auth-field input {
  width: 100%;
  height: 43px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: 160ms ease;
}

.auth-field input:focus {
  border-color: rgba(44, 175, 121, 0.52);
  box-shadow: 0 0 0 3px rgba(44, 175, 121, 0.09);
}

.auth-field > small {
  color: var(--faint);
  font-size: 9px;
}

.auth-field > small.has-code {
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 700;
}

.auth-field > small.success {
  color: var(--green-deep);
}

.auth-field > small.error {
  color: var(--danger);
}

.code-row,
.password-row {
  display: flex;
  gap: 7px;
}

.code-row input,
.password-row input {
  min-width: 0;
  flex: 1;
}

.code-row button,
.password-toggle {
  min-width: 104px;
  border: 1px solid rgba(44, 175, 121, 0.24);
  border-radius: 9px;
  background: #edf8f1;
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.code-row button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.password-toggle {
  min-width: 58px;
  background: #f3f1eb;
  color: var(--muted);
}

.password-meter {
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8ebe5;
}

.password-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  transition: 180ms ease;
}

.password-meter i[data-strength="2"] {
  background: #e6b84c;
}

.password-meter i[data-strength="3"] {
  background: var(--green);
}

.terms-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.terms-row input {
  accent-color: var(--green-deep);
}

.terms-row button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green-deep);
  font-size: 10px;
  cursor: pointer;
}

.auth-error {
  min-height: 16px;
  margin: -2px 0;
  color: var(--danger);
  font-size: 10px;
}

.auth-submit {
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(22, 56, 45, 0.18);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.6;
}

.switch-auth {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.forgot-password {
  width: max-content;
  margin: -4px 0 0 auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--green-deep);
  font-size: 10px;
  cursor: pointer;
}

.terms-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
}

.terms-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(12, 38, 29, 0.64);
  backdrop-filter: blur(8px);
}

.terms-overlay > section {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100% - 28px));
  padding: 18px;
  border-radius: 20px;
  background: #fffdf8;
  box-shadow: 0 28px 80px rgba(10, 35, 27, 0.3);
}

.terms-overlay header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terms-overlay h2 {
  margin: 0;
  font-family: "STZhongsong", serif;
  font-size: 24px;
}

.terms-overlay header button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #eef2ec;
  font-size: 20px;
  cursor: pointer;
}

#terms-copy {
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.85;
}

.terms-overlay footer {
  text-align: right;
}

.terms-overlay footer button {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

.auth-toast {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 22px;
  max-width: 340px;
  padding: 11px 15px;
  border-radius: 10px;
  background: rgba(20, 54, 44, 0.95);
  color: #fff;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

.auth-toast.show {
  opacity: 1;
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .auth-header,
  .auth-layout {
    width: min(620px, calc(100% - 22px));
  }

  .auth-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .auth-story {
    min-height: 250px;
    padding: 28px;
  }

  .auth-story h1 {
    font-size: 37px;
  }

  .auth-story > p {
    max-width: 330px;
  }

  .story-points {
    display: none;
  }

  .story-paper {
    right: 3%;
    bottom: -18%;
    transform: scale(0.72) rotate(8deg);
  }

  .paper-two {
    right: 16%;
    bottom: -5%;
    transform: scale(0.72) rotate(-8deg);
  }

  .story-caption {
    display: none;
  }

  .auth-card {
    margin-top: -36px;
    padding: 22px 18px 24px;
  }
}

@media (max-width: 520px) {
  .auth-header {
    min-height: 64px;
  }

  .auth-story {
    min-height: 220px;
    border-radius: 23px;
  }

  .auth-story h1 {
    font-size: 31px;
  }

  .auth-story > p {
    font-size: 11px;
  }

  .auth-card {
    border-radius: 20px;
  }

  .code-row {
    flex-direction: column;
  }

  .code-row button {
    height: 38px;
  }

  .auth-toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }
}
