/* crew/css/v3-chat.css — crew chat (crew v3 stream S2). Tokens from crew/css/app.css only, so light / dark
   follow the theme; motion uses the shell's durations and is switched off by app.css under
   prefers-reduced-motion. Bubbles reuse .msg / .bubble / .meta from app.css. */

/* ── channel list ── */
.cht-row .body { gap: 3px; }
.cht-row.has-unread .body .t { font-weight: 700; }
.cht-row .cht-prev { color: var(--text-2); }
.cht-row.has-unread .cht-prev { color: var(--text); font-weight: 500; }
.cht-row .cht-pinline { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--gold-text); font-size: 13px; font-weight: 500; }
.cht-row .right { align-self: flex-start; padding-top: 2px; }
.cht-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--pill); background: var(--teal); color: var(--text-inv); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }

/* ── thread layout: the screen is one viewport tall; only the log scrolls ── */
.screen[data-screen="chatThread"] { height: 100dvh; min-height: 0; padding-bottom: 0; overflow: hidden; }
/* phones (column layout): .screen's flex: 1 would let it grow with its content; the two-pane row keeps flex: 1 for width */
.view:not(.split) > .screen[data-screen="chatThread"] { flex: none; }
.cht-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cht-logwrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cht-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 8px var(--gutter) 14px; display: flex; flex-direction: column; gap: 2px; }
.cht-log:focus-visible { outline-offset: -3px; }
.cht-sk { gap: 12px; padding-top: 16px; }
.cht-saved { padding: 6px var(--gutter) 0; }
.cht-errbox { padding-top: 12px; }
.cht-earlier { display: flex; justify-content: center; padding: 6px 0 10px; }
.cht-earlier .btn { min-height: 36px; }
.cht-privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 2px auto 10px; padding: 6px 12px; border-radius: var(--pill); background: var(--surface-2); color: var(--text-2); font-size: 12.5px; text-align: center; max-width: 100%; }
.cht-day { display: flex; justify-content: center; margin: 12px 0 6px; }
.cht-day span { padding: 3px 10px; border-radius: var(--pill); background: var(--surface-2); color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: .02em; }

