/**
 * ShangCloud 认证页设计系统。
 *
 * 覆盖范围：登录 / 注册 / 短信登录注册 / 邮箱快捷登录 / 两步验证 / 密码重置，
 * 以及三个 OAuth 授权页（/oauth/authorize、/auth/window、/oauth/device）与
 * OAuth 回调页。这些页面**不继承 base.html**，也不引入 Tailwind / Bootstrap /
 * 任何前端框架——它们是站点的信任边界，依赖越少越好，样式全部手写维护在这里。
 *
 * 设计语汇沿用新版界面（static/next/src/styles/tokens.css）：Google Sans 字族、
 * #0b57d0 主色、大圆角、pill 按钮，随主题切换浅色 / 深色。令牌名与新版保持一致，
 * 两边看起来才是同一个产品。
 *
 * 主题：<html data-theme="light|dark">，由 auth-theme.js 在首屏前写入。
 * JS 不可用时退回 prefers-color-scheme（见下方两段重复的深色令牌）。
 *
 * 视图切换（.stage / .view）配合 auth-flow.js 使用，在单页内模拟多页跳转。
 */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f0f4f9;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --outline: #dadce0;
  --outline-soft: #e8eaed;
  --outline-strong: #bdc1c6;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-3: #5f6368;
  --primary: #0b57d0;
  --on-primary: #ffffff;
  --hover: rgba(11, 87, 208, 0.08);
  --neutral-hover: rgba(31, 31, 31, 0.06);
  --chip: #f1f3f4;
  --success-bg: #e6f4ea;
  --success-fg: #1e7e34;
  --warning-bg: #fef7e0;
  --warning-fg: #8a5300;
  --info-bg: #e8f0fe;
  --info-fg: #0b57d0;
  --danger: #b3261e;
  --danger-bg: #fce8e6;
  --surface-inverse: #303134;
  --on-surface-inverse: #e3e3e3;

  --shadow-1:
    0 1px 2px rgba(60, 64, 67, 0.16), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  --shadow-2:
    0 1px 3px rgba(60, 64, 67, 0.18), 0 4px 8px 3px rgba(60, 64, 67, 0.1);

  /* 第三方 logo 垫底色：ZeroCat / 40code 的图标是深色描边，深色模式下会糊成一团，
     必须始终垫白底才认得出来。 */
  --logo-plate: #ffffff;
}

/* auth-theme.js 会把 auto 解析成具体值写到 data-theme，因此这段只在 JS 不可用
   （或脚本被拦截）时生效——所以选择器是 :not([data-theme])，不需要再排除 light。
   深色令牌不得不写两份：CSS 没有变量组复用，下面那份 [data-theme="dark"] 是同样的值。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --bg: #131314;
    --surface: #1e1f20;
    --surface-2: #282a2c;
    --outline: #444746;
    --outline-soft: #2d2f31;
    --outline-strong: #5f6368;
    --text: #e3e3e3;
    --text-2: #c4c7c5;
    --text-3: #9aa0a6;
    --primary: #a8c7fa;
    --on-primary: #062e6f;
    --hover: rgba(168, 199, 250, 0.12);
    --neutral-hover: rgba(227, 227, 227, 0.08);
    --chip: #282a2c;
    --success-bg: #14342a;
    --success-fg: #6dd58c;
    --warning-bg: #3a2c10;
    --warning-fg: #f7bd6b;
    --info-bg: #1b2b42;
    --info-fg: #a8c7fa;
    --danger: #f2b8b5;
    --danger-bg: #3b1f1d;
    --surface-inverse: #e3e3e3;
    --on-surface-inverse: #1f1f1f;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
    --shadow-2:
      0 1px 3px rgba(0, 0, 0, 0.55), 0 4px 8px 3px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131314;
  --surface: #1e1f20;
  --surface-2: #282a2c;
  --outline: #444746;
  --outline-soft: #2d2f31;
  --outline-strong: #5f6368;
  --text: #e3e3e3;
  --text-2: #c4c7c5;
  --text-3: #9aa0a6;
  --primary: #a8c7fa;
  --on-primary: #062e6f;
  --hover: rgba(168, 199, 250, 0.12);
  --neutral-hover: rgba(227, 227, 227, 0.08);
  --chip: #282a2c;
  --success-bg: #14342a;
  --success-fg: #6dd58c;
  --warning-bg: #3a2c10;
  --warning-fg: #f7bd6b;
  --info-bg: #1b2b42;
  --info-fg: #a8c7fa;
  --danger: #f2b8b5;
  --danger-bg: #3b1f1d;
  --surface-inverse: #e3e3e3;
  --on-surface-inverse: #1f1f1f;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 3px rgba(0, 0, 0, 0.55), 0 4px 8px 3px rgba(0, 0, 0, 0.35);
}

:root {
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --font-sans:
    "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ 布局：卡片正中 ============ */
