.chat-container {
    background: #fff;   /* the page ground is grey (style.css); the chat bubbles are near-white */
    display: flex;
    height: calc(100vh - 120px);
    gap: 0;
}

.chat-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dee2e6;
}

.preview-pane {
    width: 50%;
    overflow-y: auto;
    padding: 1.5rem;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
}

/* Composer: textarea beside a fixed-size send button.
   Replaces the Bootstrap .input-group, which stretched the button to the full
   height of the textarea (158px with the old six-row default).

   Scoped to .chat-mobile-docked at every width, not just under the breakpoint.
   The Post a Listing page pulls this file in via listing-chat.css and still
   wraps its composer in an .input-group, so an unscoped `display: flex` and
   border-radius here would restyle a page this change is not meant to touch. */
.chat-mobile-docked .chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-mobile-docked .chat-input-area .form-control {
    flex: 1 1 auto;
    min-width: 0;
    resize: none;
    border-radius: 1.375rem;
    padding: 0.5625rem 1rem;   /* 9px: one 24px line + 18px + 2px border = 44px */
    line-height: 1.5;
}

/* Desktop floor: about two lines. Was six, which is the same mistake the
   mobile layout had, just less painful on a big screen. */
.chat-mobile-docked .chat-input-area #chat-input {
    min-height: 72px;
    max-height: 360px;
}

.chat-send-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Bootstrap's disabled state is the same blue at 65% opacity, which on a solid
   circle still reads as "tap me". Say it in the fill instead. */
.chat-send-btn:disabled,
.chat-send-btn.disabled {
    background-color: #ced4da;
    border-color: #ced4da;
    color: #6c757d;
    opacity: 1;
}

.chat-msg {
    margin-bottom: 1rem;
    max-width: 85%;
}

.chat-msg-user {
    white-space: pre-wrap;      /* the buyer's own line breaks (ERW PR #359) */
    overflow-wrap: anywhere;
    margin-left: auto;
    background: #0d6efd;
    color: white;
    border-radius: 1rem 1rem 0.25rem 1rem;
    padding: 0.75rem 1rem;
}

/* The page's own "[Timeline check]" turn (request-chat.js): on the buyer's
   side, because the model reads it as theirs, but plainly not typed by them. */
.chat-msg-user.chat-msg-auto {
    background: #e7f0fb;
    color: #1f3f6e;
    font-style: italic;
}

.chat-msg-assistant {
    background: #f8f9fa;
    border-radius: 1rem 1rem 1rem 0.25rem;
    padding: 0.75rem 1rem;
    overflow-wrap: anywhere;
}

/* Rendered by renderAssistantText (paragraphs, numbered and bulleted lines, bold). */
.chat-msg-assistant p,
.chat-msg-assistant ol,
.chat-msg-assistant ul { margin: 0 0 0.6rem; }
.chat-msg-assistant > :last-child { margin-bottom: 0; }
.chat-msg-assistant ol,
.chat-msg-assistant ul { padding-left: 1.4rem; }
.chat-msg-assistant li + li { margin-top: 0.35rem; }

.chat-msg-error {
    background: #f8d7da;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.typing-indicator {
    display: none;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 1rem;
    width: fit-content;
    margin-bottom: 1rem;
}

