:root, :root[data-theme="light"] {
  --ok-soft: #e8f6ee;
  --danger: #c4271a;
  --danger-soft: #fff1f0;
}
:root[data-theme="dark"] {
  --ok-soft: #173528;
  --danger: #ff8a80;
  --danger-soft: #3a1c1c;
}

/* —— 顶栏用户入口 —— */
.auth-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}
:root[lang="en"] .auth-entry { padding: 0 12px; }
.auth-entry:hover { background: var(--accent-hover); }

.user-menu { position: relative; }
.user-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.user-toggle .chev {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--muted);
}
.user-toggle[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--ring); }
.avatar {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.user-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 160px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.user-menu-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}
.user-menu-list button:hover { background: var(--soft); }
.user-menu-list .menu-signout { color: var(--danger); }
.user-menu-list svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* —— 登录 / 注册 —— */
.auth-wrap {
  display: grid;
  place-items: start center;
  padding: 64px 20px 48px;
}
.auth-card {
  width: min(100%, 400px);
  max-width: 100%;
  min-width: 0;
  padding: 28px 28px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 800;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 650;
}
.field input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.field input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.field-error { color: var(--danger); font-size: 13px; font-weight: 650; }
.field.is-invalid input { border-color: var(--danger); }
.auth-tabs { margin: 0 0 18px; }
.auth-card, .field, .code-row { min-width: 0; max-width: 100%; }
.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.code-row input { flex: 1 1 0; min-width: 0; width: auto; }
.code-row .btn-secondary { flex: none; flex-shrink: 0; height: 38px; padding: 0 12px; white-space: nowrap; }

.auth-actions { display: grid; gap: 10px; margin-top: 6px; }
.auth-actions .btn-primary,
.auth-actions .btn-secondary { width: 100%; min-height: 44px; border-radius: 14px; }
.auth-closed {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 12px 0 4px;
}
.auth-closed p {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
}

.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}
.notice.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
}
.notice.err {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
}


button:disabled { box-shadow: none; }
.user-menu-list .menu-signout { color: var(--text); }
.user-name { max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.field input { min-width: 0; width: 100%; }
.field-error { margin: 0; }
.auth-card .captcha { width: 100%; margin: 4px 0 16px; padding: 12px 10px; border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.auth-card .captcha #captcha-widget { min-height: 58px; max-width: 300px; margin: auto; align-items: center; }
.auth-card .captcha-status { font-weight: 650; line-height: inherit; opacity: 1; }
.auth-card .captcha[data-state="verified"] .captcha-status { color: var(--ok); }
#upload-limit { margin: 0 0 14px; text-align: left; }
.dropzone:disabled { opacity: .55; pointer-events: none; background: var(--soft); }
#upload-button:disabled { opacity: 1; }
#forgot-step-success .notice { width: 100%; }
@media (max-width: 800px) {
  .auth-wrap { padding: 28px 16px 40px; }
  .auth-card { padding: 24px 18px; }
}
@media (max-width: 700px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .topbar .brand, .topbar .brand-mark, .topbar .brand-mark img { flex-shrink: 0; }
  .top-controls { gap: 6px; flex-shrink: 0; }
  .user-toggle .user-name { display: none; }
  .user-toggle { padding: 3px 8px 3px 4px; gap: 4px; }
  .lang-switch .lang-current, .lang-switch .chev { display: none !important; }
  .lang-switch .lang-toggle { width: 36px; min-width: 36px; padding: 0; justify-content: center; gap: 0; }
  :root[lang="en"] .topbar .brand-name { max-width: 90px; white-space: normal; line-height: 1.2; }
  :root[lang="en"] .auth-entry { padding: 0 10px; font-size: 12px; }
}
@media (max-width: 360px) { .topbar { flex-wrap: wrap; } }
.auth-card .captcha[data-state="pending"] .captcha-status { opacity: 1; }

#view-upload .seg button:disabled { opacity: .5; }
