/* Frontend only. The accepted admin styles and shared renderer remain unchanged. */
body.telegram-page {
  --accent: #3290d5;
  --tg-blue: #3287b7;
  --tg-text: #17212b;
  --tg-muted: #83949e;
  --wallpaper: #dce9d5;
  margin: 0;
  min-height: 100vh;
  background: var(--wallpaper) url("/images/channel-wallpaper.svg") repeat;
  background-size: 420px 420px;
  background-attachment: fixed;
  color: var(--tg-text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.telegram-page button,
.telegram-page a {
  -webkit-tap-highlight-color: transparent;
}
.telegram-page :focus-visible {
  outline: 3px solid #71b4e5;
  outline-offset: 3px;
}
.telegram-page .skip-link:focus {
  z-index: 100;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.channel-bar {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid #d6dedb;
  box-shadow: 0 1px 3px #234d2c08;
  padding-top: env(safe-area-inset-top, 0px);
}
.channel-bar-inner {
  max-width: 930px;
  margin: auto;
  height: 74px;
  padding: 0 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.channel-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  padding: 0;
  min-width: 0;
  text-align: left;
  color: inherit;
}
.tg-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #4da1d2;
  color: white;
  font-size: 23px;
  font-weight: 500;
  overflow: hidden;
}
.tg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.identity-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}
.channel-title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-subtitle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: #84939c;
  white-space: nowrap;
  overflow: hidden;
}
.channel-subtitle > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-subtitle > span + span:before {
  content: "·";
  margin-right: 9px;
  color: #9aaba9;
}
.channel-tools {
  display: flex;
  align-items: center;
  gap: 17px;
  flex-shrink: 0;
}
.telegram-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #3287b7;
  font-size: 13px;
  font-weight: 550;
  min-height: 38px;
  border-radius: 8px;
  padding: 7px 10px;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
}
.telegram-entry:hover {
  background: #eef6fb;
}
.telegram-entry[aria-disabled="true"] {
  color: #8b9da7;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: #6f818c;
  border-radius: 50%;
  flex-shrink: 0;
}
.icon-button:hover {
  background: #eff3f5;
}
.icon-button svg {
  fill: currentColor;
}
.channel-stage {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(94px + env(safe-area-inset-top, 0px)) 20px 26px;
}
.channel-brief {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px 43px;
  padding: 9px 13px;
  color: #4e7050;
  background: #ffffff65;
  border-radius: 8px;
  max-width: 640px;
  font-size: 12px;
  line-height: 1.6;
}
.brief-icon {
  padding-top: 2px;
  color: #648e64;
  flex-shrink: 0;
}
.channel-brief > div {
  min-width: 0;
}
.channel-brief p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.content-note {
  display: block;
  font-size: 10px;
  color: #849477;
  margin-top: 1px;
}
.message-feed {
  width: 100%;
  min-width: 0;
}
.date-divider {
  display: flex;
  justify-content: center;
  width: calc(100% - 43px);
  max-width: 640px;
  margin: 17px 0 12px 43px;
  scroll-margin-top: 94px;
}
.date-divider time,
.service-pill {
  display: table;
  margin-left: auto;
  margin-right: auto;
  width: max-content;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 20px;
  background: #83a376a8;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 1px 1px #48683a09;
}
.date-divider time {
  margin: 0;
  backdrop-filter: blur(8px);
}
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  min-width: 0;
  margin-bottom: 9px;
  padding-right: 30px;
}
.telegram-page .message-avatar {
  width: 34px;
  height: 34px;
  font-size: 17px;
  margin-bottom: 1px;
  box-shadow: 0 1px 2px #51704518;
}
.telegram-page .post-card.message-bubble {
  flex: 0 1 auto;
  width: fit-content;
  min-width: 0;
  max-width: 640px;
  margin: 0;
  padding: 0;
  background: #fff;
  border: 0;
  border-radius: 12px 12px 12px 4px;
  box-shadow: 0 1px 2px #35522a24;
  overflow: hidden;
  scroll-margin-top: 94px;
}
.telegram-page .message-bubble:has(.message-media) {
  width: 100%;
}
.message-author {
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--tg-blue);
  padding: 8px 12px 4px;
  overflow-wrap: anywhere;
}
.telegram-page .post-text.message-text {
  padding: 0 12px;
  margin: 1px 0 0;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.telegram-page .post-text.collapsed {
  -webkit-line-clamp: 12;
}
.telegram-page .text-toggle {
  background: transparent;
  margin: 0;
  padding: 5px 12px 0;
  font-size: 12px;
  color: var(--tg-blue);
}
.telegram-page .message-media {
  margin: 3px 0 7px;
  border-radius: 0;
  overflow: hidden;
}
.telegram-page .message-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 590px;
  object-fit: contain;
  background: #edf2ea;
  aspect-ratio: auto;
}
.media-open {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: zoom-in;
  line-height: 0;
}
.telegram-page .message-media.album {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}
.telegram-page .message-media.album figure {
  min-width: 0;
  overflow: hidden;
  grid-column: auto;
}
.telegram-page .message-media.album .media-open {
  height: 100%;
}
.telegram-page .message-media.album img {
  height: 100%;
  min-height: 0;
  max-height: 260px;
  aspect-ratio: 1.15;
  object-fit: cover;
}
.telegram-page .message-media.album[data-count="3"] figure:first-child {
  grid-column: 1/-1;
}
.telegram-page .message-media.album[data-count="3"] figure:first-child img {
  aspect-ratio: 2.1;
  max-height: 320px;
}
.telegram-page .message-media.album[data-count="5"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.telegram-page .message-media.album[data-count="5"] figure {
  grid-column: span 2;
}
.telegram-page .message-media.album[data-count="5"] figure:nth-child(-n + 2) {
  grid-column: span 3;
}
.telegram-page
  .message-media.album:is(
    [data-count="6"],
    [data-count="7"],
    [data-count="8"],
    [data-count="9"],
    [data-count="10"]
  ) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.telegram-page .message-media.album[data-count="7"] figure:first-child {
  grid-column: 1/-1;
}
.telegram-page .message-media.album[data-count="10"] figure:first-child {
  grid-column: 1/-1;
}
.telegram-page .message-media video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 560px;
  aspect-ratio: 16/9;
  background: #162018;
  border-radius: 0;
}
.telegram-page .message-media.album video {
  height: 100%;
  min-height: 100px;
  object-fit: contain;
  aspect-ratio: 1.15;
}
.telegram-page .message-media .media-fallback {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 180px;
  padding: 25px 16px;
  background: #edf4eb;
  color: #75916e;
  gap: 8px;
  font-size: 12px;
  text-align: center;
}
.media-fallback-symbol {
  font-size: 27px;
  line-height: 1.2;
}
.telegram-page .media-fallback small {
  font-size: 10px;
  color: #95a58e;
}
.telegram-page .video-placeholder .video-label {
  left: 10px;
  bottom: 10px;
  font-size: 10px;
}
.telegram-page .post-footer.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin: 0;
  padding: 5px 11px 7px;
  border: 0;
  font-size: 10px;
  line-height: 1.5;
  color: #9aa5a9;
  min-height: 25px;
}
.message-source {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.telegram-page .original-link {
  padding: 0;
  color: #7d9bad;
  font-size: 10px;
}
.telegram-page .original-link:hover {
  color: var(--tg-blue);
}
.message-time {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  color: #91a0a5;
}
.edited-label {
  font-size: 10px;
}
.telegram-page .feed-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  margin: 20px auto 0;
  padding: 8px 17px;
  border-radius: 22px;
  background: #fff9;
  color: #4e7957;
  font-size: 12px;
  box-shadow: 0 1px 2px #35522a0b;
}
.telegram-page .feed-control:hover {
  background: #fff;
}
.telegram-page .feed-control:disabled {
  cursor: progress;
}
.telegram-page .feed-end {
  margin-top: 20px;
  background: #8ba37f85;
  font-size: 11px;
}
.channel-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 22px 15px 0;
  color: #79906f;
  font-size: 10px;
  line-height: 1.6;
}
.channel-footer > span {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.feed-state {
  max-width: 420px;
  margin: 45px auto;
  padding: 30px 25px;
  text-align: center;
  background: #ffffffb8;
  border-radius: 12px;
  color: #78936b;
}
.feed-state h2 {
  font-size: 15px;
  color: #547349;
  margin-bottom: 8px;
}
.feed-state p {
  font-size: 12px;
}
.empty-channel-icon {
  display: block;
  font-size: 30px;
  line-height: 1.4;
  margin-bottom: 15px;
  color: #9db391;
}
.jump-button {
  position: fixed;
  z-index: 20;
  right: max(24px, calc((100vw - 850px) / 2));
  bottom: 25px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  color: #5c8d64;
  box-shadow: 0 2px 9px #314f2c26;
}
.jump-button:hover {
  background: #f6faf4;
}
.telegram-page .toast {
  background: #31543aeb;
  font-size: 12px;
  border-radius: 9px;
  bottom: 20px;
  max-width: calc(100vw - 32px);
}
.telegram-page .channel-dialog {
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: 85dvh;
  background: white;
  border: 0;
  border-radius: 16px;
  padding: 0;
  color: var(--tg-text);
}
.channel-dialog::backdrop {
  background: #1b2d2480;
  backdrop-filter: blur(3px);
}
.info-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid #edf1f3;
}
.channel-dialog-identity {
  text-align: center;
  padding: 24px 24px 20px;
}
.tg-avatar.large {
  width: 76px;
  height: 76px;
  font-size: 35px;
  margin: 0 auto 14px;
}
.channel-dialog-identity h2 {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.channel-dialog-identity p {
  font-size: 13px;
  color: #8b9ba4;
  margin-top: 5px;
}
.channel-dialog-details {
  padding: 0 24px;
  color: #536c78;
  font-size: 13px;
  line-height: 1.8;
}
.channel-dialog-details > p + p {
  font-size: 11px;
  color: #92a6a8;
  margin-top: 12px;
}
.site-attribution {
  border-top: 1px solid #edf1f3;
  margin-top: 18px;
  padding-top: 13px;
  color: #a0aeb4;
  font-size: 11px;
}
.site-attribution > span {
  color: #7b909c;
}
.site-attribution p {
  margin-top: 3px;
}
.dialog-telegram {
  display: flex;
  margin: 18px 18px 20px;
  background: #eef6fc;
}
.telegram-page .media-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #111b23f7;
  color: #fff;
  overflow: hidden;
}
.media-viewer::backdrop {
  background: #101921;
}
.viewer-header {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: #111b23d9;
  gap: 15px;
}
.viewer-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}
.viewer-header strong {
  font-size: 14px;
  font-weight: 500;
}
.viewer-header span {
  font-size: 12px;
  color: #b4c3cf;
}
.viewer-tools {
  display: flex;
  gap: 8px;
}
.viewer-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff10;
  color: white;
  font-size: 22px;
  display: grid;
  place-items: center;
  padding: 0;
}
.viewer-icon:hover {
  background: #ffffff22;
}
.viewer-stage {
  position: absolute;
  inset: 78px 70px 55px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-stage > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.viewer-stage.zoomed {
  display: block;
  cursor: zoom-out;
}
.viewer-stage.zoomed > img {
  max-width: none;
  max-height: none;
  margin: auto;
}
.viewer-navigation {
  position: absolute;
  z-index: 5;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 54px;
  border-radius: 8px;
  background: #ffffff0c;
  color: white;
  font-size: 35px;
  line-height: 1;
  padding: 0;
}
.viewer-navigation.prev {
  left: 14px;
}
.viewer-navigation.next {
  right: 14px;
}
.viewer-navigation:disabled {
  opacity: 0.18;
  cursor: default;
}
.viewer-caption {
  position: absolute;
  bottom: 16px;
  left: 60px;
  right: 60px;
  text-align: center;
  font-size: 12px;
  color: #c4d0d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-open,
.channel-info-open {
  overflow: hidden;
}
@media (min-width: 1600px) {
  .channel-bar-inner {
    max-width: 1000px;
  }
  .channel-stage {
    max-width: 820px;
  }
  .telegram-page .post-card.message-bubble {
    max-width: 680px;
  }
  .channel-brief,
  .date-divider {
    max-width: 680px;
  }
}
@media (max-width: 800px) {
  .channel-bar-inner {
    padding: 0 20px;
    height: 70px;
  }
  .channel-stage {
    padding-top: 87px;
    padding-left: 18px;
    padding-right: 18px;
  }
  .channel-tools {
    gap: 6px;
  }
  .channel-identity {
    gap: 10px;
  }
  .telegram-entry {
    font-size: 12px;
    padding: 7px 8px;
  }
  .channel-title {
    font-size: 16px;
  }
  .channel-subtitle {
    font-size: 11px;
  }
  .message-row {
    padding-right: 12px;
  }
  .telegram-page .post-card.message-bubble {
    max-width: calc(100% - 43px);
  }
  .telegram-page .message-bubble:has(.message-media) {
    max-width: 640px;
  }
  .channel-brief {
    margin-left: 43px;
  }
  .viewer-header {
    padding: 13px 16px;
  }
  .viewer-stage {
    inset: 70px 45px 48px;
  }
  .viewer-navigation {
    width: 34px;
    height: 45px;
  }
  .viewer-navigation.prev {
    left: 5px;
  }
  .viewer-navigation.next {
    right: 5px;
  }
}
@media (max-width: 600px) {
  .channel-bar-inner {
    height: 65px;
    padding: 0 12px;
    gap: 10px;
  }
  .channel-identity {
    gap: 9px;
    flex: 1;
  }
  .tg-avatar {
    width: 39px;
    height: 39px;
    font-size: 21px;
  }
  .channel-title {
    font-size: 15px;
    font-weight: 650;
  }
  .channel-subtitle {
    gap: 6px;
    font-size: 10px;
  }
  .channel-subtitle > span + span:before {
    margin-right: 6px;
  }
  .channel-subtitle > span:first-child {
    max-width: 115px;
  }
  .channel-subtitle > span:last-child {
    max-width: 90px;
  }
  .channel-tools {
    gap: 1px;
  }
  .telegram-entry {
    gap: 5px;
    font-size: 11px;
    max-width: 112px;
    white-space: normal;
    line-height: 1.4;
    text-align: center;
    padding: 7px;
  }
  .telegram-entry svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
  }
  .icon-button {
    width: 29px;
    height: 34px;
  }
  .channel-stage {
    padding: calc(78px + env(safe-area-inset-top, 0px)) 10px 20px;
  }
  .channel-brief {
    margin: 0 3px 12px;
    padding: 7px 10px;
    gap: 8px;
    font-size: 11px;
    line-height: 1.55;
    background: #ffffff5e;
    border-radius: 7px;
  }
  .brief-icon {
    padding-top: 0;
  }
  .brief-icon svg {
    width: 17px;
    height: 17px;
  }
  .content-note {
    font-size: 9px;
  }
  .telegram-page .message-avatar {
    display: none;
  }
  .message-row {
    display: block;
    margin-bottom: 8px;
    padding: 0 20px 0 0;
  }
  .telegram-page .post-card.message-bubble {
    max-width: 100%;
    border-radius: 11px 11px 11px 4px;
    width: fit-content;
  }
  .telegram-page .message-bubble:has(.message-media) {
    width: 100%;
    max-width: 100%;
  }
  .message-author {
    font-size: 12px;
    padding: 7px 10px 4px;
  }
  .telegram-page .post-text.message-text {
    font-size: 15px;
    line-height: 1.57;
    padding-left: 10px;
    padding-right: 10px;
  }
  .telegram-page .post-footer.message-footer {
    padding: 5px 9px 6px;
    gap: 10px;
    min-height: 24px;
  }
  .message-source {
    gap: 8px;
    font-size: 9px;
  }
  .message-time {
    font-size: 10px;
    gap: 4px;
  }
  .edited-label {
    font-size: 9px;
  }
  .telegram-page .original-link {
    font-size: 9px;
  }
  .telegram-page .message-media {
    margin: 2px 0 6px;
  }
  .telegram-page .message-media img {
    max-height: 460px;
  }
  .telegram-page .message-media.album {
    gap: 2px;
  }
  .telegram-page .message-media.album img {
    max-height: 180px;
  }
  .telegram-page .message-media.album[data-count="3"] figure:first-child img {
    max-height: 220px;
  }
  .telegram-page .message-media video {
    max-height: 360px;
  }
  .telegram-page .text-toggle {
    padding-left: 10px;
    font-size: 12px;
  }
  .date-divider {
    width: calc(100% - 20px);
    max-width: none;
    margin: 14px 20px 11px 0;
  }
  .date-divider time {
    font-size: 11px;
    padding: 3px 10px;
  }
  .telegram-page .feed-end {
    font-size: 10px;
  }
  .channel-footer {
    font-size: 9px;
    padding-top: 17px;
  }
  .jump-button {
    right: 16px;
    bottom: 20px;
    width: 42px;
    height: 42px;
  }
  .channel-dialog-identity {
    padding-top: 20px;
  }
  .dialog-telegram {
    max-width: none;
    margin-left: 18px;
    margin-right: 18px;
    font-size: 13px;
  }
  .viewer-stage {
    inset: 75px 10px 55px;
  }
  .viewer-navigation {
    top: auto;
    bottom: 11px;
    transform: none;
    width: 38px;
    height: 35px;
    background: #ffffff17;
  }
  .viewer-navigation.prev {
    left: 15px;
  }
  .viewer-navigation.next {
    right: 15px;
  }
  .viewer-caption {
    left: 65px;
    right: 65px;
    bottom: 20px;
    font-size: 11px;
  }
  .viewer-header {
    padding: 13px 12px;
  }
  .viewer-header > div:first-child {
    gap: 9px;
  }
  .viewer-header strong {
    font-size: 12px;
  }
  .viewer-header span {
    font-size: 11px;
  }
  .viewer-icon {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }
  .feed-state {
    margin: 30px 8px;
    padding: 26px 17px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .telegram-page {
    scroll-behavior: auto;
  }
  .telegram-page * {
    transition: none !important;
  }
}

@media (max-width: 600px) {
  .channel-tools .telegram-entry {
    max-width: 108px;
    padding: 7px 5px;
    white-space: nowrap;
  }
  .channel-tools .telegram-entry > span {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .channel-tools .telegram-entry svg {
    display: none;
  }
}

/* Keep portrait clips readable instead of forcing them into landscape frames. */
.telegram-page .message-media:not(.album) video {
  aspect-ratio: auto;
}
.telegram-page .post-card.message-bubble.portrait-message {
  width: min(100%, 330px);
  max-width: 330px;
}
.telegram-page .portrait-message .message-media video {
  aspect-ratio: auto;
  max-height: none;
}

/* A quieter channel surface: metadata stays out of the conversation. */
.channel-heading {
  min-width: 0;
}
.message-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  min-width: 0;
}
.message-heading .message-author {
  min-width: 0;
  padding-top: 7px;
  padding-bottom: 3.5px;
}
.telegram-page .post-card.message-bubble {
  overflow: visible;
}
.telegram-page .message-bubble:has(.message-menu[open]) {
  position: relative;
  z-index: 15;
}
.telegram-page .post-footer.message-footer {
  justify-content: flex-end;
  padding-top: 4.5px;
  padding-bottom: 6px;
  min-height: 22px;
}
.telegram-page .message-media {
  margin-top: 2.5px;
  margin-bottom: 6px;
}
.message-menu {
  position: relative;
  flex-shrink: 0;
  margin: 2px 5px 0 0;
  align-self: flex-start;
}
.message-menu > summary {
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  list-style: none;
  cursor: pointer;
  border-radius: 5px;
  color: #91a3ac;
  font-size: 20px;
  line-height: 1;
  user-select: none;
}
.message-menu > summary::-webkit-details-marker {
  display: none;
}
.message-menu > summary:hover {
  background: #f0f5f7;
}
.message-menu-popover {
  position: absolute;
  right: 0;
  top: 29px;
  min-width: 157px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px #20313b24;
  padding: 5px;
  z-index: 30;
}
.message-original {
  display: block;
  padding: 10px 12px;
  color: #425d6d;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 5px;
}
.message-original:hover {
  background: #edf5fa;
}
.channel-tools .header-telegram-action {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  max-width: 34px;
  padding: 0;
  color: #7793a3;
  border-radius: 50%;
  background: transparent;
}
.channel-tools .header-telegram-action:hover {
  background: #f1f6f9;
}
.channel-tools .header-telegram-action svg {
  display: block;
  width: 19px;
  height: 19px;
}
.channel-tools .header-telegram-action > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.telegram-page .media-fallback .media-original-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 17px;
  border-radius: 50%;
  background: #ffffffa6;
}
.channel-dialog-details:has(#dialog-description[hidden]) {
  display: none;
}
@media (max-width: 600px) {
  .message-heading .message-author {
    padding-top: 6px;
    padding-bottom: 3.5px;
  }
  .telegram-page .post-footer.message-footer {
    padding-top: 4px;
    padding-bottom: 5.5px;
    min-height: 20px;
  }
  .telegram-page .message-media {
    margin-top: 1.75px;
    margin-bottom: 5.25px;
  }
  .message-menu {
    margin-top: 1px;
    margin-right: 3px;
  }
  .message-menu > summary {
    width: 27px;
    height: 25px;
    font-size: 19px;
  }
  .message-menu-popover {
    min-width: 148px;
    top: 27px;
  }
  .channel-tools .header-telegram-action {
    max-width: 32px;
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
  }
  .channel-tools .header-telegram-action svg {
    display: block;
  }
  .telegram-page .message-media:not(.album) .media-open img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    max-height: 70dvh;
    object-fit: contain;
    margin-inline: auto;
  }
  .telegram-page .message-media.album img {
    max-height: min(180px, 70vh);
    max-height: min(180px, 70dvh);
  }
  .telegram-page .message-media.album[data-count="3"] figure:first-child img {
    max-height: min(220px, 70vh);
    max-height: min(220px, 70dvh);
  }
}

