/* X Chat surface. Loaded after twitter.css so these rules replace the old
   gradient / frosted Material presentation without changing DM behavior. */
#twitter-page #twitter-dm-root {
    --x-dm-surface: #fff;
    --x-dm-text: #0f1419;
    --x-dm-muted: #536471;
    --x-dm-line: #eff3f4;
    --x-dm-soft: #eff3f4;
    --x-dm-hover: #f7f9f9;
    --x-dm-blue: #1d9bf0;
    background: var(--x-dm-surface) !important;
    color: var(--x-dm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

#twitter-page #twitter-dm-root[data-dm-chat-overlay="on"] {
    --twitter-dm-status-slot: calc(max(12px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) + 32px);
    top: var(--twitter-dm-status-slot);
    height: calc(100% - var(--twitter-dm-status-slot));
    min-height: 0;
    background: var(--x-dm-surface) !important;
}

html.lovemi-statusbar-hidden #twitter-page #twitter-dm-root[data-dm-chat-overlay="on"] {
    --twitter-dm-status-slot: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
}

/* The live phone status bar sits above the chat overlay. Its safe inset is
   already consumed there, so the chat toolbar needs only its normal padding. */
#twitter-page #twitter-dm-root[data-dm-chat-overlay="on"] .twitter-dm-chat-header,
#twitter-page #twitter-dm-root[data-dm-chat-overlay="on"] .twitter-dm-multiselect-topbar {
    padding-top: 8px !important;
}

#twitter-page.twitter-page--dm-inbox #twitter-fab-compose {
    display: none !important;
}

#twitter-page #twitter-dm-root [hidden] {
    display: none !important;
}

/* Inbox: search, functional filters, followed accounts, conversation rows. */
#twitter-page #twitter-dm-root .twitter-dm-list-view {
    background: var(--x-dm-surface);
    overscroll-behavior-y: contain;
    padding-bottom: 78px;
    box-sizing: border-box;
}

#twitter-page #twitter-dm-root .twitter-dm-new-chat {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--x-dm-blue);
    color: #fff;
    box-shadow: 0 6px 18px rgba(29, 155, 240, .26);
    cursor: pointer;
}

#twitter-page #twitter-dm-root .twitter-dm-new-chat:hover {
    background: #1a8cd8;
}

#twitter-page #twitter-dm-root .twitter-dm-new-chat:focus-visible {
    outline: 2px solid var(--x-dm-text);
    outline-offset: 3px;
}

#twitter-page #twitter-dm-root .twitter-dm-new-chat svg {
    width: 25px;
    height: 25px;
}

#twitter-page #twitter-dm-root .twitter-dm-search-wrap {
    height: 42px;
    margin: 11px 16px 9px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--x-dm-soft);
    color: var(--x-dm-muted);
    transition: border-color .15s ease, background .15s ease;
}

#twitter-page #twitter-dm-root .twitter-dm-search-wrap:focus-within {
    border-color: var(--x-dm-blue);
    background: var(--x-dm-surface);
    color: var(--x-dm-blue);
}

#twitter-page #twitter-dm-root .twitter-dm-search-wrap svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

#twitter-page #twitter-dm-root .twitter-dm-search-input {
    width: 100%;
    min-width: 0;
    border: 0 !important;
    outline: 0;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--x-dm-text) !important;
    box-shadow: none !important;
    font: inherit;
    font-size: 16px;
    line-height: 1.3;
    -webkit-appearance: none;
    appearance: none;
}

#twitter-page #twitter-dm-root .twitter-dm-search-input::placeholder {
    color: var(--x-dm-muted);
    opacity: 1;
}

#twitter-page #twitter-dm-root .twitter-dm-search-input:focus {
    border: 0 !important;
    box-shadow: none !important;
}

#twitter-page #twitter-dm-root .twitter-dm-inbox-filters {
    display: flex;
    padding: 0 16px;
    border-bottom: 1px solid var(--x-dm-line);
}

#twitter-page #twitter-dm-root .twitter-dm-inbox-filter {
    position: relative;
    min-width: 72px;
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--x-dm-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

#twitter-page #twitter-dm-root .twitter-dm-inbox-filter[aria-pressed="true"] {
    color: var(--x-dm-text);
    font-weight: 700;
}

#twitter-page #twitter-dm-root .twitter-dm-inbox-filter[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 4px;
    border-radius: 999px;
    background: var(--x-dm-blue);
}

