/* Полоса историй: аватарки как у .avatar в списке чатов — 48×48 (styles.css) */

.stories-strip {
  flex-shrink: 0;
  min-height: 76px;
  max-height: 96px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.stories-strip-inner {
  display: flex;
  flex-direction: row;
  gap: 10px;
  /* Запас под кольцо за 48px (зазор 4px + толщина 3px от края аватара → до r≈29) */
  padding: 11px 17px 13px;
  align-items: flex-start;
}

.story-cell {
  flex: 0 0 auto;
  width: 56px;
  text-align: center;
  cursor: pointer;
}

/* Внешний круг = 48px как .avatar в чат-листе */
.story-avatar-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto;
  overflow: visible;
}

/* SVG-обводка Telegram-style: сегменты = число слайдов (см. stories.js buildStoryRingSvg) */
.story-ring-host {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.story-ring-svg {
  display: block;
  width: 48px;
  height: 48px;
  transform-origin: 24px 24px;
  overflow: visible;
}

/* Непросмотренные — яркий синий; просмотренные — тёмно-серые (толщина кольца та же, что у синего) */
.story-ring-svg path.story-ring-accent {
  fill: #1877f2;
}

.story-ring-svg path.story-ring-viewed {
  fill: #6b7280;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.22));
}

.story-ring-svg circle.story-ring-accent {
  stroke: #1877f2;
  fill: none;
}

.story-ring-svg circle.story-ring-viewed {
  stroke: #6b7280;
  fill: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.22));
}

.story-ring-svg circle.story-ring-empty {
  stroke: #e0e0e0;
}

#storiesStrip.stories-strip-loading .story-ring-svg,
.story-ring-host.story-ring-loading .story-ring-svg {
  animation: story-ring-spin 0.85s linear infinite;
}

@keyframes story-ring-spin {
  to {
    transform: rotate(360deg);
  }
}

.story-avatar,
.story-avatar-fallback {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d7769;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  z-index: 1;
}

.story-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.story-add-btn {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: #128c7e;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-label {
  display: block;
  font-size: 11px;
  margin-top: 3px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Полноэкранный просмотр (как в Android / Telegram) */
/*
 * В styles.css задано глобально: button { width:100%; background:#128c7e; ... }.
 * Без сброса под #storyViewerOverlay кнопки «Назад»/«Меню» превращаются в полосы на всю ширину.
 */
#storyViewerOverlay button {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  font-weight: normal !important;
  border-radius: 0 !important;
}

#storyViewerOverlay button:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.story-viewer-menu-popup {
  position: fixed;
  z-index: 10002;
  min-width: 180px;
  background: rgba(28, 28, 28, 0.96);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.story-viewer-menu-popup.story-viewer-menu-popup-visible {
  display: block;
}

.story-viewer-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.story-viewer-menu-item:hover,
.story-viewer-menu-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.story-viewer-menu-item.story-viewer-menu-danger {
  color: #ff5b6b;
}

.story-viewer-menu-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
}

.story-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.story-viewer-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.story-viewer-topbar {
  flex-shrink: 0;
  padding: env(safe-area-inset-top, 0) 0 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
}

.story-viewer-segments {
  display: flex;
  flex-direction: row;
  gap: 4px;
  padding: 8px 10px 4px;
  align-items: center;
}

/* Трек белый, заполнение синее (текущий слайд «плывёт» за время показа) */
.story-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.95);
  min-width: 0;
  overflow: hidden;
}

.story-seg-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: #1877f2;
  box-sizing: border-box;
}

.story-seg-past .story-seg-fill {
  width: 100%;
}

.story-seg-future {
  opacity: 0.4;
}

.story-seg-future .story-seg-fill {
  width: 0%;
}

.story-viewer-header-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  padding: 4px 8px 12px 4px;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.story-viewer-icon-btn {
  flex-shrink: 0;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px;
  border: none;
  background: transparent !important;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
}

.story-viewer-avatar-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #0d7769;
}

.story-viewer-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-viewer-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}

.story-viewer-names {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.story-viewer-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-viewer-subtitle {
  color: #b0b0b0;
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-viewer-media-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#storyViewerMedia {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

.story-viewer-img,
.story-viewer-video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.story-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}

.story-viewer-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: story-spin 0.75s linear infinite;
}

@keyframes story-spin {
  to {
    transform: rotate(360deg);
  }
}

.story-viewer-tap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.story-tap-left,
.story-tap-right {
  flex: 1;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
}

.story-tap-left:active,
.story-tap-right:active,
.story-tap-left:focus,
.story-tap-right:focus {
  background: transparent !important;
  outline: none !important;
}

