:root {
  --bg: #efe4cc;
  --paper: #fffaf1;
  --ink: #1a1612;
  --muted: #6d6256;
  --line: #e0d0b4;
  --accent: #0e6b54;
  --accent-ink: #f4fff9;
  --warn: #c45c26;
  --danger: #b42318;
  --stamp: #c43d32;
  --shadow: 0 10px 30px rgba(26, 22, 18, 0.08);
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(196, 93, 38, 0.12), transparent 50%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
a { color: var(--accent); }

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(239, 228, 204, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 22px;
  letter-spacing: 0.08em;
  margin: 0;
  font-weight: 700;
}
.brand small {
  display: block;
  font-size: 12px;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.page { padding: 16px; display: grid; gap: 14px; }
.page h2 { margin: 0; font-size: 20px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-variant-numeric: tabular-nums; margin-top: 6px; font-weight: 700; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 4px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.list { display: grid; gap: 10px; }
.item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
}
.item .email { font-weight: 700; word-break: break-all; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stamp {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.stamp.ok { color: var(--accent); }
.stamp.warn { color: var(--warn); }
.stamp.bad { color: var(--stamp); }
.stamp.mute { color: var(--muted); }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #ece2cd;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: #f8e1dc; color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 13px; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label.check {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  color: var(--ink);
  font-size: 14px;
  padding: 8px 0;
  border: 0;
  background: transparent;
}
label.check input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  max-width: 16px;
  max-height: 16px;
  margin: 0;
  padding: 0;
  flex: none;
  border: 1px solid var(--line);
  accent-color: var(--accent);
}

.item .when { font-size: 12px; color: var(--muted); margin-top: -2px; }
.meta.stamps { gap: 6px; }
.meta.prices {
  font-variant-numeric: tabular-nums;
  gap: 12px;
}

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fffaf1;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 760px;
  margin: 0 auto;
  z-index: 30;
}
.bottom-nav a {
  text-decoration: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  gap: 2px;
}
.bottom-nav a.active { color: var(--accent); font-weight: 700; }
.bottom-nav .ico { font-size: 18px; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate .card { width: min(100%, 420px); display: grid; gap: 12px; }
.gate h1 { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 24px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 50;
  font-size: 14px;
  max-width: 86%;
}

.secret {
  margin: 4px 0 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
  font-size: 14px;
}
.field-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.field-row:last-child { border-bottom: 0; }
.label { font-size: 12px; color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.token-text { max-height: 120px; overflow: auto; font-size: 12px; }

.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(26, 22, 18, 0.4);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: min(100%, 760px);
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
}
.search { display: flex; gap: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}
.field-edit {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.field-edit input,
.field-edit textarea {
  flex: 1;
  min-width: 0;
}
.field-edit .btn { flex-shrink: 0; }
textarea.token-input { min-height: 110px; font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.code-input {
  text-align: center;
  letter-spacing: 0.28em;
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
}
.pickup-show {
  font-size: 28px;
  letter-spacing: 0.18em;
  font-weight: 700;
  text-align: center;
  margin: 6px 0 0;
}

.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

.preview-item {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  display: grid;
  gap: 4px;
}

.extract-body { background: var(--bg); }
.extract-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: grid;
  gap: 14px;
}
.extract-head h1 { margin: 4px 0 8px; }
.brand-mark {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--stamp);
  font-weight: 700;
}
.empty-card { text-align: center; padding: 36px 16px; }

.copy-box {
  white-space: pre-wrap;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  user-select: all;
}

.form-stack { display: grid; gap: 10px; }
.top-actions { display: flex; gap: 8px; }