.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

/* margin:auto 而非 justify-content:center —— 内容超出视口时不会裁掉顶部 */
.shell {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--outline-soft);
  border-radius: 28px;
  padding: 40px 36px 28px;
}

/* 注册这类字段较多的表单页，卡片略宽一点，两列信息不至于挤在一起 */
.card-wide {
  max-width: 460px;
}

.page-footer {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 20px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.page-footer a {
  color: inherit;
  text-decoration: none;
}

.page-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.page-footer .footer-meta {
  width: 100%;
  color: var(--text-3);
  opacity: 0.85;
}

/* ============ 视图切换（单页内模拟多页跳转） ============ */
.stage {
  position: relative;
  transition: height 0.3s var(--ease);
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.3s var(--ease),
    visibility 0s linear 0.3s;
}

.view.is-active {
  position: relative;
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition-delay: 0s;
}

.view.slide-left {
  transform: translateX(-32px);
}

.view.slide-right {
  transform: translateX(32px);
}

@media (prefers-reduced-motion: reduce) {
  .stage,
  .view {
    transition-duration: 0.01ms !important;
  }
  .view.slide-left,
  .view.slide-right {
    transform: none;
  }
}

/* ============ 头部 ============ */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
}

.brand img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
}

.app-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(135deg, #4285f4, #7b5cf0);
  margin-bottom: 16px;
  user-select: none;
}

/* 页面级图标（登录 / 注册 / 验证等），比 .app-avatar 中性 */
.head-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: var(--info-bg);
  color: var(--info-fg);
  font-size: 21px;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 400;
  color: var(--text);
  word-break: break-word;
}

.subtitle {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-2);
  word-break: break-word;
}

/* ============ 账号信息 ============ */
.account {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 5px 14px 5px 5px;
  margin-bottom: 24px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-2);
}

.account img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--chip);
  flex-shrink: 0;
}

.account span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -16px 0 24px;
  font-size: 12.5px;
  color: var(--text-3);
}

.app-meta[hidden],
.verified[hidden] {
  display: none;
}

.app-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success-fg);
  font-size: 12px;
  font-weight: 500;
}

/* ============ 权限列表 ============ */
.section-title {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--text);
}

.scopes {
  margin: 12px 0 20px;
  list-style: none;
  padding: 0;
}

.scopes li {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  align-items: flex-start;
}

.scopes li + li {
  border-top: 1px solid var(--outline-soft);
}

.scopes .icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1.45;
}

.scopes strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.scopes p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
}

.notice i {
  color: var(--text-3);
  font-size: 15px;
}

.notice a {
  color: var(--primary);
  text-decoration: none;
}

.notice a:hover {
  text-decoration: underline;
}

/* ============ 表单 ============ */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: block;
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.input {
  width: 100%;
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--hover);
}

.input::placeholder {
  color: var(--text-3);
}

.input:disabled {
  background: var(--chip);
  color: var(--text-3);
  cursor: not-allowed;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* 带前置图标的输入框 */
.input-icon {
  position: relative;
  display: block;
}

.input-icon > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}

