:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #101315;
  color: #f5f5f6;
  --sheet: #171c1f;
  --ring: #586371;
  --avatar-size: clamp(72px, 21.8vw, 142px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 90% 0%, #252526, transparent 49%), #101315;
}

.sheet {
  width: min(100%, 58rem);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  overflow: hidden;
  border-radius: 1.8rem 1.8rem 0 0;
  background: var(--sheet);
}

.sheet-header {
  padding: max(.72rem, env(safe-area-inset-top)) .8rem .85rem;
  border-bottom: 1px solid #262c30;
  text-align: center;
}

.handle {
  display: block;
  width: 2.1rem;
  height: .22rem;
  margin: 0 auto .85rem;
  border-radius: 2rem;
  background: #a0a9b8;
}

h1, p { margin: 0; }
h1 {
  font-size: clamp(1.22rem, 4.7vw, 2.2rem);
  font-weight: 680;
  line-height: 1.13;
  letter-spacing: -.025em;
}
.title-note {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: .3rem auto 0;
  color: #aeb7c4;
  font-size: .87rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-underline-offset: .2em;
}
.title-note:hover { color: #fff; }
.participants { padding: 1.2rem clamp(.65rem, 3.7vw, 2.6rem) 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  column-gap: clamp(.55rem, 2.8vw, 2rem);
  row-gap: clamp(1.25rem, 5.2vw, 2.45rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
.grid > li { width: 100%; min-width: 0; }

.tile {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: .46rem;
  color: inherit;
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.tile:focus-visible, button:focus-visible, #story-retry-link:focus-visible {
  outline: 3px solid #a8caff;
  outline-offset: 4px;
  border-radius: .45rem;
}

.frame {
  position: relative;
  display: block;
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex: 0 0 auto;
  padding: clamp(3px, .8vw, 5px);
  border: clamp(3px, .9vw, 5px) solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(var(--sheet), var(--sheet)) padding-box,
    conic-gradient(from 0deg,
      #ed00aa 0%, #f300a7 24%, #ff304d 47%,
      #ff9420 65%, #ffd42d 78%, #ff6927 90%, #ed00aa 100%) border-box;
  box-shadow: 0 0 9px rgba(255, 43, 105, .18);
  transition: box-shadow .16s ease;
}
.tile[data-seen="true"] .frame {
  background:
    linear-gradient(var(--sheet), var(--sheet)) padding-box,
    linear-gradient(var(--ring), var(--ring)) border-box;
  box-shadow: none;
}

.media {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #353b42;
}
.initials {
  color: #dce1e6;
  font-size: clamp(1.4rem, 5vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -.04em;
}
.media img, .media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--crop-x, 50%) var(--crop-y, 50%);
  transform: scale(var(--zoom, 1));
  transform-origin: var(--crop-x, 50%) var(--crop-y, 50%);
  pointer-events: none;
}
.media video { opacity: 0; }
.media video.ready { opacity: 1; }
.tile[aria-busy="true"] .media::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  background: rgba(13, 16, 20, .42);
  pointer-events: none;
}
.tile[aria-busy="true"] .media::after {
  content: "";
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 2.1rem;
  height: 2.1rem;
  margin: -1.05rem;
  border: 3px solid rgba(255, 255, 255, .42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  pointer-events: none;
}

.username {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #f1f2f3;
  font-size: clamp(.77rem, 3.25vw, 1.08rem);
  font-weight: 400;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status { padding: 1.1rem; color: #b6bec7; line-height: 1.5; text-align: center; }
.feed-loading { display: flex; justify-content: center; padding: 1.1rem 0 .45rem; }
.loading-wheel {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  border: 2.5px solid #5b6673;
  border-top-color: #f4f5f7;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton > div {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border: 4px solid #414b56;
  border-radius: 50%;
  background: #272d33;
  animation: breathe 1.7s ease-in-out infinite alternate;
}
@keyframes breathe { to { opacity: .52; } }

button { color: inherit; font: inherit; cursor: pointer; }
.retry {
  display: block;
  min-height: 2.8rem;
  margin: 0 auto 1rem;
  padding: .5rem 1rem;
  border: 1px solid #56616d;
  border-radius: .7rem;
  background: #30373d;
}

#story-retry {
  position: fixed;
  z-index: 2;
  bottom: max(.85rem, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  width: max-content;
  max-width: calc(100% - 2rem);
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: .55rem .4rem .55rem 1rem;
  transform: translateX(-50%);
  border: 1px solid #58616a;
  border-radius: 1rem;
  background: #24292e;
  box-shadow: 0 .35rem 1.75rem #0006;
}
#story-retry-message { color: #c5cbd2; font-size: .82rem; }
#story-retry-link {
  grid-column: 1;
  padding: .3rem 0;
  color: #fff;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-underline-offset: .18em;
}
#dismiss-story-retry {
  width: 2.75rem;
  height: 2.75rem;
  grid-column: 2;
  grid-row: 1 / 3;
  margin-left: .35rem;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
}

@media (min-width: 58rem) {
  .sheet { margin-top: 1.2rem; min-height: calc(100dvh - 1.2rem); border-radius: 2rem 2rem 0 0; }
  .sheet-header { padding-top: 1.05rem; padding-bottom: 1.1rem; }
  .handle { margin-bottom: 1.3rem; }
  .participants { padding-top: 2rem; }
}
@media (hover: hover) {
  .tile:hover .username { text-decoration: underline; text-underline-offset: .16em; }
  .tile:not([data-seen="true"]):hover .frame { box-shadow: 0 0 14px rgba(255, 43, 105, .32); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
