/* BeautyV — просмотрщик историй. BEM. */
.story-viewer {
  --sv-ink: #101918;
  --sv-tiffany: #5ec7c2;
  --sv-cream: #fefefe;
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Manrope", "Montserrat", system-ui, sans-serif;
}
.story-viewer[hidden] { display: none; }
.story-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 14, 13, .86);
  animation: sv-fade .22s ease-out both;
}
.story-viewer__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sv-in .3s cubic-bezier(.22, 1, .36, 1) both;
}
.story-viewer__card {
  position: relative;
  width: min(560px, calc((100vh - 48px) * .707));
  max-height: calc(100vh - 48px);
  aspect-ratio: 9 / 13;
  overflow: hidden;
  border-radius: 26px;
  background: var(--sv-ink);
  box-shadow: 0 24px 64px -22px rgba(0, 0, 0, .62);
  isolation: isolate;
}
.story-viewer__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.story-viewer__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(5, 14, 13, .6) 0%, rgba(5, 14, 13, .06) 27%, rgba(5, 14, 13, 0) 48%, rgba(5, 14, 13, .8) 100%),
    linear-gradient(90deg, rgba(5, 14, 13, .12), transparent 28%, transparent 72%, rgba(5, 14, 13, .18));
}
.story-viewer__progress {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  gap: 5px;
}
.story-viewer__progress-item {
  position: relative;
  height: 2.5px;
  flex: 1;
  border-radius: 99px;
  background: rgba(255, 255, 255, .32);
  overflow: hidden;
  cursor: pointer;
}
.story-viewer__progress-item::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, .96);
}
.story-viewer__progress-item.is-done { background: rgba(255, 255, 255, .95); }
.story-viewer__progress-item.is-done::after { width: 100%; }
.story-viewer__progress-item.is-active { background: rgba(255, 255, 255, .32); }
.story-viewer__progress-item.is-active::after {
  animation: story-progress 5s linear forwards;
}
.story-viewer__progress-item.is-active.is-paused::after {
  animation-play-state: paused;
}
.story-viewer__progress-item:hover { background: rgba(255, 255, 255, .65); }
.story-viewer__progress-item:hover::after { background: rgba(255, 255, 255, .9); }
@keyframes story-progress { to { width: 100%; } }
.story-viewer__header {
  position: absolute;
  top: 26px;
  left: 18px;
  right: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
}
.story-viewer__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, .75);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  flex: 0 0 38px;
}
.story-viewer__author { min-width: 0; flex: 1; color: #fff; }
.story-viewer__author span { display: block; color: rgba(255, 255, 255, .72); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; line-height: 1.2; }
.story-viewer__author strong { display: block; margin-top: 2px; color: #fff; font-size: 13px; font-weight: 700; line-height: 1.25; }
.story-viewer__tools { display: flex; align-items: center; gap: 8px; }
.story-viewer__tool {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.story-viewer__tool:hover { background: rgba(255, 255, 255, .25); transform: translateY(-1px); }
.story-viewer__tool svg { width: 17px; height: 17px; }
.story-viewer__tool--close { border-color: rgba(255, 255, 255, .28); }
.story-viewer__tool.is-muted { color: rgba(255, 255, 255, .55); }
.story-viewer__actions {
  position: absolute;
  right: 16px;
  bottom: 205px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.story-viewer__action {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #fff;
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: transform .2s, color .2s;
}
.story-viewer__action:hover { transform: translateY(-2px); color: #fff; }
.story-viewer__action svg { width: 28px; height: 28px; stroke-width: 1.7; }
.story-viewer__action.is-liked svg { fill: #ff7b8a; stroke: #ff7b8a; }
.story-viewer__action span { font-size: 10px; color: #fff; }
.story-viewer__content {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 4;
  color: #fff;
}
.story-viewer__kicker { margin-bottom: 6px; color: rgba(255, 255, 255, .72); font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.story-viewer__title { margin: 0; color: #fff; font-family: "Manrope", "Montserrat", system-ui, sans-serif; font-size: 21px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.story-viewer__description { margin: 7px 0 0; max-width: 90%; color: rgba(255, 255, 255, .78); font-size: 11.5px; font-weight: 500; line-height: 1.5; }
.story-viewer__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border-radius: 13px;
  background: var(--sv-tiffany);
  color: #0b2a29;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background .2s, transform .2s;
}
.story-viewer__cta:hover { background: #7ad9d3; color: #0b2a29; transform: translateY(-1px); }
.story-viewer__arrow {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #fefefe;
  color: #101918;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transform: translateY(-50%);
  transition: transform .2s, background .2s;
}
.story-viewer__arrow:hover { background: #e9f7f4; transform: translateY(-50%) scale(1.05); }
.story-viewer__arrow::before { content: ""; width: 9px; height: 9px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; }
.story-viewer__arrow--prev { left: -66px; }
.story-viewer__arrow--prev::before { transform: rotate(-45deg); margin-left: 4px; }
.story-viewer__arrow--next { right: -66px; }
.story-viewer__arrow--next::before { transform: rotate(135deg); margin-right: 4px; }
body.is-story-open { overflow: hidden; }

@keyframes sv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sv-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 820px) {
  .story-viewer { padding: 12px; }
  .story-viewer__card { width: min(440px, calc((100vh - 24px) * .707)); max-height: calc(100vh - 24px); border-radius: 22px; }
  .story-viewer__arrow { display: none; }
  .story-viewer__actions { bottom: 190px; right: 12px; }
  .story-viewer__content { left: 16px; right: 16px; bottom: 16px; }
  .story-viewer__title { font-size: 19px; }
  .story-viewer__description { font-size: 11px; }
}
@media (max-width: 520px) {
  .story-viewer { padding: 0; align-items: stretch; }
  .story-viewer__stage { width: 100%; height: 100%; }
  .story-viewer__card { width: 100%; max-height: none; height: 100%; aspect-ratio: auto; border-radius: 0; }
  .story-viewer__header { top: 22px; }
  .story-viewer__progress { top: 12px; }
  .story-viewer__actions { bottom: 200px; }
  .story-viewer__content { left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .story-viewer__title { font-size: 20px; }
  .story-viewer__cta { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .story-viewer__backdrop, .story-viewer__stage { animation: none; }
}

/* Комментарии к историям */
.story-viewer__action[hidden] { display: none; }
.story-viewer__comments {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: inherit;
  background: #0b1211;
  color: #fff;
}
.story-viewer__comments[hidden] { display: none; }
.story-viewer__comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}
.story-viewer__comments-head b { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.story-viewer__comments-head button {
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.story-viewer__comments-list {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.story-viewer__comments-empty { margin: auto 0; color: rgba(255,255,255,.6); font-size: 11px; text-align: center; line-height: 1.5; }
.story-viewer__comment {
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 11px;
  background: rgba(255,255,255,.055);
}
.story-viewer__comment-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.story-viewer__comment-head b { color: #fff; font-size: 10px; font-weight: 700; }
.story-viewer__comment-head time { color: rgba(255,255,255,.45); font-size: 8px; white-space: nowrap; }
.story-viewer__comment p { margin: 0; color: rgba(255,255,255,.82); font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.story-viewer__comment-form { display: grid; gap: 6px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.14); }
.story-viewer__comment-form input[type="text"],
.story-viewer__comment-form textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 9px;
  background: rgba(255,255,255,.07);
  color: #fff;
  padding: 8px 9px;
  font: inherit;
  font-size: 11px;
  outline: 0;
}
.story-viewer__comment-form input::placeholder,
.story-viewer__comment-form textarea::placeholder { color: rgba(255,255,255,.45); }
.story-viewer__comment-form textarea { min-height: 62px; resize: vertical; line-height: 1.4; }
.story-viewer__comment-form input:focus,
.story-viewer__comment-form textarea:focus { border-color: rgba(198,162,74,.75); box-shadow: 0 0 0 2px rgba(198,162,74,.14); }
.story-viewer__comment-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.story-viewer__comment-foot span { color: #ffb4ae; font-size: 8.5px; line-height: 1.3; }
.story-viewer__comment-foot button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #d4af37, #f5e5a3);
  color: #211a0d;
  font: inherit;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}
.story-viewer__comment-foot button:disabled { opacity: .65; cursor: wait; }
.story-viewer__hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
@media (max-width: 720px) {
  .story-viewer__comments { padding: 16px 14px; }
  .story-viewer__comments-head b { font-size: 14px; }
  .story-viewer__comment-form textarea { min-height: 74px; font-size: 16px; }
  .story-viewer__comment-form input[type="text"] { font-size: 16px; }
}

/* Пока открыты комментарии, сторис не листаются */
.story-viewer--comments-open .story-viewer__arrow {
  opacity: 0;
  pointer-events: none;
}

.story-viewer--comments-open .story-viewer__arrow { display: none !important; }
.story-viewer--comments-open .story-viewer__comments { overscroll-behavior: contain; }

/* Нижняя шторка комментариев */
.story-viewer__comments {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(56%, 520px);
  max-height: 56%;
  padding: 24px 18px 16px;
  border-radius: 20px 20px 0 0;
  transform: translateY(102%);
  opacity: 0;
  pointer-events: none;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), opacity .22s ease;
}
.story-viewer__comments::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 38px;
  height: 4px;
  margin-left: -19px;
  border-radius: 99px;
  background: rgba(255,255,255,.28);
}
.story-viewer__comments.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.story-viewer__comments[hidden] { display: flex; }
@media (max-width: 720px) {
  .story-viewer__comments {
    height: 56%;
    max-height: 56%;
    padding: 24px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
}

/* Видео в просмотрщике историй */
.story-viewer__video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.story-viewer__video[hidden] { display: none; }
.story-viewer__image[hidden] { display: none; }
.story-viewer__shade { pointer-events: none; }
.story-viewer__progress-item.is-active.is-video::after {
  animation: none;
  width: var(--sv-video-progress, 0%);
  transition: width .12s linear;
}
.story-viewer__card:has(.story-viewer__video:not([hidden])) .story-viewer__actions { bottom: 225px; }
