/* Bereich: Storys & Storyboards (stories.js)
   Leiste wie friends_feed_page.dart (Kachel 102, Ring 90, Foto 78), Viewer wie
   story_viewer_page.dart (schwarz, randlos, 9:16), Storyboards wie profile_highlights.dart.
   Storys erstellt man nur in der App. Ohne Kacheln, ohne Farb-Glows. */

html.story-open,
html.story-open body { overflow: hidden; }

/* ======================================================================
   Story-Leiste
   ====================================================================== */
.st-bar { position: relative; }
.st-bar__track {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 4px 10px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
}
.st-bar__track::-webkit-scrollbar { display: none; }

.st-tile {
  position: relative;
  display: flex;
  justify-content: center;
  flex: 0 0 102px;
  width: 102px;
  scroll-snap-align: start;
}
.st-tile__hit {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border-radius: 12px;
}
.st-tile__hit:focus-visible { outline-offset: -2px; }

/* Ring liegt AUSSERHALB des immer gleich großen Fotos (Maske statt Lückenfarbe). */
.st-ring {
  --st-ring: transparent;
  --st-ring-w: 3px;
  position: relative;
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  transition: transform .14s ease;
}
.st-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--st-ring);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--st-ring-w)), #000 calc(100% - var(--st-ring-w) + .5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--st-ring-w)), #000 calc(100% - var(--st-ring-w) + .5px));
}
.st-ring--unseen { --st-ring: var(--ring-unseen); }
.st-ring--own { --st-ring: var(--accent-gradient); }
.st-ring--cf { --st-ring: linear-gradient(135deg, #FFB545, #1BD760); }
.st-ring--seen { --st-ring: var(--line); --st-ring-w: 1.5px; }
.st-ring--none::before { display: none; }
.st-tile__hit:active .st-ring { transform: scale(.96); }

.st-photo {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-soft);
}
.st-photo.sk { background: var(--skeleton); }
.st-photo > img { width: 100%; height: 100%; object-fit: cover; }
.st-photo > .avatar { width: 78px; height: 78px; }

.st-name {
  margin-top: 8px;
  max-width: 94px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Blätter-Knöpfe nur mit Maus (Touch wischt). */
.st-bar__arrow {
  position: absolute;
  top: 34px;
  z-index: 3;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text);
  background: var(--glass-btn);
  border: 1px solid var(--glass-btn-border);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}
.st-bar__arrow .icon { width: 20px; height: 20px; }
.st-bar__arrow--prev { left: 4px; }
.st-bar__arrow--next { right: 4px; }
@media (hover: hover) and (pointer: fine) {
  .st-bar__arrow { display: grid; }
}
.st-bar__arrow[hidden] { display: none !important; }

/* ======================================================================
   Storyboards im Profil (Kreise 62 px, Titel darunter)
   ====================================================================== */
.st-hl { margin: 0 0 14px; }
.st-hl[hidden] { display: none; }
.st-hl__title {
  padding: 0 16px 10px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -.1px;
}
.st-hl__track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 16px 2px;
}
.st-hl__track::-webkit-scrollbar { display: none; }
.st-hl__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: none;
  width: 64px;
  border-radius: 10px;
}
.st-hl__item:disabled { opacity: .55; }
.st-hl__circle {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1.4px solid var(--border);
  color: var(--text-2);
}
.st-hl__img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.st-hl__label {
  width: 64px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ======================================================================
   Viewer (immer dunkel wie die App)
   ====================================================================== */
dialog.st-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
  color-scheme: dark;
}
dialog.st-viewer[open] { display: block; }
dialog.st-viewer::backdrop { background: #000; }

.st-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  height: 100%;
}

.st-stage {
  --u: 1px;
  position: relative;
  flex: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  isolation: isolate;
}
.st-stage:focus { outline: none; }
@media (min-width: 560px) {
  dialog.st-viewer { background: #0B0B0B; }
  dialog.st-viewer::backdrop { background: #0B0B0B; }
  .st-stage {
    width: auto;
    height: calc(100% - 32px);
    max-width: calc(100vw - 150px);
    aspect-ratio: 9 / 16;
    border-radius: 12px;
  }
}

.st-media { position: absolute; inset: 0; transition: filter .2s ease; }
.st-media__img,
.st-media__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.st-media__img.is-broken { visibility: hidden; }
.st-media__video { opacity: 0; transition: opacity .2s ease; }
.st-media__video.is-ready { opacity: 1; }
.st-stage.has-emoji .st-media { filter: brightness(.45); }

.st-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, .44) 0%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, .58) 100%);
}

