:root {
  --bg: #f6f7f9;
  --fg: #0a0a0b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: rgb(9 9 11 / 0.08);
  --line-strong: rgb(9 9 11 / 0.14);
  --card: rgb(255 255 255 / 0.82);
  --solid: #ffffff;
  --hover: rgb(9 9 11 / 0.04);
  --accent: #10b981;
  --accent-fg: #047857;
  --glow-1: rgb(16 185 129 / 0.16);
  --glow-2: rgb(99 102 241 / 0.12);
  --danger: #e11d48;
  --low: #f43f5e;
  --av-l: 45%;
  --av-bg: 0.13;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px -12px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 1px 2px rgb(0 0 0 / 0.04), 0 24px 48px -20px rgb(0 0 0 / 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --fg: #fafafa;
    --muted: #a1a1aa;
    --faint: #71717a;
    --line: rgb(255 255 255 / 0.08);
    --line-strong: rgb(255 255 255 / 0.14);
    --card: rgb(24 24 27 / 0.72);
    --solid: #18181b;
    --hover: rgb(255 255 255 / 0.05);
    --accent: #34d399;
    --accent-fg: #6ee7b7;
    --glow-1: rgb(16 185 129 / 0.14);
    --glow-2: rgb(99 102 241 / 0.12);
    --danger: #fb7185;
    --low: #fb7185;
    --av-l: 70%;
    --av-bg: 0.16;
    --shadow: 0 1px 0 rgb(255 255 255 / 0.04) inset;
    --shadow-lg: 0 1px 0 rgb(255 255 255 / 0.05) inset, 0 24px 60px -20px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wrap { position: relative; width: min(1040px, 100% - 32px); margin: 0 auto; }
.mono, .code { font-family: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
h2, h3 { margin: 0; }

/* 背景：顶部两团柔光 + 渐隐的点阵 */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto;
  height: 70vh;
  background:
    radial-gradient(40% 60% at 30% 30%, var(--glow-1), transparent 70%),
    radial-gradient(35% 55% at 72% 20%, var(--glow-2), transparent 70%);
  filter: blur(20px);
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(70% 50% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(70% 50% at 50% 0%, #000 30%, transparent 75%);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font: 600 11px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--muted);
  background: var(--hover);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
}

input {
  font: inherit;
  color: inherit;
  background: var(--solid);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--faint); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { color: #fff; background: linear-gradient(180deg, #10b981, #059669); box-shadow: 0 1px 0 rgb(255 255 255 / 0.25) inset, 0 6px 16px -6px rgb(5 150 105 / 0.6); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { color: var(--fg); background: var(--solid); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }

/* 顶栏 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 28px 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; box-shadow: 0 4px 14px -4px rgb(16 185 129 / 0.6); }
.tools { display: flex; gap: 2px; padding: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 9px; cursor: pointer; transition: color 0.15s, background 0.15s; }
.tool:hover { color: var(--fg); background: var(--hover); }
.tool svg { width: 16px; height: 16px; }

/* 主面板：命令栏 + 结果 */
.panel {
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.command { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 18px; height: 60px; border-radius: 14px; cursor: text; transition: background 0.15s; }
.command:focus-within { background: var(--hover); }
.command-icon { width: 22px; height: 22px; color: var(--faint); flex: none; }
.command:focus-within .command-icon { color: var(--accent); }
.command input { flex: 1; min-width: 0; height: 100%; padding: 0; font-size: 17px; background: none; border: 0; box-shadow: none; }
.command input:not(:placeholder-shown) { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; }
.kbds { display: flex; gap: 4px; flex: none; }
.clear { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; color: var(--muted); background: var(--hover); border: 0; border-radius: 50%; cursor: pointer; flex: none; }
.clear:hover { color: var(--fg); }
.clear svg { width: 15px; height: 15px; }
.err { display: flex; align-items: center; gap: 8px; margin: 4px 10px 10px; padding: 10px 14px; color: var(--danger); font-size: 14px; background: color-mix(in srgb, var(--danger) 8%, transparent); border-radius: 10px; }

.result { margin-top: 8px; padding: 20px 18px 18px; border-top: 1px solid var(--line); animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(-4px); } }
.result-main { display: flex; align-items: center; gap: 16px; }
.result-info { display: grid; min-width: 0; flex: 1; }
.result-name { color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code.xl {
  justify-self: start;
  margin: -2px 0 0 -8px;
  padding: 0 8px;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--fg);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.2s;
}
.code.xl:hover { background: var(--hover); }
.result.low .code.xl { color: var(--low); }
.result.flash .code.xl { color: var(--accent-fg); }
.hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.hint .mono { color: var(--fg); font-weight: 600; }
.hint.center { justify-content: center; text-align: center; }
.sep { color: var(--faint); }
.save { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.save input { flex: 1 1 180px; min-width: 0; height: 40px; }
.save-actions { display: flex; gap: 8px; }
.many-title { margin: 0 0 8px; font-weight: 600; }
.many { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.many li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; font-size: 14px; }
.many li.dup { color: var(--faint); text-decoration: line-through; }

/* 头像：首字母 + 按名字算的色相 */
.avatar {
  --h: 160;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  font-weight: 700;
  font-size: 15px;
  color: hsl(var(--h) 65% var(--av-l));
  background: hsl(var(--h) 80% 55% / var(--av-bg));
  border: 1px solid hsl(var(--h) 70% 50% / 0.18);
  border-radius: 10px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 16px; }

/* 倒计时圈 */
.ring { position: relative; display: inline-grid; place-items: center; width: 52px; height: 52px; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { stroke-width: 3; }
.ring .track { stroke: var(--line-strong); }
.ring .arc { stroke: var(--accent); stroke-dasharray: 100.53; transition: stroke-dashoffset 0.2s linear, stroke 0.2s; }
.ring b { position: relative; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.ring.low .arc { stroke: var(--low); }
.ring.low b { color: var(--low); }

/* 账号列表 */
.saved { margin-top: 40px; }
.saved-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.saved-head h2 { font-size: 15px; font-weight: 650; }
.count { margin-left: 8px; padding: 1px 8px; color: var(--muted); font-size: 12px; font-weight: 600; background: var(--hover); border: 1px solid var(--line); border-radius: 999px; vertical-align: 1px; }
.count:empty { display: none; }
.search { display: flex; align-items: center; gap: 8px; width: min(300px, 100%); height: 38px; padding: 0 8px 0 12px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color 0.15s, box-shadow 0.15s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.search input { flex: 1; min-width: 0; padding: 0; font-size: 14px; background: none; border: 0; box-shadow: none; }
.search:focus-within kbd { display: none; }
.saved-head:not(.has-items) .search { display: none; }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.item {
  position: relative;
  overflow: hidden;
  padding: 16px 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: rise 0.25s ease-out backwards;
}
.item:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.item:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.item:active { transform: scale(0.99); }
.item-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who { display: grid; min-width: 0; line-height: 1.35; }
.issuer { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-code { display: flex; align-items: baseline; gap: 10px; margin-top: 14px; }
.item .code { font-size: 30px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.1; transition: color 0.2s; }
.item.low .code { color: var(--low); }
.secs { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.item.low .secs { color: var(--low); }
.next { color: var(--muted); font-size: 12px; opacity: 0; transform: translateX(-4px); transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
.item.low .next { opacity: 1; transform: none; }
.next::before { content: "下一个 "; font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 0.2s linear, background 0.2s; }
.item.low .progress i { background: var(--low); }

.item-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; padding: 2px; background: var(--solid); border: 1px solid var(--line); border-radius: 10px; opacity: 0; transform: translateY(-2px); transition: opacity 0.15s, transform 0.15s; }
.item:hover .item-actions, .item:focus-within .item-actions { opacity: 1; transform: none; }
@media (hover: none) { .item-actions { opacity: 1; transform: none; background: none; border-color: transparent; } }
.icon { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; color: var(--muted); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.icon:hover { color: var(--fg); background: var(--hover); }
.icon svg { width: 16px; height: 16px; }

/* 复制后的反馈 */
.copied {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 4px;
  align-content: center;
  color: var(--accent-fg);
  font-weight: 650;
  font-size: 14px;
  background: color-mix(in srgb, var(--solid) 88%, var(--accent));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.copied svg { width: 26px; height: 26px; stroke-width: 2.4; }
.item.flash .copied { opacity: 1; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--line-strong); border-radius: 16px; }
.empty svg { width: 34px; height: 34px; color: var(--faint); stroke-width: 1.5; }
.empty p { margin: 0; }
.empty b { color: var(--fg); font-weight: 600; }
.empty.slim { padding: 24px; }
.note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 36px 0 48px; color: var(--faint); font-size: 12.5px; text-align: center; }
.note svg { width: 14px; height: 14px; flex: none; }

/* 对话框 */
.dlg { padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--solid); color: var(--fg); width: min(380px, 100% - 32px); box-shadow: var(--shadow-lg); }
.dlg[open] { animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }
.dlg::backdrop { background: rgb(0 0 0 / 0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dlg-body { padding: 22px; }
.dlg h3 { font-size: 16px; margin-bottom: 16px; overflow-wrap: anywhere; }
.dlg label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
.dlg label input { color: var(--fg); height: 40px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.grow { flex: 1; }
.qr { padding: 10px; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: auto; }

.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; }
.drop div { display: grid; justify-items: center; gap: 12px; width: min(460px, 100%); padding: 48px 24px; font-size: 17px; font-weight: 600; color: var(--accent-fg); background: var(--solid); border: 2px dashed var(--accent); border-radius: 24px; }
.drop svg { width: 40px; height: 40px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  color: var(--bg);
  background: var(--fg);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px -8px rgb(0 0 0 / 0.35);
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .top { padding: 18px 0 16px; }
  .tool span { display: none; }
  .tool { padding: 0 10px; }
  .kbds { display: none; }
  .command { height: 54px; padding: 0 10px 0 14px; }
  .command input { font-size: 16px; }
  .code.xl { font-size: 38px; }
  .avatar.lg { width: 46px; height: 46px; font-size: 19px; border-radius: 13px; }
  .ring { width: 44px; height: 44px; }
  .save-actions { flex: 1; }
  .save-actions .btn { flex: 1; }
  .search { width: 100%; }
  .search kbd { display: none; }
  .list { grid-template-columns: 1fr; }
}
