/* NOTE: MwChat component styles
   Prefix: mw-chat-*
   Loaded via Assets["mw-chat.css"] in App.razor
   Aesthetic: refined industrial — clean dark surfaces, subtle depth, precise spacing */

/* NOTE: Page-level layout */
.mw-chat-page {
    display: flex;
    height: calc(100vh - var(--mud-appbar-height));
    background: var(--mud-palette-background);
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════
   NOTE: Sidebar
   ═══════════════════════════════════════════════════ */
.mw-chat-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--mud-palette-surface) 60%, transparent);
    border-right: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 50%, transparent);
}

.mw-chat-sidebar-header {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.mw-chat-sidebar-search {
    position: relative;
}

.mw-chat-sidebar-search .mud-input-outlined .mud-input-outlined-border {
    border-color: color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent) !important;
    border-radius: 10px;
}

.mw-chat-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.mw-chat-sidebar-list::-webkit-scrollbar {
    width: 4px;
}

.mw-chat-sidebar-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 30%, transparent);
    border-radius: 2px;
}

.mw-chat-sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 24px;
    text-align: center;
    opacity: 0.5;
}

/* NOTE: Conversation list items */
.mw-chat-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.15s ease;
    position: relative;
    margin-bottom: 2px;
    border: none;
}

.mw-chat-list-item:hover {
    background: color-mix(in srgb, var(--mud-palette-action-default-hover) 80%, transparent);
}

.mw-chat-list-item--active {
    background: color-mix(in srgb, var(--mud-palette-primary) 15%, transparent);
    box-shadow: inset 3px 0 0 var(--mud-palette-primary);
}

.mw-chat-list-item--active:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 20%, transparent);
}

.mw-chat-list-item-content {
    flex: 1;
    min-width: 0;
}

