/* Narrow column: below this the left/right split cannot read as one, so both roles go
   near-full-width and stack; colour and the tail still say who spoke. A container query on the
   transcript, so a resized dock or float answers without a resize listener. */
@container chat-transcript (max-width: 300px) {
    /* flex-start keeps a short bubble its shape; the doubled class matches the swap rules. max-width
       keeps !important to outrank the inline shrink-wrap pin (chatView.js applyShrinkWrap). */
    .chat-msg.chat-msg-user, .chat-msg.chat-msg-assistant, .chat-msg.chat-msg-error {
        max-width: 96% !important;
        align-self: flex-start;
    }
}

/* §11 choice card: the model's question rendered as pick-one / pick-many, with the option
   previews it rendered. Sits in the transcript flow like a result row. */
.chat-ask {
    align-self: flex-start;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 9px 11px;
    border: 1px solid var(--border-main);
    border-radius: 10px;
    background: var(--bg-container);
    font-size: 12.5px;
}
.chat-ask-q { font-weight: 600; }
.chat-ask-options { display: flex; flex-direction: column; gap: 4px; }
.chat-ask-option {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 6px; border-radius: 7px; cursor: pointer;
}
.chat-ask-option:hover { background: var(--bg-hover, rgba(127, 127, 127, .12)); }
.chat-ask-option input { cursor: pointer; margin: 0; flex: 0 0 auto; }
/* A rendered preview of that choice — bigger than a favicon, small enough for five in a row. */
.chat-ask-thumb {
    width: 56px; height: 56px; object-fit: contain; flex: 0 0 auto;
    border: 1px solid var(--border-main); border-radius: 6px; background: var(--bg-main);
}
.chat-ask-label { min-width: 0; overflow-wrap: anywhere; }
.chat-ask-custom-text {
    flex: 1 1 auto; min-width: 0; font: inherit; padding: 3px 6px;
    border: 1px solid var(--border-main); border-radius: 6px;
    background: var(--bg-main); color: var(--text-main);
}
.chat-ask-actions { display: flex; align-items: center; gap: 8px; }
/* The accent fill, hover lift and sweep come from the shared `button` rules (layout/shell.css);
   only the card's tighter metrics are its own. */
.chat-ask-submit {
    font: inherit; padding: 3px 12px; border-radius: 7px; cursor: pointer;
}
.chat-ask-submit:disabled { opacity: .5; cursor: default; }
/* Answered: the card stops being a control and becomes the record of what was sent. */
.chat-ask-answered { opacity: .8; }
.chat-ask-answered .chat-ask-option { cursor: default; }
.chat-ask-sent { color: var(--text-muted); font-style: italic; }

/* One column as wide as its widest card: every card shares that width, so the buttons line up. */
.chat-results { display: inline-grid; grid-template-columns: minmax(0, max-content); gap: 8px; align-self: flex-start; max-width: 100%; }
.chat-result {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border: 1px solid var(--border-main);
    border-radius: 8px;
    background: var(--bg-container);
    font-size: 12px;
}
.chat-result-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--border-main);
}
.chat-result-label { color: var(--text-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The toolbar's accent square (a bare button), at the composer buttons' scale. */
.chat-result-btn { width: 28px; height: 28px; padding: 0; flex: 0 0 auto; border-radius: 6px; }
.chat-result-label + .chat-result-btn { margin-left: auto; }

/* What the USER attached to a turn: thumbnails above their own message, so they sit
   on the user's side of the transcript (flex-end) like the bubble they belong to. */
.chat-attached { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; align-self: flex-end; max-width: 88%; }
.chat-attached-item { position: relative; display: inline-flex; }
.chat-attached-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-main);
    background: var(--bg-container);
}
/* Hover preview on the body (the panel clips its overflow), sized like .project-thumb-zoom img:
   a glance, not a lightbox. */
.chat-thumb-preview {
    position: fixed;
    left: -9999px;
    z-index: 100010;               /* over the panel (90000) and its cue */
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--border-main);
    border-radius: 10px;
    background: var(--bg-controls);
    box-shadow: 0 10px 30px var(--shadow);
    pointer-events: none;          /* never steals the hover that opened it */
    opacity: 0;
}
.chat-thumb-preview-in { opacity: 1; }
.chat-thumb-preview img {
    display: block;
    width: auto;
    height: auto;
    max-width: 25vw;
    max-height: 20vh;
    object-fit: contain;
    border-radius: 6px;
}
.chat-thumb-preview-cap { max-width: 25vw; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
/* Alt held while hovering: the glance doubles (chatView altPreview). */
.chat-thumb-preview.chat-thumb-preview-xl img { max-width: 50vw; max-height: 40vh; }
.chat-thumb-preview.chat-thumb-preview-xl .chat-thumb-preview-cap { max-width: 50vw; }

/* A video attachment shows its first sampled frame — the badge says so, since the
   video itself never goes to the model (contract §7). */
.chat-attached-badge {
    position: absolute;
    left: 4px;
    bottom: 4px;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-key);
    background: color-mix(in srgb, var(--accent) 85%, transparent);
}

