* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #ececec;
  color: #262626;
}

.phone-frame {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  box-shadow: 0 0 30px rgba(0,0,0,.08);
}

/* Верхний коллаж */
.cover-slider {
  display: flex;
  height: 130px;
  overflow: hidden;
  background: #ddd;
}
.cover-slider img {
  flex: 1;
  height: 100%;
  object-fit: cover;
  border-right: 2px solid #fff;
}
.cover-slider img:last-child { border-right: none; }

/* Аватар */
.avatar-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: -55px;
}
/* Переливающееся сияние за аватаркой */
.avatar-wrap::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 150px;
  height: 150px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff6ec4, #7c6bff, #4fd1ff, #ffd166, #ff6ec4);
  filter: blur(16px);
  opacity: .8;
  z-index: 0;
  animation: auraSpin 7s linear infinite, auraPulse 3.2s ease-in-out infinite;
}
.avatar-ring {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  outline: 3px solid #e0218a;
  background: #f2f2f2;
}

@keyframes auraSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes auraPulse {
  0%, 100% { opacity: .55; filter: blur(13px); }
  50% { opacity: .95; filter: blur(20px); }
}

.profile-info {
  text-align: center;
  padding: 10px 24px 4px;
}
.profile-name {
  font-size: 20px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.profile-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: #333;
  white-space: pre-line;
  margin: 0;
}

/* Кнопки действий */
.action-buttons {
  display: flex;
  gap: 8px;
  padding: 14px 16px 6px;
}
.action-btn {
  flex: 1;
  background: #eaf5ff;
  color: #0d6efd;
  border: none;
  border-radius: 8px;
  padding: 9px 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.3;
}
.action-btn:active { background: #d9edff; }

/* Секции */
.section { padding: 16px 16px 4px; }
.section-title { font-size: 16px; margin: 0 0 10px; }

/* Истории */
.stories-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  cursor: pointer;
}
.story-ring {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(135deg, #f9ce34, #ee2a7b, #6228d7);
}
.story-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}
.story-item span {
  font-size: 11px;
  color: #444;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Рубрики */
.categories-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  cursor: pointer;
}
.category-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f3a6a2;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  border: 2px solid transparent;
}
.category-item.is-active .category-circle { border-color: #e0218a; }
.category-circle--all { background: #b9b9b9; }
.category-label {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
}

/* Переключатель вида */
.feed-toggle {
  display: flex;
  border-top: 1px solid #efefef;
  margin-top: 10px;
}
.feed-toggle__btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: #b0b0b0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  border-bottom: 2px solid transparent;
}
.feed-toggle__btn.is-active { color: #262626; border-bottom-color: #262626; }

/* Плиточная лента */
.grid-feed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #eee;
  cursor: pointer;
}
.grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-item .play-icon {
  position: absolute; top: 6px; right: 6px;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.6));
}

/* Классическая лента */
.classic-feed { padding: 0 16px; }