/* ── bubbles ── */
.cht-msg { max-width: min(88%, 560px); margin-top: 8px; }
.cht-msg.cont { margin-top: 2px; }
.cht-col { display: flex; flex-direction: column; min-width: 0; }
.cht-msg.me .cht-col { align-items: flex-end; }
.cht-msg .bubble { max-width: 100%; }
.cht-msg.cont:not(.me) .bubble { border-top-left-radius: 6px; }
.cht-msg.cont.me .bubble { border-top-right-radius: 6px; }
.cht-msg:not(.last):not(.me) .bubble { border-bottom-left-radius: 6px; }
.cht-msg:not(.last).me .bubble { border-bottom-right-radius: 6px; }
.cht-msg.agency .bubble { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.cht-msg.pending .bubble { opacity: .8; }
.cht-av-gap { width: 32px; flex: none; }
.cht-who { margin: 0 0 3px 4px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.cht-tag { margin-left: 4px; padding: 1px 6px; border-radius: var(--pill); background: var(--gold-soft); color: var(--gold-text); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.cht-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.cht-msg .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.cht-msg .meta svg.ico { width: 13px; height: 13px; color: var(--teal); }
.cht-state { color: var(--text-3); }
.cht-err { color: var(--danger); font-weight: 600; }
.cht-fix { display: inline-flex; gap: 6px; margin-left: 4px; }
.cht-fix .btn { min-height: 32px; }
.cht-receipt { align-self: flex-end; display: inline-flex; align-items: center; gap: 4px; margin: 3px 2px 0 0; color: var(--text-3); font-size: 12px; }
.cht-receipt svg.ico { width: 14px; height: 14px; color: var(--teal); }
.cht-msg.flash .bubble, .cht-ann.flash { box-shadow: 0 0 0 3px var(--teal-soft); transition: box-shadow var(--dur) var(--ease); }

/* request card inside a bubble */
.cht-card { display: flex; align-items: center; gap: 10px; width: 100%; min-width: min(240px, 60vw); max-width: 320px; min-height: 48px; margin: 2px 0 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); color: var(--text); text-align: left; }
.msg.me .cht-card { background: var(--surface); }
.cht-card:active { transform: scale(.98); }
.cht-card.hidden { min-width: 0; color: var(--text-3); font-style: italic; }
.cht-card-b { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cht-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cht-card-r { color: var(--gold-text); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.cht-card-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; line-height: 1.3; }

/* announcement form: date and place side by side only when there is room */
.cht-grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 480px) { .cht-grid2 { grid-template-columns: 1fr 1fr; gap: 12px; } }

/* photo inside a bubble, and full view in a sheet */
.cht-photo { display: block; width: min(240px, 62vw); aspect-ratio: 4 / 3; margin: 2px 0 6px; padding: 0; overflow: hidden; border-radius: 12px; background: var(--surface-2); }
.cht-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cht-photo.broken { border: 1px dashed var(--line-2); }
.cht-photo-full img { display: block; width: 100%; height: auto; border-radius: var(--r); background: var(--surface-2); }

/* announcement card (full width, not a bubble); agency-authored ones are visibly "From {agency}" */
.cht-ann { align-self: stretch; display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 640px; margin: 10px auto 4px; padding: 10px 14px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.cht-ann.agency { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); background: linear-gradient(180deg, var(--gold-soft), transparent 70%), var(--surface); }
.cht-ann.pinned { box-shadow: inset 3px 0 0 var(--teal), var(--shadow-1); }
.cht-ann-h { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.cht-ann-h .cht-more { margin: -6px -10px -6px 0; color: var(--text-2); }
.cht-pin-ico { display: inline-flex; color: var(--teal); }
.cht-ann-t { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cht-ann-w { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: 14px; }
.cht-ann-w span { display: inline-flex; align-items: center; gap: 5px; }
.cht-ann .cht-text { font-size: 15px; line-height: 1.45; }
.cht-ann-by { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; color: var(--text-3); font-size: 12.5px; }

/* pinned bar under the top bar */
.cht-pinbar { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px var(--gutter); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; text-align: left; }
.cht-pinbar > svg.ico:first-child { color: var(--teal); }

/* "New messages" pill: shown only when you scrolled up and something arrived */
.cht-newpill { position: absolute; left: 0; right: 0; bottom: 12px; z-index: 5; width: max-content; margin: 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--pill); background: var(--teal); color: var(--text-inv); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-2); animation: pop-in var(--dur) var(--ease-out); }
.cht-newpill[hidden] { display: none; }

/* composer, bottom-anchored */
.cht-composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px var(--gutter) calc(8px + var(--safe-b)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.cht-composer.ann .btn { flex: 1; }
.cht-composer.readonly p { display: flex; align-items: flex-start; gap: 6px; padding: 6px 0; }
.cht-plus { flex: none; color: var(--text-2); }
.cht-input { flex: 1; min-width: 0; align-items: flex-end; padding: 0 12px; }
.cht-input textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 140px; padding: 11px 0; border: 0; background: transparent; color: var(--text); font-size: 16px; line-height: 1.35; resize: none; }
.cht-input textarea:focus { outline: none; }
.cht-input textarea::placeholder { color: var(--text-3); }
.cht-send { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: var(--r); background: var(--gold); color: var(--gold-ink); transition: transform var(--dur-fast), opacity var(--dur-fast); }
.cht-send:active { transform: scale(.94); }
.cht-send[disabled] { opacity: .4; }

/* touch: long-press opens Copy / Pin, so no native text callout on bubbles */
@media (hover: none) {
  .cht-log .bubble, .cht-ann { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
@media (min-width: 900px) {
  .cht-log { padding-left: 24px; padding-right: 24px; }
}
