/* ===== 主题变量 ===== */
:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-elev2: #191d26;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e9ebf1;
  --text-2: rgba(233, 235, 241, 0.64);
  --text-3: rgba(233, 235, 241, 0.4);
  --accent: #4d8dff;
  --accent-soft: rgba(77, 141, 255, 0.2);
  --on-accent: #fff;
  --danger: #ff7070;
  --danger-soft: rgba(255, 112, 112, 0.12);
  --ok: #46cf80;
  --tint: #1a2745;
  --tint-line: rgba(112, 156, 255, 0.35);
  --tint-label: #8fb0f2;
  --tint-teal: #143233;
  --tint-teal-line: rgba(72, 199, 181, 0.32);
  --tint-teal-label: #7fd2c6;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --tabbar-bg: rgba(11, 13, 18, 0.86);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-elev: #ffffff;
  --bg-elev2: #eceef3;
  --bg-hover: rgba(20, 24, 33, 0.05);
  --border: rgba(20, 24, 33, 0.09);
  --text: #16191f;
  --text-2: rgba(22, 25, 31, 0.62);
  --text-3: rgba(22, 25, 31, 0.4);
  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, 0.12);
  --on-accent: #fff;
  --danger: #d94848;
  --danger-soft: rgba(217, 72, 72, 0.1);
  --ok: #1f9d58;
  --tint: #e9f0fd;
  --tint-line: #b9d0f7;
  --tint-label: #4a6fbe;
  --tint-teal: #e6f5f1;
  --tint-teal-line: #b3e0d5;
  --tint-teal-label: #2e8a7d;
  --shadow: 0 14px 40px rgba(20, 24, 33, 0.12);
  --tabbar-bg: rgba(255, 255, 255, 0.88);
  color-scheme: light;
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 50% -12%, var(--accent-soft), transparent 72%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.text-3 { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-err { color: var(--danger); }
.text-dim { color: var(--text-2); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn.is-busy { opacity: 0.55; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); cursor: pointer; flex: none;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn-sm { width: 32px; height: 32px; color: var(--text-3); }
.icon-btn svg { display: block; }
.icon-btn.is-spinning svg { animation: spin 0.9s linear infinite; color: var(--accent); }
/* 复制按钮脱离文档流，数字才能真正居中 */
.float-copy { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 登录 ===== */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 50% at 20% 0%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 360px; padding: 36px 28px 28px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-mark {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); margin-bottom: 18px;
}
.auth-title { font-size: 22px; font-weight: 600; }
.auth-sub { color: var(--text-3); font-size: 13px; margin: 4px 0 24px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text);
  font: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--danger); font-size: 13px; margin: -4px 0 12px; }
.auth-card .btn { margin-top: 8px; height: 46px; font-size: 15px; }

/* ===== 整体框架：桌面是一块居中的面板，不是铺满屏幕 ===== */
.shell {
  width: min(1080px, calc(100vw - 48px));
  height: calc(100dvh - 32px);
  margin: 16px auto;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
}
.topbar {
  flex: none; min-height: 60px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 12px;
  padding: 0 18px; padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--border); background: var(--bg-elev); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.brand-name { font-size: 15px; font-weight: 600; white-space: nowrap; }
.tabs {
  display: flex; gap: 4px; justify-self: center; padding: 4px;
  border-radius: 14px; background: var(--bg-elev2); border: 1px solid var(--border);
}
.tab {
  height: 36px; padding: 0 22px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab:active { transform: scale(0.97); }
.tab.is-active {
  background: var(--accent); border-color: transparent; color: var(--on-accent);
  box-shadow: 0 4px 14px var(--accent-soft);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; justify-self: end; }
.sync-state { font-size: 12px; color: var(--text-3); margin-right: 8px; white-space: nowrap; }
.sync-state.is-err { color: var(--danger); }

.main { flex: 1; min-height: 0; position: relative; }
.page { position: absolute; inset: 0; display: flex; min-height: 0; }
.list-pane {
  width: 326px; height: 100%; flex: none; min-height: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--bg);
}
.list-head { flex: none; padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border-radius: 10px; background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text-3);
}
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  color: var(--text); font: inherit; appearance: none;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.list-meta { font-size: 12px; color: var(--text-3); padding: 0 4px; }
.list {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 10px 14px; overscroll-behavior: contain;
}
.row {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  cursor: pointer; text-align: left; transition: background 0.12s;
}
.row:hover { background: var(--bg-hover); }
.row.is-active { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { flex: none; font-size: 12px; color: var(--text-3); }
.badge {
  flex: none; font-size: 11px; color: var(--text-3); padding: 1px 7px; border-radius: 999px;
  background: var(--bg-elev2);
}
.list-empty { padding: 40px 16px; text-align: center; color: var(--text-3); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 28px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--bg-elev2); color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip.is-active { background: var(--accent-soft); color: var(--text); }

.detail-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 30px 34px 44px; background: var(--bg-elev); }
.detail-pane-center { display: block; }
.detail-card { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 0; margin-bottom: 8px; }
.detail-top .btn {
  height: 42px; padding: 0 18px; border-radius: 11px; border-color: transparent;
  background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.detail-top .btn:hover { filter: brightness(1.08); }
.btn-back { display: none; }
.hero-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 18px 20px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-elev2);
}
.hero { font-size: 26px; font-weight: 600; line-height: 1.25; word-break: break-all; }
.hero-email { font-size: 22px; font-weight: 600; }

