.back-to-journey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 44px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(169, 155, 245, 0.2);
  border-radius: 12px 12px 0 0;
  background: transparent;
  color: #F3EFE7;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.back-to-journey:focus-visible { outline: 3px solid #E3B873; outline-offset: 3px; }
.back-to-journey:hover { background: rgba(169, 155, 245, 0.12); }

.complete-breathing {
  min-height: 48px;
  margin-top: 24px;
  padding: 12px 24px;
  border: 1px solid #E3B873;
  border-radius: 24px;
  background: #403321;
  color: #F3EFE7;
  font: inherit;
  cursor: pointer;
}
.complete-breathing:focus-visible { outline: 3px solid #E3B873; outline-offset: 3px; }

.camera-panel {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 64px));
  padding: 24px;
  box-sizing: border-box;
  border-radius: 24px;
  background: #242034;
  color: #F3EFE7;
  text-align: center;
  box-shadow: 0 8px 40px #0008;
}
.camera-panel[hidden] { display: none; }
.camera-panel h1 { font-size: 24px; margin-top: 0; }
.camera-panel p { line-height: 1.5; }
.camera-panel button {
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  background: #A99BF5;
  color: #14121F;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.camera-panel button:disabled { opacity: 0.6; cursor: default; }
.camera-panel a { display: block; margin-top: 16px; color: #F3EFE7; }

body {
  margin: 0;
  background-color: #14121F; 
  font-family: 'Nunito', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh; /* Troque de 100vh para 100dvh */
  overflow: hidden;
}

/* Container base (Notebook) */
.video-container {
  position: relative;
  width: 95vw;
  max-width: 1400px;
  height: 82vh;
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(169, 155, 245, 0.1);
}

/* O Segredo: Sincronizar perfeitamente o vídeo e o canvas */
.input_video, .output_canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Garante que preencha o espaço sem distorcer */
  transform: scaleX(-1);
}

.output_canvas {
  pointer-events: none;
}

/* Céu crepuscular da meditação, inteiramente em CSS. */
.meditation-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(145deg, #321c50, #211535 35%, #101c3b 70%, #080f26);
  background-size: 220% 220%;
  animation: twilightSky 30s ease-in-out infinite alternate;
}

.meditation-sky::before,
.meditation-sky::after {
  content: '';
  position: absolute;
  left: -80%;
  top: 12%;
  width: 80%;
  height: 35%;
  background:
    radial-gradient(ellipse at 25% 60%, rgba(211, 202, 239, 0.12), transparent 55%),
    radial-gradient(ellipse at 55% 45%, rgba(192, 191, 225, 0.16), transparent 60%),
    radial-gradient(ellipse at 80% 65%, rgba(183, 192, 226, 0.1), transparent 50%);
  filter: blur(20px);
  animation: driftingClouds 100s linear infinite;
  animation-delay: -45s;
}

.meditation-sky::after {
  top: 50%;
  height: 28%;
  opacity: 0.65;
  animation-duration: 140s;
  animation-delay: -100s;
}

.ambient-audio {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  left: 24px;
  width: min(300px, calc(100% - 48px));
  z-index: 15;
  color-scheme: dark;
}

@keyframes twilightSky {
  from { background-position: 0% 20%; }
  to { background-position: 100% 80%; }
}

@keyframes driftingClouds {
  from { transform: translateX(0); }
  to { transform: translateX(225%); }
}

@media (prefers-reduced-motion: reduce) {
  .meditation-sky,
  .meditation-sky::before,
  .meditation-sky::after { animation: none; }
  .meditation-sky::before { transform: translateX(80%); }
  .meditation-sky::after { transform: translateX(140%); }
}

/* Adaptação para Celular (Mobile) */
@media (max-width: 768px) {
  .video-container {
    width: 100vw;
    height: 100dvh; /* Troque de 100vh para 100dvh */
    border-radius: 0; 
    border: none;
  }
  
  .ui-layer {
    padding-top: 60px; /* Dá um respiro maior no topo para não encostar na câmera do iPhone */
  }
  
  .status-card {
    display: none; /* Oculta o texto no mobile, o feedback do esqueleto dourado já basta */
  }
  
  #statusTitle {
    font-size: 20px;
  }
  
  #statusSubtitle {
    font-size: 14px;
  }

  .pose-selector {
    bottom: 20px;
    gap: 8px;
    left: 0;
    width: 100vw;
    transform: none;
    justify-content: flex-start;
    flex-wrap: nowrap;
    padding: 0 20px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .pose-btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  .mascot-card {
    bottom: 110px!important;
    right: 20px;
    padding: 12px;
  }

  #poseReference {
    width: 100px;
  }

  .circular-timer {
    top: 45%;
    right: 12px;
    width: 56px;
    height: 56px;
  }

  .skip-icon {
    font-size: 18px;
  }

  .skip-arrow {
    font-size: 18px;
  }
}

