* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

#video.preview-mode {
  opacity: 1;
}

#motionCanvas {
  display: none;
}

#stealthOverlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10;
  touch-action: manipulation;
}

#stealthOverlay.preview-mode {
  background: transparent;
}

#recordingIndicator {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: #ff3b30;
  border-radius: 50%;
  opacity: 0;
  z-index: 20;
  animation: pulse 1s infinite;
}

#recordingIndicator.active {
  opacity: 1;
}

#recordingIndicator.hidden {
  display: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

#motionIndicator {
  position: fixed;
  top: 10px;
  left: 10px;
  font-size: 16px;
  opacity: 0;
  z-index: 20;
}

#motionIndicator.active {
  opacity: 0.55;
}

#settingsPanel,
#recordingsPanel {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#settingsPanel.hidden,
#recordingsPanel.hidden {
  opacity: 0;
  pointer-events: none;
}

.settings-content {
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  background: #161616;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.recordings-content {
  max-width: 680px;
  width: min(94vw, 680px);
}

.settings-content h2 {
  color: #fff;
  font-size: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  color: #8f8f8f;
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.setting-note {
  margin-top: 8px;
  color: #8f8f8f;
  font-size: 12px;
  line-height: 1.5;
}

.button-group {
  display: flex;
  gap: 8px;
}

.button-group button,
.recording-card-actions button,
button.full-width,
.recording-preview {
  border: none;
  cursor: pointer;
}

.button-group button {
  flex: 1;
  padding: 12px;
  background: #303030;
  border-radius: 10px;
  color: #8f8f8f;
  font-size: 14px;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.button-group button.active {
  background: #0a84ff;
  color: #fff;
}

.button-group button:active,
.recording-card-actions button:active,
button.full-width:active,
.recording-preview:active,
.close-player:active {
  transform: scale(0.97);
}

button.full-width {
  width: 100%;
  padding: 14px;
  background: #303030;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  margin-top: 12px;
  transition: transform 0.15s ease, background 0.2s ease;
}

button.close-btn {
  background: #202020;
  color: #8f8f8f;
}

#recordingsList {
  max-height: min(68vh, 760px);
  overflow-y: auto;
  padding-right: 2px;
}

.recordings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: #b8b8b8;
  font-size: 13px;
}

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

.recording-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recording-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #0f0f0f;
}

.recording-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 38%, rgba(0, 0, 0, 0.62) 100%);
  pointer-events: none;
}

.recording-thumb,
.recording-thumb-placeholder {
  width: 100%;
  height: 100%;
}

.recording-thumb {
  display: block;
  object-fit: cover;
}

.recording-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.12), transparent 48%),
    linear-gradient(135deg, #1a1a1a, #050505);
  color: rgba(255, 255, 255, 0.54);
  font-size: 12px;
  letter-spacing: 2px;
}

.recording-badge {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.recording-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 38px;
}

.recording-card-title {
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
}

.recording-card-subtitle {
  color: #8f8f8f;
  font-size: 12px;
}

.recording-card-actions {
  display: flex;
  gap: 8px;
}

.recording-card-actions button {
  flex: 1;
  padding: 10px 12px;
  background: #252525;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  transition: transform 0.15s ease, background 0.2s ease;
}

.recording-card-actions button.danger {
  background: #462120;
}

.recording-card-actions button.danger:hover,
.recording-card-actions button.danger:focus-visible {
  background: #5d2827;
}

.no-recordings {
  color: #666;
  text-align: center;
  padding: 44px 20px;
}

#playerModal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#playerModal.hidden {
  display: none;
}

.player-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#player {
  width: 100%;
  max-height: 100%;
  background: #000;
}

.close-player {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 210;
}

#toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(86vw, 360px);
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.92);
  color: #000;
  border-radius: 24px;
  font-size: 14px;
  text-align: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#toast.hidden {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 560px) {
  .recordings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  .settings-content {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .close-player {
    top: calc(20px + env(safe-area-inset-top));
  }
}
