/* Chat style look for the message pages (list, thread, message forms).
   Self-hosted, no external assets. Uses the 3WordID palette (navy, paper, gold).
   Mobile first: one full-height column with a sticky header and a bottom composer. */

:root {
    --navy: #0F1C3F;
    --navy-hover: #162756;
    --slate: #5B6478;
    --muted: #8A93A6;
    --line: #E6E3DC;
    --paper: #F7F6F3;
    --white: #FFFFFF;
    --gold: #B45309;
    --well: #F3F1EC;
    --divider: #F0EEE8;
    --chat-bg: #EDE6D8;           /* beige chat background */
    --bubble-in: #FFFFFF;
    --bubble-out: #D9E4F7;        /* soft blue tint, from the navy of the brand */
    --tick: #4A6FB5;
    --info-bg: #FFF3D4;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body.chat-body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.4;
    color: var(--navy);
    background: #DDD5C4;
}
.chat-body a { color: inherit; text-decoration: none; }

/* ---------- app frame ---------- */
body.chat-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.chat-app {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    background: var(--chat-bg);
    box-shadow: 0 0 40px rgba(15, 28, 63, .12);
    overflow: hidden;
}

/* ---------- top bar (full width, stays on top: only the messages scroll) ---------- */
.chat-topbar {
    flex: 0 0 auto;
    background: var(--navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 6px rgba(15, 28, 63, .28);
    padding-top: env(safe-area-inset-top, 0px);
}
.chat-topbar .tb-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 760px;
    min-height: 60px;
    margin: 0 auto;
    padding: 8px 10px 8px 6px;
}
.chat-topbar a { color: #fff; }
.chat-topbar .tb-back {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 12px 0 6px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .22);
}
.chat-topbar .tb-back:hover, .chat-topbar .tb-back:focus-visible,
.chat-topbar .tb-btn:hover, .chat-topbar .tb-btn:focus-visible,
.chat-topbar .tb-lang summary:hover, .chat-topbar .tb-lang summary:focus-visible { background: rgba(255, 255, 255, .2); outline: 2px solid transparent; }
.chat-topbar :focus-visible { box-shadow: 0 0 0 2px #FCD34D; }
.chat-topbar .tb-who { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; margin-left: 4px; }
.chat-topbar .tb-text { min-width: 0; line-height: 1.25; }
.chat-topbar .tb-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topbar .tb-sub { font-size: 12.5px; color: rgba(255, 255, 255, .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Car chat: make + colour next to the plate (car_topbar_badge); gives way before the plate */
.chat-topbar .tb-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-topbar .tb-line .tb-name { flex: 0 0 auto; max-width: 100%; }
.chat-topbar .tb-car {
    flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
    color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden;
}
.chat-topbar .tb-car .car-ico { flex: none; color: #9fe3bd; }
.chat-topbar .tb-car-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-topbar .tb-car[hidden] { display: none; }
/* Organization name of the sender's account (sender_topbar_badges): same pill as the car;
   car + organization share one wrapper so they stay together */
.chat-topbar .tb-badges { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; }
.chat-topbar .tb-badges .tb-car { flex: 0 1 auto; }
.chat-topbar .tb-org {
    flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
    color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden;
}
.chat-topbar .tb-org .org-ico { flex: none; color: #FCD34D; }
.chat-topbar .tb-org-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.chat-topbar .avatar { width: 40px; height: 40px; }
/* sender menu in "Chatting as …" (only when you have more than one 3WordID) */
/* the sub line as a row: "Chatting as" gives way first, the menu stays readable */
.chat-topbar .tb-sub-from { display: flex; align-items: center; gap: 4px; overflow: visible; }
.chat-topbar .tb-sub-pre { flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-topbar .tb-from {
    font: inherit;
    font-weight: 600;
    color: #fff;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
    margin: 0;
    padding: 1px 18px 1px 6px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 8px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, .1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0h8L4 5z' fill='%23fff'/%3E%3C/svg%3E") no-repeat right 6px center;
}
.chat-topbar .tb-from:hover { background-color: rgba(255, 255, 255, .2); }
.chat-topbar .tb-from:focus-visible { outline: none; box-shadow: 0 0 0 2px #FCD34D; }
.chat-topbar .tb-from option { color: var(--navy); background: #fff; }
.chat-topbar .tb-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.chat-topbar .tb-btn {
    flex: 0 0 auto;
    min-width: 40px;
    height: 40px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.chat-topbar .tb-login { padding: 0 12px; border: 1px solid rgba(255, 255, 255, .35); font-size: 13px; font-weight: 600; white-space: nowrap; margin-right: 2px; }
.chat-topbar .tb-login svg { width: 18px; height: 18px; }
.chat-topbar .tb-back-login { gap: 6px; padding: 0 14px 0 10px; }
.chat-topbar .tb-back-login svg { width: 18px; height: 18px; }

/* language menu: current code, the others drop down */
.tb-lang { position: relative; flex: 0 0 auto; }
.tb-lang summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 9px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    user-select: none;
}
.tb-lang summary::-webkit-details-marker { display: none; }
.tb-lang summary::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .8; margin-left: 1px; }
.tb-lang[open] summary::after { transform: rotate(180deg); }
.tb-lang ul {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px 0;
    list-style: none;
    min-width: 150px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 28, 63, .28);
    z-index: 30;
}
.chat-topbar .tb-lang a { display: block; padding: 9px 16px; color: var(--navy); font-size: 14px; font-weight: 500; }
.chat-topbar .tb-lang a:hover, .chat-topbar .tb-lang a:focus-visible { background: var(--well); outline: none; box-shadow: none; }
.chat-topbar .tb-lang a[aria-current="true"] { font-weight: 700; }
.chat-topbar .tb-lang a[aria-current="true"]::after { content: " \2713"; color: var(--tick); }

/* phones: icons only (the labels stay as accessible names) */
@media (max-width: 560px) {
    .chat-topbar .tb-back { padding: 0; width: 40px; justify-content: center; }
    .chat-topbar .tb-back-label, .chat-topbar .tb-btn-label { display: none; }
    /* "Login" (visitors) keeps its text: it is the main button for them */
    .chat-topbar .tb-back-login { width: auto; padding: 0 12px 0 8px; }
    .chat-topbar .tb-back-login .tb-back-label { display: inline; }
    .chat-topbar .tb-login { padding: 0; width: 40px; border-color: rgba(255, 255, 255, .35); }
    .chat-topbar .tb-login svg { width: 20px; height: 20px; }
    .chat-topbar .tb-who { margin-left: 0; gap: 8px; }
    .chat-topbar .tb-inner { gap: 4px; padding-right: 6px; }
    /* phones: the car goes on its own small line under the plate, so it is never cut short */
    .chat-topbar .tb-line { flex-wrap: wrap; row-gap: 0; }
    .chat-topbar .tb-line .tb-car { flex-basis: 100%; padding: 0; border: 0; background: none; font-size: 12px; font-weight: 600; gap: 4px; }
    .chat-topbar .tb-line .tb-badges { flex-basis: 100%; flex-wrap: wrap; gap: 0 10px; }
    .chat-topbar .tb-line .tb-badges > span { max-width: 100%; }
    .chat-topbar .tb-line .tb-badges .tb-car { flex-basis: auto; }
    .chat-topbar .tb-line .tb-org { padding: 0; border: 0; background: none; font-size: 12px; font-weight: 600; gap: 4px; }
    .tb-lang summary { padding: 0 6px; }
    .tb-lang summary svg { display: none; }
}
@media (max-width: 380px) {
    .chat-topbar .tb-name { font-size: 15px; }
    .chat-topbar .avatar { width: 36px; height: 36px; font-size: 16px; }
}

/* ---------- avatars ---------- */
.avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    color: var(--navy);
    background: #DDE3F0;
    user-select: none;
}
.avatar.big { width: 48px; height: 48px; font-size: 20px; }
/* profile photo (opt-in): the letter sits underneath as a fallback */
.avatar.photo { position: relative; overflow: hidden; padding: 0; border: 0; font-family: inherit; }
button.avatar.photo { cursor: zoom-in; }
.avatar.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-box { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 32, .86); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.photo-box img { max-width: min(92vw, 420px); max-height: 80vh; border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; }
.photo-box .close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 26px; line-height: 44px; cursor: pointer; }
.pill a { color: inherit; font-weight: 600; }
.avatar.c0 { background: #F6D9C2; }
.avatar.c1 { background: #D4E6D3; }
.avatar.c2 { background: #D5DFF3; }
.avatar.c3 { background: #EEDCF0; }
.avatar.c4 { background: #F6EDB9; }
.avatar.c5 { background: #CDE8EA; }
.avatar.c6 { background: #F3D3D6; }
.avatar.c7 { background: #E1E0CF; }
.avatar.visitor { background: #CBD1DE; color: #fff; }
.avatar.visitor svg { width: 22px; height: 22px; }

/* ---------- scrolling area with the beige pattern ---------- */
.chat-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 6px;
    background-color: var(--chat-bg);
    background-image:
        radial-gradient(rgba(15, 28, 63, .06) 1.3px, transparent 1.6px),
        radial-gradient(rgba(180, 83, 9, .07) 1px, transparent 1.3px),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, .13) 0 1px, transparent 1px 13px);
    background-size: 26px 26px, 26px 26px, auto;
    background-position: 0 0, 13px 13px, 0 0;
}
.chat-scroll.plain { background: #fff; padding: 0; }

.chat-footer {
    text-align: center;
    color: var(--slate);
    font-size: 12px;
    padding: 16px 8px 6px;
    opacity: .8;
}
.chat-footer a { margin: 0 6px; text-decoration: underline; }

/* ---------- centered pills: date separators, notes ---------- */
.pill-wrap { display: flex; justify-content: center; margin: 8px 0; }
.pill {
    display: inline-block;
    max-width: 92%;
    padding: 4px 11px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .88);
    color: var(--slate);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 1px 1px rgba(15, 28, 63, .1);
}
.pill.info { background: var(--info-bg); color: #5a4a1e; line-height: 1.45; padding: 7px 12px; }
.pill.info a { text-decoration: underline; font-weight: 600; }
.pill.ok { background: #E4F3E9; color: #14623C; }


/* ---------- bubbles ---------- */
.row { display: flex; margin: 2px 0; }
.row.in { justify-content: flex-start; }
.row.out { justify-content: flex-end; }
.bubble {
    position: relative;
    max-width: 84%;
    padding: 6px 9px 4px;
    border-radius: 10px;
    box-shadow: 0 1px 1px rgba(15, 28, 63, .13);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.row.in .bubble { background: var(--bubble-in); border-top-left-radius: 2px; }
.row.out .bubble { background: var(--bubble-out); border-top-right-radius: 2px; }
.row.in.first .bubble::before, .row.out.first .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    width: 8px;
    height: 10px;
}
.row.in.first .bubble::before {
    left: -7px;
    background: var(--bubble-in);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.row.out.first .bubble::before {
    right: -7px;
    background: var(--bubble-out);
    clip-path: polygon(0 0, 100% 0, 0 100%);
}
.bubble .b-title { font-weight: 700; font-size: 14px; margin-bottom: 1px; color: var(--navy); }
.bubble .b-text { font-size: 15px; white-space: normal; }
.bubble .b-text.html a { text-decoration: underline; }
.bubble .b-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 1px;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
    min-height: 14px;
}
.bubble .b-meta .del { display: inline-flex; color: var(--muted); opacity: .75; padding: 2px; }
.bubble .b-meta .del:hover, .bubble .b-meta .del:focus-visible { color: #9B1C1C; opacity: 1; outline: none; }
/* own messages: the bin sits after the ticks; member chat uses a small POST form */
.bubble .b-meta .del-form { display: inline-flex; margin: 0; }
.bubble .b-meta button.del { font: inherit; background: none; border: 0; cursor: pointer; border-radius: 4px; }
.row.out .bubble .b-meta .del { margin-left: 2px; }
/* top bar: Delete conversation is a POST form with a button that looks like the other icons */
.chat-topbar .tb-form { margin: 0; display: inline-flex; }
.chat-topbar button.tb-btn { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.chat-topbar .tb-del:hover, .chat-topbar .tb-del:focus-visible { color: #FECACA; }
.tick { color: var(--tick); vertical-align: -1px; }
.bubble.note { background: #fff; border: 1px dashed #D9CDB4; }

/* ---------- conversation list (owner) ---------- */
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--divider);
    background: #fff;
}
.chat-row:hover, .chat-row:focus-visible { background: var(--well); outline: none; }
/* Row + bin: the bin is a sibling form of the row link (a click on it never opens the conversation).
   The divider and white background move to the li so the bin sits on the same line. */
.chat-list .cr-item { display: flex; align-items: stretch; background: #fff; border-bottom: 1px solid var(--divider); }
.chat-list .cr-item .chat-row { flex: 1 1 auto; min-width: 0; border-bottom: 0; background: transparent; padding-right: 4px; }
.chat-list .cr-item:hover, .chat-list .cr-item:has(.chat-row:focus-visible) { background: var(--well); }
.chat-list .cr-del-form { display: flex; flex: 0 0 auto; margin: 0; }
.chat-list .cr-del {
    display: flex; align-items: center; justify-content: center;
    width: 44px; min-height: 44px; padding: 0 10px 0 4px; margin: 0;
    background: none; border: 0; cursor: pointer; color: var(--muted); opacity: .7; font: inherit;
}
.chat-list .cr-del svg { width: 18px; height: 18px; }
.chat-list .cr-del:hover, .chat-list .cr-del:focus-visible { color: #9B1C1C; opacity: 1; outline: none; background: rgba(155, 28, 28, .06); }
.chat-row .cr-main { flex: 1 1 auto; min-width: 0; }
.chat-row .cr-top, .chat-row .cr-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-row .cr-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .cr-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-row .cr-who .cr-name { flex: 0 1 auto; min-width: 3em; }
.chat-row .cr-car {
    display: inline-flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto;
    padding: 1px 8px; border-radius: 999px; background: #e8f5ee; color: #1f6b45;
    font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
}
.chat-row .cr-car .car-ico { flex: none; }
.chat-row .cr-car .tb-car-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-row .cr-org {
    display: inline-flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto;
    padding: 1px 8px; border-radius: 999px; background: #FDF3E1; color: #92400E;
    font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
}
.chat-row .cr-org .org-ico { flex: none; }
.chat-row .cr-org .tb-org-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* phones: with an organization name the badges may go on a line under the words, so the words stay readable */
@media (max-width: 560px) {
    .chat-row .cr-who:has(.cr-org) { flex-wrap: wrap; row-gap: 3px; }
    .chat-row .cr-who:has(.cr-org) .cr-name { flex: 0 0 auto; max-width: 100%; }
    .chat-row .cr-who:has(.cr-org) > span:not(.cr-name) { max-width: 100%; }
}
.chat-row .cr-time { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.chat-row .cr-preview { font-size: 14px; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-row .cr-preview b { font-weight: 600; color: var(--navy); }
.chat-row .cr-count {
    flex: 0 0 auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--chip, #EFECE6);
    color: var(--slate);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- bottom bars ---------- */
.composer {
    flex: 0 0 auto;
    background: #F2EDE2;
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}
.composer .c-row { display: flex; align-items: flex-end; gap: 8px; }
.composer .c-box {
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 2px 14px;
}
.composer .c-box:focus-within { border-color: var(--navy); }
.composer .c-text {
    display: block;
    width: 100%;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    font: 15px/1.4 Inter, system-ui, sans-serif;
    color: var(--navy);
    padding: 8px 0;
    max-height: 140px;
    overflow-y: auto;
}
.composer ::placeholder { color: var(--muted); opacity: 1; }
.composer .send {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 0;
    background: #00a884; /* WhatsApp's send green */
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0 0 0 2px;
}
.composer .send:hover { background: #008f6f; }
.composer .send:focus-visible { background: #008f6f; outline: 2px solid var(--navy); outline-offset: 2px; }
.composer .send:disabled, .composer .send:disabled:hover { background: #C4C9D1; opacity: 1; cursor: not-allowed; }
.composer .c-note { margin: 0 4px 6px; font-size: 12px; color: var(--slate); line-height: 1.4; }
.composer .consent { display: flex; align-items: flex-start; gap: 7px; margin: 0 4px 6px; font-size: 12px; color: var(--navy); }
.composer .consent input { margin: 2px 0 0; flex: 0 0 auto; }

/* sender / recipient fields of the logged in form (card in the chat area) */
.setup {
    background: #fff;
    border-radius: 14px;
    padding: 4px 12px;
    margin: 8px 0;
    box-shadow: 0 1px 1px rgba(15, 28, 63, .1);
}
.setup .f { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.setup .f:last-child { border-bottom: 0; }
.setup .f-status { font-size: 12px; color: var(--slate); padding: 6px 0 12px 82px; }
.setup .f-status:empty, .composer .c-status:empty { display: none; }
.setup .f:has(+ .f-status:empty) { border-bottom: 0; }
/* live recipient check (js/3wid_messageform.js): green only for a 3WordID that exists */
.setup input[type=text].rcpt-ok { color: #0B7A4B; }
.setup input[type=text].rcpt-bad { color: #344054; }
.setup .f-status.rcpt-ok { color: #0B7A4B; font-weight: 600; }
.setup .f-status.rcpt-bad { color: #475467; font-weight: 600; }
.setup .f-status.rcpt-checking { color: var(--slate); font-style: italic; }
.setup label { flex: 0 0 72px; font-size: 12px; font-weight: 600; color: var(--slate); }
.setup select, .setup input[type=text] {
    text-align: left;
    text-align-last: left;
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font: 500 15px Inter, system-ui, sans-serif;
    color: var(--navy);
    padding: 2px 0;
}

.reply-bar {
    flex: 0 0 auto;
    background: #F2EDE2;
    border-top: 1px solid var(--line);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    gap: 8px;
    align-items: center;
}
.reply-bar .fake {
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 12px 16px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-bar .note { flex: 1 1 auto; margin: 0; padding: 8px 12px; font-size: 13px; line-height: 1.4; color: var(--navy); text-align: center; white-space: normal; border: 1px dashed var(--line); border-radius: 14px; }
.reply-bar .fake.static { text-align: center; font-size: 13px; background: transparent; border-style: dashed; }
.reply-bar .go {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* mobile: 16px inputs avoid the iOS zoom on focus */
@media (max-width: 600px) {
    .composer .c-text, .setup select, .setup input[type=text] { font-size: 16px; }
    .bubble { max-width: 90%; }
}
@media (min-width: 761px) {
    .chat-scroll { padding: 14px 18px 8px; }
    .bubble { max-width: 74%; }
}
@media (prefers-reduced-motion: no-preference) {
    .chat-row, .chat-topbar .tb-back, .chat-topbar .tb-btn, .composer .send { transition: background-color .12s; }
}

/* Two-way chat: unread dot, "You:" preview, read ticks, conversation composer */
.chat-row .cr-unread { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--tick); }
.chat-row.unread .cr-name { font-weight: 700; }
.chat-row.unread .cr-preview { color: var(--navy); font-weight: 600; }
.chat-row .cr-you { color: var(--muted); font-weight: 500; }
.tick.read { color: var(--tick-read, #2F8FED); }
.composer.conv .c-note.err { margin: 0 0 6px; font-size: 13px; color: #B3261E; }

/* ---------- chat login (member) pages: 3wid_chat.php ---------- */
.chat-topbar .tb-logout-form { margin: 0 0 0 4px; display: inline-flex; }
.chat-topbar .tb-logout {
    font: inherit; font-size: 13px; font-weight: 600; color: #fff; cursor: pointer; white-space: nowrap;
    padding: 0 12px 0 10px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .35);
}
.chat-topbar .tb-logout svg { width: 18px; height: 18px; }
.chat-topbar .tb-logout:hover, .chat-topbar .tb-logout:focus-visible { background: rgba(255, 255, 255, .2); outline: 2px solid transparent; }
.member-chat .chat-topbar .tb-who { margin-left: 6px; }
/* phones: Log out keeps its text (it is the only way out), the name gives way */
@media (max-width: 560px) {
    .chat-topbar .tb-logout { padding: 0 10px 0 8px; }
}
@media (max-width: 360px) {
    .chat-topbar .tb-logout span { display: none; }
    .chat-topbar .tb-logout { padding: 0; width: 40px; }
}

/* Pending-message status on a conversation row (waiting / delivered / read / expired) */
.chat-row .cr-status {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    white-space: nowrap;
    background: #F3F0E8;
    color: #7A6A3A;
}
.chat-row .cr-status.is-waiting { background: #F3F0E8; color: #7A6A3A; }
.chat-row .cr-status.is-delivered { background: #E7F0FF; color: #1A4D9E; }
.chat-row .cr-status.is-read { background: #E6F6EA; color: #1B6B34; }
.chat-row .cr-status.is-expired { background: #F0F0F0; color: #555; }
