/**
 * Feed V3 publications — unified channel feed for guest, user, admin.
 *
 * Vocabulary:
 *   publication — any item in the feed (text, photo, gallery, voice, video, circle)
 *   kinds: text | media | voice | video | circle | live (data-publication-kind)
 *
 * Image proportions: square 1:1, portrait 4:5, landscape 16:9.
 * Multi-image layout: Telegram-style gallery grid (gallery--count-N).
 */

body.feed-v2-surface {
  --dc-publication-gap: clamp(10px, 2.4vw, 14px);
  --dc-media-gap: 2px;
  --dc-media-radius: 12px;
  --dc-publication-bubble: rgba(12, 18, 28, 0.55);
  --feed-v4-column-gutter: 14px;
  --feed-v4-col-text: min(100%, 460px);
  --feed-v4-col-text-post: min(100%, 460px);
  --feed-v4-col-voice: min(100%, 360px);
  --feed-v4-col-circle: min(100%, calc(var(--dc-feed-circle-size, 240px) + 52px));
}

html body.feed-v2-surface [data-feed-publications] {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--feed-v4-card-gap, var(--dc-publication-gap));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-inline: var(--feed-v4-column-gutter, 14px);
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  html body.feed-v2-surface.user-mode.public-feed-open:not(.feed-v2-workspace--desktop-split) [data-feed-publications] {
    align-items: center;
    padding-inline: 16px;
  }

  html body.feed-v2-surface.user-mode.public-feed-open:not(.feed-v2-workspace--desktop-split) [data-feed-publications] > .feed-publication {
    max-width: var(--feed-v4-column-readable, min(100%, 680px));
    align-self: center;
  }
}