/* Instagram-like footer: stats column + optional reply bar (React new UI) */
.story-viewer-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0));
  padding-top: 12px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.2) 45%, transparent 100%);
  pointer-events: none;
  box-sizing: border-box;
}

.story-viewer-footer-upper {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

.story-stats-column {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.story-stat-ig {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  padding: 4px 2px;
  cursor: pointer;
  line-height: 1;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 1px 0 rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.55));
}

.story-stat-ig i {
  font-size: 22px;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.65);
}

.story-stat-ig-likes.story-like-toggle-on i,
.story-like-toggle-on i {
  color: #ff3040;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.35);
}

@keyframes story-like-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

.story-like-pop i {
  animation: story-like-pop 0.38s ease;
}

.story-reply-row {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Строка как в Instagram: широкая «капсула» + контурная иконка справа вне капсулы */
.story-reply-compose {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.story-reply-toast {
  align-self: center;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* Капсула только вокруг поля (тёмная, тонкая светлая обводка) */
.story-input-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 40px;
  padding: 2px 16px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-sizing: border-box;
}

.story-reply-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.35;
  padding: 8px 0;
  min-height: 36px;
  box-sizing: border-box;
}

.story-reply-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

/* Контурный самолётик справа, ниже по высоте чем капсула */
.story-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #fff;
  opacity: 0.95;
  transition: opacity 0.15s ease, transform 0.12s ease;
}

.story-send-btn .story-send-plane {
  color: transparent;
  -webkit-text-stroke-width: 1.1px;
  -webkit-text-stroke-color: rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 0 0.5px rgba(255, 255, 255, 0.35));
}

.story-send-btn:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.06);
}

.story-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Старая панель (legacy / старые разметки) */
.story-viewer-bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  z-index: 5;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
  pointer-events: none;
  box-sizing: border-box;
}

.story-viewer-bottom-bar .story-viewer-stat-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 21px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 30px;
  cursor: pointer;
  line-height: 1;
}

.story-viewer-bottom-bar .story-viewer-stat-btn i {
  font-size: 24px;
}

.story-viewer-bottom-spacer {
  flex: 1;
  min-width: 8px;
}

.story-viewer-list-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 768px) {
  .story-viewer-list-modal.story-viewer-list-modal-visible {
    align-items: center;
    padding: 16px;
  }
  .story-viewer-list-modal-sheet {
    border-radius: 16px;
  }
}

.story-viewer-list-modal.story-viewer-list-modal-visible {
  display: flex !important;
}

.story-viewer-list-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.story-viewer-list-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: #1e1e1e;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

.story-viewer-list-modal-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.story-viewer-list-modal-title {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.story-viewer-list-modal-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #b0b0b0;
  font-size: 28px;
  line-height: 0.9;
  cursor: pointer;
  padding: 0;
}

.story-viewer-list-modal-close:hover,
.story-viewer-list-modal-close:active,
.story-viewer-list-modal-close:focus {
  background: transparent !important;
  outline: none;
}

.story-viewer-list-modal-body {
  overflow-y: auto;
  padding: 8px 0 16px;
  min-height: 120px;
}

.story-viewer-list-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.story-viewer-list-row.story-viewer-list-row-stack {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.story-viewer-list-time-right {
  flex-shrink: 0;
  color: #888;
  font-size: 13px;
  white-space: nowrap;
  text-align: right;
  padding-left: 8px;
}

.story-viewer-list-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: #0d7769;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

.story-viewer-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-viewer-list-meta {
  flex: 1;
  min-width: 0;
}

.story-viewer-list-name {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-viewer-list-sub {
  color: #888;
  font-size: 12px;
  margin-top: 2px;
}

.story-viewer-list-empty,
.story-viewer-list-loading,
.story-viewer-list-err {
  padding: 24px 16px;
  text-align: center;
  color: #b0b0b0;
  font-size: 14px;
}

/* Тёмная тема: как шапка #chatListScreen .header — #2c2c2c (см. dark-theme.css) */
body.dark-theme .stories-strip {
  background: #2c2c2c !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

body.dark-theme .story-label {
  color: #e9edef;
}

body.dark-theme .story-ring-svg circle.story-ring-empty {
  stroke: #4a4a4a;
}

body.dark-theme .story-ring-svg path.story-ring-viewed {
  fill: #ffffff;
  filter: none;
}

body.dark-theme .story-ring-svg circle.story-ring-viewed {
  stroke: #ffffff;
  fill: none;
  filter: none;
}
