* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Conteneur externe : crée la hauteur 16:9 de façon fiable */
.ccf-outer {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* ratio 16:9 */
  height: 0;
  overflow: hidden;
  background: #000;
  font-family: sans-serif;
}

/* Mobile portrait → ratio 9:16 */
@media (max-width: 600px) and (orientation: portrait) {
  .ccf-outer {
    padding-bottom: 177.78%; /* ratio 9:16 */
  }
}

#wrapper { position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
#cam,
video#cam {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  opacity: 0 !important; pointer-events: none !important;
  visibility: hidden !important;
}
.wp-video,
.wp-video-shortcode,
figure.wp-block-video { display: none !important; }

#displayCanvas {
  position: absolute; top: 0; left: 0;
  display: block; image-rendering: high-quality;
}

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.7) 100%);
  pointer-events: none; z-index: 1;
}

#filterPanel.hidden #filterGrid,
#filterPanel.hidden #filterNav { display: none; }

#toggleFilterBtn {
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.4);
  color: white; border-radius: 50px;
  padding: 8px 14px; font-size: 12px; font-weight: bold;
  cursor: pointer; letter-spacing: 1px; backdrop-filter: blur(6px);
  touch-action: manipulation; min-height: 40px;
  white-space: nowrap; margin-bottom: 6px;
}
#toggleFilterBtn.hidden-state { border-color: red; color: red; }

#topBar {
  position: absolute;
  top: 0;
  left: 0; right: 0; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; z-index: 10;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}

#liveIndicator {
  display: none; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.55); padding: 5px 12px; border-radius: 20px;
}
#liveIndicator .dot {
  width: 9px; height: 9px; background: red;
  border-radius: 50%; animation: blink 1s infinite;
}
#liveIndicator .text { color: white; font-size: 12px; font-weight: bold; letter-spacing: 2px; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

#timer {
  color: white; font-size: 15px; font-weight: bold;
  background: rgba(0,0,0,0.55); padding: 5px 14px;
  border-radius: 20px; display: none; letter-spacing: 2px; white-space: nowrap;
}

#fileSize {
  color: white; font-size: 11px;
  background: rgba(0,0,0,0.55); padding: 5px 10px;
  border-radius: 20px; display: none;
}

#settingsBtn {
  position: absolute;
  top: 120px;
  right: 12px; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.4);
  color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); touch-action: manipulation; z-index: 15;
  animation: attentionPulse 1s ease-out 3;
}

@media (max-width: 768px) {
  #settingsBtn {
    top: 130px;
    right: 8px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  #settingsBtn {
    top: 120px;
    right: 12px;
  }
}

#settingsBtn::after {
  content: "Parametres";
  position: absolute;
  right: 54px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.75);
  color: white;
  font-size: 11px;
  font-weight: bold;
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,0.3);
  animation: fadeOutLabel 3s ease-out forwards;
  animation-delay: 1s;
}

@keyframes attentionPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.6); transform: scale(1); }
  50%  { box-shadow: 0 0 0 12px rgba(255,255,255,0); transform: scale(1.15); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); transform: scale(1); }
}

@keyframes fadeOutLabel {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

#topControls {
  position: absolute;
  top: 64px;
  left: 0; right: 0; display: flex; gap: 6px; z-index: 10;
  justify-content: center; padding: 0 12px; flex-wrap: nowrap;
}
.ctrlBtn {
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.4);
  color: white; border-radius: 50px; padding: 8px 14px;
  font-size: 12px; font-weight: bold; cursor: pointer; letter-spacing: 1px;
  backdrop-filter: blur(6px); touch-action: manipulation; min-height: 40px;
  white-space: nowrap; flex: 1; max-width: 80px; text-align: center;
}

