:root {
  --bg: #f3f4f6; --surface: #ffffff; --text: #15181d; --muted: #667085; --line: #e2e5ea;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e4f3f1;
  --warn: #c2410c; --warn-soft: #fdf0e7; --danger: #b42318;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --surface: #1a1d23; --text: #eceef2; --muted: #98a1b0; --line: #2b2f38;
    --accent: #2dd4bf; --accent-ink: #05211e; --accent-soft: #132f2c;
    --warn: #fb923c; --warn-soft: #3a2414; --danger: #f97066;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0; }
code { font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* 登录页 */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.lock-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px 20px; box-shadow: var(--shadow); display: grid;
}
.mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 14px; }
.lock-card h1 { margin-bottom: 6px; }
.lock-card .lead { font-size: 13px; margin-bottom: 18px; }
.lock-card .btn.primary { padding: 10px 14px; margin-top: 4px; }
.help { margin-top: 16px; font-size: 13px; color: var(--muted); }
.help summary { cursor: pointer; text-align: center; color: var(--accent); }
.help p { margin-top: 8px; }

/* 表单 */
.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.field input, .inline input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
.err { color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.err:empty, .msg:empty { display: none; }
.msg { font-size: 13px; margin-top: 10px; }
.msg.bad { color: var(--danger); }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.note.lead { margin: 0 0 10px; }
.inline { display: flex; gap: 8px; margin-top: 10px; }
.inline input { flex: 1; min-width: 0; padding: 8px 12px; }
section > .inline:first-of-type { margin-top: 0; }

/* 主界面 */
.app { max-width: 560px; margin: 0 auto; padding: 28px 16px 48px; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.banner {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 13px;
}
.banner.warn { background: var(--warn-soft); }
#alertText { flex: 1 1 260px; min-width: 0; white-space: pre-line; }
.clock { color: var(--warn); }
.history { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.history:empty { display: none; }
.history li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
}
.history li > div { display: grid; min-width: 0; }
.history .small { overflow-wrap: anywhere; }
#search {
  margin-top: 16px; width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 4px 8px 4px 4px;
}
.copy {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  text-align: left; font: inherit; color: inherit; background: none; border: none;
  padding: 12px; border-radius: 10px; cursor: pointer;
}
.copy:hover, .row.copied .copy { background: var(--accent-soft); }
.who { min-width: 0; display: grid; }
.issuer { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name:empty { display: none; }
.code {
  font: 600 26px/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; letter-spacing: .03em; color: var(--accent); white-space: nowrap;
}
.row.ending .code { color: var(--warn); }
.ring { position: relative; width: 34px; height: 34px; flex: none; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; }
.row.ending .ring .bar { stroke: var(--warn); }
.sec { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.more { flex: none; width: 32px; height: 32px; border: none; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.more:hover { background: var(--bg); color: var(--text); }
.empty { margin-top: 40px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty p { max-width: 360px; font-size: 14px; }
.foot { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted); }

/* 对话框 */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(12,14,18,.55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 0 20px; }
.dlg-body { padding: 14px 20px 20px; display: grid; gap: 18px; }
.x { border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 8px; }
.x:hover { background: var(--bg); color: var(--text); }
hr { border: none; border-top: 1px solid var(--line); margin: 0; width: 100%; }
.steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; color: var(--muted); }
.cam { margin-top: 12px; display: grid; gap: 8px; justify-items: start; }
.cam video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.secret { display: block; margin-top: 8px; padding: 10px 12px; font-size: 14px; word-break: break-all; user-select: all; border-radius: 10px; }
.split { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 13px;
  transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px); z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
