:root {
  --fg: #fff;
  --dim: rgba(255, 255, 255, 0.62);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --card-w: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

i[data-ico] { display: block; width: 26px; height: 26px; flex: none; }
i[data-ico] svg { display: block; width: 100%; height: 100%; }

/* ============ scroller ============ */

.feed {
  position: fixed;
  inset: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  outline: none;
}
.feed::-webkit-scrollbar { width: 0; height: 0; }

.reel {
  position: relative;
  height: 100%;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
  contain: paint;
}

/* ============ screenshot ============ */

.shot-bg, .shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.shot-bg {
  object-fit: cover;
  filter: blur(34px) brightness(0.45) saturate(1.3);
  transform: scale(1.25);
}

.shot { object-fit: contain; }

.reel.ready .shot, .reel.ready .shot-bg { opacity: 1; }

.spin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.reel.ready .spin, .reel.gone .spin { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.dead {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  opacity: 0.3;
}
.dead i[data-ico] { width: 44px; height: 44px; }
.reel.gone .dead { display: block; }

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0,
    rgba(0, 0, 0, 0.35) 18%,
    rgba(0, 0, 0, 0) 42%,
    rgba(0, 0, 0, 0) 84%,
    rgba(0, 0, 0, 0.3) 100%
  );
}

/* ============ caption ============ */

.meta {
  position: absolute;
  left: 14px;
  right: 82px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 3;
}

.byline { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.ring {
  width: 34px;
  height: 34px;
  flex: none;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
}
.pfp {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: #2b2b2b;
}

.handle {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.follow {
  flex: none;
  padding: 3px 11px 4px;
  font-size: 13px;
  font-weight: 600;
  line-height: 17px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
}
.follow.on { border-color: rgba(255, 255, 255, 0.35); color: var(--dim); }

.caption {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 18px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.caption.open { -webkit-line-clamp: 6; }
.caption .more { color: var(--dim); }

.track { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.track i[data-ico] { width: 13px; height: 13px; }
.track-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* ============ action rail ============ */

.rail {
  position: absolute;
  right: 6px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.act .n { font-size: 12px; font-weight: 600; line-height: 13px; }
.act:active { transform: scale(0.88); }
.act.like.on svg { fill: #ff3040; stroke: #ff3040; }

.disc {
  width: 27px;
  height: 27px;
  overflow: hidden;
  border-radius: 7px;
  background: #1c1c1c;
  box-shadow: inset 0 0 0 1.5px #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.disc img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============ double-tap burst ============ */

.burst {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: 96px;
  height: 96px;
  margin: -48px;
  opacity: 0;
  pointer-events: none;
}
.burst i[data-ico] { width: 96px; height: 96px; }
.burst svg { fill: #fff; stroke: none; filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.45)); }
.burst.go { animation: burst 1s ease-out; }
@keyframes burst {
  0% { opacity: 0; transform: scale(0.25) rotate(-12deg); }
  15% { opacity: 1; transform: scale(1.15) rotate(6deg); }
  28% { transform: scale(0.94) rotate(-3deg); }
  40% { transform: scale(1) rotate(0deg); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

/* ============ loop bar ============ */

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 3px;
  background: rgba(255, 255, 255, 0.22);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.reel.live .bar { opacity: 1; }
.bar span { display: block; height: 100%; width: 0; background: #fff; }
.reel.live.ready .bar span { animation: creep 16s linear infinite; }
@keyframes creep { from { width: 0; } to { width: 100%; } }

/* ============ wordmark ============ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.wordmark {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.4px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* ============ desktop deck arrows ============ */

.deck { display: none; }

/* ============ sheet ============ */

.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }

.sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72%;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  background: #262626;
  border-radius: 14px 14px 0 0;
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(100%); } }

.sheet-grip {
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
}

.sheet-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 44px 12px;
  border-bottom: 1px solid #363636;
}
.sheet-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.sheet-x { position: absolute; right: 12px; top: 8px; }
.sheet-x i[data-ico] { width: 22px; height: 22px; }

.sheet-body { overflow-y: auto; padding: 14px 16px 24px; }

.empty { margin: 36px 0; text-align: center; font-size: 15px; color: var(--dim); }

.rows { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; }
.rows dt { color: var(--dim); }
.rows dd { margin: 0; overflow-wrap: anywhere; }

.sheet-acts { display: flex; flex-direction: column; margin-top: 18px; }
.sheet-acts button, .sheet-acts a {
  padding: 13px 2px;
  text-align: left;
  font-size: 15px;
  border-top: 1px solid #363636;
}

/* ============ toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  padding: 11px 16px;
  font-size: 14px;
  background: #fafafa;
  color: #000;
  border-radius: 10px;
  animation: rise 0.2s ease-out;
}
.toast[hidden] { display: none; }

/* ============ desktop ============ */

@media (min-width: 900px) and (min-height: 560px) {
  .header { display: none; }

  .reel { gap: 16px; padding: 16px 0; }

  .stage {
    width: auto;
    height: 100%;
    max-height: 880px;
    max-width: calc(100vw - 180px);
    aspect-ratio: 9 / 16;
    border-radius: 6px;
    flex: none;
  }

  .rail {
    position: static;
    align-self: flex-end;
    width: 48px;
    bottom: auto;
    right: auto;
    margin-bottom: 26px;
    gap: 22px;
  }
  .act, .disc { filter: none; }
  .act:hover { opacity: 0.55; }
  .meta { right: 20px; bottom: 26px; }
  .caption { -webkit-line-clamp: 2; cursor: pointer; }
  .bar { border-radius: 0 0 6px 6px; }

  .deck {
    position: fixed;
    right: 26px;
    top: 50%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transform: translateY(-50%);
  }
  .deck-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #262626;
  }
  .deck-btn:hover { background: #363636; }
  .deck-btn:disabled { opacity: 0.3; cursor: default; }
  .deck-btn i[data-ico] { width: 20px; height: 20px; }

  .sheet-card {
    left: 50%;
    bottom: 50%;
    right: auto;
    width: 420px;
    max-height: 68vh;
    transform: translate(-50%, 50%);
    border-radius: 14px;
    animation: fade 0.18s ease-out;
  }
  @keyframes fade { from { opacity: 0; } }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .reel.live.ready .bar span { animation: none; width: 0; }
  .burst.go { animation-duration: 0.4s; }
  .sheet-card, .toast { animation: none; }
}
