:root {
  --bg: #fff8c9;
  --bg2: #bff3ff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(30, 64, 175, 0.14);
  --text: #16213e;
  --muted: #536179;
  --accent: #0ea5e9;
  --accent-2: #22c55e;
  --danger: #f43f5e;
  --sun: #facc15;
  --pop: #f97316;
  --shadow: 0 22px 54px rgba(30, 64, 175, 0.18);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(250, 204, 21, 0.55), transparent 22%),
    radial-gradient(circle at 88% 18%, rgba(34, 197, 94, 0.36), transparent 24%),
    radial-gradient(circle at 86% 82%, rgba(14, 165, 233, 0.34), transparent 28%),
    linear-gradient(135deg, var(--bg), var(--bg2) 58%, #ffe4f0);
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  padding: 32px;
  overflow: hidden;
}

.background-orb {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.55;
  pointer-events: none;
  animation: float 12s ease-in-out infinite;
}

.orb-a {
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.22), transparent 65%);
}

.orb-b {
  left: -130px;
  bottom: -150px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.24), transparent 65%);
  animation-delay: -4s;
}

.topbar,
.content,
.site-footer {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
  color: #2563eb;
  margin-bottom: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.05;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.site-footer {
  margin-top: 18px;
  padding: 12px 16px;
  text-align: center;
  color: rgba(22, 33, 62, 0.62);
  font-size: 13px;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tab {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(37, 99, 235, 0.12);
  color: #1e3a8a;
  font-weight: 900;
  transition: all 0.22s ease;
}

.tab:hover,
.tab.active {
  background: linear-gradient(135deg, #38bdf8, #86efac);
  border-color: rgba(37, 99, 235, 0.22);
  color: #082f49;
  transform: translateY(-1px);
}

.hero-grid {
  display: grid;
  gap: 24px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-wide {
  animation: fadeUp 0.6s ease both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-kicker {
  color: #f97316;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.panel h2 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 32px);
}

.badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: #fef3c7;
  border: 2px solid rgba(249, 115, 22, 0.2);
  color: #9a3412;
  font-weight: 900;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.result-label,
.camera-title,
.threshold-copy strong {
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 900;
}

.field input,
.field select,
.threshold-control input[type="range"] {
  width: 100%;
}

.field input,
.field select {
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid rgba(14, 165, 233, 0.22);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  outline: none;
  font-weight: 800;
}

.field input:focus,
.field select:focus {
  border-color: rgba(249, 115, 22, 0.62);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.14);
}

.camera-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.recognize-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(420px, 1fr);
  gap: 18px;
  align-items: start;
}

.camera-card,
.match-card {
  background: rgba(255, 255, 255, 0.76);
  border: 2px solid rgba(37, 99, 235, 0.12);
  border-radius: 20px;
  padding: 18px;
}

.recognize-workspace .match-card {
  min-height: 520px;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(14, 165, 233, 0.16);
  box-shadow: 0 20px 46px rgba(30, 64, 175, 0.16);
}

.camera-card-compact {
  max-width: 360px;
  padding: 14px;
  opacity: 0.92;
}

.camera-card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.16), rgba(34, 197, 94, 0.12));
  object-fit: cover;
  border: 4px solid rgba(255, 255, 255, 0.82);
  transform: scaleX(-1);
}

.camera-card-compact video {
  border-radius: 14px;
  border-width: 3px;
}

.camera-title {
  margin-bottom: 12px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
  font-weight: 700;
}

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

.simple-action-row,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.danger-zone {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 228, 230, 0.92), rgba(254, 243, 199, 0.92));
  border: 2px solid rgba(244, 63, 94, 0.22);
}

.danger-zone h3 {
  margin: 0;
  font-size: 24px;
}

.danger-zone p {
  margin: 8px 0 0;
  color: #9f1239;
  line-height: 1.6;
  font-weight: 800;
}

.danger-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  min-width: min(520px, 100%);
}

.danger-actions input {
  width: 180px;
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid rgba(244, 63, 94, 0.28);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  font-weight: 900;
}

.danger-actions input:focus {
  border-color: rgba(244, 63, 94, 0.64);
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.14);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 900;
  font-size: 15px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #fb923c, #facc15);
  color: #422006;
  box-shadow: 0 14px 30px rgba(249, 115, 22, 0.22);
}

.btn-secondary {
  background: linear-gradient(135deg, #38bdf8, #86efac);
  color: #082f49;
  border: 0;
}

.btn-danger {
  background: linear-gradient(135deg, #fb7185, #f97316);
  color: #fff7ed;
  box-shadow: 0 14px 30px rgba(244, 63, 94, 0.22);
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(191, 243, 255, 0.72), rgba(255, 248, 201, 0.72));
  border: 2px dashed rgba(37, 99, 235, 0.22);
}

.preview-frame.small {
  aspect-ratio: 1 / 1;
}

.preview-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(22, 33, 62, 0.48);
  text-align: center;
  padding: 16px;
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: #e0f2fe;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.status-pill.ok {
  background: #dcfce7;
  color: #166534;
}

