:root {
  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-200: #fecdd3;
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --purple-100: #ede9fe;
  --purple-500: #8b5cf6;
  --ink: #1f1a2e;
  --ink-soft: #6b6478;
  --card: #ffffff;
  --line: #f1e8ec;
  --ok: #16a34a;
  --warn: #d97706;
  --low: #94a3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 保证 hidden 属性不被 display 样式覆盖（如 .loading / .face-panel 的 display:flex） */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--rose-100) 0%, transparent 60%),
    radial-gradient(1000px 500px at 90% 0%, var(--purple-100) 0%, transparent 55%),
    #faf7fb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  position: sticky;
  top: 0;
  background: rgba(250, 247, 251, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 12px;
  background: linear-gradient(135deg, var(--rose-500), var(--purple-500));
  color: #fff; font-weight: 700; font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.35);
}
.brand-text { font-weight: 600; font-size: 16px; }
.nav { display: flex; gap: 8px; }
.nav-link {
  text-decoration: none; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 999px; font-size: 14px;
  transition: all .2s;
}
.nav-link:hover { color: var(--rose-600); background: var(--rose-100); }
.nav-link.active { color: var(--rose-600); background: var(--rose-100); font-weight: 600; }

/* ---------- Layout ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.hero { text-align: center; padding: 40px 0 32px; }
.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  background: linear-gradient(120deg, var(--rose-600), var(--purple-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}
.hero-sub { color: var(--ink-soft); font-size: 15px; line-height: 1.8; }
.hero-sub a { color: var(--rose-600); }
.hero-small { padding: 24px 0; }
.hero-small h1 { font-size: 30px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 8px 30px rgba(150, 100, 130, 0.08);
}
.panel-narrow { max-width: 640px; margin: 0 auto 28px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.panel-head h2 { font-size: 18px; }
.hint { color: var(--ink-soft); font-size: 13px; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  border: 2px dashed var(--rose-200);
  border-radius: 16px;
  background: var(--rose-50);
  padding: 36px 20px;
  cursor: pointer;
  transition: all .2s;
  min-height: 180px;
  position: relative;
  overflow: hidden;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--rose-500);
  background: var(--rose-100);
}
.dz-icon { font-size: 34px; }
.dz-text { color: var(--ink-soft); font-size: 14px; }
.dropzone .preview {
  max-width: 200px; max-height: 220px; border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

/* ---------- 定义页：人脸选择 ---------- */
.face-panel {
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; background: #fdfbfc;
}
.face-panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.face-panel-title { font-size: 14px; font-weight: 600; }
.face-annotated {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
.face-options { display: flex; gap: 10px; flex-wrap: wrap; }
.face-option {
  flex: 1 1 200px;
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; background: #fff;
  transition: border-color .2s;
}
.face-option:has(input:checked) { border-color: var(--rose-500); background: var(--rose-50); }
.face-option.invalid { opacity: .55; cursor: not-allowed; }
.face-option input { accent-color: var(--rose-500); }
.face-option-label { font-weight: 600; font-size: 14px; }
.face-option-badge { margin-left: auto; font-size: 12px; font-weight: 600; }
.face-option-badge.ok { color: var(--ok); }
.face-option-badge.bad { color: #dc2626; }

/* ---------- Form ---------- */
.upload-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 600; }
.field input, .field textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
}
.field input:focus, .field textarea:focus {
  border-color: var(--rose-400);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}
.field textarea { resize: vertical; min-height: 110px; }

.btn {
  border: none; cursor: pointer;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  transition: all .2s;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(120deg, var(--rose-500), var(--purple-500));
  color: #fff;
  box-shadow: 0 6px 18px rgba(244, 63, 94, 0.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(244, 63, 94, 0.4); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-outline {
  background: transparent; color: var(--rose-600);
  border: 1.5px solid var(--rose-300);
}
.btn-outline:hover { background: var(--rose-100); }

/* ---------- Result ---------- */
.result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.result-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.result-head h3 { font-size: 16px; }
.result-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.match-item {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}
.match-item.top1 { border-color: var(--rose-300); box-shadow: 0 4px 16px rgba(244, 63, 94, 0.12); }
.match-top { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.match-top-photo {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 14px;
  background: #faf7fb;
  border: 1px solid var(--line);
}
.match-top-body { display: flex; flex-direction: column; gap: 6px; }
.match-top-body .badge { align-self: flex-start; }
.match-top-body h4 { font-size: 18px; }
.match-top-body p {
  font-size: 14px; color: var(--ink-soft); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.match-photo {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover;
  flex-shrink: 0;
}
.match-info { flex: 1; min-width: 0; }
.match-info h4 { font-size: 15px; }
.match-info p {
  font-size: 13px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.match-score { text-align: right; flex-shrink: 0; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-lg { padding: 6px 14px; font-size: 13.5px; }
.badge.high { background: #dcfce7; color: var(--ok); }
.badge.mid { background: #fef3c7; color: var(--warn); }
.badge.low { background: #f1f5f9; color: var(--low); }

.result-empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 18px 0; }

.query-photo { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.query-photo-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.query-photo img {
  width: 100%; max-height: 360px; object-fit: contain;
  border-radius: 12px; border: 1px solid var(--line); background: #faf7fb;
}

.empty-state { text-align: center; padding: 30px 0; color: var(--ink-soft); display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* ---------- Admin ---------- */
.admin-list { display: flex; flex-direction: column; gap: 12px; }
.admin-row {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px; background: #fff;
}
.admin-photo {
  width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
  flex-shrink: 0; background: var(--rose-100);
}
.admin-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-info { flex: 1; min-width: 0; }
.admin-info h4 { font-size: 15px; margin-bottom: 4px; }
.admin-desc {
  font-size: 13px; color: var(--ink-soft); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.admin-time { font-size: 12px; color: var(--low); }
.btn-danger {
  background: #fff; color: #dc2626;
  border: 1.5px solid #fecaca;
  padding: 8px 16px; font-size: 13px;
}
.btn-danger:hover { background: #fef2f2; }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Notice ---------- */
.notice {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px;
  font-size: 14px; line-height: 1.7;
}
.notice.ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.notice.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.notice.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---------- Spinner / Loading ---------- */
.spinner {
  width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%;
  display: inline-block; vertical-align: -3px; margin-right: 8px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-lg {
  width: 42px; height: 42px;
  border: 4px solid var(--rose-200);
  border-top-color: var(--rose-500);
  border-radius: 50%;
  display: inline-block;
  animation: spin .8s linear infinite;
}
.loading {
  margin-top: 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
  padding: 26px 16px;
  border: 1px dashed var(--rose-200);
  border-radius: 16px;
  background: var(--rose-50);
}
.loading-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.loading-sub { font-size: 13px; color: var(--ink-soft); }

.site-footer {
  text-align: center; padding: 22px; color: var(--ink-soft);
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .container { padding: 20px 14px 48px; }
  .panel { padding: 18px; }
}