.mw-chat-list-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.mw-chat-list-item-preview {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mw-chat-list-item-time {
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

/* NOTE: Delete button — appears on hover */
.mw-chat-list-item-delete {
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.mw-chat-list-item:hover .mw-chat-list-item-delete {
    opacity: 0.6;
}

.mw-chat-list-item-delete:hover {
    opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════
   NOTE: Chat area
   ═══════════════════════════════════════════════════ */
.mw-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* NOTE: Root container (legacy, kept for compatibility) */
.mw-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* NOTE: Standard embed frame — the ONE chrome for placing an inline <MwChat/> on a content
   page (bounded height + flex column so the chat's flex: 1; min-height: 0 fills it). Add
   page-specific layout (margins, flex-shrink, grid placement) via a second host class, never
   a competing frame. Surfaces that already bring their own frame (Messages page pane,
   Artist Büro .mw-ab-panel, floating MwWindow) embed the bare component instead. */
.mw-chat-panel {
    display: flex;
    flex-direction: column;
    height: 420px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    overflow: hidden;
}

/* NOTE: Header bar */
.mw-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 50%, transparent);
    flex-shrink: 0;
    backdrop-filter: blur(12px);
    z-index: 1;
}

.mw-chat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* NOTE: Context window indicator */
.mw-chat-ctx-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: default;
}

.mw-chat-ctx-label {
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* NOTE: Scrollable message area */
.mw-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mw-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.mw-chat-messages::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 20%, transparent);
    border-radius: 3px;
}

/* ═══════════════════════════════════════════════════
   NOTE: MwChatBubble message rows (mw-chat-msg-*) — "Stil 09" from
   docs/mockups/chat-message-styles.html: meta line (name · MwChatSenderChip · mono time)
   ABOVE the bubble instead of inside it, flat 14px bubble with a 4px tail corner, and a
   surface-colored border gradient standing on the tail side + bottom edge only. Own
   messages stay fully annotated. The legacy .mw-chat-bubble* rules further down are kept
   for ChatPage.razor's bespoke AI-chat markup only, until it is assimilated onto MwChat.
   ═══════════════════════════════════════════════════ */

/* NOTE: Flex column so message rows can align-self left/right — added alongside the shared
   .mw-chat-messages scroll class (which ChatPage's bespoke list also uses, so that one
   keeps its legacy block layout). */
.mw-chat-msglist {
    display: flex;
    flex-direction: column;
}

/* NOTE: Never let the fixed-height flex column compress message rows (media bubbles would
   squash before the list starts scrolling). */
.mw-chat-msglist > * {
    flex-shrink: 0;
}

/* NOTE: Surface color categories — derived from ChatMsg.SentFromLabel's prefix by
   MwChatSenderChip.GetSurfaceClass. --mw-chat-rail drives the chip colors and, on the
   .mw-chat-msg root, the incoming bubble's edge gradient + bloom. Default: transparent
   rail (plain hairline bubble — DMs and label-less rooms). */
.mw-chat-surface--office  { --mw-chat-rail: hsl(263 90% 70%); }
.mw-chat-surface--care    { --mw-chat-rail: hsl(172 62% 55%); }
.mw-chat-surface--driver  { --mw-chat-rail: hsl(38 92% 64%); }
.mw-chat-surface--neutral { --mw-chat-rail: var(--mud-palette-text-secondary); }

.mw-chat-msg {
    --mw-chat-rail: transparent;
    --mw-chat-hairline: color-mix(in srgb, var(--mud-palette-lines-default) 50%, transparent);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    align-self: flex-start;
    max-width: 84%;
    margin-bottom: 12px;
    animation: mw-chat-bubble-in 0.2s ease-out;
}

/* NOTE: The surface class must re-declare the rail AFTER the root default above wins the
   cascade (both sit on the same element). */
.mw-chat-msg.mw-chat-surface--office  { --mw-chat-rail: hsl(263 90% 70%); }
.mw-chat-msg.mw-chat-surface--care    { --mw-chat-rail: hsl(172 62% 55%); }
.mw-chat-msg.mw-chat-surface--driver  { --mw-chat-rail: hsl(38 92% 64%); }
.mw-chat-msg.mw-chat-surface--neutral { --mw-chat-rail: var(--mud-palette-text-secondary); }

.mw-chat-msg--out {
    align-self: flex-end;
    align-items: flex-end;
}

.mw-chat-msg--grouped { margin-top: -8px; }

.mw-chat-msg--system {
    align-self: center;
    align-items: center;
    max-width: 85%;
}

/* NOTE: Meta line — name · chip · time above the bubble (row-reversed for own messages),
   hidden on grouped continuations; their time moves below the bubble instead. */
.mw-chat-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.mw-chat-msg--out .mw-chat-msg-meta { flex-direction: row-reverse; }

.mw-chat-msg-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--mud-palette-text-primary) 85%, transparent);
}

.mw-chat-msg-time,
.mw-chat-msg-grouptime {
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
    font-size: 0.6rem;
    color: var(--mud-palette-text-disabled);
    font-variant-numeric: tabular-nums;
}

.mw-chat-msg-grouptime {
    font-size: 0.55rem;
    margin-top: 3px;
    padding: 0 4px;
}

/* NOTE: The bubble. Edge glow anchored at the LOWER tail corner: a radial gradient whose
   reach is sized so it climbs the tail side and runs along the bottom edge, but is fully
   faded before the top — the top border stays plain hairline. (A diagonal linear gradient
   can't do this on a wide flat bubble: its axis is dominated by the width, so the top edge
   keeps catching color.) Double background: fill on padding-box, gradient + hairline on
   border-box behind the transparent border. */
.mw-chat-msg-bubble {
    position: relative;
    overflow: hidden;
    width: fit-content;
    max-width: 100%;
    border-radius: 14px;
    border-top-left-radius: 4px;
    border: 1.5px solid transparent;
    background:
        linear-gradient(var(--mud-palette-surface), var(--mud-palette-surface)) padding-box,
        radial-gradient(135% 125% at 0% 100%,
            color-mix(in srgb, var(--mw-chat-rail) 80%, transparent) 0%,
            color-mix(in srgb, var(--mw-chat-rail) 45%, transparent) 40%,
            transparent 72%) border-box,
        linear-gradient(var(--mw-chat-hairline), var(--mw-chat-hairline)) border-box;
    box-shadow: -3px 2px 9px -8px color-mix(in srgb, var(--mw-chat-rail) 65%, transparent);
}