#twitter-page #twitter-dm-root .twitter-dm-inbox-filter:focus-visible,
#twitter-page #twitter-dm-root .twitter-dm-follow-item:focus-visible,
#twitter-page #twitter-dm-root .twitter-dm-conv-item:focus-visible {
    outline: 2px solid var(--x-dm-blue);
    outline-offset: -2px;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-strip {
    margin: 0;
    padding: 17px 0 14px;
    border-bottom: 1px solid var(--x-dm-line);
    background: var(--x-dm-surface);
}

#twitter-page #twitter-dm-root .twitter-dm-follow-strip-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 16px 13px;
    color: var(--x-dm-text);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-strip-title span {
    color: var(--x-dm-muted);
    font-size: 12px;
    font-weight: 400;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-strip-scroll {
    gap: 12px;
    padding: 0 16px 2px;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-item {
    width: 58px;
    gap: 5px;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-item-avatar {
    width: 52px;
    height: 52px;
    background-color: #cfd9de;
    background-image: none;
    color: #0f1419;
    font-size: 20px;
    box-shadow: none;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-item-avatar.has-unread {
    box-shadow: 0 0 0 2px var(--x-dm-blue);
}

#twitter-page #twitter-dm-root .twitter-dm-follow-item-avatar.has-unread::after {
    display: none;
}

#twitter-page #twitter-dm-root .twitter-dm-follow-item-name {
    color: var(--x-dm-text);
    font-size: 12px;
    line-height: 1.25;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-list {
    margin: 0;
    padding: 0;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-item {
    min-height: 74px;
    padding: 11px 16px;
    gap: 11px;
    align-items: flex-start;
    border-bottom: 1px solid var(--x-dm-line);
    background: var(--x-dm-surface);
    box-sizing: border-box;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-item:hover,
#twitter-page #twitter-dm-root .twitter-dm-conv-item:focus-visible {
    background: var(--x-dm-hover);
}

#twitter-page #twitter-dm-root .twitter-dm-conv-avatar {
    width: 48px;
    height: 48px;
    background-color: #cfd9de;
    background-image: none;
    color: #0f1419;
    font-size: 19px;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-body {
    padding-top: 2px;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-name-row {
    justify-content: flex-start;
    gap: 4px;
    min-width: 0;
    align-items: baseline;
    white-space: nowrap;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-name {
    flex: 0 1 auto;
    color: var(--x-dm-text);
    font-size: 15px;
    font-weight: 700;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-handle {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--x-dm-muted);
    font-size: 13px;
    font-weight: 400;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-time {
    flex: 0 0 auto;
    color: var(--x-dm-muted);
    font-size: 12px;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-preview {
    margin-top: 3px;
    color: var(--x-dm-muted);
    font-size: 13px;
    line-height: 1.35;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-item.is-unread .twitter-dm-conv-preview {
    color: var(--x-dm-text);
    font-weight: 600;
}

#twitter-page #twitter-dm-root .twitter-dm-conv-unread {
    width: 8px;
    min-width: 8px;
    height: 8px;
    padding: 0;
    margin: 21px 1px 0 0;
    border-radius: 50%;
    background: var(--x-dm-blue);
    font-size: 0;
}

#twitter-page #twitter-dm-root .twitter-dm-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

#twitter-page #twitter-dm-root .twitter-dm-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 56px 24px;
    color: var(--x-dm-muted);
    line-height: 1.45;
}

#twitter-page #twitter-dm-root .twitter-dm-list-empty svg {
    width: 36px;
    height: 36px;
    margin-bottom: 9px;
    color: var(--x-dm-text);
}

#twitter-page #twitter-dm-root .twitter-dm-list-empty strong {
    color: var(--x-dm-text);
    font-size: 18px;
    font-weight: 800;
}

#twitter-page #twitter-dm-root .twitter-dm-list-empty span {
    max-width: 240px;
    font-size: 13px;
}

/* Conversation: flat X header, day markers, neutral / blue message bubbles. */
#twitter-page #twitter-dm-root .twitter-dm-chat-view {
    background: var(--x-dm-surface);
}

#twitter-page #twitter-dm-root .twitter-dm-chat-header,
#twitter-page #twitter-dm-root .twitter-dm-multiselect-topbar {
    min-height: 56px;
    padding-right: 13px;
    padding-left: 9px;
    padding-bottom: 8px;
    background: var(--x-dm-surface);
    border-bottom: 1px solid var(--x-dm-line) !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-sizing: border-box;
}

#twitter-page #twitter-dm-root .twitter-dm-header-back,
#twitter-page #twitter-dm-root .twitter-dm-header-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--x-dm-text);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-page #twitter-dm-root .twitter-dm-header-back:hover,
#twitter-page #twitter-dm-root .twitter-dm-header-btn:hover {
    background: var(--x-dm-hover);
}

#twitter-page #twitter-dm-root .twitter-dm-header-back svg,
#twitter-page #twitter-dm-root .twitter-dm-header-back .twitter-dm-back-svg {
    width: 23px !important;
    height: 23px !important;
    min-width: 23px;
    min-height: 23px;
    color: var(--x-dm-text);
    stroke: var(--x-dm-text) !important;
}

