:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #10130f;
  color: #f8faf7;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  background:
    radial-gradient(circle at 20% 10%, rgba(59, 130, 246, 0.18), transparent 32%),
    linear-gradient(135deg, #0f1512 0%, #171515 38%, #0f171b 100%);
  display: grid;
  place-items: center;
}

.comment-list {
  overscroll-behavior: contain;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.stage {
  width: min(100vw, 460px);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.phone {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 9 / 16;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 32px;
  background: #050505;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.55);
}

.video {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
  background: #050505;
}

.poster-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(165deg, rgba(9, 12, 14, 0.42), rgba(4, 4, 5, 0.86) 70%),
    url("./assets/video-poster.svg") center / cover no-repeat;
  transform: scale(1.02);
  opacity: 0.62;
}

.vsl-player-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
}

.vsl-player {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 9 / 16;
  min-height: 100%;
  background: #050505;
}

.video-collapse-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  border: 0;
  padding: 0;
  background: transparent;
}

.video-collapse-layer.is-active {
  display: block;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}

.icon-button,
.rail-button,
.composer button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(12, 13, 14, 0.42);
  backdrop-filter: blur(16px);
}

.icon-button svg,
.rail-button svg,
.composer button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(12, 13, 14, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(16px);
  white-space: nowrap;
}

.live-pill strong {
  min-width: 28px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.52);
  animation: livePulse 1500ms ease-out infinite;
}

.action-rail {
  position: absolute;
  z-index: 3;
  right: 14px;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}

.rail-button {
  position: relative;
  background: rgba(0, 0, 0, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  color: #fff;
}

.rail-button svg {
  stroke: #fff;
  stroke-width: 2.4;
}

.like-rail-button {
  overflow: visible;
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.like-rail-button.is-liked {
  color: #fff;
  background: rgba(225, 29, 72, 0.86);
  box-shadow: 0 10px 26px rgba(225, 29, 72, 0.34);
}

.like-rail-button.is-popping {
  animation: likePop 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.like-rail-button.is-liked svg {
  fill: currentColor;
}

.heart-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: 14px;
  height: 14px;
  color: #fb7185;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: heartBurst 760ms ease-out forwards;
}

.heart-burst svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: #fff;
  stroke-width: 1.4;
}

.comment-sheet {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54%;
  min-height: 384px;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 14px;
  border-radius: 24px 24px 0 0;
  background: rgba(18, 20, 22, 0.88);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(24px);
  transition: background 180ms ease;
}

.comment-sheet.is-collapsed {
  left: 14px;
  right: 92px;
  bottom: max(24px, env(safe-area-inset-bottom));
  height: auto;
  min-height: 0;
  max-height: 104px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: none;
}

.comment-sheet.is-expanded {
  height: 54%;
  min-height: 384px;
  background: rgba(18, 20, 22, 0.9);
}

.handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  cursor: pointer;
}

.eyebrow {
  margin: 3px 0 0;
  color: rgba(248, 250, 247, 0.6);
  font-size: 12px;
  font-weight: 700;
}

.reaction-note {
  margin: 3px 0 0;
  color: rgba(248, 250, 247, 0.48);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.25;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.collapse-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.collapse-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comment-list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  mask-image: linear-gradient(transparent, #000 14%, #000);
}

.comment-sheet.is-collapsed .comment-list {
  flex: 0 1 auto;
  max-height: 76px;
  padding: 0;
  gap: 0;
  overflow: hidden;
  pointer-events: auto;
  mask-image: none;
}

.comment-sheet.is-collapsed .comment:not(:last-child):not(.is-leaving) {
  display: none;
}

.empty-state {
  align-self: center;
  margin: 12px 0 22px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 14px;
}

.comment {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  will-change: transform, opacity;
  animation: commentIn 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.comment-sheet.is-collapsed .comment {
  width: fit-content;
  max-width: 100%;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 14px 9px 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: rgba(10, 12, 14, 0.82);
  background-clip: padding-box;
  box-shadow: none;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  transition:
    opacity 1100ms ease,
    transform 1100ms cubic-bezier(0.16, 1, 0.3, 1),
    filter 1100ms ease;
}

.comment-sheet.is-collapsed .comment.is-leaving {
  position: absolute;
  z-index: 0;
  left: 0;
  bottom: 0;
  display: grid;
  pointer-events: none;
  animation: collapsedCommentOut 1250ms cubic-bezier(0.2, 0.72, 0.2, 1) forwards;
}

.comment-sheet.is-collapsed .comment:not(.is-leaving) {
  position: relative;
  z-index: 1;
  animation: collapsedCommentIn 900ms 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.comment-sheet.is-collapsed:not(.has-visible-bubble) .comment {
  animation: none;
  opacity: 0;
  filter: blur(2px);
  pointer-events: none;
  transform: translateY(12px) scale(0.985);
}

.comment img,
.composer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.comment img {
  object-fit: cover;
}

.composer-avatar {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.composer-avatar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comment-sheet.is-collapsed .comment img {
  width: 28px;
  height: 28px;
}

.comment-body {
  min-width: 0;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-bottom: 3px;
}

.name {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-sheet.is-collapsed .name {
  font-size: 13px;
}

.time {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.46);
  font-size: 11px;
  font-weight: 700;
}

.text {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.32;
}

.comment-sheet.is-collapsed .text {
  overflow: hidden;
  display: -webkit-box;
  max-width: min(360px, calc(100vw - 130px));
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.like {
  position: relative;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  overflow: visible;
  transition:
    color 160ms ease,
    transform 160ms ease;
}

.like.is-liked {
  color: #fb7185;
}

.like.is-liked svg {
  fill: currentColor;
}

.like.is-popping {
  animation: likePop 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.comment-sheet.is-collapsed .like,
.comment-sheet.is-collapsed .handle,
.comment-sheet.is-collapsed .sheet-head,
.comment-sheet.is-collapsed .collapse-button,
.comment-sheet.is-collapsed .composer,
.comment-sheet.is-collapsed .empty-state {
  display: none;
}

.like svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.composer {
  display: grid;
  grid-template-columns: 36px 1fr 42px;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
}

.composer input {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: 0;
  padding: 0 15px;
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.composer input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.composer button {
  background: #f4f7ef;
  color: #121417;
  transition:
    opacity 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.composer button:disabled {
  cursor: default;
  color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.14);
  opacity: 0.68;
}

.composer button svg {
  stroke-width: 2.4;
}

@keyframes commentIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.98);
  }
  65% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes collapsedCommentOut {
  0% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    filter: blur(1.5px);
    transform: translateY(-42px) scale(0.985);
  }
}

@keyframes collapsedCommentIn {
  from {
    opacity: 0;
    filter: blur(1px);
    transform: translateY(16px) scale(0.985);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes likePop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes heartBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(0deg);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--burst-x)), calc(-50% + var(--burst-y))) scale(1.2) rotate(var(--burst-rotate));
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  72%,
  100% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

@media (max-width: 430px) {
  .stage {
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  .comment-sheet {
    height: 56%;
  }

  .comment-sheet.is-collapsed {
    left: 12px;
    right: 86px;
    bottom: max(18px, env(safe-area-inset-bottom));
    height: auto;
    min-height: 0;
    max-height: 76px;
  }

  .comment-sheet.is-expanded {
    height: 56%;
    min-height: 384px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