/* Inhalt-Ebene: Texte, GIFs, Pillen – Größen relativ zur Stage-Breite (--u = 1/402). */
.st-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.st-placed {
  position: absolute;
  width: max-content;
  transform-origin: center;
}
.st-placed.is-interactive { pointer-events: auto; }

.st-text {
  display: inline-block;
  max-width: calc(var(--u) * 321.6);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.st-text--serif { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 700; }
.st-text--mono { font-family: Courier, "Courier New", monospace; font-weight: 700; }
.st-text--neon { font-weight: 900; }
.st-text--bg-none:not(.st-text--neon) { text-shadow: 0 0 calc(var(--u) * 12) rgba(0, 0, 0, .54); }
.st-text--bg-glass,
.st-text--bg-black,
.st-text--bg-white,
.st-text--bg-palette {
  padding: calc(var(--u) * 10) calc(var(--u) * 14);
  border-radius: calc(var(--u) * 18);
}
.st-text--bg-glass {
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.st-text--bg-black { background: rgba(0, 0, 0, .85); }
.st-text--bg-white { background: #fff; }

.st-gif {
  display: block;
  width: calc(var(--u) * 150);
  border-radius: calc(var(--u) * 14);
  overflow: hidden;
}
.st-gif > img { width: 100%; height: 100%; object-fit: cover; }
.st-gif--sticker { border-radius: 0; }
.st-gif--sticker > img { object-fit: contain; }

.st-chip {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--u) * 6);
  max-width: calc(var(--u) * 300);
  padding: calc(var(--u) * 7) calc(var(--u) * 12);
  border-radius: 999px;
  font-size: calc(var(--u) * 14);
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  background: rgba(0, 0, 0, .40);
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.st-chip .icon { width: calc(var(--u) * 16); height: calc(var(--u) * 16); }
.st-chip__text { overflow: hidden; text-overflow: ellipsis; }

.st-legacy-caption {
  position: absolute;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 16px;
  transform: translateX(-50%);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow-wrap: anywhere;
}

/* Oben: Fortschritt + Kopfzeile */
.st-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: max(10px, env(safe-area-inset-top)) 8px 0;
  transition: opacity .2s ease;
}
.st-progress { display: flex; gap: 4px; padding: 0 4px; }
.st-seg {
  flex: 1 1 0;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, .28);
}
.st-seg__fill {
  display: block;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left center;
}
.st-info {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding-left: 4px;
}
.st-info__spacer { flex: 1 1 auto; }
.st-who-slot { min-width: 0; display: flex; }
.st-who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 4px 2px 0;
  border-radius: 999px;
  color: #fff;
  text-align: left;
}
.st-who__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .8);
}
.st-who__avatar img { width: 100%; height: 100%; object-fit: cover; }
.st-who__avatar .icon { width: 18px; height: 18px; }
.st-who__text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.st-who__name {
  min-width: 0;
  font-size: 15.2px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 12px rgba(0, 0, 0, .87);
}
.st-who__name .sk { background: rgba(255, 255, 255, .2); }
.st-who__time {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, .78);
  text-shadow: 0 0 12px rgba(0, 0, 0, .87);
}
.st-cf {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 3.5px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FFB545, #1BD760);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.st-cf .icon { width: 12px; height: 12px; }
.st-cf[hidden] { display: none; }

.st-icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.st-icon-btn .icon { width: 22px; height: 22px; }
.st-icon-btn[hidden] { display: none; }
.st-icon-btn:disabled { opacity: .4; }

/* Unten: Antwort-Leiste bzw. Owner-Leiste */
.st-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
  transition: opacity .2s ease;
}
.st-stage.is-holding .st-top,
.st-stage.is-holding .st-bottom,
.st-stage.is-holding .st-layer .is-interactive { opacity: 0; }

.st-reply { display: flex; align-items: center; gap: 6px; }
.st-reply__pill {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .38);
  background: rgba(0, 0, 0, .22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: text;
}
.st-reply__input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.st-reply__input::placeholder { color: rgba(255, 255, 255, .7); font-weight: 500; }
.st-round {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
}
.st-round .icon { width: 26px; height: 26px; }
.st-round[hidden] { display: none; }

.st-owner { display: flex; align-items: center; gap: 8px; }
.st-owner__stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.st-owner__stat .icon { width: 20px; height: 20px; }
.st-owner__spacer { flex: 1 1 auto; }