.status-pill.warn {
  background: #ffe4e6;
  color: #be123c;
}

.result-copy {
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.6;
}

.threshold-box {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  padding: 18px;
  border-radius: 20px;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(37, 99, 235, 0.12);
}

.liveness-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 20px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.86), rgba(219, 234, 254, 0.86));
  border: 2px solid rgba(249, 115, 22, 0.16);
}

.liveness-copy h3 {
  margin: 8px 0 0;
  font-size: 18px;
}

.liveness-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.liveness-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(14, 165, 233, 0.18);
  color: var(--text);
  cursor: pointer;
}

.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.threshold-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.threshold-control input[type="range"] {
  accent-color: var(--accent);
}

.threshold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
}

.settings-board {
  display: grid;
  gap: 24px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.setting-card {
  display: grid;
  gap: 16px;
  align-content: start;
  min-height: 260px;
  padding: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid rgba(37, 99, 235, 0.12);
}

.setting-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: linear-gradient(135deg, #38bdf8, #facc15);
  color: #082f49;
  font-size: 28px;
  font-weight: 900;
}

.setting-card h3 {
  margin: 0;
  font-size: 24px;
}

.setting-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-weight: 700;
}

.setting-card input[type="range"] {
  width: 100%;
  accent-color: var(--pop);
}

.setting-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 900;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 76px;
  height: 40px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease;
}

.switch-row input:checked + .switch-track {
  background: linear-gradient(135deg, #22c55e, #38bdf8);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(36px);
}

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.match-name,
.match-meta,
.match-relation {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 16px;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 1000;
  line-height: 1.14;
}

.match-name,
.match-meta {
  background: #f8fafc;
  color: #0f172a;
  border: 2px solid rgba(14, 165, 233, 0.14);
}

.match-name {
  margin-top: 8px;
}

.match-meta {
  margin-top: 12px;
}

.match-relation {
  background: #dcfce7;
  color: #166534;
  border: 2px solid rgba(22, 101, 52, 0.12);
  margin-top: 12px;
}

.match-score {
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.6;
  font-size: 20px;
  font-weight: 900;
}

.result-photo-frame {
  width: min(240px, 100%);
  aspect-ratio: 4 / 3;
  margin-top: 16px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(191, 243, 255, 0.82), rgba(254, 243, 199, 0.82));
  border: 3px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(30, 64, 175, 0.14);
}

.result-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.match-score-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  margin-top: 16px;
  padding: 12px 18px;
  border-radius: 22px;
  background: #e0f2fe;
  color: #075985;
  border: 2px solid rgba(14, 165, 233, 0.18);
  font-size: clamp(38px, 5.8vw, 62px);
  font-weight: 1000;
  box-shadow: 0 14px 30px rgba(14, 165, 233, 0.14);
}

.match-dialog[hidden] {
  display: none;
}

.match-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.match-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
}

.match-dialog-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border: 3px solid rgba(250, 204, 21, 0.42);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 32px;
  animation: fadeUp 0.22s ease both;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(37, 99, 235, 0.12);
  border-radius: 999px;
  background: #e0f2fe;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.dialog-photo-row {
  display: grid;
  place-items: center;
  margin-top: 16px;
}

.dialog-photo-card {
  position: relative;
  width: min(280px, 62vw);
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(191, 243, 255, 0.82), rgba(254, 243, 199, 0.82));
  border: 3px dashed rgba(14, 165, 233, 0.22);
}

.dialog-photo-card .camera-title {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1;
  margin: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.dialog-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-result-row {
  margin-top: 24px;
  text-align: center;
}

.dialog-match-name {
  font-size: clamp(40px, 8vw, 72px);
  font-weight: 900;
}

.dialog-match-meta,
.dialog-match-score {
  color: var(--muted);
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.6;
}

.dialog-match-score {
  color: #16a34a;
  font-weight: 800;
  font-size: 22px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(20px) scale(1.02);
  }
}

@media (max-width: 980px) {
  .topbar,
  .panel-head,
  .threshold-box,
  .liveness-box,
  .camera-layout,
  .recognize-workspace,
  .match-grid,
  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .danger-zone,
  .danger-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .danger-actions input {
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
  }

  .page-shell {
    padding: 18px;
  }
}

@media (max-width: 720px) {
  .camera-layout,
  .recognize-workspace,
  .match-grid,
  .threshold-box,
  .liveness-box,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    margin-bottom: 18px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1 1 0;
    text-align: center;
  }
}