/* Single-image proportions (JS sets tg-media-format-* on load) */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media.tg-media-format-landscape .tg-channel-image-wrap,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media:not(.tg-media-format-square):not(.tg-media-format-portrait) .tg-channel-image-wrap {
  aspect-ratio: 16 / 9 !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media.tg-media-format-square .tg-channel-image-wrap {
  aspect-ratio: 1 / 1 !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media.tg-media-format-portrait .tg-channel-image-wrap {
  aspect-ratio: 4 / 5 !important;
  max-height: min(72vh, 520px) !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media > .tg-message-bubble::before,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media > .tg-message-bubble::after {
  content: none !important;
  display: none !important;
}

/* Gallery shell — shared base. */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery{
  display:grid !important;
  width:100% !important;
  max-width:100% !important;
  margin:0 !important;
  padding:0 !important;
  gap:var(--dc-media-gap,2px) !important;
  overflow:hidden !important;
  border-radius:0 !important;
  background:transparent !important;
  box-shadow:none !important;
  box-sizing:border-box !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery .tg-channel-gallery-item{
  display:block !important;
  margin:0 !important;
  padding:0 !important;
  overflow:hidden !important;
  min-width:0 !important;
  min-height:0 !important;
  border-radius:0 !important;
  background:transparent !important;
  box-shadow:none !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery .tg-channel-gallery-image,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery .feed-img.tg-channel-gallery-image{
  display:block !important;
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  object-fit:cover !important;
  border:0 !important;
  border-radius:0 !important;
  margin:0 !important;
  box-shadow:none !important;
}
/* 2 — full-width vertical stack (Telegram reference). */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-2,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-2{
  grid-template-columns:1fr !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-2 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-2 .tg-channel-gallery-item{
  aspect-ratio:16/9 !important;
}
/* 3 — hero top + two bottom. */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-3,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-3{
  grid-template-columns:1fr 1fr !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-3 .tg-channel-gallery-item:first-child,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-3 .tg-channel-gallery-item:first-child{
  grid-column:1 / -1 !important;
  aspect-ratio:16/9 !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-3 .tg-channel-gallery-item:not(:first-child),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-3 .tg-channel-gallery-item:not(:first-child){
  aspect-ratio:16/9 !important;
}
/* 4 — hero top + three bottom (Telegram reference). */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-4,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-4{
  grid-template-columns:1fr 1fr 1fr !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-4 .tg-channel-gallery-item:nth-child(1),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-4 .tg-channel-gallery-item:nth-child(1){
  grid-column:1 / -1 !important;
  aspect-ratio:16/9 !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-4 .tg-channel-gallery-item:nth-child(n+2),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-4 .tg-channel-gallery-item:nth-child(n+2){
  aspect-ratio:1/1 !important;
}
/* 5,7,8,10 — 6-column smart rows (halves + thirds). */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-5,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-7,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-8,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-10,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-5,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-7,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-8,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-10{
  grid-template-columns:repeat(6,minmax(0,1fr)) !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-5 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-5 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-7 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-7 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-8 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-8 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-10 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-10 .tg-channel-gallery-item{
  aspect-ratio:1/1 !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-5 .tg-channel-gallery-item:nth-child(-n+2),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-5 .tg-channel-gallery-item:nth-child(-n+2),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-7 .tg-channel-gallery-item:nth-child(-n+4),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-7 .tg-channel-gallery-item:nth-child(-n+4),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-8 .tg-channel-gallery-item:nth-child(-n+2),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-8 .tg-channel-gallery-item:nth-child(-n+2),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-10 .tg-channel-gallery-item:nth-child(-n+4),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-10 .tg-channel-gallery-item:nth-child(-n+4){
  grid-column:span 3 !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-5 .tg-channel-gallery-item:nth-child(n+3),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-5 .tg-channel-gallery-item:nth-child(n+3),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-7 .tg-channel-gallery-item:nth-child(n+5),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-7 .tg-channel-gallery-item:nth-child(n+5),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-8 .tg-channel-gallery-item:nth-child(n+3),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-8 .tg-channel-gallery-item:nth-child(n+3),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-10 .tg-channel-gallery-item:nth-child(n+5),
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-10 .tg-channel-gallery-item:nth-child(n+5){
  grid-column:span 2 !important;
}
/* 6 — 2x3 square grid. */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-6,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-6{
  grid-template-columns:1fr 1fr !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-6 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-6 .tg-channel-gallery-item{
  aspect-ratio:1/1 !important;
}
/* 9 — 3x3 square grid. */
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-9,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-9{
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
}
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.gallery--count-9 .tg-channel-gallery-item,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media .tg-channel-gallery.tg-gallery-count-9 .tg-channel-gallery-item{
  aspect-ratio:1/1 !important;
}

/* Voice / text / video publications — bubble shell: assets/feed-v4-channel.css */

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-voice > .tg-message-bubble {
  border-radius: 18px 18px 18px 4px !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-voice > .tg-message-bubble::before {
  content: none !important;
  display: none !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-publication-text > .tg-message-bubble,
html body.feed-v2-surface [data-feed-publications] > .feed-publication.tg-channel-post-media > .tg-message-bubble {
  border-radius: 12px !important;
  overflow: hidden !important;
}

/* Admin chrome — cold canvas authority in feed-v4-channel.css (no warm pane overrides) */

/* Compact top chrome — flush «Общий чат» / «Закрепленное сообщение» to pane edge */
html body.feed-v2-surface.site-feed-admin-page.admin-mode .feed-v2-pane-chat .feed-v2-chat-head,
html body.feed-v2-surface.site-feed-admin-page.admin-mode .feed-v2-pane-chat header.feed-v2-chat-head {
  padding-top: 0 !important;
  padding-bottom: 4px !important;
  border-radius: 0 !important;
}

html body.feed-v2-surface.site-feed-admin-page.admin-mode .feed-v2-pane-feed > .feed-v2-pinned-bar {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

html body.feed-v2-surface.site-feed-admin-page.admin-mode .feed-v2-pane-feed > .feed-v2-pinned-bar .feed-v2-pinned-bar__main {
  margin-top: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 4px !important;
  min-height: 0 !important;
  align-items: center !important;
}

html body.feed-v2-surface.site-feed-admin-page.admin-mode.feed-v2-desktop-active .feed-v2-pane-feed > .feed-v2-pinned-bar .feed-v2-pinned-bar__main {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  border-top-left-radius: 16px !important;
  border-top-right-radius: 16px !important;
}

/* Channel column — left-aligned rhythm; kind widths in feed-v4-channel.css */
html body.feed-v2-surface [data-feed-publications],
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts {
  align-items: flex-start !important;
}

html body.feed-v2-surface [data-feed-publications] > .feed-publication,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-publication,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.tg-channel-post {
  width: 100% !important;
  max-width: min(100%, var(--feed-v4-col-text-post, 460px)) !important;
  margin-inline: 0 !important;
  align-self: flex-start !important;
}

html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.tg-channel-post-voice,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-publication.tg-channel-post-voice,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.feed-post--video-circle,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.tg-channel-post-circle {
  width: fit-content !important;
  max-width: min(100%, var(--feed-v4-col-voice, 360px)) !important;
  align-self: flex-start !important;
}

html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.feed-post--video-circle,
html body.feed-v2-surface .feed-v2-pane-feed > #feedPosts > .feed-post.tg-channel-post-circle {
  max-width: var(--feed-v4-col-circle) !important;
}