/* Schnell-Reaktionen (2 Reihen à 4) */
.st-emoji {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
  padding: 0 24px;
}
.st-emoji[hidden] { display: none; }
.st-emoji__btn {
  font-size: 40px;
  line-height: 1;
  padding: 8px 0;
  border-radius: 14px;
  animation: st-pop .26s var(--ease-out) both;
}
.st-emoji__btn:nth-child(2) { animation-delay: .03s; }
.st-emoji__btn:nth-child(3) { animation-delay: .06s; }
.st-emoji__btn:nth-child(4) { animation-delay: .09s; }
.st-emoji__btn:nth-child(5) { animation-delay: .12s; }
.st-emoji__btn:nth-child(6) { animation-delay: .15s; }
.st-emoji__btn:nth-child(7) { animation-delay: .18s; }
.st-emoji__btn:nth-child(8) { animation-delay: .21s; }
@keyframes st-pop {
  from { opacity: 0; transform: translateY(14px) scale(.6); }
  to { opacity: 1; transform: none; }
}

/* Herz/Emoji mittig nach Doppeltipp oder Reaktion */
.st-burst {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.st-burst > * { animation: st-burst .8s var(--ease-out) forwards; }
.st-burst__heart { width: 96px; height: 96px; }
.st-burst__emoji { font-size: 84px; line-height: 1; }
@keyframes st-burst {
  0% { opacity: 0; transform: scale(.3); }
  25% { opacity: 1; transform: scale(1.1); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.st-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: rgba(255, 255, 255, .85);
  animation: st-spin .9s linear infinite;
  pointer-events: none;
}
.st-spinner[hidden] { display: none; }
@keyframes st-spin { to { transform: rotate(360deg); } }

.st-pausemark {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: none;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .38);
  pointer-events: none;
}
.st-pausemark .icon { width: 30px; height: 30px; }
.st-stage.is-paused .st-pausemark { display: grid; }

.st-expired {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: #000;
  text-align: center;
}
.st-expired[hidden] { display: none; }
.st-expired > .icon { color: rgba(255, 255, 255, .38); }
.st-expired__text { font-size: 16px; font-weight: 800; }
.st-pill-btn {
  margin-top: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  color: #fff;
  font-size: 14.5px;
  font-weight: 800;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
}

.st-toast {
  position: absolute;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 6;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(22, 22, 22, .94);
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  animation: st-toast-in .22s var(--ease-out);
}
.st-toast[hidden] { display: none; }
@keyframes st-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Blätter-Knöpfe neben der Story (ab Tablet) */
.st-nav {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .14);
}
.st-nav .icon { width: 28px; height: 28px; }
.st-nav:disabled { opacity: .25; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .st-nav:not(:disabled):hover { background: rgba(255, 255, 255, .22); }
}
@media (max-width: 559px) {
  .st-nav { display: none; }
}

/* ======================================================================
   Sheets aus dem Viewer: Aktivität und Melden
   ====================================================================== */
.st-activity { padding: 12px 0 16px; }
.st-activity__tabs { padding-bottom: 8px; }
.st-people { display: grid; }
.st-person {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  text-align: left;
}
.st-person__name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-people__empty { padding: 28px 16px; text-align: center; font-size: 14px; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) {
  button.st-person:hover { background: var(--line-soft); }
}

.st-report { display: grid; gap: 2px; padding: 12px 16px 16px; }
.st-report__note {
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-2);
}
.st-report__reasons { display: grid; }
.st-report__reason {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 2px;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}
.st-report__details { margin-top: 8px; min-height: 84px; }
.st-report__details[hidden] { display: none; }

/* ======================================================================
   Hinweis „Storys erstellst du in der App“ (eigene Kachel ohne Story)
   ====================================================================== */
.st-apphint {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 22px 24px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}
.st-apphint__qr {
  width: 132px;
  height: 132px;
  border-radius: 14px;
  background: #fff;
  padding: 6px;
}
.st-apphint__text {
  max-width: 300px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text-2);
}
/* Auf dem Handy bringt der QR-Code nichts – dort reicht der Link. */
@media (hover: none) and (pointer: coarse) {
  .st-apphint__qr { display: none; }
}

/* ======================================================================
   Weniger Bewegung
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  .st-ring,
  .st-media,
  .st-media__video,
  .st-top,
  .st-bottom { transition: none; }
  .st-emoji__btn,
  .st-burst > *,
  .st-toast { animation: none; }
  .st-burst > * { opacity: 0; }
  .st-spinner { animation-duration: 2.4s; }
}