/* --- topControls responsive mobile --- */
@media (max-width: 600px) {
  #topControls {
    top: 54px;
    gap: 3px;
    padding: 0 4px;
    flex-wrap: wrap;
  }
  .ctrlBtn {
    font-size: 9px;
    padding: 5px 4px;
    min-height: 30px;
    max-width: 52px;
    letter-spacing: 0;
  }
  #switchCam, #audioToggle {
    max-width: 80px;
    font-size: 9px;
  }
}
.ctrlBtn:active { background: rgba(255,255,255,0.35); }
.ctrlBtn.active { background: rgba(255,255,255,0.35); border-color: white; }
#switchCam, #audioToggle { max-width: 120px; font-size: 11px; }

#filterPanel {
  position: absolute;
  bottom: 110px;
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; z-index: 10; padding: 0 8px;
}
#filterGrid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 5px; width: 100%; max-width: 500px;
}
@media (min-width: 600px) {
  #filterGrid { grid-template-columns: repeat(6, 1fr); max-width: 680px; }
}
@media (max-width: 599px) {
  #filterGrid { grid-template-columns: repeat(3, 1fr); }
}

.filterThumb {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; opacity: 0.65; transition: opacity 0.2s, transform 0.15s;
  touch-action: manipulation;
}
.filterThumb:active { transform: scale(0.93); }
.filterThumb canvas {
  border-radius: 7px; border: 2px solid transparent;
  width: 100%; height: auto; display: block;
}
.filterThumb.selected { opacity: 1; }
.filterThumb.selected canvas { border-color: red; }
.filterThumb span {
  color: white; font-size: 9px; letter-spacing: 0.4px; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9); white-space: nowrap;
}

#filterNav { display: flex; align-items: center; gap: 14px; }
#filterNav button {
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.4);
  color: white; border-radius: 50%; width: 34px; height: 34px;
  cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center; touch-action: manipulation;
}
#filterNav button:disabled { opacity: 0.3; cursor: default; }
#pageIndicator { color: white; font-size: 11px; letter-spacing: 1px; }

#filterNav button#prevPage,
#filterNav button#nextPage { display: flex; }
@media (max-width: 768px) {
  #filterNav button#prevPage,
  #filterNav button#nextPage { display: none; }
  #pageIndicator::after { content: " <- ->"; opacity: 0.5; font-size: 10px; }
}

#bottomControls {
  position: absolute; bottom: 0;
  left: 0; right: 0; height: 100px;
  display: flex; align-items: center; justify-content: center;
  gap: 30px; z-index: 10; padding: 0 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
}

#fullscreenBtn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.4);
  color: white; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); touch-action: manipulation;
}

#recordBtn {
  width: 80px; height: 80px; border-radius: 50%;
  background: red; border: 4px solid white; cursor: pointer;
  box-shadow: 0 2px 18px rgba(0,0,0,0.7);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  touch-action: manipulation;
}
#recordBtn .icon {
  width: 24px; height: 24px; background: white;
  border-radius: 50%; transition: border-radius 0.2s;
}
#recordBtn.recording .icon { border-radius: 4px; }
#recordBtn .label { color: white; font-size: 10px; font-weight: bold; letter-spacing: 1px; }
#recordBtn.recording { background: darkred; animation: pulse 1s infinite; }
#recordBtn.paused { background: orange; animation: none; }
#recordBtn:disabled { opacity: 0.6; cursor: default; animation: none; }
@keyframes pulse {
  0%,100%{ box-shadow: 0 0 0 0 rgba(255,0,0,0.5); }
  50%{ box-shadow: 0 0 0 16px rgba(255,0,0,0); }
}

#pauseBtn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.4);
  color: white; font-size: 20px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); touch-action: manipulation;
}

#settingsModal {
  position: absolute; inset: 0; background: rgba(0,0,0,0.95);
  display: none; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 30; gap: 10px;
  padding: 16px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