#twitter-page #twitter-dm-root .twitter-dm-header-back .twitter-dm-back-glyph {
    color: var(--x-dm-text);
}

#twitter-page #twitter-dm-root .twitter-dm-chat-peer-info {
    gap: 9px;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-peer-avatar {
    width: 36px;
    height: 36px;
    background-color: #cfd9de;
    background-image: none;
    color: #0f1419;
    font-size: 15px;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-peer-meta {
    gap: 0;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-peer-name {
    color: var(--x-dm-text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-peer-handle {
    color: var(--x-dm-muted);
    font-size: 12px;
    line-height: 1.25;
}

#twitter-page #twitter-dm-root .twitter-dm-header-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-body {
    gap: 5px;
    padding: 13px 16px 18px;
    background: var(--x-dm-surface);
    overscroll-behavior-y: contain;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin: 22px 0 24px;
    text-align: center;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-intro-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 7px;
    border-radius: 50%;
    background-color: #cfd9de;
    background-position: center;
    background-size: cover;
    color: #0f1419;
    font-size: 24px;
    font-weight: 600;
    overflow: hidden;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-intro strong {
    color: var(--x-dm-text);
    font-size: 18px;
    font-weight: 800;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-intro span,
#twitter-page #twitter-dm-root .twitter-dm-chat-empty-note {
    color: var(--x-dm-muted);
    font-size: 13px;
}

#twitter-page #twitter-dm-root .twitter-dm-chat-empty-note {
    text-align: center;
}

#twitter-page #twitter-dm-root .twitter-dm-date-divider {
    flex: 0 0 auto;
    margin: 8px 0 11px;
    color: var(--x-dm-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

#twitter-page #twitter-dm-root .twitter-dm-msg {
    gap: 7px;
}

#twitter-page #twitter-dm-root .twitter-dm-msg-col {
    max-width: min(80%, 340px);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-sender {
    display: none;
}

#twitter-page #twitter-dm-root .twitter-dm-msg-bubble {
    padding: 9px 13px;
    border: 0 !important;
    border-radius: 20px;
    background: var(--x-dm-soft) !important;
    color: var(--x-dm-text);
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-size: 15px;
    line-height: 1.4;
}

#twitter-page #twitter-dm-root .twitter-dm-msg.from-user .twitter-dm-msg-bubble {
    border-bottom-right-radius: 5px;
    background: var(--x-dm-blue) !important;
    color: #fff;
}

#twitter-page #twitter-dm-root .twitter-dm-msg.from-peer .twitter-dm-msg-bubble {
    border-bottom-left-radius: 5px;
}

#twitter-page #twitter-dm-root .twitter-dm-msg.from-peer .twitter-dm-cn-translation {
    color: var(--x-dm-text);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-meta {
    margin-top: 3px;
    color: var(--x-dm-muted);
    font-size: 10px;
}

#twitter-page #twitter-dm-root .twitter-dm-msg.is-system .twitter-dm-msg-bubble {
    padding: 4px 8px;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    color: var(--x-dm-muted);
    font-size: 12px;
}

#twitter-page #twitter-dm-root .twitter-dm-msg-quoted {
    border-color: var(--x-dm-blue);
    background: var(--x-dm-soft);
    color: var(--x-dm-muted);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-quoted-name {
    color: var(--x-dm-text);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-forward-card,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-card,
#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card {
    border: 1px solid var(--x-dm-line);
    border-radius: 12px;
    background: var(--x-dm-surface);
    color: var(--x-dm-text);
    box-shadow: none;
}

#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

#twitter-page #twitter-dm-root .twitter-dm-msg-merged-kicker,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-summary,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-expand,
#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card-time,
#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card-handle {
    color: var(--x-dm-muted);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-merged-title,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-item-sender,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-item-content,
#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card-name,
#twitter-page #twitter-dm-root .twitter-dm-msg-twitter-card-text {
    color: var(--x-dm-text);
}

#twitter-page #twitter-dm-root .twitter-dm-msg-merged-count,
#twitter-page #twitter-dm-root .twitter-dm-msg-merged-item {
    border-color: var(--x-dm-line);
    background: var(--x-dm-soft);
    color: var(--x-dm-muted);
}