/* 卡片详情：做成一张有实体的卡片，而不是一行文字 */
.card-hero {
  position: relative; min-height: clamp(180px, 28vh, 280px); align-items: center; justify-content: center; text-align: center;
  overflow: hidden; border: 0; padding: 22px 24px; color: #fff;
  background: #2a5bc4;
  box-shadow: 0 6px 16px rgba(20, 40, 90, 0.18);
}
.card-hero::before {
  content: ''; position: absolute; top: 22px; left: 24px; width: 40px; height: 30px; border-radius: 6px;
  background: #e3c36a; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}
.card-hero::after {
  content: '支付卡'; position: absolute; top: 26px; right: 24px;
  font-size: 12px; letter-spacing: 0.22em; opacity: 0.85;
}
.card-hero .hero { position: relative; color: #fff; font-size: clamp(30px, 4.2vw, 46px); }
.card-hero .icon-btn { position: absolute; color: rgba(255, 255, 255, 0.9); }
.card-hero .float-copy { right: 20px; bottom: 18px; top: auto; transform: none; }
.card-hero .icon-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.tag { padding: 2px 8px; border-radius: 6px; background: var(--bg-elev2); color: var(--text-2); }

.sec { margin-top: 30px; }
.sec-title { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-2); letter-spacing: 0.08em; margin-bottom: 10px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
/* 账号详情：小色块用纯色，不用花哨渐变 */
.account-detail .sec {
  padding: 14px 16px; border-radius: 12px;
  background: var(--tint-teal); border: 1px solid var(--tint-teal-line);
}
.account-detail .sec-title { color: var(--tint-teal-label); }
.account-detail .totp { background: var(--tint); border: 1px solid var(--tint-line); }
.account-detail .totp .totp-hint { color: var(--tint-label); }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.fact {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 6px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--tint); border: 1px solid var(--tint-line);
}
.fact-label { grid-column: 1 / -1; font-size: 12px; color: var(--tint-label); font-weight: 500; }
.fact-value { font-size: 16px; font-weight: 500; }
.fact .icon-btn { grid-column: 2; grid-row: 2; width: 28px; height: 28px; }

.kv {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 42px; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.kv:last-child { border-bottom: 0; }
.kv-label { font-size: 13px; color: var(--text-2); }
.kv-value { min-width: 0; overflow-wrap: anywhere; }
.kv-actions { display: flex; align-items: center; gap: 2px; }
.kv-link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; overflow-wrap: anywhere; text-align: left; }
.kv-link:hover { text-decoration: underline; }
.empty-line { color: var(--text-3); padding: 6px 0; }

.sec-otp { flex: none; }
.otp-box {
  min-height: 200px; padding: 16px 20px; border-radius: 12px;
  background: var(--tint); border: 1px solid var(--tint-line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.otp-refresh { margin-top: 10px; font-size: 13px; }
.otp-main { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 68px; }
.code { font-size: clamp(44px, 7vh, 68px); font-weight: 600; letter-spacing: 0.16em; line-height: 1.15; color: var(--text); }
.code-accent { color: var(--accent); }
.otp-line { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 60px; flex-wrap: wrap; }
.otp-time {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px;
  margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--text-2);
}
.otp-err { margin-top: 8px; }
.otp-sub { display: flex; align-items: baseline; justify-content: center; }
.otp-tz { color: var(--text-3); }
.otp-time .mono { color: var(--text-2); }
.otp-age { font-size: 12px; color: var(--text-3); }
.otp-age.is-fresh { color: var(--ok); font-weight: 500; }
.otp-wait { display: flex; flex: 1; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); min-height: 150px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.totp {
  margin-bottom: 6px; padding: 18px 16px; border-radius: 14px;
  background: var(--bg-elev2); border: 1px solid var(--border); text-align: center;
}
.totp-line { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 68px; }
.totp-bar { height: 4px; border-radius: 2px; background: var(--bg-elev); margin: 14px 0 8px; overflow: hidden; }
.totp-bar-fill { height: 100%; background: var(--accent); transition: width 1s linear; }
.totp-hint { font-size: 12px; color: var(--text-3); text-align: center; }

/* 账号页的备注区和卡片页保持一致：不带青色底、不带边框 */
.account-detail .sec.note-sec { background: none; border: 0; padding: 0; }
.account-detail .sec.note-sec .sec-title { color: var(--text-2); }

/* ===== 备注（跟卡片/账号一一对应） ===== */
.note-sec { margin-top: 30px; }
.note-box {
  width: 100%; min-height: 220px; padding: 16px 18px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  font: 16px/1.7 inherit; resize: none; display: block;
}
.note-box[readonly] { color: var(--text); }
.note-box:not([readonly]) { background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-box:focus { outline: none; }
.note-box::placeholder { color: var(--text-3); }
.note-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn-note {
  height: 36px; padding: 0 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  background: var(--accent-soft); border-color: transparent; color: var(--accent); cursor: pointer;
  transition: background 0.15s, filter 0.15s;
}
.btn-note:hover { background: var(--accent-soft); filter: brightness(1.12); }

/* ===== 我的 ===== */
.settings { width: 100%; max-width: 560px; margin: 0 auto; padding: 40px 20px; }
.settings-title { font-size: 22px; font-weight: 600; margin-bottom: 18px; }
.settings-sub { font-size: 13px; color: var(--text-3); margin: 26px 0 10px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 4px 16px; }
.card-form { padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.card-form .btn { align-self: flex-start; margin-top: 6px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); flex-wrap: wrap; padding: 6px 0; }
.card-row:last-child { border-bottom: 0; }
.card-row-stack { flex-direction: column; align-items: flex-start; gap: 8px; }
.card-label { font-size: 13px; color: var(--text-2); flex: none; }
.card-value { min-width: 0; overflow-wrap: anywhere; }
.card-value-sub { font-size: 13px; color: var(--text-3); }
.card-hint { font-size: 12px; color: var(--text-3); }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--bg-elev2); }
.seg-btn { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-size: 13px; cursor: pointer; }
.seg-btn.is-active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.settings .btn-logout { margin-top: 28px; }

/* ===== 提示 ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  max-width: calc(100vw - 40px); padding: 9px 16px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 底部导航（仅手机） ===== */
.tabbar { display: none; }

/* ===== 手机 ===== */
@media (max-width: 760px) {
  body { background: var(--bg); }
  .shell {
    width: 100%; height: 100dvh; margin: 0;
    border: 0; border-radius: 0; box-shadow: none;
  }
  .topbar { display: flex; min-height: 52px; padding: 0 8px 0 14px; }
  .topbar-actions { margin-left: auto; }
  .tabs { display: none; }
  .brand-name { font-size: 16px; }
  .sync-state { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn-sm { width: 36px; height: 36px; }

  .tabbar {
    flex: none; display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--border); background: var(--tabbar-bg);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .tabbar-btn {
    flex: 1; height: 56px; border: 0; background: transparent; color: var(--text-3);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; cursor: pointer;
  }
  .tabbar-btn.is-active { color: var(--accent); font-weight: 600; }
  .tabbar-btn.is-active svg { filter: drop-shadow(0 2px 6px var(--accent-soft)); }

  .list-pane { width: 100%; border-right: 0; }
  .list-head { padding: 10px 12px 6px; }
  .search { height: 40px; }
  .search input, .field input { font-size: 16px; }
  .list { padding: 4px 8px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .row { height: 46px; }

  .page { display: block; }
  .detail-pane {
    position: absolute; inset: 0; z-index: 2; transform: translateX(100%);
    transition: transform 0.22s ease-out; padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
  }
  .hero-row { padding: 14px 16px; }
  .page.showing-detail .detail-pane { transform: none; }
  .page.showing-detail .list-pane { visibility: hidden; transition: visibility 0s 0.22s; }
  .detail-pane-center { transform: none; }
  .btn-back { display: inline-grid; }
  .detail-top { margin-bottom: 6px; min-height: 44px; }
  .hero { font-size: 20px; }
  .hero-email { font-size: 18px; }
  .card-hero { min-height: 150px; padding: 16px; }
  .card-hero::before { top: 18px; left: 16px; width: 32px; height: 24px; }
  .card-hero::after { top: 20px; right: 16px; }
  .card-hero .hero { font-size: 23px; }
  .card-hero .float-copy { right: 12px; bottom: 12px; }
  .account-detail .sec { padding: 12px; }
  .code { font-size: 36px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
  .facts .fact:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .fact { padding: 10px 12px; }
  .fact-value { font-size: 14px; }
  .kv { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .sec { margin-top: 24px; }
  .settings { padding: 20px 0; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