.empty-state { text-align: center; color: #999; padding: 30px 0; }

/* Модальное окно сообщений */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.is-open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 360px;
  position: relative;
}
.modal h3 { margin: 0 0 14px; }
.modal__close {
  position: absolute; top: 10px; right: 14px;
  border: none; background: none; font-size: 16px; cursor: pointer; color: #888;
}
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #444; }
.modal input, .modal textarea {
  padding: 9px 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.btn-submit {
  background: #0d6efd; color: #fff; border: none; border-radius: 8px;
  padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.form-status { font-size: 13px; text-align: center; min-height: 16px; }
.modal__thumb {
  display: flex; align-items: center; gap: 10px;
  background: #f5f5f5; border-radius: 10px; padding: 8px 10px; margin-bottom: 12px;
}
.modal__thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.modal__thumb span { font-size: 12px; color: #666; }

/* ===================================================================
   Просмотрщик в стиле "reels" — используется и для историй, и для
   рилс-публикаций. Вертикальная лента со scroll-snap: листается
   свайпом (телефон), колесом мыши/трекпадом и стрелками (десктоп) —
   как в YouTube Shorts / VK Клипы. Крестик — закрыть.
=================================================================== */
.reel-viewer {
  display: none;
  position: fixed; inset: 0;
  background: #000;
  z-index: 400;
}
.reel-viewer.is-open { display: flex; align-items: center; justify-content: center; }

.reel-viewer__frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

/* Сама прокручиваемая лента — один экран на слайд, со snap-остановкой */
.reel-feed-scroll {
  position: absolute; inset: 0;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.reel-feed-scroll::-webkit-scrollbar { display: none; }

.reel-slide {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
.reel-slide img,
.reel-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.reel-slide__play-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 18;
  pointer-events: none;
}

.reel-viewer__close,
.reel-viewer__mute {
  position: absolute;
  top: 14px;
  z-index: 40;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reel-viewer__close { right: 12px; }
.reel-viewer__mute { right: 58px; }

/* Текстовый блок внизу слайда — подпись/лайки/рубрики, с лёгким
   затемнением фона на всю ширину, чтобы текст читался на любом видео */
.reel-slide__caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  padding: 70px 90px 20px 16px;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  background: linear-gradient(transparent, rgba(0,0,0,.45) 68%);
  pointer-events: none;
}
.reel-slide__likes-line { margin-bottom: 4px; }
.reel-slide__cats { margin-bottom: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.reel-slide__text { opacity: .95; }
.reel-slide__caption .cat-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255,255,255,.2);
  padding: 3px 9px;
  border-radius: 20px;
}

@media (min-width: 700px) {
  .reel-viewer__frame { max-width: 460px; height: 90vh; border-radius: 14px; }
}

/* Шапка reel-плеера: аватар + название (всегда наш профиль) */
.reel-viewer__topbar {
  position: absolute;
  top: 14px; left: 12px;
  z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.35);
  padding: 5px 12px 5px 5px;
  border-radius: 30px;
}
.reel-viewer__avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid #fff;
}
.reel-viewer__username { color: #fff; font-size: 13px; font-weight: 600; }

/* Боковые кнопки (лайк/комментарий) на каждом слайде — как в TikTok/Reels */
.reel-slide__side-actions {
  position: absolute;
  right: 10px; bottom: 90px;
  z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.reel-viewer__side-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #fff; font-size: 12px; font-weight: 600;
}
.reel-viewer__side-btn svg { filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); transition: transform .15s ease; }
.reel-viewer__side-btn:active svg { transform: scale(1.25); }

/* ===================================================================
   Карточка поста (в стиле классической ленты соцсети) — используется
   и во всплывающем окне, и как визуал для карточки в классической ленте
=================================================================== */
.post-card-modal-inner {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 12px;
}
.post-card {
  background: #fff;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.post-card--embedded {
  border: 1px solid #efefef;
  margin-bottom: 18px;
}
.post-card__close {
  position: absolute; top: 10px; right: 12px; z-index: 5;
  border: none; background: rgba(255,255,255,.85); border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: 14px; color: #333;
}
.post-card__header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.post-card__avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.post-card__username { font-weight: 600; font-size: 14px; flex: 1; }
.post-card__menu { color: #666; font-weight: 700; }
.post-card__media { background: #fafafa; display: flex; align-items: center; justify-content: center; max-height: 60vh; }
.post-card__media img, .post-card__media video { width: 100%; max-height: 60vh; object-fit: contain; display: block; }
.post-card__actions {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 4px;
}
.post-card__actions-left { display: flex; gap: 14px; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 2px; display: flex; }
.icon-btn svg { transition: transform .15s ease; }
.icon-btn:active svg { transform: scale(1.2); }
.post-card__likes { padding: 4px 14px 2px; font-size: 13px; }
.post-card__categories { padding: 2px 14px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.post-card__caption { padding: 2px 14px 16px; font-size: 13.5px; line-height: 1.5; }

.cat-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: #e0218a;
  text-transform: uppercase;
  background: rgba(224,33,138,.08);
  padding: 2px 8px;
  border-radius: 20px;
}

.reel-viewer__error { color: #fff; padding: 24px; text-align: center; font-size: 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: #262626; color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 13px; transition: transform .25s ease; z-index: 300;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); }

/* ===================================================================
   Десктопная адаптация (экраны от 768px). На телефонах и планшетах
   уже (до 768px) сайт выглядит и работает точно так же, как раньше —
   ничего из правил выше не меняется.
=================================================================== */
@media (min-width: 768px) {
  body { padding: 0; }

  .phone-frame {
    max-width: none;
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }

  .cover-slider { height: 26vh; min-height: 200px; max-height: 340px; }

  .avatar-wrap { margin-top: -80px; }
  .avatar-wrap::before { width: 200px; height: 200px; }
  .avatar-ring { width: 150px; height: 150px; border-width: 5px; }

  .profile-info { padding: 18px 24px 6px; }
  .profile-name { font-size: 27px; }
  .profile-desc { font-size: 15px; max-width: 640px; margin: 0 auto; }

  .action-buttons {
    max-width: 520px;
    margin: 0 auto;
    padding: 18px 16px 8px;
  }
  .action-btn { padding: 11px 10px; font-size: 13.5px; }

  .section { padding: 24px 5vw 8px; }
  .section-title { font-size: 18px; text-align: center; }

  .stories-row, .categories-row { justify-content: center; gap: 26px; flex-wrap: wrap; }
  .story-ring { width: 86px; height: 86px; }
  .category-circle { width: 82px; height: 82px; font-size: 13px; }

  .feed-toggle { max-width: 500px; margin: 10px auto 0; }

  .grid-feed {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 4px;
    padding: 0 5vw 40px;
  }
  .grid-item img { transition: transform .25s ease; }
  .grid-item:hover img { transform: scale(1.04); }

  .classic-feed { max-width: 560px; margin: 0 auto; padding: 0 16px 40px; }
}

@media (min-width: 1400px) {
  .cover-slider { max-height: 400px; }
  .avatar-ring { width: 170px; height: 170px; }
  .avatar-wrap::before { width: 220px; height: 220px; }
  .profile-name { font-size: 30px; }
}
