html, body {
  margin: 0;
  background: #e5ebef;
  color: #000;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  html, body {
    background: #111;
    color: #fff;
  }
}

#feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0 calc(48px + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
}

#status {
  margin: 24px 16px;
  text-align: center;
}

.post {
  position: relative;
  display: block;
  width: 100%;
}

.post-widget {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.post.is-pending {
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.post-frame {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  border: 0;
  display: block;
  height: 0;
}

#modes {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 8px) 0 8px;
  background: inherit;
}

#modes button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  opacity: 0.5;
  padding: 6px 10px;
}

#modes button.is-on {
  opacity: 1;
  font-weight: 600;
}

body.mode-reels {
  height: 100dvh;
  overflow: hidden;
  background: #000;
  color: #fff;
}

body.mode-reels #modes {
  position: fixed;
  left: 0;
  right: 0;
  background: linear-gradient(rgba(0, 0, 0, 0.55) calc(100% - 20px), rgba(0, 0, 0, 0));
}

body.mode-reels #modes button {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

body.mode-reels #feed {
  display: block;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  gap: 0;
  padding: 0;
  background: #000;
}

.reel {
  position: relative;
  width: 100%;
  background: #000;
}

.reel.is-pending {
  height: 0;
  overflow: hidden;
}

.reel.is-shown {
  flex: 0 0 100dvh;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.reel-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  border-radius: 0;
  touch-action: pan-y;
  transition: top 0.28s ease, left 0.28s ease, width 0.28s ease, height 0.28s ease, border-radius 0.28s ease;
}

.reel.is-caption .reel-stage {
  border-radius: 14px;
  z-index: 3;
}

.reel-media {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  background: #000;
  display: block;
}

.reel-play {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  z-index: 3;
  pointer-events: none;
}

.reel-play::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 20px;
  border-style: solid;
  border-width: 14px 0 14px 22px;
  border-color: transparent transparent transparent #fff;
}

.reel.is-paused .reel-play {
  display: block;
}

.reel.is-caption .reel-play {
  display: none;
}

.reel-sound {
  display: none;
  position: absolute;
  z-index: 4;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  left: 50%;
  top: calc(50% - 78px);
  margin-left: -18px;
}

.reel-sound svg {
  display: block;
}

.reel.is-muted .reel-sound-on,
.reel:not(.is-muted) .reel-sound-off {
  display: none;
}

.reel.is-paused .reel-sound,
.reel.is-caption .reel-sound {
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel.is-caption .reel-sound {
  top: auto;
  left: auto;
  right: 8px;
  bottom: 8px;
  margin: 0;
}

.reel-seek {
  display: none;
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(24px + var(--tg-safe-area-inset-bottom, 0px));
  z-index: 4;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.reel.is-seeking .reel-seek {
  display: flex;
}

.reel.is-seeking .reel-meta {
  opacity: 0;
}

.reel-seek-track {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.reel-seek-bar {
  height: 100%;
  width: 0;
  background: #fff;
}

.reel-seek-time {
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.reel-meta {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(78px + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.reel.is-caption .reel-meta {
  display: none;
}

.reel-sheet {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: var(--sheet-top, 46vh);
  bottom: 0;
  z-index: 2;
  overflow-y: auto;
  padding: 8px 16px calc(28px + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  background: #000;
  color: #fff;
}

.reel.is-caption .reel-sheet {
  display: block;
}

.reel-grab {
  width: 36px;
  height: 4px;
  margin: 2px auto 14px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.45);
}

.reel-author {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-align: left;
  pointer-events: auto;
}

.reel-author img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
}

.reel-text {
  margin: 0;
  font-size: 15px;
  line-height: 20px;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  pointer-events: auto;
}

.reel-body {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 22px;
  white-space: pre-wrap;
}
