/* Dark (default) — Telegram night channel */
:root {
  --tg-header: #ffffff;
  --tg-header-text: #000000;
  --tg-bubble-rgb: 33, 45, 59;
  --tg-bubble-a: 0.78;
  --tg-bubble: rgba(var(--tg-bubble-rgb), var(--tg-bubble-a));
  --tg-name: #e29696;
  --tg-text: #f5f5f5;
  --tg-meta: #7d8b99;
  --tg-link: #6ab3f3;
  --tg-chat-bg: #0e1621;
  --tg-status-bg: rgba(0, 0, 0, 0.4);
  --tg-status-text: #ffffff;
  --tg-pinned-bg: #17212b;
  --tg-pinned-border: rgba(255, 255, 255, 0.06);
  --tg-pinned-sub: #8b9aab;
  --tg-media-bg: #101923;
  --tg-pattern-a: rgba(255, 255, 255, 0.04);
  --tg-pattern-b: rgba(100, 140, 180, 0.06);
  /* Soft bottom-only shadow — side blur looks like a dark stripe through translucent bubbles */
  --tg-bubble-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
  --tg-composer-bg: #17212b;
  --tg-composer-text: #f5f5f5;
  --tg-radius: 12px;
  --tg-max: 100%;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  color-scheme: dark;
}

/* Apple-style emoji images (same family Telegram uses) */
img.tg-emoji {
  height: 1.25em;
  width: 1.25em;
  margin: 0 0.05em;
  vertical-align: -0.25em;
  display: inline-block;
  object-fit: contain;
  pointer-events: none;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}

/* Custom emoji: span + bg-image (no <img> chrome / baked black square) */
span.tg-custom-emoji {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  margin: 0 0.05em;
  vertical-align: -0.25em;
  line-height: 0;
  background-color: transparent !important;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Animated Telegram custom emoji (Lottie from .tgs) — feed only */
span.tg-custom-emoji-anim {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  margin: 0 0.05em;
  vertical-align: -0.3em;
  line-height: 0;
  overflow: hidden;
  position: relative;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  fill: initial;
  color: initial;
  -webkit-user-modify: read-only;
  pointer-events: none;
}

span.tg-custom-emoji-anim canvas,
span.tg-custom-emoji-anim svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: transparent !important;
}

.tg-rich img.tg-emoji,
.tg-rich span.tg-custom-emoji {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  background-color: transparent !important;
}


*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

/* Hide scrollbars in Mini App / browsers (scroll still works) */
html,
body,
.tg-chat,
.tg-rich,
.tg-attach-caption-input,
.tg-mv-stage,
.avatar-crop-stage {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* old Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.tg-chat::-webkit-scrollbar,
.tg-rich::-webkit-scrollbar,
.tg-attach-caption-input::-webkit-scrollbar,
.tg-mv-stage::-webkit-scrollbar,
.avatar-crop-stage::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  font-family: var(--font);
  color: var(--tg-text);
  background-color: var(--tg-chat-bg);
  background-image: url("/uploads/g43.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  /* Header is fixed; chat fills the rest via position:fixed (see .tg-chat) */
  padding: 0;
}

/* —— Channel header —— */
.tg-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 56px;
  background: var(--tg-header);
  color: var(--tg-header-text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.tg-header-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 0 12px;
}

.tg-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #6db3f2, #3a7ebd);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}

.tg-avatar-letter {
  line-height: 1;
  z-index: 0;
}

.tg-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  z-index: 1;
}

.tg-avatar-cam {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.tg-avatar-cam svg {
  width: 20px;
  height: 20px;
  display: block;
}

.tg-avatar.is-editable {
  cursor: pointer;
}

.tg-avatar.is-editable:hover .tg-avatar-cam,
.tg-avatar.is-editable:focus-visible .tg-avatar-cam {
  opacity: 1;
}

@media (hover: none) {
  .tg-avatar.is-editable .tg-avatar-cam {
    opacity: 0.85;
    background: rgba(0, 0, 0, 0.35);
  }
}

/* —— Avatar crop editor —— */
.avatar-crop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: rgba(8, 14, 22, 0.92);
  backdrop-filter: blur(10px);
}

