/* ══ Auth Modal — 登录 / 注册 ══ */

#auth-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4, 6, 12, 0.92);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
#auth-overlay.on { opacity: 1; pointer-events: auto; }

#auth-modal {
  position: fixed; z-index: 301;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: min(90vw, 400px);
  max-height: 85vh;
  background: linear-gradient(165deg, #151c28 0%, #0e1420 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: hidden;
}
#auth-modal.on {
  opacity: 1; pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

/* ── Header ── */
#auth-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
#auth-title {
  font-family: var(--serif);
  font-size: 20px; font-weight: 600;
  color: var(--text-primary);
}
#auth-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.5); padding: 0;
  transition: background 0.2s, color 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#auth-close:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }

/* ── Tab switcher ── */
#auth-tabs {
  display: flex; gap: 0;
  margin: 20px 24px 0;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 10px 0;
  background: none; border: none;
  font-family: var(--mono); font-size: 12px; font-weight: 400;
  letter-spacing: .08em;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.25s, background 0.25s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.auth-tab:hover { color: var(--text-secondary); }
.auth-tab.active {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

/* ── Form body ── */
#auth-body {
  padding: 24px 24px 28px;
  display: flex; flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Input groups ── */
.auth-field {
  position: relative;
  margin-bottom: 16px;
}
.auth-field:last-of-type { margin-bottom: 0; }

.auth-label {
  display: block;
  font-family: var(--mono); font-size: 10px; font-weight: 300;
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.auth-input {
  width: 100%; padding: 13px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  -webkit-appearance: none;
}
.auth-input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}
.auth-input:focus {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.08);
}
.auth-input.auth-input-error {
  border-color: rgba(240, 96, 96, 0.5);
  box-shadow: 0 0 0 3px rgba(240, 96, 96, 0.08);
}

/* Name field (only visible in register mode) */
#auth-name-field {
  max-height: 0; overflow: hidden; margin-bottom: 0;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              margin-bottom 0.25s ease;
}
#auth-name-field.visible {
  max-height: 100px; opacity: 1;
  margin-bottom: 16px;
}

/* ── Error message ── */
#auth-error {
  font-family: var(--sans); font-size: 13px;
  color: #f06060;
  min-height: 0; overflow: hidden;
  max-height: 0; opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.25s ease;
  margin-top: 0;
}
#auth-error.visible {
  max-height: 60px; opacity: 1;
  margin-top: 16px;
}

/* ── Submit button ── */
#auth-submit {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  background: rgba(var(--accent-rgb), 0.15);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px; font-weight: 400;
  letter-spacing: .08em;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, opacity 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
#auth-submit:hover {
  background: rgba(var(--accent-rgb), 0.25);
  border-color: rgba(var(--accent-rgb), 0.5);
}
#auth-submit:active {
  transform: scale(0.97);
}
#auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
#auth-submit .auth-spinner {
  display: none;
}
#auth-submit.loading .auth-btn-text {
  opacity: 0;
}
#auth-submit.loading .auth-spinner {
  display: block;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  border: 2px solid rgba(var(--accent-rgb), 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}
@keyframes authSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Footer hint ── */
#auth-footer {
  padding: 0 24px 24px;
  text-align: center;
  flex-shrink: 0;
}
#auth-footer-text {
  font-family: var(--sans); font-size: 12px;
  color: var(--text-muted);
}
#auth-footer-link {
  color: var(--accent);
  cursor: pointer;
  background: none; border: none;
  font-family: inherit; font-size: inherit;
  padding: 0; text-decoration: none;
  transition: opacity 0.2s;
  touch-action: manipulation;
}
#auth-footer-link:hover { opacity: 0.8; }

/* ── Logged-in profile badge ── */
#profile-auth-badge {
  display: none;
  align-items: center; gap: 8px;
  margin-top: 6px;
}
#profile-auth-badge.visible { display: flex; justify-content: center; }
#profile-auth-email {
  font-family: var(--mono); font-size: 11px; font-weight: 300;
  letter-spacing: .04em; color: var(--text-muted);
}
#profile-auth-logout {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .06em;
  color: rgba(240, 96, 96, 0.6);
  background: none; border: none;
  cursor: pointer; padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#profile-auth-logout:hover {
  color: #f06060;
  background: rgba(240, 96, 96, 0.08);
}

/* ── Login prompt button on profile ── */
#profile-login-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  padding: 8px 20px;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: var(--radius-pill);
  font-family: var(--mono); font-size: 11px; font-weight: 400;
  letter-spacing: .08em;
  color: rgba(var(--accent-rgb), 0.85);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#profile-login-btn:hover {
  background: rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.35);
}
#profile-login-btn:active {
  transform: scale(0.95);
}
#profile-login-btn.hidden { display: none; }