.input-icon > .input {
  padding-left: 42px;
}

/* 验证码输入 + 发送按钮 */
.input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.input-row > .input,
.input-row > .input-icon {
  flex: 1;
  min-width: 0;
}

.input-row > .btn {
  flex-shrink: 0;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 13px;
  min-width: 108px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.5;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* 验证码组件挂载点：极验会往里塞自己的 DOM，只负责留出空间 */
.captcha-slot {
  min-height: 0;
}

.captcha-slot[hidden] {
  display: none;
}

.code-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.code-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--hover);
}

.code-input::placeholder {
  color: var(--text-3);
  letter-spacing: 0.18em;
}

.form-error {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--danger);
}

.form-error[hidden] {
  display: none;
}

/* ============ 内联提示条（flash / 状态说明） ============ */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin: 0 0 18px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.flash i {
  font-size: 15px;
  line-height: 1.4;
  flex-shrink: 0;
}

.flash-info {
  background: var(--info-bg);
  color: var(--info-fg);
}

.flash-ok {
  background: var(--success-bg);
  color: var(--success-fg);
}

.flash-warn {
  background: var(--warning-bg);
  color: var(--warning-fg);
}

.flash-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============ 按钮 ============ */
.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 28px;
}

.btn {
  min-height: 40px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3);
  filter: brightness(1.06);
}

.btn-text {
  background: transparent;
  color: var(--primary);
  padding: 0 16px;
}

.btn-text:hover {
  background: var(--hover);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--outline);
}

.btn-outline:hover {
  background: var(--hover);
  border-color: var(--primary);
}

.btn-tonal {
  background: var(--chip);
  color: var(--text);
}

.btn-tonal:hover {
  background: var(--neutral-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 0 16px;
}

.btn-danger:hover {
  background: var(--danger-bg);
}

/* 表单主按钮：撑满卡片宽度、比行内按钮高一档 */
.btn-block {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* ============ 第三方登录 / 其他方式 ============ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 20px;
  font-size: 12px;
  color: var(--text-3);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--outline-soft);
}

.providers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.provider {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--outline-soft);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.provider:hover {
  border-color: var(--outline-strong);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

.provider:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 图片 logo 一律垫白底，深色模式下深色描边的图标才看得清 */
.provider-logo {
  background: var(--logo-plate);
  border-color: var(--outline);
}

.provider img,
.provider svg {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

/* 底部换页链接 */
.link-row {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--outline-soft);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.link-row a,
.text-link {
  color: var(--primary);
  text-decoration: none;
}

.link-row a:hover,
.text-link:hover {
  text-decoration: underline;
}

.link-row .sep {
  margin: 0 6px;
  opacity: 0.6;
}

/* ============ 标签页（两步验证的多种方式） ============ */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 999px;
  background: var(--chip);
}

.tab {
  flex: 1;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.panel[hidden] {
  display: none;
}

/* 推送验证要用户从三个数字里挑一个，数字必须够大 */
.match-number {
  display: block;
  margin: 4px 0 18px;
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--primary);
}

/* ============ 状态视图 ============ */
.status {
  text-align: center;
  padding: 24px 0 8px;
}

.status h1 {
  font-size: 20px;
}

.status .subtitle {
  margin-bottom: 8px;
}

.status .actions {
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 20px;
  border: 3px solid var(--outline-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: auth-spin 0.9s linear infinite;
}

/* 按钮内 / 行内的旋转图标 */
.spin {
  display: inline-block;
  animation: auth-spin 0.9s linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

.status-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 16px;
  display: block;
}

.status-icon.ok {
  color: var(--success-fg);
}

.status-icon.error {
  color: var(--danger);
}

.status-icon.muted {
  color: var(--text-3);
}

/* 等待类页面的呼吸圆点 */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-fg);
  display: inline-block;
  flex-shrink: 0;
  animation: auth-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes auth-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .spin,
  .pulse-dot {
    animation: none;
  }
}

/* ============ Toast ============ */
/* 居中对齐、反色背景，与新版界面 ToastHost 设计一致 */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-inverse);
  color: var(--on-surface-inverse);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.22s var(--ease);
}

.toast i {
  font-size: 17px;
  flex-shrink: 0;
}

.toast-ok i {
  color: #6dd58c;
}

.toast-error i {
  color: #f2b8b5;
}

/* 文案来自后端，可能很长也可能带换行 */
.toast-msg {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast__close {
  flex: none;
  border: 0;
  background: none;
  color: inherit;
  opacity: 0.75;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
}

.toast__close:hover {
  opacity: 1;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-leaving {
    animation-duration: 0.01ms;
  }
}

/* ============ 移动端 ============ */
@media (max-width: 480px) {
  body {
    background: var(--surface);
  }
  .page {
    padding: 0;
  }
  .shell {
    margin: 0;
    gap: 0;
  }
  .card {
    max-width: none;
    border: none;
    border-radius: 0;
    padding: 28px 22px 24px;
    min-height: calc(100dvh - 56px);
  }
  .page-footer {
    padding: 16px;
  }
  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .btn {
    width: 100%;
  }
  /* 验证码那一行是「输入框 + 发送」，竖排会显得很奇怪，保持并排 */
  .input-row {
    flex-direction: row;
  }
  .input-row > .btn {
    width: auto;
  }
  .toast-host {
    width: calc(100vw - 32px);
    bottom: 16px;
  }
}

/* ============ 头衔徽章（赞助者 / 管理员） ============ */
/*
 * 徽章挂在 .account 里（由 auth-flow.js 的 fillAccount 动态插入）。
 *
 * 金色是徽章自身的语义色，因此**不用 var(--primary)** —— 浅色 / 深色 / 黑金
 * 三套配色下头衔都应该是金的，跟着主色变就认不出来了。
 *
 * **所有档位长一个样**：早先版本给金/银/铜/管理员各配了一套金属渐变，
 * 同一行里挤着几个发亮的渐变小块，谁都在喊反而看不出重点，而且渐变金正是
 * "廉价 VIP 皮肤"观感的最大来源。现在统一成 10% wash + 1px 金描边 + 金字，
 * 档位只靠文案区分。描边不能省：10% 的面在暗底上没有描边就是一团糊影。
 */
.sponsor-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid rgba(217, 196, 140, 0.42);
  border-radius: 999px;
  background: rgba(217, 196, 140, 0.1);
  /* 浅色底上要压深才够 4.5:1，亮金在白底上几乎看不见 */
  color: #7d6524;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.7;
}

/* .account span 那条 ellipsis 规则会把徽章文字也截掉，这里覆盖回来 */
.account .sponsor-badge {
  overflow: visible;
  white-space: nowrap;
}

.sponsor-badge i {
  font-size: 11px;
}

/* 暗底上反过来用亮金。两段各写一份的原因见文件顶部的深色令牌注释。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .sponsor-badge {
    border-color: rgba(217, 196, 140, 0.32);
    color: #ebdcb4;
  }
}

:root[data-theme="dark"] .sponsor-badge,
:root[data-theme="gold"] .sponsor-badge {
  border-color: rgba(217, 196, 140, 0.32);
  color: #ebdcb4;
}

/* ============ 黑金主题（赞助者 / 管理员专属） ============ */
/*
 * 由 auth-theme.js 在首屏前写 <html data-theme="gold">，与 light/dark 同一条路径。
 * 没资格的人（赞助到期、被降级）由 auth-flow.js 拿到服务端结论后改回 auto。
 *
 * **金色是重音符，不是背景色。** 认证页本来就只有一张卡，金色出现在标题、
 * 主按钮和几个图标上就够了，不要再给卡片、输入框铺金。
 *
 * 两条硬约束（与 next/src/styles/tokens.css 的黑金块完全一致，改一处要同步）：
 *  1. 底层灰阶中性偏冷，绝不带金色 tint —— 金色是暖色，底色再暖就没有冷暖对比，
 *     金色会"沉进去"变成脏黄。
 *  2. 不许出现"压暗的金"当填充（#3A2F10 / #5C4407 这类），压暗的金是橄榄绿/ 屎黄。
 *
 * 分层靠表面亮度阶梯 + 1px 中性描边，不靠阴影：暗底上阴影几乎不可见。
 * 因此 shadow 全部置 none。
 *
 * 必须把 dark 那份令牌逐个重声明：顶上的 `:root, :root[data-theme="light"]`
 * 会一直生效，漏掉哪个变量就退回浅色值 —— 表现是黑底上出现一道白色阴影。
 */
