/* ==========================================================================
   app.css — MemoryCollection 站点共享样式
   组成：设计变量 → 基础排版 → 布局 → 通用组件 → 各页面私有样式
   主题：由 <html data-theme="light|dark"> 控制，页面 <head> 内联脚本预置，避免闪烁
   ========================================================================== */

/* ------------------------------ 1. 设计变量 ------------------------------ */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f5f8;
  --glow-1: rgba(99, 102, 241, 0.13);
  --glow-2: rgba(14, 165, 233, 0.10);
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f3f7;
  --text: #111319;
  --text-2: #545f6e;
  --text-3: #8b94a3;
  --line: #e8eaef;
  --line-strong: #d9dde5;

  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-line: rgba(79, 70, 229, 0.22);

  --ok: #0e9f6e;
  --ok-soft: rgba(14, 159, 110, 0.10);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.10);
  --danger: #dc2626;

  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius: 13px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 16px 40px -18px rgba(16, 24, 40, 0.28), 0 2px 8px rgba(16, 24, 40, 0.04);
  --shadow-accent: 0 10px 24px -12px rgba(79, 70, 229, 0.55);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

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

  --bg: #0a0c10;
  --glow-1: rgba(99, 102, 241, 0.18);
  --glow-2: rgba(14, 165, 233, 0.10);
  --surface: #14171d;
  --surface-2: #181c23;
  --surface-3: #1d222a;
  --text: #eceef3;
  --text-2: #9aa4b3;
  --text-3: #6d7787;
  --line: #242932;
  --line-strong: #303743;

  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-ink: #12131a;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --accent-line: rgba(129, 140, 248, 0.28);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 18px 44px -20px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-accent: 0 10px 26px -14px rgba(129, 140, 248, 0.5);
}

/* ------------------------------ 2. 基础排版 ------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 var(--font-sans);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 顶部柔和光晕，比大面积渐变背景更耐看 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(52% 38% at 12% -6%, var(--glow-1), transparent 72%),
    radial-gradient(46% 34% at 96% -4%, var(--glow-2), transparent 70%);
}

h1, h2, h3, p, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.16s var(--ease);
}

a:hover {
  color: var(--accent-2);
}

b, strong {
  font-weight: 600;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

svg {
  display: block;
  flex: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-2);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------- 3. 布局 -------------------------------- */
.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 18px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page--narrow {
  max-width: 560px;
}

.page--center {
  justify-content: center;
  min-height: 100vh;
  padding-bottom: 56px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: inherit;
}

.brand:hover {
  color: inherit;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-accent);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.brand__text b {
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.brand__text small {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer {
  margin-top: 4px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--text-3);
}

.footer a {
  color: var(--text-2);
  border-bottom: 1px solid var(--line-strong);
}

.footer a:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

/* ------------------------------ 4. 通用组件 ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card--pad-lg {
  padding: 24px;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card__title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
    background-color 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}

.btn--primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn--primary:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -12px rgba(79, 70, 229, 0.62);
}

.btn--primary:active {
  transform: translateY(0) scale(0.995);
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--surface-2);
}

.btn--block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn--done {
  background: var(--ok-soft) !important;
  border-color: transparent !important;
  color: var(--ok) !important;
  box-shadow: none !important;
}

/* 图标按钮 */
.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease),
    background-color 0.16s var(--ease), transform 0.16s var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.icon-btn__sun { display: none; }
[data-theme="dark"] .icon-btn__sun { display: block; }
[data-theme="dark"] .icon-btn__moon { display: none; }

/* 徽章 / 标签 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  vertical-align: middle;
}

.badge--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--plain {
  background: var(--surface-3);
  color: var(--text-3);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.chip svg {
  opacity: 0.7;
}

/* 提示条 */
.note {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
}

.note--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* 骨架屏 */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s var(--ease) infinite;
}

@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

/* 空状态 */
.empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
  color: var(--text-3);
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------ 5. X1 下载页 ----------------------------- */
.hero {
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -60%;
  right: -20%;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  pointer-events: none;
}

