/* === ANALYZE PAGE === */
.nav-link {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--fg); }

.analyze-main {
  min-height: 100vh;
  padding: 6rem 2rem 4rem;
  max-width: 900px;
  margin: 0 auto;
}

/* START STATE */
.analyze-hero {
  text-align: center;
  margin-bottom: 3rem;
}

.analyze-hero .hero-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: block;
}

.analyze-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  color: var(--fg);
}

.analyze-sub {
  font-size: 1rem;
  color: #888;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.7;
}

/* RECORD ZONE */
.record-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.video-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16/9;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.06);
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pose-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── RECORDING INDICATOR ─────────────────────────────────────────── */
.rec-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: transparent;
}

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FF4444;
  animation: recPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.rec-timer {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  min-width: 36px;
}

.rec-bar-wrap {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}

.rec-bar {
  height: 100%;
  background: #FF4444;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
  animation: recBarGrow 10s linear forwards;
}

@keyframes recBarGrow {
  from { width: 0%; }
  to { width: 100%; }
}

/* CAMERA ERROR BANNER */
.camera-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13,13,13,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 10;
  border-radius: 16px;
  text-align: center;
  padding: 1.5rem;
}
.camera-error-icon { font-size: 2rem; }
#camera-error-text {
  font-size: 0.875rem;
  color: var(--danger);
  font-weight: 600;
}

/* CONTROLS */
.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-record {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--accent);
  color: #0D0D0D;
  border: none;
  padding: 0.875rem 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.03em;
}

.btn-record:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-record:active { transform: translateY(0); }

.record-icon {
  width: 16px;
  height: 16px;
  background: #0D0D0D;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-stop {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.875rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}

.btn-stop:hover { background: var(--surface); }

.stop-icon {
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 2px;
  flex-shrink: 0;
}

.btn-flip-camera {
  background: var(--surface);
  color: var(--fg-muted);
  border: 1px solid rgba(255,255,255,0.1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-flip-camera:hover { color: var(--fg); border-color: rgba(255,255,255,0.2); }

/* SETUP TIPS */
.setup-tips {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
}

.tip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #666;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
}

.tip-icon { font-size: 0.9rem; }

/* ANALYZING STATE (model loading) */
.analyzing-state {
  text-align: center;
  padding: 2rem;
}

.analyzing-state p {
  font-size: 0.95rem;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.analyzing-state .sub-text {
  font-size: 0.8rem !important;
  color: #666 !important;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(191,255,0,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── STATE 2: PREVIEW ─────────────────────────────────────────────── */
.preview-header {
  text-align: center;
  margin-bottom: 2rem;
}

.preview-header .hero-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: block;
}

.preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

/* TRIM SECTION */
.trim-section {
  width: 100%;
  max-width: 640px;
  margin: 1.5rem auto 0;
}

.trim-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.trim-label-text {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  flex-shrink: 0;
}

.trim-hint {
  font-size: 0.75rem;
  color: #666;
  text-align: right;
}

.trim-container {
  padding: 0 0.5rem;
}

.trim-track {
  position: relative;
  height: 40px;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}

.trim-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(191,255,0,0.08);
  /* left/right set dynamically by JS */
}

/* In/out range highlight (the selected region) */
.trim-track .trim-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(191,255,0,0.12);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
}

/* Draggable handles */
.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;
  background: var(--accent);
  cursor: ew-resize;
  z-index: 3;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trim-handle::after {
  content: '';
  width: 4px;
  height: 16px;
  background: #0D0D0D;
  border-radius: 2px;
  opacity: 0.6;
}

.trim-handle:hover, .trim-handle.dragging {
  background: #d4ff1a;
  transform: scaleX(1.2);
}

.trim-handle-in {
  left: 0;
  border-radius: 8px 0 0 8px;
}

.trim-handle-out {
  right: 0;
  border-radius: 0 8px 8px 0;
}

.trim-times {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0 0.25rem;
}

.trim-time {
  font-size: 0.75rem;
  color: #666;
  font-family: 'DM Sans', monospace;
}

.trim-duration {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  font-family: 'DM Sans', monospace;
}

/* PREVIEW ACTIONS */
.preview-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.btn-retake {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  color: var(--fg-muted);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.875rem 1.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.btn-retake:hover { color: var(--fg); border-color: rgba(255,255,255,0.2); }

.btn-analyze {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--accent);
  color: #0D0D0D;
  border: none;
  padding: 0.875rem 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.btn-analyze:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-analyze:active { transform: translateY(0); }

/* ── STATE 3: ANALYSIS LOADING ───────────────────────────────────── */
.analyzing-container {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}

.analyze-anim-icon {
  margin-bottom: 2rem;
  animation: floatPose 2s ease-in-out infinite;
}

@keyframes floatPose {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.analyze-stage-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.5rem;
  letter-spacing: 0.04em;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.analyze-stage-sub {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 2.5rem;
}

/* Staged progress track */
.analyze-progress-track {
  position: relative;
  padding-bottom: 3.5rem;
}

.analyze-progress-fill {
  position: absolute;
  bottom: 3rem;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
}

.analyze-progress-fill::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--fill, 0%);
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.analyze-stages {
  display: flex;
  justify-content: space-between;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.analyze-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.35;
  transition: opacity 0.4s;
}

.analyze-stage.active {
  opacity: 1;
}

.analyze-stage.done {
  opacity: 0.6;
}

.stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--surface-2);
  transition: all 0.3s;
}

