:root {
  --bg: #101216; --panel: #181b21; --panel2: #1f232b; --line: #2a2f3a;
  --text: #e6e8ee; --muted: #8b93a3; --accent: #4f8cff; --ok: #3ecf8e; --warn: #f5a623; --bad: #ff5d5d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 "Segoe UI", "Microsoft YaHei", sans-serif; min-height: 100vh; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
h2 { font-size: 15px; font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.spacer { flex: 1; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.brand { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand span { color: var(--accent); }
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ok .dot { background: var(--ok); }
.status.bad .dot { background: var(--bad); }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 7px 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.upload-zone { border: 2px dashed var(--line); border-radius: 14px; background: var(--panel); min-height: 180px; display: flex; align-items: center; justify-content: center; transition: border-color .15s; }
.upload-zone.drag { border-color: var(--accent); }
.upload-inner { text-align: center; padding: 30px; cursor: pointer; }
.upload-icon { font-size: 40px; color: var(--accent); }
.upload-inner p { margin-top: 6px; }
.upload-preview { display: flex; align-items: center; gap: 14px; padding: 14px; }
.upload-preview img { max-height: 160px; max-width: 320px; border-radius: 10px; border: 1px solid var(--line); }
.preview-meta { display: flex; flex-direction: column; gap: 8px; }
.preview-actions { display: flex; gap: 8px; }
.load-more { display: block; margin: 14px auto 0; }

.face-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.face-card { position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 4px; cursor: pointer; background: var(--panel); }
.face-card img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; display: block; }
.face-card .idx { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.65); border-radius: 6px; padding: 0 6px; font-size: 11px; }
.face-card.sel { border-color: var(--accent); }
.face-card.sel::after { content: "✓"; position: absolute; right: 8px; top: 6px; color: var(--accent); font-weight: 700; }
.search-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

.results-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 3px 12px; font-size: 12px; }
.chip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.sort-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; margin-left: auto; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: zoom-in; }
.result-card:hover { border-color: var(--accent); }
.result-card .thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel2); }
.result-card .meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.result-card .q { font-weight: 700; color: var(--ok); }
.result-card .t { font-size: 11px; color: var(--muted); }
.badge { display: inline-block; font-size: 10px; border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.badge.CONFIRMED_RESULT { background: rgba(62,207,142,.18); color: var(--ok); }
.badge.UNCERTAIN_RESULT { background: rgba(245,166,35,.18); color: var(--warn); }
.badge.SECONDARY_RESULT { background: rgba(139,147,163,.18); color: var(--muted); }

.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 340px; background: var(--panel); border-left: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.history-list { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.history-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: var(--panel2); }
.history-item:hover { border-color: var(--accent); }
.history-item .h1 { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.history-item .h2 { color: var(--muted); font-size: 11px; margin-top: 3px; }
.history-item .del { color: var(--bad); background: none; border: none; font-size: 12px; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 340px; display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
.modal-err { color: var(--bad); font-size: 12px; min-height: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 30px; }
.lightbox img { max-width: 90vw; max-height: 76vh; border-radius: 8px; }
.lb-close { position: absolute; right: 22px; top: 14px; background: none; border: none; color: #fff; font-size: 34px; }
.lb-meta { color: var(--muted); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.lb-meta a { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 18px; z-index: 80; font-size: 13px; }
.toast.bad { border-color: var(--bad); color: var(--bad); }