
<style>
/* ── Auth Page ─────────────────────────────── */
.auth-page {
  position: fixed; inset: 0; z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  background: var(--bg);
  overflow: hidden;
}
.auth-page.active { display: flex; }

/* 背景装饰气泡 */
.auth-bg-blob {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: .18; pointer-events: none;
}
.auth-blob-1 {
  width: 280px; height: 280px;
  background: var(--blue);
  top: -60px; right: -60px;
}
.auth-blob-2 {
  width: 220px; height: 220px;
  background: var(--blue);
  bottom: -40px; left: -40px;
  opacity: .10;
}

/* 卡片容器 */
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 360px;
  margin: 0 auto;
  padding: 32px 24px 24px;
  display: flex; flex-direction: column; gap: 0;
  /* 在 iOS 上需要 safe-area */
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* Logo */
.auth-logo {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  margin-bottom: 32px;
}
.auth-logo-icon      { font-size: 48px; line-height: 1; }
.auth-logo-wordmark  { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.auth-logo-sub       { font-size: 13px; color: var(--text-dim); }

/* Tab 按钮 */
.auth-tabs {
  display: flex; gap: 0;
  background: var(--bg2);
  border-radius: 12px; padding: 3px;
  margin-bottom: 24px;
}
.auth-tab-btn {
  flex: 1; padding: 8px 0;
  border: none; background: transparent;
  color: var(--text-dim);
  font-size: 14px; font-weight: 600;
  border-radius: 10px; cursor: pointer;
  transition: background .18s, color .18s;
}
.auth-tab-btn.active {
  background: var(--card-bg, #fff);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* 表单面板 */
.auth-panel {
  flex-direction: column; gap: 14px;
}

/* 字段 */
.auth-field       { display: flex; flex-direction: column; gap: 5px; }
.auth-label       { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: .3px; }
.auth-input {
  width: 100%; padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--separator, rgba(0,0,0,.1));
  background: var(--bg2);
  color: var(--text);
  font-size: 16px;          /* 16px 防 iOS 自动缩放 */
  outline: none;
  transition: border-color .18s;
  box-sizing: border-box;
}
.auth-input:focus {
  border-color: var(--blue);
}

/* 错误提示 */
.auth-error {
  font-size: 13px; color: var(--red, #ff3b30);
  padding: 8px 12px;
  background: rgba(255,59,48,.08);
  border-radius: 8px;
  margin-top: -4px;
}

/* 主按钮 */
.auth-btn-primary {
  width: 100%; padding: 14px;
  border: none; border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.auth-btn-primary:active  { opacity: .85; transform: scale(.98); }
.auth-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* 跳过按钮 */
.auth-skip-btn {
  margin-top: 20px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 13px; cursor: pointer;
  text-align: center; width: 100%;
  padding: 8px;
}

/* ── Sync Indicator ─────────────────────────── */
.sync-indicator {
  width: 8px; height: 8px;
  border-radius: 50%; display: inline-block;
  transition: background .3s;
}
.sync-idle    { background: var(--text-dim, #aaa); }
.sync-syncing { background: var(--blue); animation: sync-pulse 1s infinite; }
.sync-ok      { background: #34c759; }
.sync-error   { background: var(--red, #ff3b30); }
.sync-partial { background: #ff9500; }

@keyframes sync-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .3; }
}

/* ── Sync Failure Badge ───────────────────────── */
.sync-failure-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--red, #ff3b30);
  color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
  cursor: pointer; user-select: none;
}

/* ── Sync Failure Popover ─────────────────────── */
.sync-failure-popover {
  display: none; position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 120px));
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 9999; overflow: hidden;
  flex-direction: column;
}
.sync-failure-popover.open { display: flex; }

.sync-failure-popover-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border, #e0e0e0);
}
.sync-failure-popover-title { font-size: 14px; font-weight: 600; }
.sync-failure-popover-retry-all {
  font-size: 13px; color: var(--blue); background: none; border: none;
  cursor: pointer; padding: 4px 8px;
}

.sync-failure-popover-list {
  overflow-y: auto; flex: 1;
  padding: 8px 0;
}

.sync-failure-popover-entry {
  padding: 10px 16px; border-bottom: 1px solid var(--border-light, #f0f0f0);
}
.sync-failure-popover-entry.is-longterm {
  background: #fff8f0;
}
.sync-failure-popover-entry.is-longterm .sync-failure-entry-longterm {
  color: #ff9500; font-size: 12px; margin: 4px 0;
}

.sync-failure-entry-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.sync-failure-entry-type {
  font-size: 11px; color: var(--blue); background: rgba(0,122,255,.1);
  padding: 1px 6px; border-radius: 4px;
}
.sync-failure-entry-id {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
}
.sync-failure-entry-time { font-size: 11px; color: var(--text-dim, #999); margin-left: auto; }
.sync-failure-entry-error {
  font-size: 12px; color: var(--text-dim, #999);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 6px;
}

.sync-failure-entry-retry {
  font-size: 12px; color: var(--blue); background: none; border: 1px solid var(--blue);
  border-radius: 4px; padding: 2px 8px; cursor: pointer;
}

.sync-failure-popover-empty {
  padding: 32px 16px; text-align: center;
  font-size: 14px; color: var(--text-dim, #999);
}
</style>