.typing-indicator.active {
    display: block;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #adb5bd;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

/* Preview pane */
.preview-field {
    margin-bottom: 1.25rem;
    border-left: 3px solid transparent;
}

.preview-field.just-updated {
    background-color: rgba(216, 48, 108, 0.12);
    border-left-color: #D8306C;
    border-radius: 0 0.375rem 0.375rem 0;
    animation: field-flash-fade 2s ease-out forwards;
}

@keyframes field-flash-fade {
    0%   { background-color: rgba(216, 48, 108, 0.12); border-left-color: #D8306C; }
    30%  { background-color: rgba(216, 48, 108, 0.12); border-left-color: #D8306C; }
    100% { background-color: rgba(216, 48, 108, 0);    border-left-color: transparent; }
}

.preview-field-updated-label {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #D8306C;
    letter-spacing: 0.04em;
    animation: ghost-label 2s ease-out forwards;
}

@keyframes ghost-label {
    0%   { opacity: 0; transform: translateY(2px); }
    10%  { opacity: 1; transform: translateY(0); }
    70%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-2px); }
}

.preview-field-value.value-slide-in {
    animation: value-slide-in 200ms ease-out;
}

@keyframes value-slide-in {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.preview-field-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.preview-field-value {
    color: #212529;
    white-space: pre-wrap;
    min-height: 1.5rem;
}

.preview-field-empty {
    color: #adb5bd;
    font-style: italic;
}

.preview-field-edit {
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.85rem;
    color: #6c757d;
}

.preview-field:hover .preview-field-edit {
    opacity: 1;
}

.price-timeline-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.price-timeline-row > div {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

/* The busy notice (ERW PR #528): a prompt, not an error, so not the error colour.
   No display rule on the bare class, so the hidden attribute always hides it. */
.estimate-busy:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #1f3f6e;
    background: #eaf1fb;
    border: 1px solid #c7d8f0;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0 0.75rem;
}

.estimate-busy-text {
    flex: 1 1 14rem;
}

/* The notice's own dark blue on white: 10:1 against the white face, where
   Bootstrap's outline blue on the tinted box measured 3.96:1 (below AA). A
   fixed width so "Estimating..." does not push it onto its own line. */
.estimate-retry {
    color: #1f3f6e;
    background: #fff;
    border: 1px solid #1f3f6e;
    min-width: 7.5rem;
}

.estimate-retry:hover:not(:disabled),
.estimate-retry:focus-visible {
    color: #fff;
    background: #1f3f6e;
}

.suggestion-badge {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f0f0f0;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    margin-top: 0.25rem;
    display: inline-block;
}

.status-pill {
    display: inline-block;
    font-family: var(--bma-font-mono, monospace);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Tinted tags in the badge shape (style.css, status badges): neutral while
   drafting, brand blue in progress, the accent once ready to post. */
.status-pill-drafting {
    background: #EEF0F2;
    color: #4A5462;
    border: 1px solid #D5DAE0;
}

.status-pill-in-progress {
    background: #EAF0F9;
    color: #24548F;
    border: 1px solid #C5D5EC;
}

.status-pill-ready {
    background: #FCEAF1;
    color: #9E1F4D;
    border: 1px solid #F2BFD2;
    animation: pill-ready-pulse 1.2s ease-out 1;
}

@keyframes pill-ready-pulse {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(216, 48, 108, 0.6); }
    50%  { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(216, 48, 108, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(216, 48, 108, 0); }
}

/* ==========================================================================
   Preview sheet wrapper

   Desktop: `display: contents` removes the wrapper from layout entirely, so
   .preview-pane stays a direct flex child of .chat-container and keeps the
   50% width rule above. That rule is shared with the Post a Listing page via
   listing-chat.css's @import, so it must not be rewritten to suit this page.
   ========================================================================== */
.preview-sheet {
    display: contents;
}

.preview-sheet-grab,
.preview-sheet-titlebar,
.preview-sheet-toggle,
.preview-sheet-backdrop {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: auto;
    }
    .chat-pane, .preview-pane {
        width: 100%;
    }
    .chat-pane {
        height: 60vh;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    .preview-pane {
        min-height: 40vh;
    }

    /* Any focusable text control below 16px makes iOS Safari zoom the page on
       focus, and it never zooms back.

       Every type, not just textareas: this started as a textarea-only rule and
       a textarea-only test, which left /requests/new's price and timeline
       inputs and /listings/new's repo, demo and seed inputs still zooming.
       Checkboxes and radios are excluded because they carry no text and sizing
       them would move the layout. */
    .chat-mobile-docked input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    .chat-mobile-docked select,
    .chat-mobile-docked textarea {
        font-size: 16px;
    }
}

/* ==========================================================================
   Mobile docked layout, scoped to /requests/new

   Everything below overrides the generic stacked rules above and applies only
   where the template opts in with .chat-mobile-docked.
   ========================================================================== */
@media (max-width: 768px) {
    /* Scroll is locked on both html and body. Locking body alone still lets iOS
       scroll the document to reveal a focused input, which slides the page out
       from under a pinned pane. The footer would otherwise sit below the fold
       with no way to reach it. */
    html.chat-docked-lock,
    body.chat-docked-lock {
        overflow: hidden;
        height: 100%;
    }
    body.chat-docked-lock > footer {
        display: none;
    }

    /* The pane is fixed, so it paints over the navbar regardless of document
       order, and the expanded mobile menu opens underneath it: the links are
       not tappable and only the few pixels above the pane are visible.
       Lift the navbar over the pane so the menu overlays the chat.

       Not while the keyboard is up: there the pane deliberately takes the whole
       visual viewport, and a navbar painted on top of it would eat the space
       the composer needs. */
    body.chat-docked-lock:not(.chat-keyboard-open) > .navbar {
        position: relative;
        z-index: 1030;   /* pane is 1020 */
    }

    .chat-container.chat-mobile-docked {
        /* Pinned, not in flow. An in-flow pane is laid out in the layout
           viewport, which iOS moves independently of the visual one when the
           keyboard opens, leaving the composer under the URL bar or off screen.
           request-chat.js drives both variables from visualViewport. */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        flex-direction: column;
        /* Fallbacks run in order for browsers without dvh (Safari < 15.4) and
           for the frame before the script sets the variables. 76px is the
           navbar; the script replaces it with the measured height. */
        height: calc(100vh - 76px);
        height: calc(100dvh - 76px);
        height: var(--chat-height, calc(100dvh - 76px));
        transform: translateY(var(--chat-shift, 76px));
        background: #fff;
        overflow: hidden;
        z-index: 1020;
    }

    .chat-mobile-docked .chat-pane {
        width: 100%;
        height: auto;
        flex: 1 1 auto;
        min-height: 0;
        border-right: none;
        border-bottom: none;
    }

    .chat-mobile-docked .chat-header {
        flex: 0 0 auto;
        padding: 0 1rem;
        min-height: 48px;
    }

    /* 44px tap target for a link that was a bare 13px text run. */
    .chat-mobile-docked .chat-header-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 0 0.25rem;
    }

    /* /listings/new puts a "seed from a GitHub repo" row between the header and
       the conversation. It needs no flex rule of its own: .chat-messages takes
       `flex: 1 1 auto` with `min-height: 0` and absorbs all the shrinking, so
       the seed row keeps its natural 77px even with the pane forced to 200px.
       A `flex: 0 0 auto` here was measured to change nothing at any viewport. */
    .chat-mobile-docked .chat-messages {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0.75rem 1rem;
    }

    .chat-mobile-docked .chat-input-area {
        flex: 0 0 auto;
        padding: 0.5rem 0.75rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }

    .chat-mobile-docked .chat-input-area #chat-input {
        min-height: 44px;
        /* A third of the screen. The old fixed 360px ceiling was 54% of an
           iPhone SE and 43% of an iPhone 14. */
        max-height: 35dvh;
    }

    /* ---- Collapsed preview bar ---- */
    .chat-mobile-docked .preview-sheet-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 0 0 auto;
        width: 100%;
        min-height: 44px;
        padding: 0 1rem;
        background: #f8f9fa;
        border: 0;
        border-top: 1px solid #dee2e6;
        text-align: left;
        font-size: 0.9rem;
        color: #212529;
    }

    .chat-mobile-docked .preview-sheet-toggle-label {
        font-weight: 600;
    }

    .chat-mobile-docked .preview-sheet-count {
        margin-left: auto;
        color: #6c757d;
        font-size: 0.85rem;
    }

    .chat-mobile-docked .preview-sheet-chevron {
        color: #6c757d;
        font-size: 0.8rem;
        transition: transform 180ms ease;
    }

    .chat-mobile-docked.sheet-open .preview-sheet-chevron {
        transform: rotate(180deg);
    }

    .chat-mobile-docked .preview-sheet-updot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #D8306C;
    }

    .chat-mobile-docked .preview-sheet-toggle.ready {
        background: rgba(216, 48, 108, 0.08);
        border-top-color: #D8306C;
    }

    /* ---- The sheet ---- */
    .chat-mobile-docked .preview-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 16, 24, 0.42);
        opacity: 0;
        pointer-events: none;
        z-index: 1035;   /* under Bootstrap's modal-backdrop (1050) */
    }

    .chat-mobile-docked.sheet-open .preview-sheet-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .chat-mobile-docked .preview-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        /* Percentage, not dvh: the pane above is now a transformed containing
           block, so the sheet resolves against the visible chat area and
           shrinks with it when the keyboard opens. */
        height: 88%;
        background: #fff;
        border-radius: 1rem 1rem 0 0;
        box-shadow: 0 -8px 28px rgba(10, 16, 24, 0.2);
        transform: translateY(100%);
        z-index: 1040;
    }

    /* Transitions stay off until after first paint. translateY(100%) resolves
       against the sheet's own height, so the height settling during load
       changes the computed transform, and a transition declared up front
       animates that: the sheet visibly slides down on every page load. The
       `sheet-ready` class is added by request-chat.js once layout is stable. */
    .chat-mobile-docked.sheet-ready .preview-sheet {
        transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
    }

    .chat-mobile-docked.sheet-ready .preview-sheet-backdrop {
        transition: opacity 200ms ease;
    }

    .chat-mobile-docked.sheet-open .preview-sheet {
        transform: translateY(0);
    }

    .chat-mobile-docked .preview-sheet-grab {
        display: grid;
        place-items: center;
        flex: 0 0 auto;
        padding: 0.5rem 0 0.25rem;
    }

    .chat-mobile-docked .preview-sheet-grab span {
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: #ced4da;
    }

    .chat-mobile-docked .preview-sheet-titlebar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: 0 0 auto;
        padding: 0 0.5rem 0.5rem 1rem;
        border-bottom: 1px solid #dee2e6;
    }

    .chat-mobile-docked .preview-sheet-close {
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 50%;
        background: transparent;
        font-size: 1.5rem;
        line-height: 1;
        color: #6c757d;
    }

    .chat-mobile-docked .preview-sheet .preview-pane {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        overflow-y: auto;
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    /* The sheet's own title bar already names the pane, so the heading inside
       it is a duplicate. Two selectors because the two pages mark theirs up
       differently: /requests/new wraps its heading with a status pill that is
       worth keeping, /listings/new opens with a plain h5. */
    .chat-mobile-docked .preview-sheet #preview-header-normal h5,
    .chat-mobile-docked .preview-sheet .preview-pane > h5:first-child {
        display: none;
    }
    .chat-mobile-docked .preview-sheet #preview-header-normal .status-pill {
        margin-left: auto;
    }

    /* Price / Timeline / Licensing sit in one row. At 390px that gives each
       about 110px, which wraps "Timeline (days)" onto two lines and turns the
       licensing help text into a narrow ribbon. Two up, then full width. */
    .chat-mobile-docked .price-timeline-row {
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
    }
    .chat-mobile-docked .price-timeline-row > div {
        flex: 1 1 calc(50% - 0.5rem);
    }
    .chat-mobile-docked .price-timeline-row > div:last-child {
        flex-basis: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .preview-sheet,
    .preview-sheet-backdrop,
    .preview-sheet-chevron {
        transition: none;
    }
}