#twitter-page #twitter-dm-root .twitter-dm-composer {
    gap: 7px;
    padding-top: 8px;
    padding-right: 12px;
    padding-left: 12px;
    background: var(--x-dm-surface);
    border-top: 1px solid var(--x-dm-line) !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--x-dm-blue);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-btn:hover {
    background: rgba(29, 155, 240, .1);
}

#twitter-page #twitter-dm-root .twitter-dm-composer-btn svg {
    width: 21px;
    height: 21px;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-input-wrap {
    min-height: 38px;
    padding: 5px 13px;
    border: 1px solid #cfd9de;
    border-radius: 22px;
    background: var(--x-dm-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-input {
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--x-dm-text) !important;
    box-shadow: none !important;
    font-size: 16px;
    line-height: 1.4;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-input:focus {
    border: 0 !important;
    box-shadow: none !important;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-input::placeholder {
    color: var(--x-dm-muted);
}

#twitter-page #twitter-dm-root[data-dm-editing-id] .twitter-dm-composer-input-wrap {
    border-color: var(--x-dm-blue);
}

#twitter-page #twitter-dm-root .twitter-dm-composer-send {
    width: 36px;
    height: 36px;
    margin-bottom: 1px;
    background: var(--x-dm-blue) !important;
    color: #fff;
    box-shadow: none !important;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-send[disabled] {
    opacity: .4;
}

#twitter-page #twitter-dm-root .twitter-dm-composer-send:hover:not([disabled]) {
    background: #1a8cd8 !important;
}

#twitter-page #twitter-dm-root .twitter-dm-emoji-panel,
#twitter-page #twitter-dm-root .twitter-dm-quote-bar,
#twitter-page #twitter-dm-root .twitter-dm-edit-bar,
#twitter-page #twitter-dm-root .twitter-dm-multiselect-bar {
    background: var(--x-dm-surface);
    color: var(--x-dm-text);
    border-color: var(--x-dm-line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-page #twitter-dm-root .twitter-dm-emoji-item {
    background: var(--x-dm-soft);
    border-color: var(--x-dm-line);
}

#twitter-dm-context-menu {
    border: 1px solid #eff3f4 !important;
    border-radius: 13px;
    background: #fff !important;
    color: #0f1419;
    box-shadow: 0 8px 28px rgba(15, 20, 25, .16);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#twitter-dm-context-menu .twitter-dm-context-menu-item {
    color: #0f1419;
}

#twitter-dm-context-menu .twitter-dm-context-menu-item:hover {
    background: #eff3f4;
}

/* X's dark palette keeps the same spacing and blue accent. */
html[data-appearance="dark"] #twitter-page #twitter-dm-root {
    --x-dm-surface: #000;
    --x-dm-text: #e7e9ea;
    --x-dm-muted: #71767b;
    --x-dm-line: #2f3336;
    --x-dm-soft: #202327;
    --x-dm-hover: #080808;
    --x-dm-blue: #1d9bf0;
}

html[data-appearance="dark"] #twitter-page #twitter-dm-root .twitter-dm-follow-item-avatar,
html[data-appearance="dark"] #twitter-page #twitter-dm-root .twitter-dm-conv-avatar,
html[data-appearance="dark"] #twitter-page #twitter-dm-root .twitter-dm-chat-peer-avatar,
html[data-appearance="dark"] #twitter-page #twitter-dm-root .twitter-dm-chat-intro-avatar {
    background-color: #333639;
    color: #e7e9ea;
}

html[data-appearance="dark"] #twitter-page #twitter-dm-root .twitter-dm-composer-input-wrap {
    border-color: #536471;
}

html[data-appearance="dark"] #twitter-dm-context-menu {
    border-color: #2f3336 !important;
    background: #16181c !important;
    color: #e7e9ea;
}

html[data-appearance="dark"] #twitter-dm-context-menu .twitter-dm-context-menu-item {
    color: #e7e9ea;
}

html[data-appearance="dark"] #twitter-dm-context-menu .twitter-dm-context-menu-item:hover {
    background: #202327;
}

@media (max-width: 350px) {
    #twitter-page #twitter-dm-root .twitter-dm-conv-item {
        padding-right: 12px;
        padding-left: 12px;
        gap: 9px;
    }

    #twitter-page #twitter-dm-root .twitter-dm-conv-avatar {
        width: 44px;
        height: 44px;
    }

    #twitter-page #twitter-dm-root .twitter-dm-conv-name-row {
        gap: 3px;
    }

    #twitter-page #twitter-dm-root .twitter-dm-conv-handle {
        display: none;
    }

    #twitter-page #twitter-dm-root .twitter-dm-msg-col {
        max-width: 86%;
    }
}