/* Message chronology and viewport anchoring only; the accepted bubble design stays unchanged. */
html:has(body.telegram-page) {
  scroll-behavior: auto;
  overflow-anchor: none;
}
.telegram-page.feed-initializing .channel-stage {
  visibility: hidden;
}
.telegram-page .load-older {
  margin-top: 0;
  margin-bottom: 15px;
}
.telegram-page #feed-end {
  margin-top: 0;
  margin-bottom: 14px;
}
.telegram-page .jump-button.has-new-messages {
  width: auto;
  min-width: 44px;
  padding: 0 14px;
  display: flex;
  gap: 6px;
  border-radius: 23px;
  font-size: 12px;
  white-space: nowrap;
}
.telegram-page #latest-message-label {
  font-size: 12px;
}
/* iOS channel alignment: compact chrome, edge-to-edge media, safe areas. */
body.telegram-page {
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
.channel-bar-inner {
  height: 64px;
}
.channel-stage {
  padding-top: calc(76px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.message-row {
  position: relative;
  margin-bottom: 6px;
}
.telegram-page .post-card.message-bubble {
  position: relative;
  border-radius: 15px 15px 15px 5px;
}
.message-heading .message-author {
  font-size: 11px;
  font-weight: 500;
  padding: 6px 12px 3px;
  color: #6b96ae;
}
.message-bubble:has(.message-media) .message-heading {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
}
.message-bubble:has(.message-media) .message-author {
  display: none;
}
.message-bubble:has(.message-media) .message-menu {
  margin: 0;
}
.message-bubble:has(.message-media) .message-menu > summary {
  background: #17212b55;
  color: white;
  border-radius: 50%;
  width: 27px;
  height: 27px;
  text-shadow: 0 1px 2px #0005;
}
.telegram-page .message-media {
  margin: 0;
  border-radius: 0;
}
.telegram-page .message-media figure {
  margin: 0;
  border-radius: 0;
}
.telegram-page .message-media.album {
  gap: 1.5px;
}
.telegram-page .message-media + .message-text {
  margin-top: 7px;
}
.telegram-page .post-footer.message-footer {
  justify-content: flex-end;
}
.telegram-page .media-only:not([data-post-type="video"]) .message-footer {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-height: 0;
  padding: 2px 6px;
  border-radius: 10px;
  background: #17212b66;
}
.media-only:not([data-post-type="video"]) .message-time {
  color: #fff;
}
.telegram-page .sticker-message {
  background: transparent;
  box-shadow: none;
}
.telegram-page .sticker-message .message-media img {
  background: transparent;
}
.telegram-page .sticker-message:has(.message-media) {
  width: min(280px, 100%);
}
.message-share {
  position: absolute;
  right: 0;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #84a17c99;
}
.message-share:hover {
  background: #6e9166c9;
}
.message-views {
  font-variant-numeric: tabular-nums;
}
.jump-button {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.viewer-header {
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}
.viewer-stage {
  top: calc(78px + env(safe-area-inset-top, 0px));
}
.viewer-caption {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 600px) {
  .channel-bar {
    border-bottom: 1px solid #c7d0d466;
    box-shadow: none;
  }
  .channel-bar-inner {
    position: relative;
    height: 54px;
    padding: 0 8px;
  }
  .channel-identity {
    position: absolute;
    inset: 0 48px;
    justify-content: center;
    width: auto;
  }
  .channel-identity .tg-avatar {
    position: absolute;
    right: -40px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .channel-identity .identity-copy {
    align-items: center;
    width: 100%;
    gap: 1px;
  }
  .channel-title {
    width: 100%;
    text-align: center;
    font-size: 15px;
    line-height: 1.25;
  }
  .channel-subtitle {
    font-size: 11px;
    line-height: 1.3;
    justify-content: center;
  }
  .channel-subtitle > span:first-child,
  .channel-subtitle > span:last-child {
    max-width: 100%;
  }
  .channel-tools {
    position: absolute;
    left: 7px;
  }
  #channel-menu {
    display: none;
  }
  .channel-tools .header-telegram-action {
    color: #6095b5;
  }
  .channel-stage {
    padding: calc(61px + env(safe-area-inset-top, 0px)) 5px
      calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .message-row {
    padding: 0 29px 0 0;
    margin-bottom: 5px;
  }
  .telegram-page .post-card.message-bubble {
    max-width: 100%;
    border-radius: 14px 14px 14px 5px;
  }
  .message-heading {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 3;
  }
  .message-author {
    display: none;
  }
  .message-menu {
    margin: 0 1px 0 0;
  }
  .message-menu > summary {
    width: 26px;
    height: 26px;
    font-size: 18px;
  }
  .telegram-page .post-text.message-text {
    margin: 0;
    padding: 8px 29px 0 10px;
    line-height: 1.47;
    font-size: 16px;
  }
  .telegram-page .message-media + .message-text {
    padding: 7px 10px 0;
  }
  .telegram-page .post-footer.message-footer {
    padding: 2px 8px 5px;
    min-height: 19px;
  }
  .message-time {
    font-size: 10px;
  }
  .telegram-page .message-media {
    margin: 0;
  }
  .telegram-page .message-media:not(.album) .media-open img {
    max-height: 70vh;
    max-height: 70dvh;
    width: 100%;
    height: auto;
    object-fit: contain;
  }
  .telegram-page .message-media video {
    max-height: 70vh;
    max-height: 70dvh;
    object-fit: contain;
  }
  .telegram-page .message-media.album {
    gap: 1px;
  }
  .telegram-page .message-media.album img {
    max-height: none;
  }
  .telegram-page .message-media.album[data-count="3"] figure:first-child img {
    max-height: none;
  }
  .date-divider {
    width: calc(100% - 29px);
    margin: 10px 29px 8px 0;
  }
  .message-share {
    width: 25px;
    height: 25px;
  }
}
/* Keep the share action beside its own bubble, including short text/stickers. */
.message-row {
  padding-right: 0;
}
.message-share {
  position: static;
  flex: 0 0 27px;
  margin-bottom: 4px;
}
@media (max-width: 600px) {
  .message-row {
    display: flex;
    gap: 4px;
    padding: 0;
  }
  .message-share {
    flex-basis: 25px;
  }
}

/* Channel profile sheet: no outbound Telegram navigation. */
#dialog-description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.channel-contacts {
  padding: 18px 24px 24px;
}
.channel-contacts h3 {
  font-size: 13px;
  color: #81919b;
  margin-bottom: 10px;
}
.profile-contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 12px 0;
  border-top: 1px solid #edf1f3;
  overflow-wrap: anywhere;
}
.profile-contact > span:first-child {
  grid-column: 1;
  font-size: 12px;
  color: #8799a5;
}
.profile-contact > a,
.profile-contact > span:nth-child(2) {
  grid-column: 1;
  color: #3287b7;
  font-size: 15px;
}
.contact-copy {
  grid-column: 2;
  grid-row: 1/3;
  align-self: center;
  border: 0;
  background: transparent;
  color: #3287b7;
  font-size: 12px;
  padding: 8px;
}
.message-menu-popover button {
  background: transparent;
  color: inherit;
  padding: 7px 10px;
  border: 0;
  font: inherit;
  cursor: pointer;
}
#dialog-followers {
  color: #81929b;
}
.channel-dialog-details:has(#dialog-description[hidden]) {
  display: none;
}
@media (max-width: 600px) {
  .channel-tools {
    left: auto;
    right: 7px;
  }
  #channel-menu {
    display: grid;
  }
  .channel-identity {
    inset: 0 50px 0 7px;
    justify-content: flex-start;
  }
  .channel-identity .identity-copy {
    padding-left: 43px;
    align-items: flex-start;
  }
  .channel-identity .channel-title {
    text-align: left;
  }
  .channel-identity .channel-subtitle {
    justify-content: flex-start;
  }
  .channel-identity .tg-avatar {
    left: 0;
    right: auto;
  }
  .telegram-page .channel-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    margin: 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .channel-contacts {
    padding-bottom: 24px;
  }
}
.telegram-page #channel-contacts[hidden],.telegram-page #dialog-followers[hidden]{display:none!important}