/* Camada da Interface de Usuário por cima de tudo */
/* Camada da Interface de Usuário por cima de tudo */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: center; /* Centraliza horizontalmente */
  align-items: flex-start;  /* Mantém no topo */
  padding-top: 40px;
  z-index: 10;
}

/* Glassmorphism Card Corrigido */
.status-card {
  display: none;
  background: rgba(20, 18, 31, 0.75); /* Fundo um pouco mais opaco para legibilidade */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(169, 155, 245, 0.2);
  border-radius: 24px;
  padding: 16px 36px;
  text-align: center;
  width: auto;              /* Impede que estique */
  max-width: 400px;         /* Limita a largura máxima */
  pointer-events: auto;     /* Permite interação se precisar */
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.4s ease;
}

.status-card.success {
  border-color: rgba(227, 184, 115, 0.6); /* Borda Dourada ao acertar */
  box-shadow: 0 0 32px rgba(227, 184, 115, 0.2);
}

#statusTitle {
  margin: 0;
  color: #F3EFE7; /* Areia */
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

#statusSubtitle {
  margin: 8px 0 0 0;
  color: #A99BF5; /* Lavanda */
  font-size: 16px;
  font-weight: 600;
}

.skip-hint {
  margin: 6px 0 0 0;
  color: #A99BF5; /* Lavanda */
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
}

/* Card com glassmorphism que envolve a mascote Luna flutuando */
.mascot-card {
  position: absolute;
  bottom: 32px;
  right: 32px;
  z-index: 15;
  background: rgba(20, 18, 31, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(169, 155, 245, 0.2);
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* Imagem de referência da postura ativa */
#poseReference {
  width: 112px;
  height: 160px;
  object-fit: contain;
}

@media (max-width: 768px) {
  .mascot-card {
    right: max(12px, env(safe-area-inset-right, 0px));
    padding: 8px;
    border-radius: 20px;
    gap: 4px;
  }
  #poseReference { width: 88px; height: 124px; }
}

/* Cronômetro de progressão automática (aparece ao acertar a postura) */
.pose-timer {
  font-family: 'Nunito', sans-serif;
  color: #E3B873; /* Dourado */
  font-weight: 800;
  font-size: 20px;
  opacity: 0;
  height: 24px; /* Reserva o espaço fixo para o card não pular */
  line-height: 24px;
  margin: 0;
  text-align: center;
  transition: opacity 400ms ease-in-out, color 400ms ease-in-out;
}

.pose-timer.active {
  opacity: 1;
}

/* Referência ampliada; a animação mede o destino real no canto em qualquer tela. */
.pose-preview {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 50%;
  width: min(76vw, 42dvh, 336px);
  aspect-ratio: 7 / 10;
  transform: translate(-50%, -50%);
  transform-origin: center;
  border-radius: 24px;
  background: rgba(20, 18, 31, 0.96);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(169, 155, 245, 0.4);
  pointer-events: none;
}
.pose-preview[hidden] { display: none; }
.pose-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }

/* Dígitos grandes e estáveis: o número muda sem pulsar a cada segundo. */
.pose-countdown {
  position: fixed;
  z-index: 30;
  top: 50%;
  left: 50%;
  width: min(76vw, 48dvh, 340px);
  aspect-ratio: 1;
  box-sizing: border-box;
  padding: clamp(8px, 3vmin, 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(227, 184, 115, 0.75);
  border-radius: 50%;
  color: #FFE1A6;
  background: rgba(20, 18, 31, 0.72);
  box-shadow: 0 0 42px rgba(227, 184, 115, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) scale(0.82);
  transition: opacity 400ms ease-in-out, transform 500ms ease-in-out, color 400ms ease-in-out, border-color 400ms ease-in-out, box-shadow 400ms ease-in-out, visibility 0s linear 500ms;
  pointer-events: none;
}
.pose-countdown.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition-delay: 0s;
}
.pose-countdown-value {
  font-size: clamp(64px, 24vmin, 160px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-shadow: 0 0 20px rgba(227, 184, 115, 0.45);
}
.pose-countdown-caption, .pose-countdown-unit {
  font-size: clamp(14px, 3.8vmin, 20px);
  font-weight: 800;
  text-align: center;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .pose-countdown, .pose-countdown.is-visible {
    transform: translate(-50%, -50%);
    transition: opacity 150ms ease-in-out, visibility 0s linear 150ms;
  }
  .pose-countdown.is-visible { transition-delay: 0s; }
}

/* Botão flutuante de "pular postura" via gesto de mão aberta */
.circular-timer {
  --progress: 0;
  position: absolute;
  top: 50%;
  right: 32px;
  transform: translateY(-50%);
  z-index: 15;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(#E3B873 calc(var(--progress) * 1%), rgba(169, 155, 245, 0.15) 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.circular-timer.active {
  opacity: 1;
  pointer-events: auto;
  animation: pulseRing 1.5s ease-in-out infinite;
}

@keyframes pulseRing {
  0%, 100% {
    box-shadow: 0 0 0 rgba(227, 184, 115, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(227, 184, 115, 0.5);
  }
}

.skip-btn {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(20, 18, 31, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(169, 155, 245, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: default;
  padding: 0;
}

.skip-icon {
  font-size: 22px;
}

.skip-arrow {
  color: #E3B873;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

/* Seletor de Posturas (Calm Tech / Glassmorphism) */
.pose-selector {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10;
}

.pose-selector::-webkit-scrollbar {
  display: none;
}

.pose-btn {
  background: rgba(169, 155, 245, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(169, 155, 245, 0.4);
  color: #A99BF5;
  border-radius: 16px;
  padding: 10px 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.pose-btn:hover {
  background: rgba(169, 155, 245, 0.25);
}

.pose-btn.active {
  background: rgba(227, 184, 115, 0.2);
  border-color: #E3B873;
  color: #E3B873;
  box-shadow: 0 0 16px rgba(227, 184, 115, 0.3);
}

/* As quatro animações compartilham o ciclo de 4s + 4s + 6s. */
.breathing-mode .video-container,
.breathing-mode .ui-layer,
.breathing-mode .pose-selector { display: none; }

.breathing-practice {
  --breathing-cycle: 14s;
  position: fixed;
  inset: 0;
  overflow: auto;
  background: #14121F;
  color: #F3EFE7;
}
.breathing-practice[hidden] { display: none; }
.breathing-back {
  position: absolute;
  top: max(20px, env(safe-area-inset-top, 0px));
  left: max(20px, env(safe-area-inset-left, 0px));
  border: 1px solid rgba(169, 155, 245, 0.2);
  border-radius: 16px;
  padding: 0 16px;
  z-index: 1;
}
.breathing-title {
  position: absolute;
  top: max(24px, env(safe-area-inset-top, 0px));
  right: 24px;
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: #A99BF5;
}
.breathing-guide {
  min-height: max(100dvh, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 40px;
  box-sizing: border-box;
}
.breathing-orb {
  width: clamp(150px, 45vw, 240px);
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #F1E9FF, #C8BAFA 35%, #A99BF5 65%, #7766BE);
  box-shadow: 0 0 35px #A99BF566, 0 0 80px #A99BF538, 0 0 130px #A99BF51F;
  animation: breathingOrb var(--breathing-cycle) ease-in-out infinite;
}
.breathing-prompts {
  display: grid;
  margin: 64px 0 0;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  text-align: center;
}
.breathing-prompts span {
  grid-area: 1 / 1;
  animation-duration: var(--breathing-cycle);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.breathing-inhale { animation-name: breathingInhale; }
.breathing-hold { animation-name: breathingHold; }
.breathing-exhale { animation-name: breathingExhale; }
.breathing-caption {
  margin-top: 16px;
  color: #A99BF5;
  font-size: 14px;
  text-align: center;
}
.breathing-practice.is-paused .breathing-orb,
.breathing-practice.is-paused .breathing-prompts span { animation-play-state: paused; }

@keyframes breathingOrb {
  0%, 100% { transform: scale(0.65); opacity: 0.75; }
  28.5714%, 57.1429% { transform: scale(1); opacity: 1; }
}
@keyframes breathingInhale {
  0%, 28.5714%, 100% { opacity: 0; }
  3%, 25.5714% { opacity: 1; }
}
@keyframes breathingHold {
  0%, 28.5714%, 57.1429%, 100% { opacity: 0; }
  31.5714%, 54.1429% { opacity: 1; }
}
@keyframes breathingExhale {
  0%, 57.1429%, 100% { opacity: 0; }
  60.1429%, 97% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .breathing-orb { animation: none; }
  .breathing-prompts span { animation-timing-function: steps(1, end); }
}

/* O tempo continua visível quando a postura é perdida, sem brilho dourado. */
.pose-timer.is-gentle { color: #CFC5F3; }
.pose-countdown.is-gentle {
  color: #E4DDF7;
  border-color: rgba(169, 155, 245, 0.55);
  box-shadow: none;
}
.pose-countdown-value { transition: text-shadow 400ms ease-in-out; }
.pose-countdown.is-gentle .pose-countdown-value { text-shadow: none; }

/* Porta de entrada exclusiva para Yoga e Alongamento. */
.practice-start {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  color: #F3EFE7;
  background: rgba(29, 24, 47, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 1;
  visibility: visible;
  transition: opacity 450ms ease-in-out, visibility 0s linear;
}
.practice-start[hidden] { display: none; }
.practice-start.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 450ms ease-in-out, visibility 0s linear 450ms;
}
.practice-start-card {
  width: min(100%, 380px);
  box-sizing: border-box;
  padding: clamp(24px, 6vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 28px;
  background: rgba(169, 155, 245, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  text-align: center;
  font-family: 'Nunito', sans-serif;
}
.practice-start-card h1 { margin: 10px 0; font-size: 28px; line-height: 1.2; }
.practice-start-card p { line-height: 1.6; }
.practice-start-eyebrow { color: #D9CEF9; font-size: 14px; }
.practice-start-button {
  width: 100%;
  min-height: 56px;
  margin: 16px 0 20px;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  background: rgba(169, 155, 245, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #FFFFFF;
  font: 800 18px 'Nunito', sans-serif;
  cursor: pointer;
  transition: background 250ms ease-in-out;
}
.practice-start-button:hover { background: rgba(169, 155, 245, 0.35); }
.practice-start-button:focus-visible, .practice-start-card a:focus-visible {
  outline: 3px solid #E3B873;
  outline-offset: 4px;
}
.practice-start-card a { display: inline-block; padding: 10px; color: #E4DDF7; }
@media (prefers-reduced-motion: reduce) {
  .practice-start, .practice-start.is-dismissed {
    transition: opacity 150ms ease-in-out, visibility 0s linear 150ms;
  }
}

.cycle-complete { z-index: 110; animation: cycle-appear 450ms ease-in-out; }
.cycle-complete .practice-start-button { margin: 8px 0; }
@keyframes cycle-appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cycle-complete { animation: none; } }