.preview-callout {
    position: relative;
    padding: 0.75rem 2rem 0.75rem 0.75rem;
    margin-bottom: 1rem;
    background: rgba(48, 108, 192, 0.08);
    border-left: 3px solid #306CC0;
    border-radius: 0 0.375rem 0.375rem 0;
    font-size: 0.9rem;
    color: #1f3a66;
    animation: callout-fade-in 300ms ease-out;
}

.preview-callout-close {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
}

.preview-callout-close:hover {
    color: #212529;
}

@keyframes callout-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.preview-header-banner {
    padding: 0.75rem 1rem;
    background: rgba(216, 48, 108, 0.10);
    border-left: 3px solid #D8306C;
    border-radius: 0 0.375rem 0.375rem 0;
    color: #6b1a3a;
    animation: banner-fade-in 300ms ease-out;
}

.preview-header-banner i {
    color: #D8306C;
    margin-right: 0.4rem;
}

@keyframes banner-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.post-btn-pulse {
    animation: post-btn-pulse 2s ease-out 1;
}

@keyframes post-btn-pulse {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0   rgba(216, 48, 108, 0.5); }
    50%  { transform: scale(1.03); box-shadow: 0 0 0 12px rgba(216, 48, 108, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0   rgba(216, 48, 108, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .preview-field.just-updated,
    .preview-field-updated-label,
    .preview-field-value.value-slide-in,
    .preview-callout,
    .preview-header-banner {
        animation: none;
    }
    .status-pill-ready,
    .post-btn-pulse {
        animation: none;
    }
    .typing-indicator span {
        animation: none;
        opacity: 0.6;
    }
}

/* ---------------------------------------------------------------------------
   Autosave state and the discard control, shared with /listings/new via this
   file's @import into listing-chat.css. Both start hidden and composer-draft.js
   reveals them, so neither is ever a control that looks live and does nothing.
   --------------------------------------------------------------------------- */

.draft-bar {
    min-height: 1.25rem;
    font-size: 0.8rem;
}

.draft-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #6c757d;
}

.draft-status::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.draft-status-saving   { color: #6c757d; }
.draft-status-restored { color: #6c757d; }
.draft-status-saved    { color: #1a7f37; }

/* A failed save is the one state the buyer has to act on: they may be about to
   close a tab believing the work is safe. It gets the accent colour and stays
   until the next successful save replaces it. */
.draft-status-failed {
    color: #D8306C;
    font-weight: 600;
}

.draft-discard {
    color: #6c757d;
    text-decoration: underline;
    font-size: 0.8rem;
}

.draft-discard:hover:not(:disabled) { color: #D8306C; }
.draft-discard:disabled { color: #adb5bd; text-decoration: none; }

/* Fit to my budget (ticket FIT_TO_BUDGET, PR #957; static/js/budget-fit.js).
   Every rule that sets `display` is scoped to :not([hidden]), so the hidden
   attribute keeps meaning hidden (BMA_UX_CONVENTIONS section I). */
.budget-fit:not([hidden]) {
    display: block;
    margin: 0.25rem 0 1rem;
}

.budget-fit-open {
    color: var(--brand, #306CC0);
    background: #fff;
    border: 1px solid var(--brand, #306CC0);
}

.budget-fit-open:hover:not(:disabled),
.budget-fit-open:focus-visible {
    color: #fff;
    background: var(--brand, #306CC0);
}

.budget-fit-entry:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid #c9d8ee;
    border-radius: 8px;
    background: #f5f8fd;
}

.budget-fit-amount {
    max-width: 12rem;
}

.budget-fit-actions:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.budget-fit-reason,
.budget-fit-cap {
    font-size: 0.8rem;
    color: var(--prompt, #306CC0);
}

.budget-fit-reason:empty {
    display: none;
}

.budget-fit-refusal,
.budget-fit-over {
    font-size: 0.8rem;
    color: var(--accent, #D8306C);
}

.budget-fit-busy:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: #1f3f6e;
    background: #eaf1fb;
    border: 1px solid #c7d8f0;
    border-radius: 6px;
}

.budget-fit-busy-text {
    flex: 1 1 14rem;
}

.budget-fit-busy .estimate-retry {
    min-width: 13rem;
}

.budget-fit-cap:not([hidden]),
.budget-fit-cannot:not([hidden]) {
    display: block;
    margin-top: 0.5rem;
}

.budget-fit-result:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.budget-fit-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.budget-fit-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.6rem;
    border: 1px solid #ced4da;
    border-radius: 8px;
    cursor: pointer;
}

.budget-fit-card:has(input:checked) {
    border: 2px solid var(--brand, #306CC0);
    background: #f5f8fd;
}

.budget-fit-card-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.budget-fit-card-price {
    font-size: 1.05rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.budget-fit-card-meta {
    font-size: 0.8rem;
    color: #4f575e;
}

.budget-fit-core {
    margin: 0;
    font-size: 0.85rem;
}

.budget-fit-kept,
.budget-fit-cut {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.85rem;
}

.budget-fit-later {
    padding: 0.6rem;
    border: 1px solid #e3d3b5;
    border-radius: 8px;
    background: #fdf9f1;
}

.budget-fit-cut {
    list-style: none;
    padding-left: 0;
}

.budget-fit-cut .budget-fit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.2rem 0;
}

.budget-fit-cut .budget-fit-item > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.budget-fit-item .btn,
.budget-fit-keep-item .btn {
    flex: 0 0 auto;
    color: var(--brand, #306CC0);
    background: #fff;
    border: 1px solid var(--brand, #306CC0);
}

.budget-fit-change {
    align-self: flex-start;
}

/* An item added back sits in the numbered kept list: it stays a list item, so
   the numbers after it keep counting; its Remove button sits inline. */
.budget-fit-keep-item .btn {
    margin-left: 0.5rem;
    padding: 0 0.4rem;
}

/* A budget already typed keeps no Required prompt while the trim runs: a
   disabled input matches neither :valid nor :invalid, so bma_ui.css's hide
   rule stops matching. budget-fit.js sets this class from the value. */
.budget-fit .field-row.budget-fit-filled .field-required-tag,
.budget-fit .field-row.budget-fit-filled .field-hint--empty {
    display: none;
}

#budget-fit-result-heading:focus,
#budget-fit-cannot-text:focus {
    outline: 2px solid var(--brand, #306CC0);
    outline-offset: 2px;
}

/* A button doing its work keeps focus (aria-disabled), drawn as greyed. */
.budget-fit .btn.budget-fit-working {
    opacity: 0.65;
    cursor: progress;
}

/* "Whole dollars only." after a typed ".": a prompt, not an error. */
.budget-fit-note:not([hidden]) {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--prompt, #306CC0);
}