.avatar-crop[hidden] {
  display: none !important;
}

.avatar-crop-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px 8px;
}

.avatar-crop-canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  border-radius: 4px;
}

.avatar-crop-canvas:active {
  cursor: grabbing;
}

.avatar-crop-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(23, 33, 43, 0.96);
  border-radius: 16px 16px 0 0;
}

.avatar-crop-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 10px;
}

.avatar-crop-btn.is-primary {
  color: #64b5ef;
  font-weight: 600;
}

.avatar-crop-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.avatar-crop-icon {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.avatar-crop-icon svg {
  width: 22px;
  height: 22px;
}

body.avatar-crop-open {
  overflow: hidden;
}

.tg-header-text {
  min-width: 0;
  flex: 1;
}

.tg-channel-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Europa flag badges */
.eu-flag {
  display: inline-block;
  object-fit: contain;
  flex-shrink: 0;
  vertical-align: middle;
  user-select: none;
  -webkit-user-drag: none;
}

.eu-flag--header {
  width: 22px;
  height: 15px;
}

.eu-flag--author {
  width: 18px;
  height: 12px;
  margin-right: 5px;
  vertical-align: -1px;
}

.eu-flag--empty {
  width: 96px;
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.eu-flag--login {
  width: 72px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.tg-chat,
.tg-composer,
.tg-attach-modal,
.avatar-crop,
.login-view {
  position: relative;
  z-index: 1;
}

.empty-wrap--flag {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  text-align: center;
}

.tg-channel-sub {
  margin: 1px 0 0;
  font-size: 13px;
  opacity: 0.85;
  line-height: 1.2;
}


/* —— Pinned bar —— */
.tg-pinned {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 15;
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 8px 12px;
  background: var(--tg-pinned-bg);
  border-bottom: 1px solid var(--tg-pinned-border);
  cursor: pointer;
}

.tg-pinned[hidden] {
  display: none !important;
}

.tg-pinned-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #64a9e0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.tg-pinned-icon svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

.tg-pinned-icon--flag {
  background: #0b1c3d;
  padding: 3px;
}

.tg-pinned-icon--flag img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tg-pinned-body {
  min-width: 0;
  flex: 1;
}

.tg-pinned-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-name);
  line-height: 1.2;
}

.tg-pinned-text {
  font-size: 13px;
  color: var(--tg-pinned-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-pinned-text img.tg-emoji,
.tg-pinned-text .tg-custom-emoji,
.tg-pinned-text .tg-custom-emoji-anim {
  height: 1.15em;
  width: 1.15em;
  vertical-align: -0.2em;
  margin: 0 0.05em;
}

.tg-pinned-text .tg-custom-emoji-anim {
  display: inline-block;
  line-height: 0;
  overflow: hidden;
}

.tg-pinned-text .tg-custom-emoji-anim canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: transparent !important;
}

/* —— Chat scroll area: column-reverse opens at the bottom (TG WebView) —— */
.tg-chat {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column-reverse;
  /* Wallpaper stays on body only — avoids shift when this node scrolls */
  background: transparent;
}

.tg-chat-inner {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 8px 6px;
  flex: 0 0 auto;
}

.tg-chat-inner > .tg-post:last-of-type {
  margin-bottom: 0;
}

body.has-pinned .tg-chat {
  top: calc(56px + var(--pinned-h, 48px));
}

body.has-composer .tg-chat {
  bottom: var(--composer-h, 64px);
}

body.has-composer .tg-chat-inner {
  padding-bottom: 8px;
}

.tg-status {
  display: inline-block;
  margin: 24px auto;
  padding: 5px 12px;
  border-radius: 12px;
  background: var(--tg-status-bg);
  color: var(--tg-status-text);
  font-size: 14px;
  text-align: center;
  width: fit-content;
  max-width: 90%;
}

.tg-chat > .tg-status {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.tg-date {
  display: flex;
  justify-content: center;
  margin: 12px 0 8px;
}

.tg-date span {
  background: var(--tg-status-bg);
  color: var(--tg-status-text);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
}

.tg-post {
  display: flex;
  justify-content: flex-start;
  margin: 4px 0;
  padding-left: 9px;
  scroll-margin-top: 120px;
}

.tg-bubble {
  position: relative;
  max-width: min(100%, 480px);
  width: fit-content;
  background: transparent;
  border-radius: 12px 12px 12px 0;
  box-shadow: none;
  margin-left: 9px;
}

/*
 * Body + tail share ONE opacity group (opaque fills inside).
 * Overlap is fine — no gap stripe, no double-alpha darkening.
 */
.tg-bubble-skin {
  position: absolute;
  inset: 0;
  left: -9px;
  z-index: 0;
  pointer-events: none;
  opacity: var(--tg-bubble-a);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}

.tg-bubble-skin-body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 8px; /* 1px tuck over the tail */
  background: rgb(var(--tg-bubble-rgb));
  border-radius: 12px 12px 12px 0;
}

.tg-bubble-skin-tail {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 9px;
  height: 18px;
  background: rgb(var(--tg-bubble-rgb));
  /* Attach at x=9 from y=0..18; tip curves to bottom-left, baseline y=18 */
  clip-path: path(
    evenodd,
    "M9 18L9 0C7.9 4.5 6.2 9 3.8 12.8C2.2 15.4 1 17.2.45 17.7C.15 18 .5 18 1.2 18H9Z"
  );
}

.tg-bubble-tail {
  display: none !important;
}

.tg-bubble > *:not(.tg-bubble-skin) {
  position: relative;
  z-index: 1;
}

.tg-bubble.has-media {
  width: min(100%, 420px);
  max-width: min(100%, 420px);
  border-radius: 12px 12px 12px 0;
}

.tg-media-open {
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  display: block;
  width: 100%;
  background: transparent;
  cursor: zoom-in;
  line-height: 0;
  overflow: hidden;
  position: relative;
}

/* Single photo/video: full width, natural height — no grey letterbox */
.tg-bubble > .tg-media-open > .tg-post-media {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: min(70vh, 480px) !important;
  object-fit: unset !important;
  pointer-events: none;
  background: transparent !important;
}

/* Multi-photo album: row1=2, row2=2|3, row3=rest */
.tg-album {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  overflow: hidden;
  background: transparent;
}

.tg-album-row {
  display: grid !important;
  gap: 4px;
  width: 100%;
  align-items: stretch;
}

.tg-album-row.cols-1 {
  grid-template-columns: minmax(0, 1fr) !important;
}

.tg-album-row.cols-2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
}

.tg-album-row.cols-3 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) !important;
}

.tg-album-row.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.tg-album-row.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.tg-album-row.cols-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
}

.tg-album .tg-media-open {
  display: block !important;
  width: 100%;
  height: auto;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: transparent;
}

/* Stacked album items (photo then video): natural size, no letterbox */
.tg-album-row.cols-1 .tg-media-open {
  aspect-ratio: auto;
  max-height: none;
  background: transparent;
}

.tg-album-row.cols-1 .tg-media-open > .tg-post-media {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: min(70vh, 480px) !important;
  object-fit: unset !important;
  background: transparent !important;
}

/* Multi-col tiles: fill cell (Telegram-like), no grey bars */
.tg-album-row.cols-2 .tg-media-open,
.tg-album-row.cols-3 .tg-media-open,
.tg-album-row.cols-4 .tg-media-open,
.tg-album-row.cols-5 .tg-media-open,
.tg-album-row.cols-6 .tg-media-open {
  aspect-ratio: 1 / 1;
  background: var(--tg-media-bg);
}

.tg-album-row.cols-2 .tg-media-open > .tg-post-media,
.tg-album-row.cols-3 .tg-media-open > .tg-post-media,
.tg-album-row.cols-4 .tg-media-open > .tg-post-media,
.tg-album-row.cols-5 .tg-media-open > .tg-post-media,
.tg-album-row.cols-6 .tg-media-open > .tg-post-media {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center !important;
  background: transparent !important;
}