#settingsModal h2 {
  color: white; font-size: 17px; margin-bottom: 4px;
  letter-spacing: 2px; text-transform: uppercase;
}
.settingRow {
  width: 100%; max-width: 420px; background: rgba(255,255,255,0.08);
  border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.settingRow label {
  color: rgba(255,255,255,0.6); font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase;
}
.toggleRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toggleRow span { color: white; font-size: 14px; font-weight: bold; }
.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; background: rgba(255,255,255,0.2);
  border-radius: 28px; cursor: pointer; transition: background 0.3s;
}
.switch .slider:before {
  content: ""; position: absolute; width: 22px; height: 22px;
  left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform 0.3s;
}
.switch input:checked + .slider { background: red; }
.switch input:checked + .slider:before { transform: translateX(22px); }
.settingRow input[type="text"] {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3);
  color: white; border-radius: 8px; padding: 10px 12px;
  font-size: 15px; width: 100%; outline: none;
}
.settingRow input[type="text"]::placeholder { color: rgba(255,255,255,0.35); }

#resInfo {
  color: rgba(255,255,255,0.45);
  font-size: 11px; text-align: center; letter-spacing: 1px;
}
#closeSettingsBtn {
  margin-top: 8px; padding: 14px 40px; border-radius: 30px;
  background: red; color: white; border: none; font-size: 15px; font-weight: bold;
  cursor: pointer; letter-spacing: 1px;
  touch-action: manipulation; min-height: 52px; min-width: 160px;
}

#countdown {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 120px; font-weight: bold; color: white;
  text-shadow: 0 4px 24px rgba(0,0,0,0.9);
  display: none; pointer-events: none; z-index: 20;
}
@keyframes pop {
  0%{ transform: translate(-50%,-50%) scale(1.5); opacity:0; }
  100%{ transform: translate(-50%,-50%) scale(1); opacity:1; }
}

#previewModal {
  position: absolute; inset: 0; background: rgba(0,0,0,0.94);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 30; gap: 16px; padding: 20px;
}
#previewVideo {
  max-width: 92vw; max-height: 62vh;
  border-radius: 12px; border: 2px solid rgba(255,255,255,0.6);
  background: #000;
}
.previewActions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#previewModal button {
  padding: 13px 28px; border-radius: 30px; border: none;
  font-size: 14px; font-weight: bold; cursor: pointer; letter-spacing: 1px;
  touch-action: manipulation; min-height: 52px;
}
#downloadBtn { background: red; color: white; }
#closePreviewBtn { background: rgba(255,255,255,0.15); color: white; border: 2px solid white !important; }

#errorMsg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(180,0,0,0.92); color: white;
  padding: 16px 22px; border-radius: 14px; font-size: 14px; text-align: center;
  display: none; z-index: 50; width: min(85vw, 320px);
}

@media (min-width: 768px) and (orientation: landscape) {
  #topControls { top: 60px; gap: 10px; }
  .ctrlBtn { max-width: 90px; font-size: 13px; }
  #switchCam, #audioToggle { max-width: 140px; }
  #filterPanel { bottom: 120px; }
  #bottomControls { height: 110px; gap: 40px; }
  #recordBtn { width: 90px; height: 90px; }
  #fullscreenBtn, #pauseBtn { width: 58px; height: 58px; }
}

#filterNav button#prevPage,
#filterNav button#nextPage { display: flex; }
@media (max-width: 768px) {
  #filterNav button#prevPage,
  #filterNav button#nextPage { display: none; }
  #pageIndicator::after { content: " <- ->"; opacity: 0.5; font-size: 10px; }
}

.navArrow {
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  width: 34px; height: 34px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; position: relative;
  overflow: visible;
}
.navArrow:disabled { opacity: 0.3; cursor: default; }

.navArrow.prev::after {
  content: "";
  display: block;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 9px solid white;
  transform: none;
}

.navArrow.next::after {
  content: "";
  display: block;
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid white;
  transform: none;
}

@media (max-width: 768px) {
  .navArrow.prev,
  .navArrow.next { display: none; }
}
/* Overlays cadres format */
.overlayLabel {
  color: white;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.overlayLabel input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: red;
  cursor: pointer;
}
/* Bouton choix fichier incrustation */
.overlayFileBtn {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.4);
  color: white; border-radius: 50px;
  padding: 8px 18px; font-size: 13px; font-weight: bold;
  cursor: pointer; letter-spacing: 1px; text-align: center;
  touch-action: manipulation;
}
.overlayFileBtn:active { background: rgba(255,255,255,0.3); }
