* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }

.icon { width: 1em; height: 1em; display: block; flex: none; }

/* Kept rendered rather than display:none, which some mobile browsers refuse to
   open a file picker from. */
.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Feed: one full-height clip at a time, centred in a phone-shaped column on desktop. */
.feed {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  max-width: calc(100dvh * 9 / 16);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

@media (max-aspect-ratio: 3/4) {
  .feed { max-width: none; }
}

.slide {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #000;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide video { width: 100%; height: 100%; object-fit: contain; display: block; }

.slide::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 28%;
  background: linear-gradient(to top, rgba(0, 0, 0, .65), transparent);
  pointer-events: none;
}

/* Overlays let taps through to the clip underneath. */
.slide-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.big-play {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  background: rgba(0, 0, 0, .4);
  padding-left: 4px;
}
.slide-message {
  max-width: 70%;
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, .7);
}

.rail {
  position: absolute;
  z-index: 2;
  right: 10px;
  bottom: calc(44px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.rail-item .icon { font-size: 30px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6)); }

.time-left {
  position: absolute;
  z-index: 2;
  left: 14px;
  bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}

/* Thin progress line along the bottom; press and drag anywhere on it to scrub. */
.seek {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom);
  height: 24px;
  display: flex;
  align-items: flex-end;
  cursor: pointer;
  touch-action: none;
}
.seek-track { width: 100%; height: 2px; background: rgba(255, 255, 255, .25); transition: height .15s; }
.seek-fill { height: 100%; width: 0; background: #fff; }
.seek.scrubbing .seek-track { height: 6px; }
.seek-time { font-size: 24px; font-weight: 700; text-shadow: 0 2px 8px rgba(0, 0, 0, .8); }
.seek-time small { font-size: inherit; font-weight: inherit; color: rgba(255, 255, 255, .6); }

/* Top bar */
.topbar {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: calc(100dvh * 9 / 16);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .5), transparent);
  pointer-events: none;
}
@media (max-aspect-ratio: 3/4) {
  .topbar { max-width: none; }
}
.topbar-actions { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: -.3px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.brand b { color: #22d3ee; }
.post-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #000;
  background: linear-gradient(90deg, #22d3ee, #34d399);
}
.post-btn .icon { font-size: 18px; }
.topbar-round {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 22px;
  background: rgba(0, 0, 0, .45);
}

/* Upload progress: stays out of the way while the viewer keeps watching. */
.upload-chip {
  position: absolute;
  top: calc(100% - 2px);
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.ring {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ring svg { position: absolute; inset: 3px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-track { stroke: rgba(255, 255, 255, .25); }
.ring-fill {
  stroke: #22d3ee;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .2s linear;
}
.ring.done .ring-fill { stroke: #34d399; }
.ring.failed .ring-fill { stroke: #fb7185; }
.ring span { position: relative; }
.upload-cancel {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  background: rgba(0, 0, 0, .65);
}

.sound-hint {
  position: fixed;
  z-index: 4;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, .55);
  white-space: nowrap;
}
.sound-hint .icon { font-size: 16px; }

/* Empty, loading and error states */
.state {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: rgba(255, 255, 255, .7);
}
.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.primary {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 700;
  color: #000;
  background: linear-gradient(90deg, #22d3ee, #34d399);
}

/* Camera */
.camera {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: 0;
  color: #fff;
  background: #000;
  overflow: hidden;
}
.camera::backdrop { background: #000; }
.camera > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera > video.mirror { transform: scaleX(-1); }

.camera-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.camera-round {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  background: rgba(0, 0, 0, .5);
}
.camera-round:disabled { opacity: .35; cursor: default; }
.camera-status {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: #e11d48;
}
.camera-error {
  position: absolute;
  top: 50%;
  left: 24px;
  right: 24px;
  transform: translateY(-50%);
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, .85);
}
.camera-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 24px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent);
}
.camera-hint { font-size: 12px; text-align: center; color: rgba(255, 255, 255, .75); }
.camera-controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.camera-spacer { width: 44px; }
.shutter {
  width: 76px;
  height: 76px;
  padding: 6px;
  border-radius: 50%;
  border: 4px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shutter span { width: 100%; height: 100%; border-radius: 50%; background: #e11d48; transition: all .15s; }
.shutter.recording span { width: 45%; height: 45%; border-radius: 6px; }
.shutter:disabled { opacity: .35; cursor: default; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: 88%;
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: #000;
  background: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .feed { scroll-behavior: auto; }
  .seek-track, .shutter span, .ring-fill { transition: none; }
}
