/* ============================================================
   v5 — auth (login + account) + auth-aware nav
   ============================================================ */

/* hide topbar on /login (full-screen card).
   NOTE: the footer is deliberately NOT hidden — a public site must
   show ICP备案号/公网安备 on every page, including login (公共合规
   页脚 .sitefoot, rendered by site-footer.js). */
body.is-auth-page .topbar { display: none; }
body.is-auth-page .view { padding: 0; max-width: none; }

/* ---------- Login page -------------------------------------- */
.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 0%, var(--accent-soft) 0%, transparent 55%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--accent-soft) 70%, transparent) 0%, transparent 50%),
    var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 16px;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 36px 28px;
  box-shadow: 0 12px 48px rgba(15, 22, 60, .08), 0 1px 0 rgba(255,255,255,.5) inset;
}
.auth-card__brand {
  font-size: 20px; font-weight: 600;
  text-align: center;
  display: flex; align-items: baseline; justify-content: center; gap: 0;
  letter-spacing: .04em;
}
.auth-card__brand .brand__arrow { color: var(--accent); font-size: 16px; }
.auth-card__brand .brand__to    { color: var(--accent); }
.auth-card__sub {
  text-align: center; color: var(--ink-3);
  font-size: 12.5px; margin: 6px 0 24px;
}

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.auth-tab {
  background: transparent; border: 0; cursor: pointer;
  padding: 12px 0 13px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-3);
  position: relative;
  transition: color .15s var(--ease);
}
.auth-tab:hover { color: var(--ink-2); }
.auth-tab.is-active { color: var(--ink); }
.auth-tab.is-active::after {
  content: ''; position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: -1px; width: 36px; height: 2px;
  background: var(--accent); border-radius: 2px;
}

.auth-body { min-height: 280px; }

/* agreement */
.auth-agree {
  display: flex; align-items: flex-start; justify-content: center; gap: 8px;
  margin: 16px 0 8px;
  padding: 8px 4px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: var(--r-2);
  line-height: 1.55;
  text-align: center;
  transition: transform .2s var(--ease);
}
.auth-agree__cb { margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.auth-agree__link { color: var(--accent); text-decoration: none; }
.auth-agree__link:hover { text-decoration: underline; }
.auth-agree.is-shake { animation: shake .35s var(--ease); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.auth-foot {
  margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 12px; color: var(--ink-4);
}
.auth-foot__link { color: var(--ink-3); }
.auth-foot__link:hover { color: var(--accent); }
.auth-foot .dot { color: var(--line-strong); }

/* ---------- WeChat QR pane --------------------------------- */
.wx-pane {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 4px;
}
.wx-qr {
  width: 200px; height: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 10px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  color: var(--ink);
}
.wx-qr.is-loading,
.wx-qr.is-expired { color: var(--ink-4); }
.wx-qr__img {
  width: 100%; height: 100%;
  display: block;
  transition: filter .2s var(--ease);
}
.wx-qr.is-expired .wx-qr__img { filter: grayscale(1) blur(2px) opacity(.45); }
.wx-qr__overlay {
  position: absolute; inset: 10px;
  pointer-events: none;
}
.wx-qr.is-expired .wx-qr__overlay::after {
  content: '已过期';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink-2);
  background: rgba(255,255,255,.8);
  border-radius: var(--r-2);
}
.wx-qr__skel {
  width: 70%; height: 70%;
  background:
    repeating-linear-gradient(45deg, var(--bg-soft) 0 6px, var(--surface-2) 6px 12px);
  border-radius: var(--r-2);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

.wx-cap {
  margin: 14px 0 8px;
  font-size: 13px; color: var(--ink-2);
}
.wx-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
}
.wx-status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-4);
}
.wx-status--pending   { background: var(--bg-soft); }
.wx-status--pending   .wx-status__dot { background: var(--ink-3); animation: dotPulse 1.2s ease-in-out infinite; }
.wx-status--scanned   { background: var(--accent-soft); color: var(--accent-ink); }
.wx-status--scanned   .wx-status__dot { background: var(--accent); }
.wx-status--confirmed { background: var(--ok-soft); color: var(--ok); }
.wx-status--confirmed .wx-status__dot { background: var(--ok); }
.wx-status--expired   { background: var(--warn-soft); color: var(--warn); }
.wx-status--expired   .wx-status__dot { background: var(--warn); }
.wx-status--error     { background: var(--err-soft); color: var(--err); }
.wx-status--error     .wx-status__dot { background: var(--err); }
@keyframes dotPulse { 50% { opacity: .35; } }