.analyze-stage.active .stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(191,255,0,0.4);
}

.analyze-stage.done .stage-dot {
  background: var(--good);
  border-color: var(--good);
}

.analyze-stage span {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.analyze-stage.active span {
  color: var(--accent);
}

.analyze-stage.done span {
  color: var(--good);
}

.analyze-detail {
  font-size: 0.8rem;
  color: #555;
  margin-top: 1rem;
  font-family: 'DM Sans', monospace;
}

/* ── STATE 4: RESULTS ─────────────────────────────────────────────── */
.results-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: block;
}

.results-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 5rem;
  line-height: 1;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.results-sub {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.results-primary {
  margin-bottom: 1.5rem;
}

.finding-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 1.5rem;
}

.finding-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.finding-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.finding-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.finding-text {
  font-size: 1.05rem;
  color: var(--fg);
  font-weight: 500;
  line-height: 1.5;
}

.results-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.metric-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.metric-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.metric-good { color: var(--good); }
.metric-warn { color: var(--warn); }
.metric-bad { color: var(--danger); }
.metric-neutral { color: var(--fg); }

.metric-sub {
  font-size: 0.7rem;
  color: #666;
}

/* RISK */
.results-risk {
  background: rgba(255, 170, 0, 0.06);
  border: 1px solid rgba(255, 170, 0, 0.2);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.risk-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.risk-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.risk-badge.high {
  background: rgba(255, 77, 77, 0.15);
  color: var(--danger);
}
.risk-badge.moderate {
  background: rgba(255, 170, 0, 0.15);
  color: var(--warn);
}
.risk-badge.low {
  background: rgba(0, 230, 118, 0.12);
  color: var(--good);
}

.risk-text {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.risk-note-text {
  font-size: 0.875rem;
  color: #999;
  line-height: 1.5;
}

/* FIX */
.results-fix {
  background: var(--accent-dim);
  border: 1px solid rgba(191,255,0,0.15);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.fix-label-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.fix-body {
  font-size: 0.95rem;
  color: var(--fg);
  line-height: 1.6;
}

/* ACTIONS */
.results-actions {
  text-align: center;
}

.btn-another {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.875rem 2rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}

.btn-another:hover {
  background: var(--surface-2);
  border-color: rgba(255,255,255,0.2);
}

/* State block utility */
.state-block {
  width: 100%;
}

@media (max-width: 600px) {
  .results-metrics { grid-template-columns: 1fr 1fr; }
  .analyze-main { padding: 5rem 1rem 3rem; }
  .trim-label { flex-direction: column; gap: 0.25rem; }
  .trim-hint { text-align: left; }
  .analyze-stages span { display: none; }
  .preview-actions { flex-direction: column; align-items: stretch; }
  .btn-retake, .btn-analyze { justify-content: center; }
}