/* NOTE: Own messages — tail corner mirrored to the right, quiet primary wash (~7%) over the
   surface fill, edge gradient + bloom always in the primary color (the chip still shows the
   actual surface). Keep the bloom faint. */
.mw-chat-msg--out .mw-chat-msg-bubble {
    border-radius: 14px;
    border-top-right-radius: 4px;
    background:
        linear-gradient(
            color-mix(in srgb, var(--mud-palette-primary) 7%, transparent),
            color-mix(in srgb, var(--mud-palette-primary) 7%, transparent)) padding-box,
        linear-gradient(var(--mud-palette-surface), var(--mud-palette-surface)) padding-box,
        radial-gradient(135% 125% at 100% 100%,
            color-mix(in srgb, var(--mud-palette-primary) 75%, transparent) 0%,
            color-mix(in srgb, var(--mud-palette-primary) 42%, transparent) 40%,
            transparent 72%) border-box,
        linear-gradient(var(--mw-chat-hairline), var(--mw-chat-hairline)) border-box;
    box-shadow: 3px 2px 9px -8px color-mix(in srgb, var(--mud-palette-primary) 65%, transparent);
}

.mw-chat-msg--system .mw-chat-msg-bubble {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--mud-palette-text-secondary);
    font-style: italic;
}

/* NOTE: Content inside the bubble */
.mw-chat-msg-content {
    padding: 9px 13px;
    font-size: 0.875rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.mw-chat-msg-content .mud-typography {
    font-size: inherit;
    line-height: inherit;
}

.mw-chat-msg-content--media { padding: 4px; }

/* NOTE: Sender-surface chip (MwChatSenderChip) — mono micro-pill in the surface color;
   rendered only for messages with a SentFromLabel (purpose-bound rooms). */
.mw-chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    color: var(--mw-chat-rail, var(--mud-palette-text-secondary));
    background: color-mix(in srgb, var(--mw-chat-rail, var(--mud-palette-text-secondary)) 13%, transparent);
    border: 1px solid color-mix(in srgb, var(--mw-chat-rail, var(--mud-palette-text-secondary)) 35%, transparent);
}

.mw-chat-chip-dot {
    flex-shrink: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--mw-chat-rail, var(--mud-palette-text-secondary));
}

/* NOTE: Individual bubble wrapper (LEGACY — ChatPage.razor's bespoke AI markup only; MwChatBubble
   renders mw-chat-msg-* above) */
.mw-chat-bubble {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    margin-bottom: 2px;
    animation: mw-chat-bubble-in 0.2s ease-out;
}

@keyframes mw-chat-bubble-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mw-chat-bubble--incoming {
    align-self: flex-start;
}

.mw-chat-bubble--outgoing {
    align-self: flex-end;
}

.mw-chat-bubble--system {
    align-self: center;
    max-width: 85%;
}

/* NOTE: Bubble content area */
.mw-chat-bubble-content {
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
    font-size: 0.9rem;
}

.mw-chat-bubble--incoming .mw-chat-bubble-content {
    background: var(--mud-palette-surface);
    border-bottom-left-radius: 4px;
}

.mw-chat-bubble--outgoing .mw-chat-bubble-content {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 4px;
}

.mw-chat-bubble--system .mw-chat-bubble-content {
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font-style: italic;
    text-align: center;
    padding: 4px 8px;
    font-size: 0.8rem;
}

/* NOTE: Sanitized Markdown rendered inside chat bubbles */
.mw-chat-markdown {
    white-space: normal;
}

