#container {
  isolation: isolate;
}

#container > video {
  z-index: 0 !important;
}

#container canvas {
  z-index: 1 !important;
  pointer-events: none;
}

.facemesh-control {
  position: fixed;
  top: max(20px, env(safe-area-inset-top, 0px));
  left: max(20px, env(safe-area-inset-left, 0px));
  z-index: 1001;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100vw - 40px);
}

.facemesh-record-row {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top, 0px) + 50px));
  left: max(20px, env(safe-area-inset-left, 0px));
  z-index: 1001;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: calc(100vw - 40px);
}

.facemesh-viewer #status {
  top: max(120px, calc(env(safe-area-inset-top, 0px) + 100px));
}

.facemesh-viewer .ar-record-btn,
.birthday-ar-viewer.facemesh-viewer .ar-record-btn,
.facemesh-record-row .ar-record-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.facemesh-viewer .ar-record-btn:hover {
  background: rgba(0, 0, 0, 0.75);
}

.facemesh-viewer .ar-record-btn.is-recording {
  background: rgba(220, 53, 69, 0.92);
  animation: ar-record-pulse 1.2s ease-in-out infinite;
}

.facemesh-viewer .ar-record-btn.is-armed {
  background: rgba(255, 193, 7, 0.92);
  color: #111;
}

.facemesh-viewer .ar-record-transport {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.facemesh-viewer .ar-record-pause-btn.is-paused {
  background: rgba(40, 167, 69, 0.92);
}

.facemesh-viewer .ar-record-stop-btn {
  background: rgba(220, 53, 69, 0.92);
}

.facemesh-viewer .ar-record-stop-btn:hover {
  background: rgba(200, 35, 51, 0.95);
}

.facemesh-viewer .ar-record-badge.is-paused {
  background: rgba(255, 193, 7, 0.92);
  color: #111;
}

.facemesh-viewer .ar-record-badge.is-paused .ar-record-dot {
  animation: none;
  opacity: 1;
}

@keyframes ar-record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
}

.facemesh-viewer .ar-record-icon {
  font-size: 14px;
  line-height: 1;
}

.facemesh-viewer .ar-record-badge {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 10200;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(220, 53, 69, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.facemesh-viewer .ar-record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: ar-record-blink 1s step-end infinite;
}

@keyframes ar-record-blink {
  50% { opacity: 0.2; }
}

.facemesh-viewer .ar-record-share-panel {
  position: fixed;
  inset: 0;
  z-index: 10300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}

.facemesh-viewer .ar-record-share-card {
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  border-radius: 16px;
  background: #111;
  color: #fff;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.facemesh-viewer .ar-record-share-card h3 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.facemesh-viewer .ar-record-preview,
.facemesh-viewer .ar-photo-preview {
  width: 100%;
  max-height: 50vh;
  border-radius: 10px;
  background: #000;
  margin-bottom: 14px;
  object-fit: contain;
}

.facemesh-viewer .ar-photo-btn {
  background: rgba(0, 0, 0, 0.55);
}

.facemesh-viewer .ar-record-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}

.facemesh-viewer .ar-record-action-btn,
.facemesh-viewer a.ar-record-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff !important;
  text-decoration: none !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.facemesh-viewer .ar-record-action-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.facemesh-viewer #arRecordDownload,
.facemesh-viewer #arRecordShare,
.facemesh-viewer .ar-record-action-btn.primary {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  border-color: transparent;
  color: #111 !important;
}

.facemesh-viewer .ar-record-action-btn.ghost {
  background: transparent;
}

.facemesh-viewer .ar-record-share-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.75);
}

.facemesh-viewer #arRecordDownload {
  min-width: 140px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
}

@media (max-width: 480px) {
  .facemesh-viewer .ar-record-share-actions {
    flex-direction: column;
    width: 100%;
  }

  .facemesh-viewer #arRecordDownload,
  .facemesh-viewer #arRecordShare,
  .facemesh-viewer #arRecordClose {
    width: 100%;
  }

  .facemesh-record-row .ar-record-btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 11px;
  }
}

.facemesh-scans-toggle {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10050;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.facemesh-scans-toggle-icon {
  font-size: 16px;
  line-height: 1;
}

.facemesh-scans-toggle-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(102, 126, 234, 0.85);
  font-size: 11px;
  font-weight: 800;
}

.facemesh-scans-panel {
  pointer-events: none;
}

.facemesh-scans-panel.is-collapsed {
  display: none;
}

.facemesh-viewer #face-scans-list {
  position: fixed;
  bottom: max(68px, calc(env(safe-area-inset-bottom, 0px) + 52px));
  left: max(10px, env(safe-area-inset-left, 0px));
  z-index: 10040;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 11px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  max-width: min(220px, calc(100vw - 24px));
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.facemesh-viewer .face-scans-list-header {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.facemesh-viewer .face-scans-list-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(42vh, 320px);
  overflow-y: auto;
  pointer-events: auto;
}

.facemesh-viewer .face-scan-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease;
  pointer-events: auto;
  cursor: pointer;
}

.facemesh-viewer .face-scan-item.active {
  background: rgba(40, 167, 69, 0.3);
  border: 1px solid rgba(40, 167, 69, 0.6);
}

.facemesh-viewer .face-scan-number {
  font-weight: 700;
  font-size: 11px;
  min-width: 16px;
  text-align: center;
  opacity: 0.85;
}

.facemesh-viewer .face-scan-thumbnail {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.facemesh-viewer .face-scan-placeholder {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  flex-shrink: 0;
}

.facemesh-viewer .face-scan-label {
  font-size: 10px;
  line-height: 1.2;
  opacity: 0.95;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.facemesh-viewer .face-scan-status {
  margin-left: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
}

.facemesh-viewer .face-scan-item.active .face-scan-status {
  color: #4facfe;
}

.facemesh-viewer .facemesh-scan-hint {
  position: fixed;
  bottom: max(68px, calc(env(safe-area-inset-bottom, 0px) + 52px));
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 10035;
  max-width: min(200px, calc(100vw - 24px));
  pointer-events: none;
}

.facemesh-viewer .facemesh-scan-hint-card {
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.facemesh-viewer .facemesh-scan-hint-caption {
  display: block;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  opacity: 0.85;
}

.facemesh-viewer .facemesh-scan-hint-card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: block;
}

.facemesh-viewer.ar-is-recording #face-scans-list,
.facemesh-viewer.ar-is-recording .facemesh-scan-hint {
  opacity: 0.35;
}

@media (max-width: 768px) {
  .facemesh-scans-toggle {
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 24px);
  }

  .facemesh-viewer #face-scans-list {
    bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 48px));
    left: max(10px, env(safe-area-inset-left, 0px));
    max-width: min(200px, calc(100vw - 24px));
  }

  .facemesh-viewer .facemesh-scan-hint {
    bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 48px));
    right: max(10px, env(safe-area-inset-right, 0px));
    max-width: min(160px, calc(50vw - 16px));
  }
}
