:root {
  --bg: #0f1216;
  --card: #171c22;
  --card-2: #1e242c;
  --line: #2a323c;
  --ink: #e8edf3;
  --muted: #8b97a6;
  --acc: #4cc2a0;
  --acc-ink: #06231c;
  --warn: #f0b45a;
  --bad: #e2705f;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 720px; margin: 0 auto; padding: 0 12px 24px; }

/* ---------- 顶栏 ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 2px 10px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 72%, rgba(15, 18, 22, 0));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: linear-gradient(145deg, #2fd6a8, #1c8f74);
  color: #04211a; font-weight: 800; font-size: 17px;
  display: grid; place-items: center;
}
h1 { font-size: 16px; margin: 0; letter-spacing: .3px; }
.top p { margin: 1px 0 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.engine { display: flex; background: var(--card-2); border-radius: 999px; padding: 3px; flex: none; }
.engine button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; padding: 6px 10px; border-radius: 999px; font-weight: 600;
}
.engine button.on { background: var(--acc); color: var(--acc-ink); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}

.pick-actions { display: flex; gap: 8px; }
.pick-actions .primary { flex: 1; }
.pick-sub { display: flex; gap: 8px; margin-top: 8px; }
.pick-sub button { flex: 1; }

button { font: inherit; cursor: pointer; touch-action: manipulation; }
.primary {
  background: var(--acc); color: var(--acc-ink); border: 0;
  border-radius: 11px; padding: 12px 16px; font-weight: 700; font-size: 15px;
}
.primary:disabled { opacity: .45; }
.primary.wide { width: 100%; margin-top: 12px; }
.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 14px;
}
.ghost.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.ghost:active, .primary:active { transform: scale(.98); }

#btnSmall.on { border-color: var(--acc); color: var(--acc); background: rgba(76,194,160,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip {
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
}
.chip.on { border-color: var(--acc); color: var(--acc); background: rgba(76,194,160,.1); }
.chip.hit { border-color: var(--acc); color: var(--acc); font-weight: 700; font-size: 14px; font-family: ui-monospace, Menlo, monospace; }
.chip.hit:active { background: rgba(76,194,160,.18); }

label.mt { margin-top: 10px; }
label.check {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 13px; color: var(--ink);
}
label.check input { width: 18px; height: 18px; accent-color: var(--acc); }

.batch-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
}
.link {
  background: transparent; border: 0; color: var(--muted);
  font-size: 12.5px; padding: 4px 2px; text-decoration: underline;
}
.batch-table { margin-top: 10px; overflow-x: auto; }
.batch-table table { min-width: 100%; }
.batch-table td, .batch-table th { white-space: nowrap; }
.batch-table td { font-size: 13px; }
.batch-table td.miss { color: var(--muted); }
.drop-hint { color: var(--muted); font-size: 12px; margin-top: 10px; }

.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 2px; }
.thumb {
  position: relative; flex: none; width: 62px; height: 62px; border-radius: 10px;
  overflow: hidden; border: 2px solid transparent; background: var(--card-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.on { border-color: var(--acc); }
.thumb .del {
  position: absolute; top: 0; right: 0; width: 20px; height: 20px;
  background: rgba(0,0,0,.62); color: #fff; border: 0; font-size: 12px; line-height: 20px;
  border-radius: 0 8px 0 8px; padding: 0;
}

/* ---------- tabs ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.tabs { display: flex; gap: 6px; background: var(--card-2); padding: 3px; border-radius: 11px; }
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 9px; font-size: 13px; font-weight: 600;
}
.tabs button.on { background: #2b3540; color: var(--ink); }

.pane { margin-top: 12px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
code { background: var(--card-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

label { display: block; font-size: 12px; color: var(--muted); }
label > span { display: block; margin-bottom: 4px; }
input[type="text"], select {
  width: 100%; background: var(--card-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; font-size: 14px;
}
select { appearance: none; }

/* ---------- 字段编辑 ---------- */
.field-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.field {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 11px; padding: 10px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.field .f-name { grid-column: span 1; }
.field .f-kw { grid-column: span 1; }
.field .f-regex { grid-column: span 2; }
.field .f-foot { grid-column: span 2; display: flex; align-items: center; gap: 8px; }
.field .f-foot select { width: auto; flex: 1; padding: 7px 8px; font-size: 13px; }
.field .f-del {
  border: 1px solid var(--line); background: transparent; color: var(--bad);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
}
.btn.add { margin-top: 10px; width: 100%; }

/* ---------- 状态 ---------- */
.status { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.status.busy { color: var(--acc); }
.status.err { color: var(--bad); }

/* ---------- 结果 ---------- */
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h2 { font-size: 15px; margin: 0; }

.shot-wrap { position: relative; margin: 12px 0; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); }
.shot-wrap img { width: 100%; display: block; }
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark {
  position: absolute; border: 2px solid var(--acc); border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(6, 12, 16, .38);
  transition: opacity .18s;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
td.name { color: var(--muted); white-space: nowrap; width: 30%; }
td.val { font-weight: 600; word-break: break-all; }
td.val.miss { color: var(--muted); font-weight: 400; }
tr.pickable { cursor: pointer; }
tr.pickable:active { background: var(--card-2); }
.badge {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: #223; color: var(--muted); margin-left: 6px; vertical-align: 1px;
}
.badge.low { background: #3a2f1c; color: var(--warn); }
.badge.auto { background: #1d2f2a; color: var(--acc); }

.actions { margin-top: 12px; flex-wrap: wrap; }

details.raw { margin-top: 12px; }
details.raw summary { font-size: 13px; color: var(--muted); padding: 6px 0; }
details.raw pre {
  white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.65;
  background: var(--card-2); border-radius: 10px; padding: 10px; max-height: 240px; overflow: auto;
  color: #b9c4d1;
}

.install-help summary { cursor: pointer; padding: 4px 0; }
.install-help ol { margin: 6px 0 0 18px; padding: 0; }
.install-help li { margin: 3px 0; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(15, 18, 22, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.dock[hidden] { display: none; }
.dock-btn { flex: 0 0 auto; padding: 11px 16px; border-radius: 11px; font-weight: 700; }
.dock-btn.primary { background: var(--acc); color: var(--acc-ink); border: 0; }
.dock-btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.dock-btn.ghost.on { color: var(--acc); border-color: var(--acc); }
.dock-btn[disabled] { opacity: .45; }
body { padding-bottom: 88px; }

.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 6px 0 12px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #2b3540; color: var(--ink); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }
