/* Discussion screen — comments as Telegram chat bubbles */
.tx-thread-list { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 8px; }
.tx-thread-root { margin-bottom: 6px; }

.tx-msg { display: flex; align-items: flex-end; gap: 7px; margin-top: 2px; }
.tx-msg.is-first { margin-top: 8px; }
.tx-msg .tx-avatar-slot { width: 38px; flex-shrink: 0; }
.tx-msg.is-out { flex-direction: row-reverse; }
.tx-msg.is-out .tx-avatar-slot { display: none; }

.tx-msg .tx-bubble {
  flex: 0 1 auto;
  max-width: min(84%, 520px);
  border-radius: var(--tx-bubble-radius);
}
.tx-msg:not(.is-out) .tx-bubble { border-bottom-left-radius: var(--tx-bubble-radius-small); }
.tx-msg:not(.is-out):not(.is-last) .tx-bubble { border-bottom-left-radius: var(--tx-bubble-radius-small); border-top-left-radius: var(--tx-bubble-radius-small); }
.tx-msg:not(.is-out).is-first:not(.is-last) .tx-bubble { border-top-left-radius: var(--tx-bubble-radius); }
.tx-msg:not(.is-out).is-last:not(.is-first) .tx-bubble { border-top-left-radius: var(--tx-bubble-radius-small); }
.tx-msg.is-out .tx-bubble { border-bottom-left-radius: var(--tx-bubble-radius); border-bottom-right-radius: var(--tx-bubble-radius-small); }

.tx-msg-name { padding: 6px 11px 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-msg-body { display: flow-root; padding: 4px 11px 6px; font-size: var(--tx-text-size); line-height: 1.36; overflow-wrap: anywhere; }
.tx-msg-body .emoji { width: 1.25em !important; height: 1.25em !important; vertical-align: -0.25em !important; }
.tx-msg-time { float: right; margin: 7px -3px -4px 10px; font-size: 12.5px; color: var(--tx-text-2); line-height: 1; }
.tx-msg.is-out .tx-msg-time { color: rgba(255, 255, 255, 0.6); }
.tx-msg-media { margin: 2px 2px 0; border-radius: calc(var(--tx-bubble-radius) - 3px); overflow: hidden; max-width: 320px; }
.tx-msg-media img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.tx-msg-media.is-sticker { background: none; max-width: 180px; }
.tx-msg-media.is-sticker img { object-fit: contain; }
.tx-msg .tx-reactions { padding: 0 9px 4px; }
.tx-msg .tx-reaction { height: 28px; font-size: 14px; }

.tx-reply {
  display: block; margin: 6px 8px 0; padding: 3px 8px 4px 9px; border-radius: 6px; cursor: pointer;
  border-left: 3px solid var(--peer, var(--tx-accent)); background: color-mix(in srgb, var(--peer, var(--tx-accent)) 14%, transparent);
  font-size: 14px; line-height: 1.3; max-width: 100%; box-sizing: border-box;
}
.tx-reply b { display: block; font-weight: 600; color: var(--peer, var(--tx-accent)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-reply span { display: block; color: #e3e3e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Composer fixed at the bottom */
.tx-composer {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  padding: 8px 10px calc(10px + var(--tx-safe-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent);
}
.tx-composer-inner { max-width: calc(var(--tx-column-w) - 20px); margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.tx-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.tx-composer-field {
  flex: 1; min-height: 50px; display: flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: 26px;
}
.tx-composer-field textarea {
  flex: 1; min-width: 0; max-height: 140px; resize: none; background: transparent; border: 0; outline: none;
  color: #fff; font: inherit; font-size: 17px; line-height: 1.3; padding: 14px 4px;
}
.tx-composer-field textarea::placeholder { color: var(--tx-hint); }
.tx-composer-field .tx-icon-btn { color: var(--tx-text-2); }
.tx-send-btn {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tx-accent-fill) !important; color: #fff; transition: transform 0.15s ease;
}
.tx-send-btn .icon { font-size: 24px; }
.tx-send-btn:active { transform: scale(0.92); }
.tx-reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 18px;
}
.tx-reply-bar .icon-reply { color: var(--tx-accent); font-size: 22px; }
.tx-reply-bar .tx-reply { flex: 1; margin: 0; background: none; padding: 0 0 0 8px; }
.tx-emoji-pop { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; border-radius: 20px; max-height: 220px; overflow-y: auto; }
.tx-emoji-pop button { height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.tx-emoji-pop button:hover { background: rgba(255, 255, 255, 0.08); }
.tx-emoji-pop .emoji { width: 28px !important; height: 28px !important; }

/* Comments header / composer details (Telegram 12) */
#screen-thread .tx-pill { padding-left: 5px; }
#screen-thread .tx-pill-title { font-size: 18px; }
#thread-search { position: sticky; top: calc(66px + var(--tx-safe-top)); z-index: 29; margin: -2px 0 8px; }
.tx-msg.is-filtered { opacity: 0.25; filter: saturate(0.4); transition: opacity 0.2s ease; }
.tx-composer-me { display: inline-flex; padding-left: 4px; }
.tx-composer-me:empty { display: none; }
.tx-composer-me .tx-avatar { width: 34px; height: 34px; font-size: 13px; }
.tx-composer-inner { position: relative; }
.tx-thread-jump {
  position: absolute; right: 2px; bottom: calc(100% + 12px); width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  animation: tx-jump-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.tx-thread-jump .icon { font-size: 26px; }
.tx-thread-jump .tx-badge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }
@keyframes tx-jump-in { from { opacity: 0; transform: scale(0.6); } }
#thread-send { transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.18s ease; }
.tx-composer.is-empty #thread-send { transform: scale(0.7); opacity: 0.55; }

/* Discussion skeleton */
.tx-thread-skeleton { padding-top: 6px; }
.tx-skel-msg { animation: tx-enter 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.tx-skel-bubble { padding: 11px 13px 12px; min-width: 120px; }
.tx-skel {
  display: block; border-radius: 6px;
  background: rgba(255, 255, 255, 0.06) linear-gradient(100deg, transparent 25%, rgba(140, 160, 255, 0.1) 45%, rgba(255, 255, 255, 0.12) 50%, rgba(140, 160, 255, 0.1) 55%, transparent 75%) no-repeat;
  background-size: 220% 100%;
  animation: tx-shimmer 1.5s linear infinite;
}
.tx-skel-ava { width: 36px; height: 36px; border-radius: 50%; }
.tx-skel-ava { background-color: rgba(255, 255, 255, 0.12); }
