/* Desktop conversation reading layout. Load after the shared home/detail
 * styles so route transitions and docked navigation use the same column.
 * Keep the existing stage as the scroll owner for streaming and history. */
@media (min-width: 921px) {
    html:has(> body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:not(.chat-landing)):has(#ai-chat-model) {
        overflow: hidden !important;
        scrollbar-gutter: auto !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) {
        --chat-reading-navigation-width: var(--fuuvo-desktop-navigation-width, var(--fuuvo-workspace-rail-width, 72px));
        --chat-reading-column-width: min(860px, calc(100vw - var(--chat-reading-navigation-width) - 64px));
        --chat-reading-surface: #fff;
        overflow: hidden !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing):is([data-ui-theme="dark"], [data-theme="dark"]) {
        --chat-reading-surface: #171c24;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .workspace {
        background: var(--chat-reading-surface) !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .workspace > .stage,
    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        [data-fuuvo-app-shell="1"]:has(> nav#fuuvo-workspace-rail) .workspace[data-fuuvo-app-workspace="1"] > .stage {
        position: fixed !important;
        inset: 72px 0 0 var(--chat-reading-navigation-width) !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        scrollbar-gutter: stable both-edges !important;
        scroll-padding-block: 20px var(--chat-detail-content-clearance, 184px);
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        .stage :is(.result-card, #result-content, #chat-area) {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        .stage :is(.result-card, #result-content) {
        width: 100% !important;
        min-height: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .stage #chat-area {
        box-sizing: border-box !important;
        width: var(--chat-reading-column-width) !important;
        max-width: calc(100% - 48px) !important;
        margin: 0 auto !important;
        padding: 20px 0 var(--chat-detail-content-clearance, 184px) !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-thread {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        gap: 22px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) {
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-assistant-identity {
        margin-bottom: 8px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown {
        font-size: 16px !important;
        line-height: 1.65 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown p {
        margin: 0 0 10px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown :is(h1, h2, h3, h4, h5, h6) {
        margin: 20px 0 8px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown :is(ul, ol) {
        margin: 6px 0 12px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown li {
        line-height: 1.65 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown li + li {
        margin-top: 4px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown blockquote {
        margin: 12px 0 !important;
        padding: 8px 12px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown > :first-child {
        margin-top: 0 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-bubble:is(.assistant, .system) .chat-markdown > :last-child {
        margin-bottom: 0 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-answer-actions:not(:empty) {
        justify-content: flex-start !important;
        margin: 8px 0 0 !important;
        padding: 0 !important;
        gap: 4px !important;
        border: 0 !important;
        min-height: 32px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-answer-actions > button {
        width: 32px !important;
        min-width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        padding: 7px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-answer-actions .chat-speech-feedback {
        text-align: start !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .chat-thread .chat-bubble.assistant > .chat-reply-disclaimer {
        margin: 4px 0 0 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        .workspace > .composer:has(#chat-compose-field) {
        left: calc(50% + var(--chat-reading-navigation-width) / 2) !important;
        right: auto !important;
        width: var(--chat-reading-column-width) !important;
        max-width: none !important;
    }

    /* The stage reaches the right/bottom edges; an opaque lower surface keeps
     * scrolled text behind the composer instead of visible through its gaps. */
    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing) .workspace::after {
        content: "" !important;
        display: block !important;
        position: fixed !important;
        inset: auto 8px 0 var(--chat-reading-navigation-width) !important;
        width: auto !important;
        height: var(--chat-detail-content-clearance, 184px) !important;
        transform: none !important;
        opacity: 1 !important;
        background: linear-gradient(to bottom, transparent, var(--chat-reading-surface) 16px) !important;
        pointer-events: none !important;
        z-index: 3 !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        #chat-compose-field.has-chat-input > .chat-input-wrap {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        #chat-compose-field.has-chat-input > .chat-input-wrap:not(.has-attachments) {
        height: 114px !important;
        min-height: 114px !important;
        max-height: 114px !important;
        border-radius: 18px !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        #chat-compose-field.has-chat-input > .chat-input-wrap:not(.has-attachments) > #chat-input {
        height: 58px !important;
        min-height: 58px !important;
        max-height: 58px !important;
        padding: 12px 16px 4px !important;
        font-size: 15px !important;
        line-height: 1.5 !important;
        overflow-y: auto !important;
    }

    html body:is(.chat-detail-page, .chat-detail-open)[data-mode="chat"]:has(#ai-chat-model):not(.chat-landing)
        #chat-compose-field.has-chat-input > .chat-input-wrap:not(.has-attachments) .chat-input-tools {
        inset: auto 12px 7px !important;
    }
}
