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

body {
  background: #0b1220;
  color: #e8edf5;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #111a2e;
  border-bottom: 1px solid #1f2b45;
}

.brand { font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.brand span { color: #3fa9f5; }

.topright { display: flex; align-items: center; gap: 14px; }

.modes { display: flex; gap: 8px; }

.mode {
  background: #1c2942;
  color: #9fb2cf;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.mode.active { background: #2f6fed; color: #fff; }
.mode:hover { background: #243350; color: #fff; }

.cam-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #2f6fed;
  color: #fff;
  font-size: 12px;
  text-align: center;
}

/* ---------- camera drawer ---------- */
.cam-wrap { position: relative; }

.drawer {
  position: fixed;
  top: 66px;
  right: 16px;
  width: min(400px, calc(100vw - 32px));
  max-height: 72vh;
  background: #111a2e;
  border: 1px solid #2a3a5c;
  border-radius: 12px;
  box-shadow: 0 16px 50px rgba(0,0,0,.55);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1f2b45;
}

.drawer-title { font-size: 16px; font-weight: 700; }

.drawer-x {
  background: none;
  border: none;
  color: #9fb2cf;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.drawer-x:hover { color: #fff; }

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  overflow-y: auto;
}

.cam-list-title { font-size: 13px; color: #9fb2cf; }

#cam-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cam-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #16213a;
  border: 1px solid #243350;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.cam-item:hover { background: #1c2942; }

.cam-item.sel { border-color: #2f6fed; background: #1a2a4a; }

.cam-name {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cam-del {
  flex: none;
  background: none;
  border: none;
  color: #f06d6d;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.cam-del:hover { color: #ff9b9b; }

.drawer-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #1f2b45;
}

.drawer-add input,
.panel input {
  background: #0e1728;
  border: 1px solid #2a3a5c;
  color: #e8edf5;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  width: 100%;
}

.drawer-add input:focus,
.panel input:focus { border-color: #2f6fed; }

.row { display: flex; gap: 10px; }

.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  cursor: pointer;
}

.btn.primary { background: #2f6fed; color: #fff; }
.btn.primary:hover { background: #4380ff; }
.btn.ok { background: #1f9d55; color: #fff; }
.btn.ok:hover { background: #27b666; }

/* ---------- views ---------- */
.view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  flex-wrap: wrap;
}

.stage {
  position: relative;
  width: min(720px, 92vw);
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  border: 1px solid #1f2b45;
}

.stage.small { width: min(420px, 92vw); }

.stage video,
.stage img#cam-img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- face box overlay (like a security camera) ---------- */
.face-box {
  position: absolute;
  border: 3px solid #3fa9f5;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 14px rgba(63,169,245,.55);
  pointer-events: none;
  display: none;
  z-index: 5;
}

.badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.65);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: .5px;
  z-index: 6;
}

/* ---------- result card ---------- */
.result {
  min-width: 260px;
  background: linear-gradient(160deg, #16446f, #0e2747);
  border: 1px solid #2f6fed;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(47,111,237,.35);
}

.result-name {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-meta { color: #9fb2cf; font-size: 14px; }

/* ---------- register panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(420px, 92vw);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 88px;
}

.thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #2a3a5c;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }

.hint { min-height: 20px; color: #9fb2cf; font-size: 14px; }