.tg-media-timer {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.2;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.tg-media-timer[hidden] {
  display: none !important;
}

.tg-post-media {
  display: block;
  background: var(--tg-media-bg);
  vertical-align: top;
  pointer-events: none;
}

video.tg-post-media::-webkit-media-controls {
  display: none !important;
}

.tg-bubble-body {
  padding: 5px 10px 4px;
}

.tg-bubble.has-media > .tg-bubble-body:first-child {
  padding-bottom: 4px;
}

.tg-author {
  margin: 0 0 1px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-name);
  line-height: 1.25;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0;
}

.tg-title {
  margin: 0 0 2px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--tg-text);
}

.tg-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.3125;
  letter-spacing: -0.01em;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  color: var(--tg-text);
  white-space: pre-wrap; /* keep leading / multiple spaces (Telegram-like indent) */
}

/* clearfix for inline meta */
.tg-bubble-body::after {
  content: "";
  display: table;
  clear: both;
}

.tg-text b {
  font-weight: 700;
}

.tg-text i {
  font-style: italic;
}

.tg-text u {
  text-decoration: underline;
}

.tg-text s {
  text-decoration: line-through;
  opacity: 0.85;
}

/* Telegram inline monospace — compact, not Courier billboard */
.tg-text code,
.tg-rich code,
.tg-code {
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
  font-size: 0.92em;
  font-weight: 400;
  font-style: normal;
  line-height: inherit;
  letter-spacing: -0.03em;
  color: inherit;
  background: transparent;
  border-radius: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Telegram ``` code block */
.tg-pre {
  display: block;
  margin: 0.35em 0;
  padding: 0.45em 0.6em;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
  font-size: 0.88em;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.tg-pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  white-space: inherit;
  font-size: inherit;
}

.tg-link {
  color: var(--tg-link);
  text-decoration: none;
}

.tg-link:hover {
  text-decoration: underline;
}

.tg-quote {
  margin: 0.35em 0;
  padding: 0.25em 0 0.25em 0.7em;
  border-left: 3px solid var(--tg-name);
  color: var(--tg-text);
  opacity: 0.92;
}

.tg-spoiler {
  background: var(--tg-text);
  border-radius: 3px;
  cursor: pointer;
  color: transparent;
  text-shadow: none;
  transition: color 0.12s ease, background 0.12s ease;
}

.tg-spoiler.is-open {
  background: rgba(127, 127, 127, 0.25);
  color: inherit;
}

/* 👻 as invisible marker */
.tg-invisible {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  font-size: 0;
}

.tg-footer {
  float: right;
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  margin: 4px 0 -1px 10px;
  min-height: 16px;
  position: relative;
  z-index: 1;
}

.tg-bubble.has-media .tg-footer {
  float: none;
  display: flex;
  width: 100%;
  margin: 2px 0 0;
  justify-content: flex-end;
}

.tg-views {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--tg-meta);
  line-height: 1;
  white-space: nowrap;
}

.tg-views svg {
  width: 14px;
  height: 14px;
  fill: var(--tg-meta);
}

.tg-time {
  font-size: 11px;
  color: var(--tg-meta);
  line-height: 1;
  white-space: nowrap;
}

.tg-pin-mark {
  display: inline-flex;
  align-items: center;
  color: var(--tg-meta);
}

.tg-pin-mark svg {
  width: 12px;
  height: 12px;
  fill: var(--tg-meta);
}

.empty-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 12px;
}

.empty-wrap .tg-status {
  margin: 0;
}

.brand,
.atmosphere {
  display: none;
}

.feed-status {
  color: var(--tg-pinned-sub);
  font-size: 14px;
}

@media (min-width: 720px) {
  .tg-bubble {
    max-width: 480px;
  }

  .tg-bubble.has-media {
    max-width: 420px;
  }
}

.tg-header-link {
  color: rgba(0, 0, 0, 0.75);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.tg-header-link[hidden],
.tg-header-btn[hidden] {
  display: none !important;
}

.tg-header-link:hover {
  background: rgba(0, 0, 0, 0.06);
}


/* —— Bottom composer (Telegram-like) —— */
.tg-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: var(--tg-composer-bg);
  border-top: 1px solid var(--tg-pinned-border);
}

.tg-composer[hidden] {
  display: none !important;
}

.tg-composer-attach-preview {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 10px 12px 0;
}

.tg-composer-attach-preview[hidden] {
  display: none !important;
}

.tg-edit-media-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
}

#edit-media-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.tg-composer-attach-preview img,
.tg-composer-attach-preview video {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
}

.tg-composer-attach-clear {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 15px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.tg-composer-bar {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.tg-composer-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  color: #8b9aab;
}

.tg-composer-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.tg-composer-icon .tg-icon-clip {
  width: 24px;
  height: 24px;
}

.tg-composer-icon:hover {
  color: #6ab3f3;
}



.tg-composer-input,
.tg-rich {
  flex: 1;
  min-height: 42px;
  max-height: 140px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--tg-composer-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  padding: 10px 4px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-composer-input::-webkit-scrollbar,
.tg-rich::-webkit-scrollbar {
  display: none;
}

.tg-rich:empty:before,
.tg-rich.is-empty:before {
  content: attr(data-placeholder);
  color: var(--tg-meta);
  pointer-events: none;
}

.tg-rich a.tg-link,
.tg-rich a {
  color: #64a9e0;
  text-decoration: none;
  cursor: text;
}

.tg-rich a:hover {
  text-decoration: underline;
}

.tg-rich b,
.tg-rich strong {
  font-weight: 700;
}

.tg-rich i,
.tg-rich em {
  font-style: italic;
}

.tg-rich .tg-spoiler {
  background: var(--tg-composer-text, var(--tg-text));
  border-radius: 3px;
  color: transparent;
  text-shadow: none;
}

.tg-rich .tg-spoiler:focus,
.tg-rich .tg-spoiler.is-open {
  color: inherit;
  background: rgba(127, 127, 127, 0.2);
}

.tg-composer-send {
  appearance: none;
  border: none;
  background: transparent;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--tg-name);
  padding: 0;
}

.tg-composer-send:disabled {
  opacity: 0.35;
  cursor: default;
}

.tg-composer-send svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* reuse format menu styles on feed page */
.tg-fmt-menu {
  position: fixed;
  z-index: 1400;
  min-width: 240px;
  padding: 6px 0;
  background: #1c272f;
  color: #e8eef4;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font);
  font-size: 14px;
}


.tg-fmt-item {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.tg-fmt-item:hover {
  background: rgba(100, 169, 224, 0.22);
}

.tg-fmt-item kbd {
  font: inherit;
  font-size: 12px;
  color: #8b9aab;
  white-space: nowrap;
}

.tg-fmt-sep {
  height: 1px;
  margin: 5px 0;
  background: rgba(255, 255, 255, 0.08);
}


.tg-post-menu {
  position: fixed;
  z-index: 1100;
  min-width: 220px;
  padding: 6px 0;
  background: #1c272f;
  color: #e8eef4;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font);
  font-size: 15px;
}


.tg-post-menu[hidden] {
  display: none !important;
}

.tg-post-menu-item {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.tg-post-menu-item:hover {
  background: rgba(100, 169, 224, 0.22);
}

.tg-post-menu-item.is-danger {
  color: #e35d6a;
}

.tg-post-menu-ico {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.9;
}

.tg-post-menu-sep {
  height: 1px;
  margin: 5px 0;
  background: rgba(255, 255, 255, 0.08);
}


.tg-composer-edit-bar {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 0;
  color: var(--tg-name);
  font-size: 13px;
  font-weight: 600;
}

.tg-composer-edit-bar[hidden] {
  display: none !important;
}

.tg-composer-edit-bar button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--tg-meta);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.tg-composer-edit-bar button:hover {
  color: var(--tg-composer-text);
}

.tg-edit-media {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
}

/* Media placement chip in composer / caption */
.tg-media-slot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(100, 169, 224, 0.18);
  color: #6ab3f3;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  user-select: none;
  -webkit-user-select: none;
  vertical-align: middle;
  cursor: default;
}

/* Attach modal (Telegram-like) */
.tg-attach-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.tg-attach-modal[hidden] {
  display: none !important;
}

.tg-attach-dialog {
  width: min(100%, 420px);
  max-height: min(92dvh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1c272f;
  color: #e8eef4;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 14px 16px 12px;
}


.tg-attach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.tg-attach-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.tg-attach-body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.tg-attach-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.tg-attach-close {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 4px;
}

.tg-attach-close:hover {
  opacity: 1;
}

.tg-attach-preview {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #0b1118;
  min-height: 180px;
}

.tg-attach-preview.is-multi {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  background: transparent;
  min-height: 0;
}

.tg-attach-preview:not(.is-multi) {
  display: grid;
  place-items: center;
}

.tg-attach-item {
  position: relative;
  background: #0b1118;
  border-radius: 8px;
  overflow: hidden;
  min-height: 120px;
}

.tg-attach-preview:not(.is-multi) .tg-attach-item {
  width: 100%;
  min-height: 180px;
}

.tg-attach-media {
  display: block;
  width: 100%;
  height: 100%;
  max-height: min(42dvh, 280px);
  object-fit: contain;
  background: #0b1118;
  pointer-events: none;
}

.tg-attach-preview.is-multi .tg-attach-media {
  max-height: 160px;
  object-fit: cover;
  min-height: 120px;
}

.tg-attach-upload {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  pointer-events: none;
}

.tg-attach-upload.is-error {
  pointer-events: auto;
}

.tg-attach-upload.is-done {
  opacity: 0;
  transition: opacity 0.35s ease 0.4s;
  pointer-events: none;
}

.tg-attach-upload-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.tg-attach-upload-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #64a9e0;
  transition: width 0.12s linear;
}

.tg-attach-upload-text {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.tg-attach-retry {
  appearance: none;
  border: none;
  align-self: flex-start;
  margin-top: 2px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tg-attach-retry:hover {
  background: rgba(255, 255, 255, 0.22);
}

.tg-attach-item-tools {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
}

.tg-attach-item-remove,
.tg-attach-item-more {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.tg-attach-item-more {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.tg-attach-item-remove:hover,
.tg-attach-item-more:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tg-attach-item-menu {
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 180px;
  padding: 6px 0;
  border-radius: 10px;
  background: #1c272f;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tg-attach-item-menu[hidden] {
  display: none !important;
}

.tg-attach-item-menu button {
  appearance: none;
  border: none;
  background: transparent;
  color: #e8eef4;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  cursor: pointer;
}

.tg-attach-item-menu button:hover {
  background: rgba(100, 169, 224, 0.2);
}

.tg-attach-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tg-attach-preview video.tg-attach-media::-webkit-media-controls {
  display: none !important;
}

.tg-attach-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 8px;
  font-size: 14px;
  color: var(--tg-pinned-sub, #8b9aab);
  cursor: pointer;
}

.tg-attach-doc input {
  width: 16px;
  height: 16px;
  accent-color: #64a9e0;
}

.tg-attach-caption-label {
  color: #64a9e0;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.tg-attach-caption-input {
  width: 100%;
  box-sizing: border-box;
  flex: none;
  border: none;
  border-bottom: 1px solid rgba(100, 169, 224, 0.55);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  min-height: 28px;
  max-height: 220px;
  padding: 6px 0;
  outline: none;
  scrollbar-width: none;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.tg-attach-caption-input::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.tg-attach-caption-input:empty:before,
.tg-attach-caption-input.is-empty:before {
  content: attr(data-placeholder);
  color: #8b9aab;
  pointer-events: none;
}

.tg-attach-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  flex-shrink: 0;
  padding-top: 4px;
}

.tg-attach-actions-right {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tg-attach-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #64a9e0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
}

.tg-attach-btn:hover {
  background: rgba(100, 169, 224, 0.12);
}

.tg-attach-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.tg-attach-btn.is-primary {
  color: #64a9e0;
}

video.tg-post-media {
  background: #000;
  display: block;
  pointer-events: none;
}

/* —— Media viewer (Telegram-like) —— */
body.mv-open {
  overflow: hidden;
}

/* Keep feed from peeking through while viewer is open */
body.mv-open .tg-chat,
body.mv-open .tg-header,
body.mv-open .tg-pinned,
body.mv-open .tg-composer {
  visibility: hidden;
}

.tg-media-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #0e0e0e;
  color: #fff;
  padding: 48px 0 8px;
  box-sizing: border-box;
}

.tg-media-viewer[hidden] {
  display: none !important;
}

.tg-mv-stage {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 56px;
}

.tg-mv-media {
  max-width: min(100%, 1100px);
  max-height: calc(100dvh - 200px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  background: #000;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.tg-mv-video-wrap {
  width: min(100%, 1100px);
  display: grid;
  place-items: center;
}

.tg-mv-video-wrap .tg-mv-media {
  width: 100%;
  max-height: calc(100dvh - 200px);
}

.tg-mv-close,
.tg-mv-nav {
  appearance: none;
  border: none;
  position: absolute;
  z-index: 3;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.15s ease;
}

.tg-mv-close {
  background: rgba(255, 255, 255, 0.08);
}

.tg-mv-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.tg-mv-nav:hover {
  opacity: 0.75;
}

.tg-mv-close {
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.tg-mv-nav {
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  width: 44px;
  height: 72px;
  border-radius: 10px;
  font-size: 36px;
  line-height: 1;
  /* left/top set in JS relative to media box */
}

.tg-mv-footer {
  flex: 0 0 auto;
  padding: 6px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #0e0e0e;
}

.tg-mv-caption {
  max-width: min(720px, 92vw);
  max-height: min(28vh, 180px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: #e8eef4;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  scrollbar-width: none;
}

.tg-mv-caption::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.tg-mv-caption[hidden] {
  display: none !important;
}

.tg-mv-caption a {
  color: #6cb7f0;
}

.tg-mv-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(720px, 92vw);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.tg-mv-count {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .tg-media-viewer {
    padding: 44px 0 6px;
  }

  .tg-mv-stage {
    padding: 0 12px;
  }

  .tg-mv-nav {
    width: 36px;
    height: 56px;
    font-size: 30px;
  }

  .tg-mv-media {
    max-height: calc(100dvh - 220px);
  }

  .tg-mv-video-wrap .tg-mv-media {
    max-height: calc(100dvh - 220px);
  }
}

/* Create / edit link dialog */
.tg-link-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.tg-link-modal[hidden] {
  display: none !important;
}

.tg-link-dialog {
  width: min(100%, 360px);
  background: #1c272f;
  color: #e8eef4;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 16px 18px 12px;
}


.tg-link-head h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.tg-link-field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.tg-link-label {
  font-size: 13px;
  color: #8b9aab;
  font-weight: 500;
}

.tg-link-label.is-accent {
  color: #64a9e0;
}

.tg-link-field input {
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(100, 169, 224, 0.55);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  padding: 6px 0;
  outline: none;
}

.tg-link-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
}

.tg-link-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #64a9e0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
}

.tg-link-btn:hover {
  background: rgba(100, 169, 224, 0.12);
}