.wx-actions { margin-top: 10px; min-height: 28px; }

/* ---------- SMS pane --------------------------------------- */
.sms-pane { padding: 4px 0; }
.sms-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
  margin: 0 0 6px;
  letter-spacing: .02em;
}
.sms-label + .sms-row { margin-bottom: 4px; }
.sms-row {
  display: flex; align-items: stretch; gap: 8px;
  margin-bottom: 6px;
}
.sms-prefix {
  display: flex; align-items: center;
  padding: 0 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-size: 13px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.sms-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 14px;
  letter-spacing: .04em;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.sms-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.sms-input:disabled {
  background: var(--bg-soft);
  color: var(--ink-3);
  cursor: not-allowed;
  opacity: .65;
}
.sms-input--code {
  letter-spacing: .35em;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}
.sms-send {
  flex-shrink: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 92px;
}
.sms-send.is-cooling { color: var(--ink-3); }
.sms-err {
  font-size: 12px; color: var(--err);
  min-height: 18px;
  margin: -2px 0 4px;
}
.sms-hint {
  font-size: 12px; color: var(--ink-4);
  margin: -2px 0 16px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: var(--r-2);
  display: inline-block;
}
.auth-submit {
  width: 100%;
  height: 40px;
  margin-top: 4px;
  font-size: 14px;
}
.auth-submit.is-disabled,
.auth-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Wechat scan & SMS modals (account binding) ----- */
.modal--wx, .modal--sms { width: min(420px, calc(100vw - 32px)); padding: 0; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal__head .modal__title { margin: 0; }
.modal__close {
  background: transparent; border: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  color: var(--ink-3); cursor: pointer;
}
.modal__close:hover { background: var(--bg-soft); color: var(--ink); }
.modal--wx .wx-pane,
.modal--sms .sms-pane { padding: 24px 28px 28px; }

/* ---------- Auth-aware top nav ----------------------------- */
.topnav__login {
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.topnav__login:hover { border-color: var(--accent); color: var(--accent); }
.topnav__login:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* user dropdown */
.user-dd { position: relative; }
.user-dd__trigger {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s var(--ease);
}
.user-dd__trigger:hover { background: var(--bg-soft); }
.user-dd__av {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
  flex-shrink: 0;
  object-fit: cover;
}
.user-dd__av--ph { letter-spacing: 0; }
.user-dd__name {
  font-size: 13px; color: var(--ink);
  max-width: 96px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dd__chev { color: var(--ink-3); font-size: 10px; }

.user-dd__menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: 0 16px 40px rgba(0,0,0,.10);
  padding: 4px;
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
  z-index: 40;
}
.user-dd.is-open .user-dd__menu {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.user-dd__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: transparent; border: 0;
  padding: 8px 10px;
  font-size: 13px; color: var(--ink);
  border-radius: var(--r-2);
  cursor: pointer;
}
.user-dd__item:hover { background: var(--bg-soft); }
.user-dd__item--danger { color: var(--err); }
.user-dd__item--danger:hover { background: var(--err-soft); }
.user-dd__sep { height: 1px; background: var(--line); margin: 4px 0; }

/* logged-out state: nav has no items, push login button to the right */
#topnav:empty + #topbar-right { margin-left: auto; }

/* ---------- Account page ----------------------------------- */
.account { max-width: 760px; margin: 0 auto; }
.account__skel {
  padding: 32px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
}
.account__sec { margin-bottom: 16px; }

/* KV list */
.kv-list { display: flex; flex-direction: column; }
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: start;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv__label {
  font-size: 12.5px;
  color: var(--ink-3);
  padding-top: 5px;
  letter-spacing: .02em;
}
.kv__val {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink);
  min-height: 28px;
}
.kv__val--ro { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kv__display { font-size: 13.5px; }
.kv__display--empty { color: var(--ink-4); font-style: italic; }
.kv__edit {
  background: transparent; border: 0;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  border-radius: var(--r-1);
  transition: background .12s var(--ease);
}
.kv__edit:hover { background: var(--accent-soft); }
.kv__hint { font-size: 12px; color: var(--ink-4); }
.kv__sub { width: 100%; font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.kv-link { color: var(--accent); }
.kv-link:hover { text-decoration: underline; }
.kv__input {
  flex: 1; min-width: 200px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  font: inherit; font-size: 13.5px;
}
.kv__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.kv__actions { display: flex; gap: 6px; }

.kv-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.kv-avatar__img { width: 100%; height: 100%; object-fit: cover; }
.kv-avatar__ph {
  font-size: 22px; font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent-soft);
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* Login methods */
.lm-list { display: flex; flex-direction: column; gap: 10px; }
.lm-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface-2);
}
.lm-left { display: flex; align-items: center; gap: 12px; }
.lm-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lm-icon--wechat { background: #e8f7ec; color: #07c160; }
.lm-icon--phone  { background: var(--accent-soft); color: var(--accent-ink); }
.lm-meta { display: flex; flex-direction: column; gap: 2px; }
.lm-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.lm-detail { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lm-detail--empty { color: var(--ink-4); }
.lm-right { display: flex; align-items: center; gap: 10px; }
.lm-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
}
.lm-pill--linked {
  background: var(--ok-soft);
  color: var(--ok);
}
.lm-pill--linked .lm-pill__dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ok);
}
.lm-pill--empty { background: var(--bg-soft); color: var(--ink-3); }
.lm-note {
  font-size: 12px; color: var(--ink-3);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  padding: 8px 12px;
  border-radius: var(--r-2);
  margin-bottom: 12px;
}

/* Danger zone */
.account__danger { border-color: color-mix(in srgb, var(--err) 12%, var(--line)); }
.danger-block { display: flex; flex-direction: column; }
.danger-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.danger-row:last-child { border-bottom: 0; }
.danger-row__title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.danger-row__title--err { color: var(--err); }
.danger-row__sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* Delete account modal */
.danger-modal { width: min(480px, calc(100vw - 32px)); }
.danger-modal__instr {
  font-size: 13px; color: var(--ink-2);
  margin: 4px 0 10px;
}
.danger-modal__target {
  font-family: var(--mono);
  background: var(--err-soft);
  color: var(--err);
  padding: 1px 6px;
  border-radius: var(--r-1);
  font-weight: 600;
}
.danger-modal__input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font: inherit;
  font-family: var(--mono);
  font-size: 14px;
}
.danger-modal__input:focus {
  outline: none;
  border-color: var(--err);
  box-shadow: 0 0 0 3px var(--err-soft);
}

