:root {
  color: #f4f8fb;
  background: #06111d;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #f4f8fb;
  --muted: #8fa4b6;
  --line: rgba(166, 205, 220, 0.16);
  --panel: rgba(8, 24, 38, 0.88);
  --field: rgba(2, 14, 25, 0.62);
  --cyan: #65e6ee;
  --cyan-strong: #9af7f5;
  --danger: #ff8f9e;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #06111d; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 32px;
  background: linear-gradient(90deg, rgba(5, 17, 30, 0.2), rgba(5, 17, 30, 0.94) 72%), #06111d;
  isolation: isolate;
}

.login-body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background: url("./images/yaochi-quantum-logo.png") center / contain no-repeat;
  opacity: 0.18;
  filter: saturate(0.86) contrast(1.06);
}

.login-body::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background: linear-gradient(180deg, rgba(4, 14, 26, 0.08), #06111d 96%), linear-gradient(90deg, rgba(4, 14, 26, 0.08), rgba(4, 14, 26, 0.82));
}

.particles, .login-glow { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.login-glow { background: radial-gradient(circle at 73% 48%, rgba(101, 230, 238, 0.1), transparent 30%); }
.particle { position: absolute; border-radius: 50%; background: rgba(205, 250, 255, 0.8); box-shadow: 0 0 8px rgba(101, 230, 238, 0.55); animation: float-up linear infinite; }

@keyframes float-up {
  0% { opacity: 0; transform: translateY(0); }
  12% { opacity: 0.7; }
  100% { opacity: 0; transform: translateY(-110vh); }
}

.auth-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(360px, 440px);
  grid-template-rows: auto auto auto;
  align-content: center;
  column-gap: clamp(44px, 7vw, 96px);
  width: min(980px, 100%);
  min-height: 560px;
  padding: clamp(34px, 4vw, 52px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(112deg, rgba(7, 21, 35, 0.5) 0 49%, var(--panel) 49% 100%);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(24px);
}

.auth-card::before { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; content: ""; background: linear-gradient(transparent, var(--line) 18%, var(--line) 82%, transparent); }

.auth-logo {
  grid-column: 1;
  grid-row: 1 / 4;
  align-self: center;
  width: min(320px, 100%);
  aspect-ratio: 1;
  margin: auto auto 18px;
  overflow: hidden;
  border-radius: 50%;
  filter: drop-shadow(0 22px 44px rgba(0, 0, 0, 0.34));
  mask-image: radial-gradient(circle, #000 57%, rgba(0, 0, 0, 0.96) 65%, transparent 74%);
  -webkit-mask-image: radial-gradient(circle, #000 57%, rgba(0, 0, 0, 0.96) 65%, transparent 74%);
}

.auth-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-title { grid-column: 2; grid-row: 1; margin: 0 0 30px; text-align: left; color: var(--ink); font-size: clamp(1.9rem, 3vw, 2.75rem); font-weight: 750; line-height: 1.1; letter-spacing: 0; }
.auth-title::after { display: block; margin-top: 12px; content: "星海在线 · 功德发光"; color: var(--muted); font-size: 0.82rem; font-weight: 500; }

.auth-tabs, .auth-form { grid-column: 2; }
.auth-tabs { grid-row: 2; }
.auth-form { grid-row: 3; }
.auth-tabs { align-self: end; display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.auth-tab { position: relative; height: 48px; padding: 0; border: 0; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; }
.auth-tab::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; content: ""; background: var(--cyan); opacity: 0; transform: scaleX(0.4); transition: opacity 180ms ease, transform 180ms ease; }
.auth-tab.active { color: var(--ink); }
.auth-tab.active::after { opacity: 1; transform: scaleX(1); }

.auth-tab:focus-visible, .auth-submit:focus-visible, .sms-send-button:focus-visible, .auth-modal-button:focus-visible, .registered-close:focus-visible, .registered-login:focus-visible { outline: 2px solid var(--cyan-strong); outline-offset: 3px; }
.auth-form { display: none; align-content: start; gap: 17px; }
.auth-form.active { display: grid; }
.form-group { display: grid; gap: 8px; }
.form-label { color: #c4d2dc; font-size: 0.84rem; font-weight: 600; }

.input-wrapper {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-icon { display: grid; place-items: center; height: 20px; border-right: 1px solid var(--line); color: #84a6b8; font-size: 0.68rem; font-weight: 700; }
.form-input { width: 100%; height: 50px; padding: 0 14px; border: 0; outline: 0; background: transparent; color: var(--ink); caret-color: var(--cyan); }
.form-input::placeholder { color: rgba(196, 210, 220, 0.42); }
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--cyan);
  box-shadow: 0 0 0 1000px #071827 inset;
  transition: background-color 9999s ease-out 0s;
}
.input-wrapper:focus-within { border-color: rgba(101, 230, 238, 0.66); background: rgba(3, 18, 29, 0.84); box-shadow: 0 0 0 3px rgba(101, 230, 238, 0.09); }

.sms-code-row { display: grid; grid-template-columns: minmax(0, 1fr) 116px; gap: 10px; align-items: stretch; }
.sms-send-button { min-width: 0; border: 1px solid rgba(101, 230, 238, 0.34); border-radius: 6px; background: rgba(101, 230, 238, 0.08); color: var(--cyan-strong); font-size: 0.82rem; font-weight: 650; cursor: pointer; }
.sms-send-button:hover { background: rgba(101, 230, 238, 0.14); }
.sms-send-button:disabled { cursor: not-allowed; opacity: 0.52; }
.form-error { min-height: 20px; color: var(--danger); font-size: 0.84rem; line-height: 1.45; }

.privacy-consent { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 0.78rem; line-height: 1.55; cursor: pointer; }
.privacy-consent input { flex: 0 0 auto; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--cyan); }
.privacy-consent a { color: var(--cyan-strong); text-underline-offset: 3px; }

.auth-submit { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: 0; border-radius: 6px; background: var(--cyan); color: #04151d; font-weight: 750; cursor: pointer; box-shadow: 0 12px 28px rgba(18, 154, 164, 0.16); transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.auth-submit:hover { background: var(--cyan-strong); box-shadow: 0 14px 34px rgba(18, 154, 164, 0.24); transform: translateY(-1px); }
.auth-submit:disabled { background: #35444e; color: #84939d; cursor: not-allowed; box-shadow: none; transform: none; }
.auth-submit.is-loading { gap: 10px; }
.auth-submit.is-loading::before { width: 16px; height: 16px; content: ""; border: 2px solid rgba(4, 21, 29, 0.26); border-top-color: #04151d; border-radius: 50%; animation: auth-submit-spin 700ms linear infinite; }
@keyframes auth-submit-spin { to { transform: rotate(360deg); } }

.auth-footer { position: absolute; left: 0; bottom: 22px; width: 50%; margin: 0; text-align: center; color: rgba(143, 164, 182, 0.54); font-size: 0; }
.auth-footer::after { content: "Yaochi Planet · 连接善意与星光"; font-size: 0.72rem; }

.auth-modal-overlay { position: fixed; inset: 0; z-index: 40; display: none; background: rgba(1, 7, 12, 0.78); backdrop-filter: blur(8px); }
.auth-modal-overlay.active { display: block; }
.auth-modal { position: fixed; left: 50%; top: 50%; z-index: 41; display: none; width: min(360px, calc(100% - 40px)); padding: 28px 24px 22px; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 8px; background: #0a1b2a; box-shadow: 0 28px 80px rgba(0, 0, 0, 0.54); text-align: center; }
.auth-modal.active { display: block; animation: auth-modal-in 180ms ease-out; }
@keyframes auth-modal-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
.auth-modal-title { margin: 0 0 10px; color: var(--ink); font-size: 1.08rem; }
.auth-modal-message { margin: 0 0 20px; color: var(--muted); font-size: 0.9rem; line-height: 1.7; }
.auth-modal-button, .registered-login { width: 100%; height: 44px; border: 0; border-radius: 6px; background: var(--cyan); color: #04151d; font-weight: 750; cursor: pointer; }

.registered-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(1, 7, 12, 0.78); backdrop-filter: blur(8px); }
.registered-dialog { position: relative; width: min(360px, 100%); padding: 32px 24px 24px; border: 1px solid var(--line); border-radius: 8px; background: #0a1b2a; box-shadow: 0 28px 80px rgba(0, 0, 0, 0.54); color: var(--ink); text-align: center; font-size: 1rem; }
.registered-close { position: absolute; right: 10px; top: 8px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.registered-login { margin-top: 20px; }

@media (max-width: 820px) {
  .login-body { display: block; padding: 16px; }
  .login-body::after { background: linear-gradient(180deg, rgba(4, 14, 26, 0.42), #06111d 52%); }
  .auth-card { display: block; width: min(500px, 100%); min-height: auto; margin: 0 auto; padding: 28px clamp(18px, 6vw, 34px) 24px; background: rgba(7, 21, 35, 0.88); }
  .auth-card::before { display: none; }
  .auth-logo { width: 142px; margin: -4px auto 2px; }
  .auth-title { margin-bottom: 0; text-align: center; font-size: 1.75rem; }
  .auth-title::after { margin-top: 8px; }
  .auth-tabs { margin-top: 28px; margin-bottom: 24px; }
  .auth-footer { position: static; width: auto; margin-top: 20px; }
}

@media (max-width: 420px) {
  .login-body { padding: 8px; }
  .auth-card { padding: 24px 16px 20px; }
  .auth-logo { width: 124px; }
  .auth-form { gap: 14px; }
  .sms-code-row { grid-template-columns: minmax(0, 1fr) 104px; }
  .sms-send-button { font-size: 0.76rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Customer service is visible below the login form. */
.auth-support { grid-column: 2; grid-row: 4; min-width: 0; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; }
.auth-support-label { margin: 0; padding: 6px 0; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.auth-support-label span { margin-left: 8px; color: var(--cyan-strong); }
.auth-support-content { padding-top: 14px; }
.auth-support-title { margin: 0 0 12px; color: var(--ink); font-size: 0.94rem; font-weight: 600; }
.auth-support-content img { display: block; width: min(220px, 100%); height: auto; margin: 0 auto; padding: 10px; border-radius: 8px; background: #fff; }
.auth-support-hint { margin: 12px 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.8; }

.auth-link-button{border:0;background:transparent;color:var(--cyan);cursor:pointer;text-align:right;padding:0;font-size:.86rem}.login-sms-row{margin-top:-8px}
.login-mode-switch{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:2px;padding:4px;border:1px solid var(--line);border-radius:7px;background:rgba(2,14,25,.42)}
.login-mode{border:0;border-radius:5px;padding:9px 6px;color:var(--muted);background:transparent;cursor:pointer;font-size:.86rem}.login-mode.active{color:#06111d;background:var(--cyan);font-weight:700}
.reset-modal{position:fixed;inset:0;z-index:10;display:grid;place-items:center;padding:18px;background:rgba(1,8,16,.78);backdrop-filter:blur(8px)}.reset-modal[hidden]{display:none}.reset-dialog{position:relative;width:min(430px,100%);padding:28px;border:1px solid var(--line);border-radius:10px;background:var(--panel);box-shadow:0 24px 80px rgba(0,0,0,.5)}.reset-dialog h2{margin:0;color:var(--ink);font-size:1.35rem}.reset-hint{margin:8px 0 22px;color:var(--muted);font-size:.84rem}.reset-close{position:absolute;right:14px;top:10px;border:0;background:transparent;color:var(--muted);font-size:1.7rem;cursor:pointer}.reset-dialog .auth-submit{width:100%;margin-top:10px}

/* Keep inactive login fields hidden even when form layouts use grid. */
.auth-form [hidden] { display: none !important; }
.login-mode-toggle { text-align: center; justify-self: center; padding: 6px 12px; }
.auth-link-button:focus-visible { outline: 2px solid var(--cyan-strong); outline-offset: 3px; }

/* Match the verification image to the other rectangular form controls. */
.captcha-image-button { overflow: hidden; padding: 4px; border-radius: 6px; background: #dceff2; border-color: rgba(101, 230, 238, 0.45); transition: border-color 160ms ease, box-shadow 160ms ease; }
.captcha-image-button:hover { background: #e6f5f6; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(101, 230, 238, 0.09); }
.captcha-image-button img { display: block; width: 100%; height: 40px; object-fit: contain; border-radius: 3px; }
.captcha-image-button span { color: #225361; font-size: 0.78rem; }
.captcha-image-button:focus-visible { outline: 2px solid var(--cyan-strong); outline-offset: 3px; }
.captcha-code-row .input-wrapper { border-radius: 6px; }

.auth-sms-toast { position: fixed; z-index: 1001; top: max(16px, env(safe-area-inset-top)); left: 50%; display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px); padding: 18px 22px; border: 1px solid #155c37; border-radius: 16px; background: #042416; color: #70f5a6; box-shadow: 0 10px 32px rgba(0, 0, 0, .28); font-size: 14px; line-height: 1.5; opacity: 0; visibility: hidden; transform: translate(-50%, -10px); transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease; pointer-events: none; }
.auth-sms-toast.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.auth-sms-toast-icon { display: grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; font-size: 12px; line-height: 1; }

.auth-support-trigger { margin-left: 8px; padding: 4px 0; border: 0; background: transparent; color: var(--cyan-strong); font: inherit; cursor: pointer; }
.auth-support-trigger:hover { text-decoration: underline; text-underline-offset: 4px; }
.auth-support-trigger:focus-visible, .support-close:focus-visible { outline: 2px solid var(--cyan-strong); outline-offset: 4px; }
.support-dialog { position: fixed; width: min(360px, calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 30px 24px 24px; border: 1px solid var(--line); border-radius: 12px; background: #0a1b2a; color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, .5); text-align: center; }
.support-dialog::backdrop { background: rgba(1, 7, 12, .78); backdrop-filter: blur(8px); }
.support-close { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.support-dialog .auth-support-content { padding-top: 0; }
.support-dialog .auth-support-title { margin-bottom: 20px; font-size: 1.15rem; }
