/* Stories sit under the Home tabs. The viewer is full-screen in every theme. */
.story-tray {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.story-tray::-webkit-scrollbar { display: none; }
.story-card {
  width: 72px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 12px/16px var(--font);
  cursor: pointer;
}
.story-ring {
  position: relative;
  width: 64px;
  height: 64px;
  box-sizing: border-box;
  border-radius: 16px;
  padding: 2px;
  background: var(--muted);
}
.story-card.unseen .story-ring {
  background: linear-gradient(210deg, #f9ce34, #ee2a7b 45%, #6228d7);
}
.story-face {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 2px solid var(--bg);
  border-radius: 14px;
  overflow: hidden;
  background: var(--ava);
}
.story-face img,
.story-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.story-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--initials-fg);
  background: var(--initials-bg);
  font-weight: 700;
}
.story-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-badge svg { width: 12px; height: 12px; fill: var(--text); }
.story-name {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.story-card:focus-visible .story-ring { outline: 2px solid var(--blue); outline-offset: 2px; }

#stories {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #000;
  color: #fff;
  color-scheme: dark;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  overscroll-behavior: none;
  outline: none;
}
#stories[hidden] { display: none; }
html.stories-open,
html.stories-open body { overflow: hidden; }
.story-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.story-bars { display: flex; gap: 4px; }
.story-bar {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}
.story-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
}
.story-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 2px 0;
}
.story-mini { width: 36px; height: 36px; flex: none; }
.story-mini .story-face { border-width: 0; border-radius: 10px; }
.story-who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 18px; }
.story-who b { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-who span { color: rgba(255, 255, 255, 0.75); font-size: 13px; }
.story-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.story-icon svg { width: 22px; height: 22px; fill: currentColor; }
.story-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-media {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
}
.story-stage video.story-media { width: 100%; height: 100%; object-fit: contain; }
.story-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  color: #fff;
  font-size: 16px;
  line-height: 22px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-miss {
  position: absolute;
  color: #fff;
  font-size: 15px;
}
.story-menu {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 3;
  min-width: 200px;
  background: #16181c;
  color: #e7e9ea;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}
.story-menu[hidden] { display: none; }
.story-menu a,
.story-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 14px 16px;
  font: 15px/20px var(--font);
  text-decoration: none;
}
.story-menu a:hover,
.story-menu button:hover { background: rgba(255, 255, 255, 0.08); }

@media (max-width: 499px) {
  .story-tray { gap: 12px; padding: 10px 12px 8px; }
}
@media (min-width: 500px) {
  .story-stage { max-width: 460px; }
  #stories { background: #000; }
}
