:root {
  --paper: #fff9e9;
  --cream: #fffef8;
  --yellow: #e7be3d;
  --yellow-deep: #9e7312;
  --yellow-soft: #fff0b4;
  --blue: #6babc0;
  --blue-soft: #e4f3f8;
  --ink: #393227;
  --muted: #8d816d;
  --line: rgba(92, 75, 41, 0.12);
  --serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 95% 5%, rgba(99, 177, 202, 0.15), transparent 23rem),
    radial-gradient(circle at 8% 90%, rgba(231, 190, 61, 0.2), transparent 25rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(198, 151, 25, 0.3);
  outline-offset: 2px;
}

.login-layout {
  width: min(1100px, calc(100% - 48px));
  min-height: min(700px, calc(100vh - 64px));
  margin: 32px auto;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  overflow: hidden;
  background: rgba(255, 254, 248, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  box-shadow: 0 30px 80px rgba(105, 80, 25, 0.15);
}

.login-story {
  position: relative;
  min-height: 640px;
  padding: 34px 38px 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fffdf6;
  background:
    radial-gradient(circle at 82% 17%, rgba(101, 176, 200, 0.62) 0 7%, rgba(101, 176, 200, 0.1) 7.5% 23%, transparent 36%),
    linear-gradient(145deg, #91680f, #bc8b1d 54%, #d9ae37);
}

.login-story::after {
  position: absolute;
  right: -100px;
  bottom: -150px;
  width: 390px;
  height: 390px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  box-shadow:
    0 0 0 36px rgba(255, 255, 255, 0.035),
    0 0 0 78px rgba(255, 255, 255, 0.025);
  content: "";
}

.login-brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 11px;
  align-self: flex-start;
  color: #fffdf6;
  text-decoration: none;
}

.login-brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #936c14;
  background: #fff1b2;
  border-radius: 12px 12px 12px 4px;
  font-size: 18px;
  transform: rotate(-3deg);
}

.login-brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.08em;
}

.login-brand small {
  display: block;
  margin-top: 5px;
  color: rgba(255, 253, 246, 0.55);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.story-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: 104px;
  right: 74px;
  width: 42px;
  height: 42px;
  background: rgba(255, 239, 168, 0.76);
  border-radius: 50%;
  box-shadow: 0 0 0 13px rgba(255, 239, 168, 0.08);
}

.cloud {
  position: absolute;
  width: 82px;
  height: 20px;
  background: rgba(227, 244, 249, 0.36);
  border-radius: 99px;
}

.cloud::before,
.cloud::after {
  position: absolute;
  bottom: 0;
  background: inherit;
  border-radius: 50%;
  content: "";
}

.cloud::before {
  left: 16px;
  width: 36px;
  height: 36px;
}

.cloud::after {
  right: 15px;
  width: 26px;
  height: 26px;
}

.cloud-one {
  top: 190px;
  right: 30px;
  transform: scale(0.8);
}

.cloud-two {
  top: 270px;
  left: 36px;
  opacity: 0.55;
  transform: scale(0.48);
}

.hill {
  position: absolute;
  right: -14%;
  bottom: 66px;
  left: -14%;
  height: 190px;
  border-radius: 50% 50% 0 0;
  transform: rotate(-5deg);
}

.hill-one {
  background: rgba(106, 167, 183, 0.16);
}

.hill-two {
  bottom: -54px;
  background: rgba(81, 141, 157, 0.16);
  transform: rotate(7deg);
}

.story-copy {
  position: relative;
  z-index: 2;
  margin-top: auto;
  margin-bottom: 78px;
}

.story-kicker {
  margin: 0 0 13px;
  color: rgba(255, 253, 246, 0.56);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.story-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(27px, 3vw, 39px);
  font-weight: 500;
  line-height: 1.48;
  letter-spacing: 0.02em;
}

.story-copy > p:last-child {
  margin: 17px 0 0;
  color: rgba(255, 253, 246, 0.64);
  font-size: 11px;
  line-height: 1.85;
}

