/* BOSS's printed conversation shares one stylesheet across the page and its
   navigation/chat shadow roots. Screen presentation keeps its existing theme. */
@media print {
    @page {
        margin: 15mm;
    }

    /* Print colors override selected screen palettes, including custom skins. */
    :root,
    body,
    :host {
        --background: rgb(255, 255, 255) !important;
        --modal-background: rgb(255, 255, 255) !important;
        --text-color: rgb(20, 20, 20) !important;
        --accent-color: rgb(20, 20, 20) !important;
        --button-text-color: rgb(20, 20, 20) !important;
        --border-color: rgb(150, 150, 150) !important;
        --arcane-surface: rgb(255, 255, 255) !important;
        --arcane-surface-raised: rgb(255, 255, 255) !important;
        --arcane-surface-muted: rgb(255, 255, 255) !important;
        --arcane-border: rgb(150, 150, 150) !important;
        color-scheme: light;
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
        font-size: 11pt;
        line-height: 1.45;
    }

    /* Release every scrolling ancestor so the browser can paginate all turns. */
    html,
    body,
    main.contents,
    .nav,
    .chat,
    :host,
    .chat_area,
    .chat_output {
        display: block;
        position: static;
        box-sizing: border-box;
        width: auto;
        height: auto;
        min-width: 0;
        min-height: 0;
        max-width: none;
        max-height: none;
        margin: 0;
        padding: 0;
        overflow: visible;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* These IDs override the status and speech owners' screen display rules. */
    .header,
    .modal,
    #questionnaireModal,
    #uploadStatus,
    #aiStatus,
    #bossConversationEmail,
    #appBar,
    #supportModal,
    .chat_area > :not(.chat_output) {
        display: none !important;
    }

    /* The lifecycle remains printable while the active chat collapses it onscreen. */
    :host .lifecycle,
    :host([data-conversation-active]) .lifecycle {
        display: block;
        margin: 0 0 6mm;
        border: 0;
        border-bottom: 1pt solid rgb(20, 20, 20);
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
        box-shadow: none;
        opacity: 1;
        transform: none;
        transition: none;
        break-inside: avoid;
        break-after: avoid;
    }

    .lifecycle-inner {
        display: block;
        padding: 0 0 4mm;
        overflow: visible;
    }

    .lifecycle-summary {
        display: block;
        min-width: 0;
        margin-bottom: 3mm;
    }

    .lifecycle-summary span {
        margin-inline-end: 2mm;
        color: inherit;
        font-size: 9pt;
    }

    .lifecycle-summary strong {
        color: inherit;
        font-size: 11pt;
    }

    .lifecycle-stages {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 1.5mm;
        padding: 0;
        overflow: visible;
    }

    .lifecycle-stage {
        min-width: 0;
        padding: 2mm;
        border: 1pt solid rgb(150, 150, 150);
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
        font-size: 8pt;
        overflow-wrap: anywhere;
    }

    .lifecycle-stage[data-current="true"] {
        border: 2pt solid rgb(20, 20, 20);
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
        font-weight: 800;
    }

    .lifecycle-stage .lifecycle-stage-number,
    .lifecycle-stage[data-current="true"] .lifecycle-stage-number {
        color: inherit;
        font-size: 8pt;
    }

    .lifecycle-current {
        font-size: 7pt;
    }

    /* Source order becomes print order; even a single long turn can span pages. */
    .chat_area .chat_output {
        display: block !important;
        scrollbar-gutter: auto;
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
    }

    .chat_output > li,
    .chat_output > li:is(.ai, .user) {
        display: block;
        float: none;
        width: auto;
        max-width: none;
        max-inline-size: none;
        margin: 0 0 5mm;
        padding: 0 0 4mm;
        overflow: visible;
        border: 0;
        border-bottom: 0.5pt solid rgb(150, 150, 150);
        border-radius: 0;
        color: rgb(20, 20, 20);
        background: rgb(255, 255, 255);
        text-align: start;
        break-inside: auto;
        orphans: 3;
        widows: 3;
    }

    .chat_output * {
        color: inherit !important;
        text-shadow: none;
    }

    .chat_output .message_header,
    .chat_output :is(h1, h2, h3, h4, h5, h6) {
        break-after: avoid;
    }

    .chat_output .message_timestamp {
        opacity: 1;
        break-before: avoid;
    }

    .chat_output .message_tool_calls,
    .chat_output .message_tool_call,
    .chat_output .message_tool_details {
        display: block;
        overflow: visible;
        break-inside: auto;
    }

    .chat_output pre,
    .chat_output pre code {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        overflow: visible;
        break-inside: auto;
    }

    .chat_output table {
        table-layout: fixed;
        break-inside: auto;
    }

    .chat_output thead {
        display: table-header-group;
    }

    .chat_output img,
    .chat_output svg {
        max-width: 100%;
        height: auto;
    }

    .chat_output a {
        text-decoration: underline;
        overflow-wrap: anywhere;
    }
}
