/* 20260723-gif3x3v2
   Portal + Social + Support + Community:
   - GIF picker: clean centered sheet, true 3x3 square grid (no overlap/off-screen)
   - Global emotes: exactly TWO visible rows, scroll inside the popup (never spill off)
*/

/* ========== GIF backdrop ========== */
.gif-picker-backdrop,
.gif-picker-backdrop-dm,
body.portal-section-messages .gif-picker-backdrop,
body.portal-section-messages .gif-picker-backdrop-dm,
body.social-messages .gif-picker-backdrop,
body.social-messages .gif-picker-backdrop-dm {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    background: rgba(0, 0, 0, 0.62) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    pointer-events: auto !important;
}

/* ========== GIF sheet (modal) ========== */
.gif-picker,
.gif-picker-dm,
body.portal-section-messages .gif-picker,
body.portal-section-messages .gif-picker-dm,
body.portal-section-messages.msg-has-thread .gif-picker,
body.portal-section-messages.msg-has-thread .gif-picker-dm,
body.social-messages .gif-picker,
body.social-messages .gif-picker-dm,
.portal-messages-app .gif-picker,
.portal-messages-app .gif-picker-dm {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    transform: translateX(-50%) !important;
    width: min(360px, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: min(56vh, 460px) !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 2147483001 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 16px !important;
    border: 1px solid var(--social-border, #2f3336) !important;
    background: var(--bg, #000) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65) !important;
    box-sizing: border-box !important;
}

/* Desktop / wide: center fully in viewport */
@media (min-width: 901px) {
    .gif-picker,
    .gif-picker-dm,
    body.portal-section-messages .gif-picker,
    body.portal-section-messages .gif-picker-dm,
    body.social-messages .gif-picker {
        top: 50% !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        max-height: min(70vh, 520px) !important;
        width: min(420px, calc(100vw - 32px)) !important;
    }
}

.gif-picker-header,
.gif-picker .gif-picker-header,
.gif-picker-dm .gif-picker-header {
    flex: 0 0 auto !important;
    padding: 12px !important;
    border-bottom: 1px solid var(--social-border, #2f3336) !important;
    box-sizing: border-box !important;
}

.gif-search {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ========== GIF grid: true 3 columns ========== */
.gif-grid,
body.portal-section-messages .gif-grid,
body.social-messages .gif-grid,
.portal-messages-app .gif-grid,
.gif-picker .gif-grid,
.gif-picker-dm .gif-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-rows: auto !important;
    gap: 8px !important;
    padding: 10px !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    align-content: start !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

.gif-grid-status {
    grid-column: 1 / -1 !important;
    padding: 28px 12px !important;
    text-align: center !important;
    color: var(--text-muted, #71767b) !important;
    font-size: 14px !important;
}

/* Square cells — no max-height that collapses/overlaps */
.gif-card,
body.portal-section-messages .gif-card,
body.social-messages .gif-card,
.portal-messages-app .gif-card,
.gif-picker .gif-card,
.gif-picker-dm .gif-card {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: 0 !important;
    padding: 0 0 100% 0 !important; /* 1:1 square via padding trick (works everywhere) */
    margin: 0 !important;
    aspect-ratio: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    border: none !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #111 !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    box-sizing: border-box !important;
}

.gif-card .gif-thumb,
body.portal-section-messages .gif-card .gif-thumb,
.gif-picker .gif-card .gif-thumb {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    border: 0 !important;
}

/* ========== Global emotes: TWO rows inside the emoji popup ========== */
.emoji-picker-section-global,
.composer-emoji-picker .emoji-picker-section-global,
.emoji-picker-dm .emoji-picker-section-global,
.emoji-picker-section-premium {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    max-height: none !important;
}

.emoji-picker-heading-global,
.emoji-picker-section-global .emoji-picker-heading {
    display: block !important;
    width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.25 !important;
    padding: 8px 8px 4px !important;
    box-sizing: border-box !important;
}

/* Grid with ~5 cols, capped to 2 rows of height; extra emotes scroll *inside* */
.emoji-picker-grid-emotes,
.composer-emoji-picker .emoji-picker-grid-emotes,
.emoji-picker-dm .emoji-picker-grid-emotes,
body.portal-section-messages .emoji-picker-grid-emotes,
body.social-messages .emoji-picker-grid-emotes,
.portal-messages-app .emoji-picker-grid-emotes {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    grid-auto-rows: 40px !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    /* exactly two rows visible */
    max-height: calc(40px * 2 + 6px) !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 4px 6px !important;
    margin: 0 !important;
    flex-wrap: unset !important;
    align-items: stretch !important;
}

.emoji-picker-grid-emotes .emoji-picker-emote-btn,
.composer-emoji-picker .emoji-picker-grid-emotes .emoji-picker-emote-btn,
.emoji-picker-dm .emoji-picker-grid-emotes .emoji-picker-emote-btn,
body.portal-section-messages .emoji-picker-grid-emotes .emoji-picker-emote-btn {
    width: 100% !important;
    height: 40px !important;
    min-width: 0 !important;
    min-height: 40px !important;
    max-width: none !important;
    max-height: 40px !important;
    padding: 4px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: unset !important;
    box-sizing: border-box !important;
}

.emoji-picker-grid-emotes .emoji-picker-emote-btn img,
.composer-emoji-picker .emoji-picker-grid-emotes img,
.emoji-picker-dm .emoji-picker-grid-emotes img {
    width: 28px !important;
    height: 28px !important;
    object-fit: contain !important;
    display: block !important;
}

/* Emoji popup itself stays on-screen */
.emoji-picker,
.composer-emoji-picker,
.emoji-picker-dm,
body.portal-section-messages .composer-emoji-picker,
body.portal-section-messages .emoji-picker-dm,
body.social-messages .composer-emoji-picker,
body.social-messages .emoji-picker-dm {
    position: fixed !important;
    z-index: 2147483001 !important;
    right: auto !important;
    width: min(320px, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: min(62vh, 460px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

@media (max-width: 700px) {
    .emoji-picker-grid-emotes,
    body.portal-section-messages .emoji-picker-grid-emotes,
    body.social-messages .emoji-picker-grid-emotes {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        grid-auto-rows: 42px !important;
        max-height: calc(42px * 2 + 6px) !important;
    }
    .emoji-picker-grid-emotes .emoji-picker-emote-btn,
    body.portal-section-messages .emoji-picker-grid-emotes .emoji-picker-emote-btn {
        height: 42px !important;
        min-height: 42px !important;
        max-height: 42px !important;
    }
}

/* Keep media chip / in-field emote bits */
.composer-emote-tip { display: none !important; }
.composer-chat-preview { display: none !important; }

.composer-media-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 12px 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(29, 155, 240, 0.45);
    background: rgba(29, 155, 240, 0.12);
    color: #e7e9ea;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.3;
}
.composer-media-chip[hidden] { display: none !important; }
.composer-media-chip-icon { font-size: 16px; }
.composer-media-chip-text { flex: 1 1 auto; min-width: 0; }
.composer-media-chip-clear {
    border: 0;
    background: rgba(255,255,255,.08);
    color: #e7e9ea;
    border-radius: 999px;
    min-height: 30px;
    padding: 0 12px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}
.composer-has-media .composer-media-slot,
.composer-has-media .media-preview {
    outline: 2px solid rgba(29, 155, 240, 0.35);
    outline-offset: 2px;
    border-radius: 12px;
}
.media-preview {
    position: relative;
    margin: 8px 12px 0;
    max-width: min(280px, 70vw);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--social-border, #2f3336);
    background: #000;
}
.media-preview img,
.media-preview video {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    background: #000;
}

.dm-msg-emote-img,
.dm-message-body .dm-msg-emote-img,
.dm-bubble .dm-msg-emote-img {
    width: 1.35em !important;
    height: 1.35em !important;
    max-width: 1.35em !important;
    max-height: 1.35em !important;
    object-fit: contain !important;
    vertical-align: -6px !important;
    display: inline-block !important;
    margin: 0 1px !important;
}

.composer-hl-emote {
    display: inline-block;
    /* width measured */
    height: 1.25em;
    /* max-width measured */
    max-height: 22px;
    vertical-align: -0.25em;
    object-fit: contain;
    margin: 0 1px;
}
.composer-hl-emote-missing {
    display: inline-block;
    width: 0.4em;
    height: 1em;
}
.dm-convo-preview {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.dm-convo-preview-emote {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex: 0 0 auto;
    vertical-align: middle;
}
.dm-convo-preview-emoji {
    font-size: 15px;
    line-height: 1;
}
.portal-messages-app .dm-compose .composer-highlight-wrap {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}
.portal-messages-app .dm-compose .composer-highlight-input {
    width: 100%;
}

/* media-tag-only: no visual preview — just Media attached chip */
.media-preview,
.composer-media-slot .media-preview,
.dm-media-slot .media-preview,
.dm-compose .media-preview,
.feed-composer .media-preview {
    display: none !important;
}
.composer-media-chip {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 6px 0 0 !important;
    padding: 8px 12px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(29, 155, 240, 0.45) !important;
    background: rgba(29, 155, 240, 0.12) !important;
    color: #e7e9ea !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    line-height: 1.2 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.composer-media-chip[hidden] { display: none !important; }
.composer-media-chip-text { flex: 1 1 auto; min-width: 0; }
.composer-media-chip-clear {
    border: 0 !important;
    background: rgba(255,255,255,.1) !important;
    color: #e7e9ea !important;
    border-radius: 999px !important;
    min-height: 28px !important;
    padding: 0 10px !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    cursor: pointer !important;
}
.composer-media-slot:empty { display: none !important; }
.composer-media-slot:not(:empty) {
    display: block !important;
    margin: 0 !important;
    padding: 0 0 4px !important;
    min-height: 0 !important;
}

/* voice-ready: status + recording UI always visible */
.dm-voice-status {
    display: block !important;
    margin: 6px 0 0 !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    background: rgba(29, 155, 240, 0.12) !important;
    border: 1px solid rgba(29, 155, 240, 0.35) !important;
    color: #e7e9ea !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
}
.dm-compose [data-action="voice"].is-recording,
.dm-compose-tools [data-action="voice"].is-recording {
    color: #f4212e !important;
    background: rgba(244, 33, 46, 0.15) !important;
    border-radius: 999px !important;
}
/* Voice uses Media attached chip — keep visible */
.composer-media-chip:not([hidden]) { display: inline-flex !important; }
.composer-media-chip[hidden] { display: none !important; }
.media-preview.dm-voice-preview { display: none !important; }

/* chip-remove-empty: no leftover bubble after remove */
.composer-media-chip:empty,
.composer-media-chip[hidden] {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
.composer-media-slot:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
}
.dm-compose:not(.composer-has-media) .composer-media-slot:empty,
.dm-compose:not(.composer-has-media) .composer-media-chip {
    display: none !important;
}

/* emote-picker-viewport-lock */
.emoji-picker,
.composer-emoji-picker,
.emoji-picker-dm,
body.portal-section-messages .composer-emoji-picker,
body.social-messages .composer-emoji-picker {
    position: fixed !important;
    transform: none !important;
    max-width: calc(100vw - 16px) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}
/* proxy char + image: same 1.15em width */
.composer-highlight-input {
    letter-spacing: 0 !important;
}
.composer-hl-emote-compact {
    /* width: measured px from JS */
    /* min-width measured */
    /* max-width/height measured */
    /* height: from inline */
    display: inline-block !important;
    overflow: hidden !important;
    vertical-align: -0.15em !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ========== emote + dm tools 20260727-emotetools1 ========== */
/* Emote proxy width = backdrop image width (1em) — kills caret flying away */
.composer-highlight-input,
.composer-highlight-backdrop,
.portal-messages-app .composer-highlight-input,
.portal-messages-app .composer-highlight-backdrop,
body.portal-section-messages .composer-highlight-input,
body.portal-section-messages .composer-highlight-backdrop {
    /* font-family left to page (caret metrics) */
    letter-spacing: 0 !important;
    font-variant-ligatures: none !important;
    font-kerning: none !important;
}
.composer-hl-emote-slot,
.composer-hl-emote-compact,
.composer-hl-emote-slot.composer-hl-emote-compact {
    display: inline-block !important;
    /* margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    vertical-align: -0.15em !important;
    text-indent: 0 !important;
}
.composer-hl-emote,
.composer-hl-emote-compact .composer-hl-emote {
    /* width: measured px from JS */
    /* height: from inline */
    /* max-width/height measured */
    /* max-width/height measured */
    display: block !important;
    margin: 0 auto !important;
    padding: 0 !important;
    object-fit: contain !important;
}
.composer-hl-emote-missing {
    display: inline-block !important;
    /* width: measured px from JS */
    /* min-width measured */
    /* height: from inline */
    overflow: hidden !important;
    visibility: hidden !important;
}

/* DM tools: ⋯ on mobile, full row on desktop */
.dm-tools-cluster {
    display: flex;
    align-items: center;
    position: relative;
    flex: 0 0 auto;
}
.dm-tools-more {
    display: none;
}
.dm-tools-panel {
    display: flex;
    align-items: center;
    gap: 0;
}
.dm-tools-panel[hidden] {
    display: flex !important; /* desktop always shows panel */
}

@media (max-width: 1100px) {
    body.portal-section-messages .dm-compose-inner,
    body.portal-section-messages.msg-has-thread .dm-compose-inner,
    .portal-messages-app .dm-compose-inner {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        grid-template-areas: "tools editor send" !important;
        gap: 6px !important;
        align-items: center !important;
        width: 100% !important;
    }
    body.portal-section-messages .dm-compose-tools,
    .portal-messages-app .dm-compose-tools {
        grid-area: tools !important;
        display: flex !important;
        align-items: center !important;
        gap: 0 !important;
        min-width: 0 !important;
        max-width: 44px !important; /* only ⋯ visible when closed */
    }
    .dm-tools-more {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        color: #1d9bf0 !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 999px !important;
        padding: 0 !important;
        cursor: pointer !important;
    }
    .dm-tools-panel {
        display: none !important;
        position: absolute !important;
        left: 0 !important;
        bottom: calc(100% + 6px) !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 2px !important;
        padding: 6px !important;
        border-radius: 999px !important;
        background: #16181c !important;
        border: 1px solid #2f3336 !important;
        box-shadow: 0 8px 28px rgba(0,0,0,.55) !important;
        z-index: 50 !important;
    }
    .dm-tools-panel[hidden] {
        display: none !important;
    }
    .dm-tools-cluster.is-open .dm-tools-panel,
    .dm-tools-cluster.is-open .dm-tools-panel[hidden] {
        display: flex !important;
    }
    .dm-tools-panel .composer-control {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        color: #1d9bf0 !important;
    }
    /* Give the text pill max room */
    body.portal-section-messages .dm-compose-editor,
    .portal-messages-app .dm-compose-editor {
        grid-area: editor !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    body.portal-section-messages .dm-compose textarea,
    body.portal-section-messages .dm-compose .composer-highlight-input,
    body.portal-section-messages .dm-compose .composer-highlight-wrap,
    .portal-messages-app .dm-compose textarea,
    .portal-messages-app .dm-compose .composer-highlight-input,
    .portal-messages-app .dm-compose .composer-highlight-wrap {
        width: 100% !important;
        min-width: 0 !important;
    }
    body.portal-section-messages .dm-compose .composer-highlight-wrap {
        background: #16181c !important;
        box-shadow: inset 0 0 0 1px #38444d !important;
        border-radius: 22px !important;
        min-height: 44px !important;
    }
    body.portal-section-messages .dm-compose textarea,
    body.portal-section-messages .dm-compose .composer-highlight-input {
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 11px 14px !important;
    }
    body.portal-section-messages .dm-compose textarea.composer-highlight-input {
        color: transparent !important;
        -webkit-text-fill-color: transparent !important;
        caret-color: #e7e9ea !important;
        background: transparent !important;
    }
    body.portal-section-messages .dm-compose textarea:not(.composer-highlight-input) {
        color: #e7e9ea !important;
        -webkit-text-fill-color: #e7e9ea !important;
        background: #16181c !important;
    }
    body.portal-section-messages .dm-compose textarea::placeholder,
    body.portal-section-messages .dm-compose .composer-highlight-input::placeholder {
        color: #71767b !important;
        -webkit-text-fill-color: #71767b !important;
        opacity: 1 !important;
    }
}

@media (min-width: 1101px) {
    .dm-tools-more { display: none !important; }
    .dm-tools-panel,
    .dm-tools-panel[hidden] {
        display: flex !important;
        position: static !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}
/* ========== /emote + dm tools 20260727-emotetools1 ========== */

/* ========== msgall surfaces 20260727-msgall1 ========== */
/* Same compose UX on social messages, portal messages, support */
body.social-messages .dm-compose-inner,
body.social-messages-portal-ui .dm-compose-inner,
body.portal-section-messages .dm-compose-inner,
.portal-messages-app .dm-compose-inner {
    /* inherit grid from earlier rules */
}
body.social-messages .dm-tools-cluster,
body.social-messages-portal-ui .dm-tools-cluster,
body.portal-section-messages .dm-tools-cluster {
    display: flex;
    align-items: center;
    position: relative;
    flex: 0 0 auto;
}
@media (max-width: 1100px) {
    body.social-messages .dm-compose-inner,
    body.social-messages-portal-ui .dm-compose-inner,
    body.social-messages.msg-has-thread .dm-compose-inner {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        grid-template-areas: "tools editor send" !important;
        gap: 6px !important;
        align-items: center !important;
        width: 100% !important;
    }
    body.social-messages .dm-compose-tools,
    body.social-messages-portal-ui .dm-compose-tools {
        grid-area: tools !important;
        display: flex !important;
        max-width: 44px !important;
        min-width: 0 !important;
    }
    body.social-messages .dm-compose-editor,
    body.social-messages-portal-ui .dm-compose-editor {
        grid-area: editor !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    body.social-messages .dm-send-btn,
    body.social-messages-portal-ui .dm-send-btn {
        grid-area: send !important;
    }
    body.social-messages .dm-tools-more,
    body.social-messages-portal-ui .dm-tools-more {
        display: inline-flex !important;
        width: 40px !important;
        height: 40px !important;
        color: #1d9bf0 !important;
    }
    body.social-messages .dm-tools-panel,
    body.social-messages-portal-ui .dm-tools-panel {
        display: none !important;
        position: absolute !important;
        left: 0 !important;
        bottom: calc(100% + 6px) !important;
        flex-direction: row !important;
        gap: 2px !important;
        padding: 6px !important;
        border-radius: 999px !important;
        background: #16181c !important;
        border: 1px solid #2f3336 !important;
        box-shadow: 0 8px 28px rgba(0,0,0,.55) !important;
        z-index: 50 !important;
    }
    body.social-messages .dm-tools-panel[hidden],
    body.social-messages-portal-ui .dm-tools-panel[hidden] {
        display: none !important;
    }
    body.social-messages .dm-tools-cluster.is-open .dm-tools-panel,
    body.social-messages .dm-tools-cluster.is-open .dm-tools-panel[hidden],
    body.social-messages-portal-ui .dm-tools-cluster.is-open .dm-tools-panel,
    body.social-messages-portal-ui .dm-tools-cluster.is-open .dm-tools-panel[hidden] {
        display: flex !important;
    }
    body.social-messages .dm-compose .composer-highlight-wrap,
    body.social-messages-portal-ui .dm-compose .composer-highlight-wrap {
        background: #16181c !important;
        box-shadow: inset 0 0 0 1px #38444d !important;
        border-radius: 22px !important;
        min-height: 44px !important;
        width: 100% !important;
    }
    body.social-messages .dm-compose textarea,
    body.social-messages .dm-compose .composer-highlight-input,
    body.social-messages-portal-ui .dm-compose textarea,
    body.social-messages-portal-ui .dm-compose .composer-highlight-input {
        min-height: 44px !important;
        font-size: 16px !important;
        width: 100% !important;
    }
    body.social-messages .dm-compose textarea.composer-highlight-input,
    body.social-messages-portal-ui .dm-compose textarea.composer-highlight-input {
        color: transparent !important;
        -webkit-text-fill-color: transparent !important;
        caret-color: #e7e9ea !important;
        background: transparent !important;
    }
    body.social-messages .dm-compose textarea::placeholder,
    body.social-messages .dm-compose .composer-highlight-input::placeholder,
    body.social-messages-portal-ui .dm-compose textarea::placeholder,
    body.social-messages-portal-ui .dm-compose .composer-highlight-input::placeholder {
        color: #71767b !important;
        -webkit-text-fill-color: #71767b !important;
        opacity: 1 !important;
    }
}
/* ========== /msgall surfaces 20260727-msgall1 ========== */

/* Site-wide custom stream/global emotes in posts, comments, bios, DMs */
img.social-emote-img,
img.post-emote-img,
.post-text img.social-emote-img,
.reply-text img.social-emote-img,
.dm-bubble-text img.social-emote-img {
  display: inline-block !important;
  width: 1.35em !important;
  height: 1.35em !important;
  max-width: 1.35em !important;
  max-height: 1.35em !important;
  object-fit: contain !important;
  vertical-align: -0.25em !important;
  margin: 0 0.05em !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Composer overlay: match proxy glyph width exactly (kill weird gaps) */
.composer-hl-emote-slot.composer-hl-emote-compact,
.composer-hl-emote-compact,
.composer-hl-emote-slot {
  display: inline-block !important;
  /* width: measured px from JS */
  /* min-width measured */
  /* max-width/height measured */
  /* height: from inline */
  line-height: 1 !important;
  overflow: hidden !important;
  vertical-align: -0.15em !important;
  margin: 0 !important;
  padding: 0 !important;
  letter-spacing: 0 !important;
}
.composer-hl-emote-compact .composer-hl-emote,
.composer-hl-emote-slot .composer-hl-emote,
.composer-hl-emote {
  /* width: measured px from JS */
  /* height: from inline */
  /* max-width/height measured */
  /* max-width/height measured */
  display: block !important;
  margin: 0 auto !important;
  padding: 0 !important;
  object-fit: contain !important;
}
.composer-highlight-input,
.composer-highlight-backdrop {
  letter-spacing: normal !important;
  font-variant-ligatures: none !important;
  font-kerning: none !important;
}

/* ========== caret + emote align 20260727-caretfix1 ========== */
.composer-highlight-wrap {
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
}
.composer-highlight-backdrop {
    position: absolute !important;
    inset: 0 !important;
    z-index: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    margin: 0 !important;
    background: transparent !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}
.composer-highlight-input,
textarea.composer-highlight-input {
    position: relative !important;
    z-index: 1 !important;
    background: transparent !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    caret-color: var(--text, #e7e9ea) !important;
    letter-spacing: 0 !important;
    font-kerning: none !important;
    font-variant-ligatures: none !important;
}
.composer-highlight-input,
.composer-highlight-backdrop,
textarea.composer-highlight-input {
    letter-spacing: 0 !important;
    font-kerning: none !important;
    font-variant-ligatures: none !important;
}
.composer-hl-emote-slot,
.composer-hl-emote-compact,
.composer-hl-emote-slot.composer-hl-emote-compact {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    vertical-align: -0.12em !important;
    line-height: 1 !important;
    text-indent: 0 !important;
    letter-spacing: 0 !important;
    box-sizing: border-box !important;
}
.composer-hl-emote,
.composer-hl-emote-compact .composer-hl-emote,
.composer-hl-emote-slot .composer-hl-emote {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    object-fit: contain !important;
    vertical-align: top !important;
}
.composer-hl-emote-missing {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    vertical-align: -0.12em !important;
}
/* ========== /caret + emote align 20260727-caretfix1 ========== */

/* caret-emote-final-override */
.composer-hl-emote-slot,
.composer-hl-emote-compact,
.composer-hl-emote-slot.composer-hl-emote-compact {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  letter-spacing: 0 !important;
}
.composer-hl-emote-slot .composer-hl-emote,
.composer-hl-emote {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  object-fit: contain !important;
}

/* ========== emote enter-space 20260727-emotespace1 ========== */
/* Emotes sit inside the line like normal emoji — no tall gap after Enter */
.composer-highlight-backdrop {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    line-height: inherit;
}
.composer-hl-emote-slot,
.composer-hl-emote-compact,
.composer-hl-emote-slot.composer-hl-emote-compact {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    line-height: 0 !important;
    vertical-align: -0.15em !important;
    overflow: hidden !important;
    letter-spacing: 0 !important;
    box-sizing: border-box !important;
    /* do not force height/width — JS sets measured px */
}
.composer-hl-emote,
.composer-hl-emote-slot .composer-hl-emote,
.composer-hl-emote-compact .composer-hl-emote {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    vertical-align: top !important;
    object-fit: contain !important;
    /* kill old display:block gap under images */
}
.composer-hl-emote-missing {
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
    vertical-align: -0.15em !important;
    overflow: hidden !important;
}
/* ========== /emote enter-space 20260727-emotespace1 ========== */

/* ========== unified emote size 20260727-emotesize1 ========== */
/* One final size for custom emotes in posts, comments, and chat bubbles.
   Stops small→large pop when PHP HTML is later replaced by JS. */
img.dm-msg-emote-img,
img.social-emote-img,
img.post-emote-img,
.dm-msg-emote-img,
.social-emote-img,
.post-emote-img,
.dm-message-body .dm-msg-emote-img,
.dm-bubble .dm-msg-emote-img,
.dm-bubble-text img.dm-msg-emote-img,
.dm-bubble-text img.social-emote-img,
.dm-bubble-text img.post-emote-img,
.post-text img.social-emote-img,
.post-text img.post-emote-img,
.reply-text img.social-emote-img,
.reply-text img.post-emote-img {
    display: inline-block !important;
    width: 1.35em !important;
    height: 1.35em !important;
    max-width: 1.35em !important;
    max-height: 1.35em !important;
    min-width: 0 !important;
    min-height: 0 !important;
    object-fit: contain !important;
    vertical-align: -0.25em !important;
    margin: 0 0.05em !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    /* no transitions — size must be correct on first paint */
    transition: none !important;
}
/* ========== /unified emote size 20260727-emotesize1 ========== */

/* ========== mobile text visible 20260727-mobvis1 ========== */
/* Typed characters must ALWAYS be visible on phones / WebView apps.
   Transparent overlay is desktop-only (emote images in field). */
@media (max-width: 1100px), (hover: none) and (pointer: coarse) {
    .composer-highlight-input,
    textarea.composer-highlight-input,
    .composer-highlight-wrap textarea,
    body.portal-section-messages .dm-compose textarea,
    body.portal-section-messages .dm-compose .composer-highlight-input,
    body.portal-section-messages.msg-has-thread .dm-compose textarea,
    body.portal-section-messages.msg-has-thread .dm-compose .composer-highlight-input,
    .portal-messages-app .dm-compose textarea,
    .portal-messages-app .dm-compose .composer-highlight-input,
    body.social-messages .dm-compose textarea,
    body.social-messages .dm-compose .composer-highlight-input,
    .composer-textarea,
    .comment-textarea,
    #dmComposeInput,
    #dmEditInput,
    #postEditContent,
    .feed-composer textarea,
    .composer-modal textarea,
    .reply-modal textarea {
        color: #e7e9ea !important;
        -webkit-text-fill-color: #e7e9ea !important;
        caret-color: #e7e9ea !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    .composer-highlight-backdrop,
    .composer-highlight-wrap .composer-highlight-backdrop,
    body.portal-section-messages .composer-highlight-backdrop,
    .portal-messages-app .composer-highlight-backdrop {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    /* When highlight wrap remains, give the field its own pill background */
    body.portal-section-messages .dm-compose .composer-highlight-wrap textarea,
    .portal-messages-app .dm-compose .composer-highlight-wrap textarea,
    .composer-highlight-wrap > textarea {
        background: #16181c !important;
        color: #e7e9ea !important;
        -webkit-text-fill-color: #e7e9ea !important;
    }
    body.portal-section-messages .dm-compose textarea::placeholder,
    body.portal-section-messages .dm-compose .composer-highlight-input::placeholder,
    .portal-messages-app .dm-compose textarea::placeholder,
    .composer-highlight-input::placeholder,
    textarea.composer-highlight-input::placeholder {
        color: #71767b !important;
        -webkit-text-fill-color: #71767b !important;
        opacity: 1 !important;
    }
}
/* Desktop-only: transparent text for highlight overlay */
@media (min-width: 1101px) and (hover: hover) {
    textarea.composer-highlight-input.composer-highlight-input {
        /* keep existing transparent overlay on real desktop */
    }
}
/* ========== /mobile text visible 20260727-mobvis1 ========== */

/* ========== dm edit modal visible text 20260727-editedit1 ========== */
/* Edit message popup must NEVER use transparent highlight text */
#dmEditModal .dm-edit-textarea,
#dmEditModal textarea,
#dmEditInput,
textarea#dmEditInput,
textarea.dm-edit-textarea,
.dm-edit-modal .dm-edit-textarea,
.dm-edit-modal textarea,
.dm-edit-sheet .dm-edit-textarea,
.dm-edit-panel .dm-edit-textarea {
    color: #e7e9ea !important;
    -webkit-text-fill-color: #e7e9ea !important;
    caret-color: #e7e9ea !important;
    background: #000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    -webkit-opacity: 1 !important;
}
#dmEditModal .dm-edit-textarea::placeholder,
#dmEditInput::placeholder,
textarea.dm-edit-textarea::placeholder {
    color: #71767b !important;
    -webkit-text-fill-color: #71767b !important;
    opacity: 1 !important;
}
/* If highlight wrap was incorrectly applied inside edit modal, kill it */
#dmEditModal .composer-highlight-backdrop,
.dm-edit-modal .composer-highlight-backdrop,
#dmEditModal .composer-highlight-wrap .composer-highlight-backdrop {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}
#dmEditModal .composer-highlight-input,
#dmEditModal textarea.composer-highlight-input,
#dmEditModal .composer-highlight-wrap textarea {
    color: #e7e9ea !important;
    -webkit-text-fill-color: #e7e9ea !important;
    caret-color: #e7e9ea !important;
    background: #000 !important;
}
#dmEditModal .composer-highlight-wrap {
    background: #000 !important;
}
/* ========== /dm edit modal visible text 20260727-editedit1 ========== */

/* ========== dm paste media preview 20260727-dmpaste1 ========== */
/* Override old media-tag-only hide — pasted/attached media must show a real thumb */
body.portal-section-messages .dm-compose .media-preview.composer-media-preview,
body.portal-section-messages .dm-compose .composer-media-preview,
.portal-messages-app .dm-compose .media-preview.composer-media-preview,
.portal-messages-app .dm-compose .composer-media-preview,
body.social-messages .dm-compose .media-preview.composer-media-preview,
body.social-messages .dm-compose .composer-media-preview {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 8px 0 0 !important;
    padding: 8px 10px !important;
    border-radius: 14px !important;
    border: 1px solid #2f3336 !important;
    background: #16181c !important;
    outline: none !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 72px !important;
    height: auto !important;
    overflow: visible !important;
}
body.portal-section-messages .dm-compose .composer-media-thumb-wrap,
.portal-messages-app .dm-compose .composer-media-thumb-wrap {
    position: relative !important;
    width: 72px !important;
    height: 72px !important;
    min-width: 72px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    flex: 0 0 72px !important;
    background: #0a0a0a !important;
    display: block !important;
}
body.portal-section-messages .dm-compose .composer-media-thumb,
.portal-messages-app .dm-compose .composer-media-thumb {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
body.portal-section-messages .dm-compose .composer-media-meta,
.portal-messages-app .dm-compose .composer-media-meta {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #e7e9ea !important;
    font-weight: 700 !important;
    font-size: 13px !important;
}
body.portal-section-messages .dm-compose .composer-media-chip-clear,
body.portal-section-messages .dm-compose .media-preview-remove,
.portal-messages-app .dm-compose .composer-media-chip-clear {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: rgba(255,255,255,.1) !important;
    color: #e7e9ea !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    min-height: 32px !important;
    padding: 0 12px !important;
    cursor: pointer !important;
}
body.portal-section-messages .dm-compose .composer-media-slot.dm-media-slot:not(:empty),
.portal-messages-app .dm-compose .composer-media-slot.dm-media-slot:not(:empty) {
    display: block !important;
    margin: 0 0 6px !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    outline: none !important;
}
/* Don't draw empty blue outline when media is attached */
body.portal-section-messages .dm-compose.composer-has-media .composer-media-slot,
body.portal-section-messages .dm-compose .composer-has-media .composer-media-slot,
.portal-messages-app .dm-compose.composer-has-media .composer-media-slot {
    outline: none !important;
}
/* ========== /dm paste media preview 20260727-dmpaste1 ========== */


/* Premium strip + section must never be clipped */
.ted-premium-emote-strip {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  width: 100% !important;
  padding: 6px 4px 4px !important;
  margin: 0 0 4px !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid rgba(245, 197, 66, 0.25) !important;
}
.ted-premium-emote-strip-label {
  font-size: 11px !important;
  font-weight: 800 !important;
  color: #f5c542 !important;
}
.ted-premium-emote-strip-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
}
.ted-premium-emote-btn {
  width: 36px !important;
  height: 36px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,0.04) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 4px !important;
  cursor: pointer !important;
}
.ted-premium-emote-btn img {
  width: 28px !important;
  height: 28px !important;
  object-fit: contain !important;
  display: block !important;
}