.mw-chat-markdown > :first-child {
    margin-top: 0;
}

.mw-chat-markdown > :last-child {
    margin-bottom: 0;
}

.mw-chat-markdown h1,
.mw-chat-markdown h2,
.mw-chat-markdown h3,
.mw-chat-markdown h4,
.mw-chat-markdown h5,
.mw-chat-markdown h6 {
    margin: 0.65rem 0 0.35rem;
    font-size: 0.95rem;
    line-height: 1.3;
    font-weight: 700;
}

.mw-chat-markdown p {
    margin: 0.35rem 0;
}

.mw-chat-markdown ul,
.mw-chat-markdown ol {
    margin: 0.35rem 0;
    padding-left: 1.25rem;
}

.mw-chat-markdown li {
    margin: 0.2rem 0;
}

.mw-chat-markdown a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mw-chat-markdown code {
    font-size: 0.85em;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
    background: color-mix(in srgb, currentColor 10%, transparent);
}

.mw-chat-markdown pre {
    overflow-x: auto;
    padding: 0.6rem;
    border-radius: 8px;
    background: color-mix(in srgb, currentColor 8%, transparent);
}

/* NOTE: Wiki RAG source excerpts */
.mw-chat-wiki-sources {
    margin-top: 0.7rem;
}

.mw-chat-wiki-sources .mud-expand-panel {
    background: color-mix(in srgb, currentColor 5%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
    border-radius: 8px;
    box-shadow: none;
    overflow: hidden;
}

.mw-chat-wiki-sources .mud-expand-panel-header {
    min-height: 36px;
    padding: 0.35rem 0.55rem;
}

.mw-chat-wiki-source-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    font-size: 0.78rem;
    font-weight: 600;
}

.mw-chat-wiki-source-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mw-chat-wiki-source-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0 0.65rem 0.65rem;
}

.mw-chat-wiki-source-excerpt {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.65rem;
    border-radius: 6px;
    background: color-mix(in srgb, currentColor 6%, transparent);
    white-space: pre-wrap;
    font-size: 0.78rem;
    line-height: 1.45;
}

.mw-chat-wiki-source-link {
    align-self: flex-start;
    border-radius: 8px;
    text-transform: none;
}

/* NOTE: Timestamp + status line */
.mw-chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px 0;
    opacity: 0.6;
}

.mw-chat-bubble--incoming .mw-chat-bubble-meta {
    justify-content: flex-start;
}

.mw-chat-bubble--outgoing .mw-chat-bubble-meta {
    justify-content: flex-end;
}

/* NOTE: Reasoning/thinking toggle */
.mw-chat-reasoning {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px 2px;
    cursor: pointer;
}

.mw-chat-reasoning:hover {
    opacity: 0.8;
}

.mw-chat-reasoning-content {
    padding: 4px 14px 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 30%, transparent);
    margin-bottom: 2px;
    max-height: 300px;
    overflow-y: auto;
}

/* NOTE: Mic recording pulse animation */
.mw-chat-mic-recording {
    animation: mw-chat-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mw-chat-mic-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* NOTE: Failed/stale message indicator */
.mw-chat-bubble-failed {
    padding: 8px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    background: color-mix(in srgb, var(--mud-palette-error) 10%, var(--mud-palette-surface));
    border: 1px solid color-mix(in srgb, var(--mud-palette-error) 25%, transparent);
    font-size: 0.82rem;
    color: var(--mud-palette-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* NOTE: Action proposal card */
.mw-chat-action {
    border: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 60%, transparent);
    border-radius: 14px;
    padding: 16px;
    min-width: 280px;
    background: color-mix(in srgb, var(--mud-palette-surface) 80%, transparent);
    backdrop-filter: blur(8px);
}

.mw-chat-action-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.mw-chat-action-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--mud-palette-background) 50%, transparent);
    border-radius: 8px;
}

.mw-chat-action-param {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
}