.story-foot {
  position: relative;
  z-index: 2;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 253, 246, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.login-panel {
  padding: 34px 54px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.back-link {
  margin-bottom: auto;
  align-self: flex-start;
  color: var(--muted);
  font-size: 9px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--yellow-deep);
}

.existing-session {
  margin-top: 58px;
  padding: 23px;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 12%, rgba(103, 177, 200, 0.16), transparent 9rem),
    linear-gradient(135deg, #fff4c8, #fffdf5);
  border: 1px solid rgba(202, 157, 34, 0.22);
  border-radius: 17px;
  box-shadow: 0 13px 35px rgba(110, 80, 17, 0.08);
}

.existing-session-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 17px;
  display: grid;
  place-items: center;
  color: #fffdf5;
  background: #72a779;
  border-radius: 50%;
  font-size: 18px;
}

.existing-session h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
}

.existing-session > p:nth-of-type(2) {
  margin: 9px 0 0;
  color: #8a7a58;
  font-size: 9px;
  line-height: 1.7;
}

.existing-session-actions {
  margin-top: 18px;
  display: flex;
  gap: 9px;
}

.existing-session-actions button {
  min-height: 39px;
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 9px;
}

#continue-session {
  color: #49380f;
  background: #efc64d;
  border: 1px solid #d7a82b;
  font-weight: 600;
}

#switch-session {
  color: #796b51;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(119, 99, 54, 0.16);
}

.panel-head {
  margin-top: 22px;
}

.panel-eyebrow {
  margin: 0 0 9px;
  color: var(--yellow-deep);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.35;
}

.panel-head > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.auth-switch {
  margin-top: 28px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f8f0d9;
  border-radius: 12px;
}

.auth-switch button {
  height: 37px;
  color: #948262;
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 10px;
}

.auth-switch button.is-active {
  color: #675111;
  background: var(--cream);
  box-shadow: 0 5px 14px rgba(104, 77, 18, 0.08);
  font-weight: 600;
}

#login-form {
  margin-top: 20px;
}

.field {
  display: block;
}

.field + .field {
  margin-top: 14px;
}

.field > span:first-child {
  display: block;
  margin-bottom: 7px;
  color: #776b56;
  font-size: 9px;
}

.field em {
  margin-left: 5px;
  color: #a79980;
  font-style: normal;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.86);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  font-size: 11px;
}

.field input:focus {
  background: #fffef9;
  border-color: rgba(192, 146, 23, 0.45);
  box-shadow: 0 0 0 3px rgba(231, 190, 61, 0.11);
}

.field input::placeholder {
  color: #b3a792;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 55px;
}

.password-wrap button {
  position: absolute;
  top: 50%;
  right: 11px;
  padding: 5px;
  color: #9b7618;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 8px;
  transform: translateY(-50%);
}

