:root {
  --bg: #000;
  --fg: #fff;
  --fg-muted: rgba(255, 255, 255, 0.75);
  --accent: #ff2d55;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Topbar */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent);
}
.topbar > * {
  pointer-events: auto;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 0;
  cursor: pointer;
  border-radius: 999px;
}
.icon-btn:active {
  background: rgba(255, 255, 255, 0.12);
}
.mute-btn .icon-unmuted {
  display: none;
}
.mute-btn[data-muted='false'] .icon-muted {
  display: none;
}
.mute-btn[data-muted='false'] .icon-unmuted {
  display: inline-block;
}

/* Right side action rail */
.actions {
  position: absolute;
  right: calc(var(--safe-right) + 8px);
  bottom: calc(var(--safe-bottom) + 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  z-index: 20;
}
.action {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg);
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}
.action:active {
  transform: scale(0.92);
  transition: transform 80ms;
}
.action-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.avatar-btn .avatar {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #444;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  line-height: 40px;
  text-align: center;
}
.like-btn.liked {
  color: var(--accent);
}
.like-btn.liked-bump svg {
  animation: likepop 280ms ease-out;
}
@keyframes likepop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

/* Footer meta */
.meta {
  position: absolute;
  left: calc(var(--safe-left) + 14px);
  right: calc(var(--safe-right) + 80px);
  bottom: calc(var(--safe-bottom) + 18px);
  z-index: 15;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}
.author {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}
.desc {
  font-size: 14px;
  line-height: 1.35;
  color: var(--fg);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tags {
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 500;
}
.tags .tag {
  display: inline-block;
  margin-right: 6px;
}

/* First-visit hint */
.hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  pointer-events: none;
  animation: fadeIn 200ms ease-out;
}
.hint[hidden] {
  display: none;
}
.hint.dismiss {
  animation: fadeOut 240ms ease-in forwards;
}
.hint-arrow {
  animation: bobUp 1.4s ease-in-out infinite;
}
.hint-text {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
@keyframes bobUp {
  0%,
  100% {
    transform: translateY(8px);
    opacity: 0.85;
  }
  50% {
    transform: translateY(-12px);
    opacity: 1;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 90px);
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 40;
  pointer-events: none;
  animation: toastIn 200ms ease-out;
}
.toast[hidden] {
  display: none;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Double-tap hearts (TikTok-style: spawn at tap point, with random tilt) */
.hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 35;
  overflow: hidden;
}
.heart-pop {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  color: #fe2c55;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.55));
  will-change: transform, opacity;
  animation: heartPop 900ms cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}
.heart-pop svg {
  width: 100%;
  height: 100%;
  display: block;
}
@keyframes heartPop {
  0% {
    opacity: 0;
    transform: translateY(0) var(--rot, rotate(0deg)) scale(0.2);
  }
  18% {
    opacity: 1;
    transform: translateY(0) var(--rot, rotate(0deg)) scale(1.2);
  }
  35% {
    opacity: 1;
    transform: translateY(0) var(--rot, rotate(0deg)) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateY(0) var(--rot, rotate(0deg)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) var(--rot, rotate(0deg)) scale(1.05);
  }
}

/* Loading slot fallback (when video not yet ready) */
.slot.loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #050505;
}

/* Play / pause center indicator */
.play-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 34;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.6));
}
.play-indicator .ico {
  display: none;
}
.play-indicator[data-state='play'] .ico-play {
  display: block;
}
.play-indicator[data-state='pause'] .ico-pause {
  display: block;
}
.play-indicator.show {
  animation: playPop 520ms ease-out forwards;
}
@keyframes playPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.18);
  }
}

/* Progress bar (TikTok-style timeline) */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--safe-bottom);
  z-index: 18;
  padding: 0 8px 4px;
  pointer-events: none;
  transition: padding 160ms ease-out;
}
.progress-track {
  position: relative;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
  transition: height 160ms ease-out;
}
.progress-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: #fff;
  border-radius: inherit;
}
.progress-time {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 12px);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  pointer-events: none;
}
.progress.scrubbing {
  padding-bottom: 18px;
}
.progress.scrubbing .progress-track {
  height: 6px;
}
/* Hide chrome while scrubbing for clarity */
.scrubbing-mode .meta,
.scrubbing-mode .actions,
.scrubbing-mode .topbar {
  opacity: 0.25;
  transition: opacity 160ms ease-out;
}