.mw-chat-action-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* NOTE: Text input area (sticky bottom) */
.mw-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 24px 16px;
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent);
    flex-shrink: 0;
    background: color-mix(in srgb, var(--mud-palette-surface) 30%, transparent);
    backdrop-filter: blur(12px);
}

.mw-chat-input > *:first-child {
    flex: 1;
}

.mw-chat-input .mud-input-outlined .mud-input-outlined-border {
    border-radius: 14px;
    border-color: color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent) !important;
}

.mw-chat-input .mud-input-outlined:focus-within .mud-input-outlined-border {
    border-color: var(--mud-palette-primary) !important;
}

/* NOTE: Composer variant of the input row — attach button + growing text field + send.
   The generic .mw-chat-input > *:first-child { flex: 1 } rule (kept for ChatPage) is
   overridden here so the leading attach button keeps its natural size. */
.mw-chat-input--composer > *:first-child {
    flex: 0 0 auto;
}

.mw-chat-input--composer .mw-chat-input-field {
    flex: 1;
}

.mw-chat-input--composer .mw-chat-attach {
    margin-top: 0;
    align-self: flex-end;
}

/* NOTE: Pending-attachment strip above the composer (uploaded, not yet sent) */
.mw-chat-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-top: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent);
    background: color-mix(in srgb, var(--mud-palette-surface) 30%, transparent);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.mw-chat-pending-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: color-mix(in srgb, var(--mud-palette-surface) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 50%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mw-chat-pending-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mw-chat-pending-remove {
    position: absolute !important;
    top: 0;
    right: 0;
    padding: 2px !important;
    background: color-mix(in srgb, var(--mud-palette-background) 70%, transparent) !important;
    border-radius: 0 0 0 8px !important;
}

/* NOTE: Drag-over highlight while an image drag hovers over the chat (mw-chat-paste module) */
.mw-chat--dragover {
    outline: 2px dashed var(--mud-palette-primary);
    outline-offset: -6px;
    border-radius: 12px;
}

/* NOTE: Media (image) message bubbles */
.mw-chat-bubble-content--media {
    padding: 4px;
    overflow: hidden;
}

.mw-chat-media {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mw-chat-media--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}

.mw-chat-media-img {
    display: block;
    width: 100%;
    max-width: 360px;
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    cursor: zoom-in;
    transition: filter 0.15s ease;
}

.mw-chat-media-img:hover {
    filter: brightness(1.08);
}

.mw-chat-media--grid .mw-chat-media-img {
    aspect-ratio: 1;
    max-height: 180px;
}

/* NOTE: Odd image count — first image spans the full grid width */
.mw-chat-media--grid .mw-chat-media-img:first-child:nth-last-child(odd) {
    grid-column: 1 / -1;
    aspect-ratio: auto;
}

.mw-chat-media-caption {
    padding: 6px 10px 4px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* NOTE: Typing indicator (animated dots) */
.mw-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--mud-palette-surface);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.mw-chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mud-palette-text-secondary);
    animation: mw-chat-typing-bounce 1.4s ease-in-out infinite;
}

.mw-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.mw-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mw-chat-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-5px);
        opacity: 0.8;
    }
}

/* NOTE: Empty state — no conversation selected */
.mw-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0.4;
    user-select: none;
}

.mw-chat-empty-icon {
    font-size: 64px;
    opacity: 0.3;
    animation: mw-chat-empty-float 4s ease-in-out infinite;
}

@keyframes mw-chat-empty-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* NOTE: Date separator line */
.mw-chat-date-sep {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 16px 0 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.mw-chat-date-sep::before,
.mw-chat-date-sep::after {
    content: "";
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent);
}

/* NOTE: Unread count badge */
.mw-chat-unread-badge {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* NOTE: Responsive */
@media (max-width: 768px) {
    .mw-chat-sidebar {
        width: 260px;
    }

    .mw-chat-bubble {
        max-width: 85%;
    }
}

@media (max-width: 600px) {
    .mw-chat-sidebar {
        display: none;
    }
}