.password-strength {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.password-strength > span {
  width: 92px;
  height: 4px;
  overflow: hidden;
  background: #efe6d2;
  border-radius: 99px;
}

.password-strength i {
  width: 8%;
  height: 100%;
  display: block;
  background: #d7a52b;
  border-radius: inherit;
  transition: width 180ms ease, background 180ms ease;
}

.password-strength i[data-score="3"] {
  background: #80a75f;
}

.password-strength i[data-score="4"] {
  background: #5e9e72;
}

.password-strength small {
  color: #a09278;
  font-size: 8px;
}

.forgot-password {
  margin: 8px 0 0 auto;
  padding: 2px 0;
  display: block;
  color: #8c6a13;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 8px;
}

.forgot-password:hover {
  color: #5f470d;
  text-decoration: underline;
}

.reset-help {
  margin: 10px 0 0;
  padding: 10px 11px;
  color: #857454;
  background: #fff8df;
  border: 1px solid rgba(199, 154, 35, 0.18);
  border-radius: 9px;
  font-size: 8px;
  line-height: 1.65;
}

.is-hidden {
  display: none !important;
}

.form-message {
  display: none;
  margin: 12px 0 0;
  padding: 9px 11px;
  color: #985248;
  background: #fff0ea;
  border-radius: 9px;
  font-size: 9px;
  line-height: 1.55;
}

.form-message.is-visible {
  display: block;
}

.form-message.is-success {
  color: #3e7052;
  background: #edf8ee;
}

.submit-button {
  width: 100%;
  height: 44px;
  margin-top: 17px;
  color: #433615;
  background: linear-gradient(135deg, #ecc443, #f6d66d);
  border: 1px solid #d8ab2c;
  border-radius: 11px;
  box-shadow: 0 9px 20px rgba(182, 133, 20, 0.18);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.submit-button:hover {
  background: linear-gradient(135deg, #dfb22f, #efc94f);
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.back-to-login {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  color: #87775a;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 9px;
}

.recovery-result {
  padding: 22px;
  background:
    radial-gradient(circle at 90% 10%, rgba(105, 178, 201, 0.16), transparent 9rem),
    linear-gradient(135deg, #fff1b7, #fffdf5);
  border: 1px solid rgba(204, 159, 35, 0.24);
  border-radius: 17px;
  box-shadow: 0 13px 35px rgba(116, 80, 12, 0.09);
}

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

.recovery-result > p:nth-of-type(2) {
  margin: 9px 0 0;
  color: #897754;
  font-size: 9px;
  line-height: 1.7;
}

.recovery-result code {
  margin: 18px 0;
  padding: 15px;
  display: block;
  color: #67500f;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(168, 122, 16, 0.35);
  border-radius: 11px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
}

.recovery-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recovery-actions button,
.recovery-actions a {
  min-height: 35px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 9px;
  text-decoration: none;
}

.recovery-actions button {
  color: #6c5311;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(177, 132, 20, 0.25);
  cursor: pointer;
}

.recovery-actions a {
  margin-left: auto;
  color: #fffdf6;
  background: #ad8019;
  border: 1px solid #9e7414;
}

.privacy-note {
  margin: 15px 0 0;
  color: #9a8d76;
  font-size: 8px;
  line-height: 1.6;
  text-align: center;
}

.mobile-switch {
  display: none;
}

@media (max-width: 780px) {
  body {
    background:
      radial-gradient(circle at 96% 2%, rgba(90, 171, 198, 0.18), transparent 15rem),
      radial-gradient(circle at 4% 80%, rgba(243, 201, 72, 0.2), transparent 16rem),
      var(--paper);
  }

  .login-layout {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    display: block;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .login-story {
    min-height: 230px;
    padding: calc(22px + env(safe-area-inset-top)) 22px 24px;
    border-radius: 0 0 28px 28px;
  }

  .login-brand-mark {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .login-brand strong {
    font-size: 17px;
  }

  .story-copy {
    margin: 38px 0 0;
  }

  .story-copy h1 {
    font-size: 24px;
    line-height: 1.4;
  }

  .story-copy > p:last-child,
  .story-foot {
    display: none;
  }

  .sun {
    top: 75px;
    right: 35px;
    transform: scale(0.75);
  }

  .hill {
    bottom: -35px;
    height: 120px;
  }

  .login-panel {
    padding: 22px 22px calc(30px + env(safe-area-inset-bottom));
    display: block;
  }

  .back-link {
    float: right;
    margin: 0;
  }

  .panel-head {
    margin-top: 9px;
  }

  .panel-head h2 {
    font-size: 23px;
  }

  .auth-switch {
    margin-top: 19px;
  }

  #login-form {
    margin-top: 16px;
  }

  .mobile-switch {
    width: 100%;
    margin-top: 16px;
    display: block;
    color: #8d6c16;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 9px;
  }

  .recovery-result {
    margin-top: 20px;
    padding: 18px;
  }

  .recovery-result code {
    font-size: 14px;
    letter-spacing: 0.08em;
  }

  .recovery-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .recovery-actions a {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