.hero__head {
  display: flex;
  align-items: center;
  gap: 15px;
}

.appicon {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 16px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #fff;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-accent);
}

.appicon::after {
  content: "";
  position: absolute;
  inset: 1px 1px auto;
  height: 46%;
  border-radius: 15px 15px 40% 40% / 15px 15px 26% 26%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent);
  pointer-events: none;
}

.hero__title {
  min-width: 0;
}

.hero__title h1 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hero__title p {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-3);
}

.verline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 12px;
}

.verline__ver {
  font-family: var(--font-mono);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.verline__build {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.actions .btn--primary {
  flex: 1 1 190px;
}

/* 更新日志 */
.log {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.log > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.log > summary::-webkit-details-marker {
  display: none;
}

.log > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.6px solid var(--text-3);
  border-bottom: 1.6px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s var(--ease);
}

.log[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

.log__body {
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--text-2);
}

.log__line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.log__type {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

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

.log__rest {
  margin-top: 8px;
  font-size: 12.8px;
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 安装步骤 */
.steps {
  display: grid;
  gap: 12px;
  counter-reset: step;
}

.step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  counter-increment: step;
}

.step::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: none;
  margin-top: 1px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
}

.step b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}

.step span {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-3);
}

/* 历史版本 */
.history {
  display: flex;
  flex-direction: column;
}

.history__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.history__row:first-child {
  border-top: 0;
  padding-top: 2px;
}

.history__ver {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history__meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history__get {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}

.history__get:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ------------------------------ 6. 2FA 页面 ------------------------------ */
.totp__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.totp__title h1 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.totp__title p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
}

/* 倒计时环 */
.ring {
  position: relative;
  width: 46px;
  height: 46px;
  margin-left: auto;
  flex: none;
}

.ring svg {
  transform: rotate(-90deg);
}

.ring__track {
  stroke: var(--surface-3);
}

.ring__bar {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s var(--ease);
}

.ring.is-low .ring__bar {
  stroke: var(--warn);
}

.ring__num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.ring.is-low .ring__num {
  color: var(--warn);
}

.totp__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.totp-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.totp-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.totp-card::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: var(--left, 100%);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.55;
  transition: width 0.9s linear, background 0.3s var(--ease);
}

.totp-card.is-low::after {
  background: var(--warn);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.totp-card__body {
  min-width: 0;
  flex: 1;
}

.totp-card__name {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.totp-card__code {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
  user-select: all;
  transition: filter 0.22s var(--ease), opacity 0.22s var(--ease);
}

.totp-card__code.is-error {
  color: var(--danger);
  font-size: 17px;
  letter-spacing: 0;
}

.masked .totp-card__code {
  filter: blur(9px);
  opacity: 0.55;
  cursor: pointer;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.16s var(--ease);
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.copy-btn:active {
  transform: scale(0.97);
}

.copy-btn.is-done {
  color: var(--ok);
  border-color: transparent;
  background: var(--ok-soft);
}

.totp__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--text-3);
}

@media (max-width: 420px) {
  .totp-card {
    padding: 14px;
    gap: 11px;
  }

  .totp-card__code {
    font-size: 22px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
  }
}

/* ------------------------------- 7. 404 页 ------------------------------- */
.err {
  text-align: center;
  padding: 8px 4px 4px;
}

.err__code {
  font-family: var(--font-mono);
  font-size: clamp(64px, 20vw, 96px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.err__title {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 650;
}

.err__desc {
  margin: 6px auto 22px;
  max-width: 300px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-3);
}

.err__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------------------------- 8. 动效降级 ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------- 9. 小屏微调 ---------------------------- */
@media (max-width: 480px) {
  body {
    font-size: 14.5px;
  }

  .page {
    padding: 18px 14px 44px;
  }

  .card,
  .card--pad-lg {
    padding: 17px;
    border-radius: 16px;
  }

  .verline__ver {
    font-size: 24px;
  }

  .actions .btn {
    flex: 1 1 100%;
  }
}