/* ---------- Legal placeholder pages ------------------------ */
.legal { max-width: 760px; margin: 0 auto; }
.legal__body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 32px 36px;
}
.legal__h2 {
  margin: 28px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .02em;
}
.legal__h2:first-child { margin-top: 0; }
.legal__p {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.85;
}

/* ---------- Login modal (B-1) + nickname step (B-2b) -------- */
/* Reuses .modal-overlay (v6.css) for the backdrop and .auth-card for
   the card chrome — only the modal-specific affordances live here. */
.auth-card--modal {
  position: relative;
  margin: 0;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.auth-modal__close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink-3);
  border-radius: 8px;
  z-index: 1;
}
.auth-modal__close:hover { background: var(--bg-soft); color: var(--ink); }
.auth-modal__reason {
  margin: 4px 0 16px;
  padding: 9px 12px;
  background: var(--accent-soft);
  color: var(--ink-2);
  border-radius: 8px;
  font-size: 12.5px; text-align: center;
}
.nickname-step__actions {
  display: flex; gap: 10px; margin-top: 18px;
}
.nickname-step__actions .auth-submit { flex: 1; width: auto; margin: 0; }
.nickname-step__actions .auth-skip { flex: 0 0 auto; height: 40px; }

/* ---------- Responsive ------------------------------------- */
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px 20px; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .kv__label { padding-top: 0; }
  .lm-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .lm-right { justify-content: space-between; }
  .danger-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .user-dd__name { display: none; }
}
