:root {
  color-scheme: dark;
  --accent: #ff2f5f;
  --accent-alt: #28f3e6;
  --panel: rgba(10, 10, 12, 0.68);
  --panel-strong: rgba(10, 10, 12, 0.88);
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.54);
  --stroke: rgba(255, 255, 255, 0.16);
  --rail-width: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050505;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050505;
}

.loading-screen,
.error-screen {
  display: grid;
  gap: 16px;
  justify-items: center;
  color: var(--text-soft);
  text-align: center;
  padding: 24px;
}

.loading-screen p,
.error-screen p {
  margin: 0;
}

.loader-mark {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-right-color: var(--accent-alt);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.phone-stage {
  position: relative;
  width: min(100vw, 520px);
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  background: #000000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.feed {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
  background: #000000;
}

.feed::-webkit-scrollbar {
  display: none;
}

.video-card {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 520px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #000000;
  isolation: isolate;
}

.video-card video,
.video-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
}

.video-card video {
  z-index: 1;
}

.video-fallback {
  z-index: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--text-soft);
  text-align: center;
  background:
    linear-gradient(160deg, rgba(255, 47, 95, 0.22), rgba(40, 243, 230, 0.14)),
    #111114;
}

.video-card::before,
.video-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}

.video-card::before {
  top: 0;
  height: 132px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.52), transparent);
}

.video-card::after {
  bottom: 0;
  height: 46%;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.72), transparent);
}

.top-tabs {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 8;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 20px;
  align-items: center;
  transform: translateX(-50%);
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 700;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.top-tabs span:last-child {
  color: #ffffff;
  position: relative;
}

.top-tabs span:last-child::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: #ffffff;
  transform: translateX(-50%);
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 9;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-alt), var(--accent));
}

.caption {
  position: absolute;
  left: 16px;
  right: calc(var(--rail-width) + 18px);
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  gap: 8px;
  min-width: 0;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.58);
}

.creator {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.caption-text {
  margin: 0;
  display: -webkit-box;
  max-height: 4.35em;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 48px;
  overflow: hidden;
}

.tag {
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 700;
}

.action-rail {
  position: absolute;
  right: 10px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  gap: 16px;
  justify-items: center;
  width: 56px;
}

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 47, 95, 0.95), rgba(40, 243, 230, 0.9)),
    #17171b;
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.rail-item {
  display: grid;
  gap: 5px;
  justify-items: center;
  min-width: 48px;
  color: #ffffff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.54);
}

.rail-item-compact {
  margin-top: -4px;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  transition:
    transform 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.icon-button:active {
  transform: scale(0.92);
}

.icon-button svg {
  width: 31px;
  height: 31px;
  display: block;
  fill: currentColor;
  filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.55));
}

.icon-button.is-liked {
  color: var(--accent);
}

.sound-button {
  width: 42px;
  height: 42px;
  background: rgba(0, 0, 0, 0.2);
}

.sound-button svg {
  width: 27px;
  height: 27px;
}

.sound-button.is-sound-on {
  color: var(--accent-alt);
}

.count {
  min-width: 44px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.88);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.video-card.is-paused .play-badge {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.play-badge svg {
  width: 38px;
  height: 38px;
  fill: #ffffff;
  transform: translateX(2px);
}

.heart-burst {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 7;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  color: var(--accent);
  transform: translate(-50%, -50%) scale(0.4) rotate(-12deg);
  animation: heart-burst 680ms ease forwards;
  pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
}

.heart-burst svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  height: calc(58px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  padding: 7px 10px max(6px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.82);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.nav-button {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.nav-button svg {
  width: 23px;
  height: 23px;
  fill: currentColor;
}

.nav-button.is-active {
  color: #ffffff;
}

.create-button {
  width: 42px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background:
    linear-gradient(90deg, var(--accent-alt) 0 18%, #ffffff 18% 82%, var(--accent) 82% 100%);
  color: #050505;
}

.comment-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: none;
  min-height: 42%;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  background: rgba(18, 18, 20, 0.96);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -18px 52px rgba(0, 0, 0, 0.45);
}

.comment-sheet.is-open {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.sheet-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 36px;
}

.sheet-header strong {
  justify-self: center;
  font-size: 15px;
}

.sheet-header button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: transparent;
}

.sheet-header svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.comment-empty {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  align-items: center;
}

.comment-form input {
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  outline: none;
}

.comment-form input:focus {
  border-color: rgba(40, 243, 230, 0.72);
}

.comment-form button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
}

.comment-form button svg {
  width: 20px;
  height: 20px;
  fill: #ffffff;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 15;
  max-width: min(320px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42);
}

@media (min-width: 760px) {
  .phone-stage {
    height: min(100dvh, 900px);
    border-radius: 8px;
  }

  .video-card {
    height: min(100dvh, 900px);
  }
}

@media (max-width: 360px) {
  :root {
    --rail-width: 62px;
  }

  .caption {
    left: 12px;
    right: calc(var(--rail-width) + 10px);
  }

  .action-rail {
    right: 6px;
    width: 50px;
  }

  .icon-button,
  .avatar {
    width: 44px;
    height: 44px;
  }

  .caption-text {
    font-size: 14px;
  }
}

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

@keyframes heart-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(-12deg);
  }

  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05) rotate(-12deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -72%) scale(1.42) rotate(-12deg);
  }
}