:root[data-theme="gold"] {
  color-scheme: dark;

  --bg: #151518;
  --surface: #1e1e22;
  --surface-2: #282830;
  --surface-3: #33333b;
  --outline: rgba(255, 255, 255, 0.1);
  --outline-soft: rgba(255, 255, 255, 0.06);
  --outline-strong: rgba(255, 255, 255, 0.16);
  --text: #f7f6f4;
  --text-2: #bdb8b2;
  --text-3: #9e968e;
  --primary: #d9c48c;
  --on-primary: #1b1710;
  --hover: rgba(217, 196, 140, 0.1);
  --neutral-hover: rgba(255, 255, 255, 0.06);
  --chip: #282830;

  /* 状态色避开金色相邻色：成功/失败绝不用黄色系，否则和主色分不清 */
  --success-bg: rgba(143, 207, 164, 0.1);
  --success-fg: #8fcfa4;
  --warning-bg: rgba(217, 196, 140, 0.1);
  --warning-fg: #ebdcb4;
  --info-bg: rgba(158, 198, 220, 0.1);
  --info-fg: #9ec6dc;
  --danger: #e5a09b;
  --danger-bg: rgba(229, 160, 155, 0.1);
  --surface-inverse: #f7f6f4;
  --on-surface-inverse: #1e1e22;

  --shadow-1: none;
  --shadow-2: none;

  /* 第三方 logo 仍然垫白底：那些图标是深色描边，垫成金色照样糊 */
  --logo-plate: #ffffff;
}

/* 实心主按钮用深金打底：主金 #D9C48C 亮度太高，整块铺开会变成一坨发光的黄。
   hover 升到主金，反馈落在"变亮"而不是"变色"上。
   ⚠️ 一屏只应该有一个实心金按钮 —— 认证页的次要动作一律是描边或文字按钮。 */
:root[data-theme="gold"] .btn-primary {
  background: #c2a96f;
}

/* 基础样式的 hover 是 brightness(1.06) + 一道浅灰阴影：
   前者会把金色推到发光的柠檬黄，后者在黑底上根本看不见。两个一起关掉，
   改成实打实地换成主金。 */
:root[data-theme="gold"] .btn-primary:hover {
  background: #d9c48c;
  box-shadow: none;
  filter: none;
}

/* 描边按钮的文字在黑金下用主金已经够（9.4:1），hover 时不要再加金底 + 金边 +
   金字三件套，只提亮描边。 */
:root[data-theme="gold"] .btn-outline:hover {
  border-color: rgba(217, 196, 140, 0.32);
}

/* ============ 黑金 Toast 覆写 ============ */
/* 反色约定下黑金的 --surface-inverse 是浅色，改用中性底 + 1px 描边 */
:root[data-theme="gold"] .toast {
  background: var(--surface-3, var(--surface));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), var(--shadow-2);
}

:root[data-theme="gold"] .toast-ok i {
  color: var(--success-fg);
}

:root[data-theme="gold"] .toast-error i {
  color: var(--danger);
}

/* 深色主题的图标颜色修正：反色底色下浅绿/浅粉看不清 */
:root[data-theme="dark"] .toast-ok i {
  color: #1e7e34;
}

:root[data-theme="dark"] .toast-error i {
  color: #b3261e;
}
