/* ===================================================================
   Chat (chat.html, scripts/chat.js): the filter row, the list (on the site now / conversations), and one visitor: who they are,
   what they did, the conversation (templates on top, messages, the message field). Built on the Websites page's glass and buttons
   (style/websites.css). Light + dark, phones (the list or the visitor, one at a time), right-to-left through logical properties.
   =================================================================== */

.ch-page {
    --ch-gap: 14px;
}

.ch-page [hidden] { display: none !important; }

/* the free conversations left today, on the right of the title */
.ch-quota {
    margin: 0;
    padding: 7px 12px;
    border-radius: 10px;
    background: var(--color-green-soft);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.ch-quota.is-out { background: color-mix(in srgb, #f59e0b 16%, var(--color-bg)); }

.ch-quota a,
.ch-limit a {
    color: var(--color-green-dark);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 2px;
}

:root[data-theme="dark"] .ch-quota a,
:root[data-theme="dark"] .ch-limit a { color: var(--color-green); }

.ch-denied {
    margin: 0;
    padding: 18px 20px;
    border-radius: 16px;
    font-size: 15px;
    color: var(--color-text-soft);
}

/* ===== the finder as on Traffic (groups, websites; the switch on the right) and under it the filters ===== */

.ch-finder {
    margin-bottom: 10px;
}

.ch-filter {
    position: relative;
    z-index: 15;   /* its popup floats over the list and the visitor */
    margin-bottom: var(--ch-gap);
}

/* the switch "Visitors can start a chat" (the one website in view) */
.ch-start {
    display: flex;
    align-self: center;
    align-items: center;
    gap: 10px;
    margin-inline-start: auto;
    padding: 6px 4px;
}

.ch-start-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.ch-start-l { font-size: 13.5px; font-weight: 700; }
.ch-start.is-many .ch-switch { display: none; }
.ch-start-h { font-size: 12px; color: var(--color-text-muted); }
.ch-start-err { font-size: 12px; font-weight: 600; color: var(--ws-bad); }

.ch-switch {
    position: relative;
    flex: none;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-text) 20%, transparent);
    transition: background .18s var(--ease);
}

.ch-switch-k {
    position: absolute;
    top: 3px;
    inset-inline-start: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
    transition: transform .18s var(--ease);
}

.ch-switch[aria-checked="true"] { background: var(--color-green); }
.ch-switch[aria-checked="true"] .ch-switch-k { transform: translateX(18px); }
[dir="rtl"] .ch-switch[aria-checked="true"] .ch-switch-k { transform: translateX(-18px); }
.ch-switch[aria-disabled="true"] { opacity: .6; cursor: progress; }

/* ===== three columns (the owner's picture): the list | the conversation | what the visitor did ===== */

/* as high as the window below the columns' top (--ch-top, measured by scripts/chat.js fitColumns: the demo bar, the groups and
   the filter chips above them change it), with a small margin at the bottom; never less than 300px (the header of the conversation and the reply box) on a very low window */
.ch-main {
    --ch-fit: calc(100dvh - var(--ch-top, 250px) - 20px);
    display: grid;
    grid-template-columns: minmax(270px, 340px) minmax(0, 1fr) minmax(290px, 370px);
    gap: var(--ch-gap);
    height: max(300px, var(--ch-fit));
}

/* nobody open (or the visit is gone): the conversation's place takes the last two columns */
.ch-main:not(.is-detail) .ch-detail,
.ch-main:has(.ch-act[hidden]) .ch-detail { grid-column: 2 / -1; }

.ch-side,
.ch-detail,
.ch-act {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border-radius: 18px;
}

/* ----- the list ----- */

.ch-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 0;
    border-bottom: 1px solid var(--ws-line);
}

.ch-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 14px;
    border-bottom: 2px solid transparent;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-soft);
}

.ch-tab[aria-selected="true"] {
    border-bottom-color: var(--color-green);
    color: var(--color-text);
}

.ch-tab-n {
    font-weight: 800;
    color: var(--color-green-dark);
}

:root[data-theme="dark"] .ch-tab-n { color: var(--color-green); }

.ch-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 8px 8px;
}

.ch-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ch-list-note {
    padding: 22px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-soft);
    text-align: center;
}

.ch-more { display: flex; margin: 6px auto 10px; }

/* "Active on site", "Recently left" */
.ch-list-h {
    margin: 12px 10px 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-soft);
}

.ch-list-h + li .ch-row { border-top: 0; }

.ch-list li + .ch-list-h {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--ws-line);
}

.ch-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: 100%;
    padding: 12px 10px 12px 12px;
    border-radius: 14px;
    text-align: start;
    transition: background .15s;
}

.ch-row:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

.ch-row.is-open { background: color-mix(in srgb, var(--color-green) 15%, transparent); }

.ch-row.is-left .ch-row-body,
.ch-row.is-left .ch-flag { opacity: .55; }

.ch-row.is-anon .ch-row-body { opacity: .55; }

.ch-row .ch-flag { width: 22px; height: 15px; margin-top: 3px; }

.ch-row-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ch-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 14.5px;
    font-weight: 700;
}

.ch-row-place {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-row-where,
.ch-row-msg {
    overflow: hidden;
    font-size: 13.5px;
    color: var(--color-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-row-facts {
    overflow: hidden;
    font-size: 12.5px;
    color: var(--color-text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-row-site {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    vertical-align: bottom;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-row-site::before { content: "· "; }

.ch-row-go {
    display: grid;
    flex: none;
    place-items: center;
    align-self: center;
    color: var(--color-text-muted);
}

.ch-row-go .material-symbols-outlined { font-size: 22px; }
[dir="rtl"] .ch-row-go .material-symbols-outlined,
[dir="rtl"] .ch-fact-go .material-symbols-outlined { transform: scaleX(-1); }

.ch-flag {
    flex: none;
    width: 18px;
    height: 13px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-text) 10%, transparent);
}

.ch-flag-none {
    display: inline-grid;
    place-items: center;
    box-shadow: none;
    color: var(--color-text-muted);
}

.ch-flag-none .material-symbols-outlined { font-size: 16px; }

.ch-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--color-green);
    color: var(--color-green-ink);
    font-size: 11.5px;
    font-weight: 800;
}

.ch-tag {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-green) 14%, transparent);
    color: var(--color-green-dark);
    font-size: 11.5px;
    font-weight: 700;
}

:root[data-theme="dark"] .ch-tag { color: var(--color-green); }

.ch-live-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 22%, transparent);
}

/* ----- the conversation ----- */

.ch-empty {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px;
    text-align: center;
    color: var(--color-text-soft);
}

.ch-empty p { max-width: 340px; margin: 0; font-size: 15px; line-height: 1.5; }

.ch-empty-ico {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-green-soft);
    color: var(--color-green-dark);
}

:root[data-theme="dark"] .ch-empty-ico { color: var(--color-green); }

.ch-empty-ico svg { width: 28px; height: 28px; }

.ch-open {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.ch-who {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 14px;
    padding: 16px 4px 14px;
    border-bottom: 1px solid var(--ws-line);
}

.ch-loading { margin: 0; font-size: 14px; color: var(--color-text-soft); }

.ch-who-main { flex: 1; min-width: 0; }

.ch-who-t {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.ch-who-t .ch-flag { width: 24px; height: 17px; }

.ch-who-facts {
    margin: 4px 0 0;
    font-size: 13.5px;
    color: var(--color-text-soft);
}

.ch-who-now { margin: 4px 0 0; font-size: 13px; }

.ch-who-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--color-text-muted);
}

.ch-who-status .ch-live-dot { background: var(--color-text-muted); box-shadow: none; }
.ch-who-status.is-on { color: var(--color-green-dark); }
:root[data-theme="dark"] .ch-who-status.is-on { color: var(--color-green); }
.ch-who-status.is-on .ch-live-dot { background: var(--color-green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 22%, transparent); }

.ch-linkbtn {
    font-size: inherit;
    font-weight: 700;
    color: var(--color-green-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

:root[data-theme="dark"] .ch-linkbtn { color: var(--color-green); }

.ch-x,
.ch-back {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--color-text-muted);
}

.ch-x:hover,
.ch-back:hover,
.ch-x[aria-expanded="true"] { background: color-mix(in srgb, var(--color-text) 8%, transparent); color: var(--color-text); }

.ch-back { display: none; }
.ch-back span:last-child { display: none; }
[dir="rtl"] .ch-back .material-symbols-outlined { transform: scaleX(-1); }

/* the ⋮ menu */
.ch-menu-wrap { position: relative; flex: none; }

.ch-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

.ch-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    text-align: start;
}

.ch-menu button:hover,
.ch-menu button:focus-visible { background: color-mix(in srgb, var(--color-text) 7%, transparent); outline: none; }
.ch-menu .material-symbols-outlined { font-size: 19px; color: var(--color-text-soft); }

/* the messages */
.ch-msgs {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    margin: 0;
    padding: 20px 18px 12px;
    overflow-y: auto;
    list-style: none;
}

.ch-msgs-none {
    margin: auto;
    padding: 20px;
    font-size: 14px;
    color: var(--color-text-muted);
    text-align: center;
}

.ch-msg {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: min(78%, 640px);
}

.ch-msg.is-team { align-self: flex-end; }
.ch-msg.is-visitor { align-self: flex-start; }

.ch-msg-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.ch-msg.is-team .ch-msg-col { align-items: flex-end; }

/* the round picture next to a bubble: a person (the visitor), initials or a photo (the team) */
.ch-msg-ava {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-bottom: 22px;   /* level with the bubble, above its time */
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-text) 7%, var(--color-bg));
    color: var(--color-text-soft);
    object-fit: cover;
    font-size: 13.5px;
    font-weight: 800;
}

.ch-msg-ava .material-symbols-outlined { font-size: 21px; }

.ch-msg-ava.is-team {
    background: color-mix(in srgb, var(--color-green) 16%, var(--color-bg));
    color: var(--color-green-dark);
}

:root[data-theme="dark"] .ch-msg-ava.is-team { color: var(--color-green); }

.ch-msg-body {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ch-msg.is-visitor .ch-msg-body {
    border-end-start-radius: 6px;
    background: color-mix(in srgb, var(--color-text) 7%, var(--color-bg));
    color: var(--color-text);
}

.ch-msg.is-team .ch-msg-body {
    border-end-end-radius: 6px;
    background: color-mix(in srgb, var(--color-green) 16%, var(--color-bg));
    color: var(--color-text);
}

.ch-msg.is-pending .ch-msg-body { opacity: .65; }
.ch-msg.is-failed .ch-msg-body { opacity: 1; background: color-mix(in srgb, var(--ws-bad) 18%, var(--color-bg)); color: var(--color-text); }

.ch-msg-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.ch-msg-tick { display: inline-grid; color: var(--color-text-muted); }
.ch-msg-tick .material-symbols-outlined { font-size: 17px; }
.ch-msg-tick.is-seen { color: var(--color-green); }

.ch-msg-fail { margin-inline-start: 4px; font-weight: 700; color: var(--ws-bad); }

.ch-limit,
.ch-send-err,
.ch-compose-note {
    margin: 0 16px 8px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
}

.ch-limit { background: color-mix(in srgb, #f59e0b 16%, var(--color-bg)); }
.ch-send-err { background: color-mix(in srgb, var(--ws-bad) 12%, var(--color-bg)); color: var(--color-text); }
.ch-compose-note { background: color-mix(in srgb, var(--color-text) 6%, transparent); color: var(--color-text-soft); }

/* the field, the templates button and Send */
.ch-compose {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 0 14px;
    padding: 14px 0 16px;
    border-top: 1px solid var(--ws-line);
}

.ch-compose textarea {
    flex: 1;
    min-height: 48px;
    max-height: 180px;
    padding: 13px 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    font: inherit;
    font-size: 14.5px;
    line-height: 1.4;
    color: var(--color-text);
    resize: none;
}

.ch-compose textarea:focus {
    outline: none;
    border-color: var(--color-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 22%, transparent);
}

.ch-tplbtn {
    display: grid;
    flex: none;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    color: var(--color-text-soft);
}

.ch-tplbtn:hover,
.ch-tplbtn[aria-expanded="true"] { border-color: var(--color-green); color: var(--color-text); }
.ch-tplbtn .material-symbols-outlined { font-size: 22px; }

.ch-send { min-height: 48px; padding-inline: 20px; font-size: 15px; }
[dir="rtl"] .ch-send .material-symbols-outlined { transform: scaleX(-1); }

/* no free conversation left today: the field and Send wait (the notice above says why) */
.ch-compose textarea:disabled { opacity: .55; cursor: not-allowed; }
.ch-send:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }

/* the templates, over the field */
.ch-tplpop {
    position: absolute;
    inset-inline: 14px;
    bottom: 84px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 260px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

.ch-tplpop-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ch-tplpop-t { font-size: 13px; font-weight: 800; color: var(--color-text-soft); }

.ch-tpls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
}

.ch-tpl {
    max-width: 240px;
    height: 34px;
    padding: 0 14px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--glass-field);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--color-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-tpl:hover { border-color: var(--color-green); background: color-mix(in srgb, var(--color-green) 10%, transparent); }

.ch-tpl-none {
    font-size: 13px;
    color: var(--color-text-muted);
}

.ch-tpl-langsel {
    flex: none;
    max-width: 150px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--glass-field);
    font: inherit;
    font-size: 12.5px;
    color: var(--color-text);
}

/* ----- what the visitor did ----- */

.ch-act { padding: 0; }

.ch-act-t {
    margin: 0;
    padding: 20px 20px 10px;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.ch-facts {
    flex: none;
    margin: 0 14px;
    padding: 0 0 8px;
    list-style: none;
    border-bottom: 1px solid var(--ws-line);
}

.ch-facts li + li .ch-fact { border-top: 1px solid var(--ws-line); }

.ch-fact {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 6px;
    color: inherit;
    text-decoration: none;
}

a.ch-fact { border-radius: 10px; }
a.ch-fact:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

.ch-fact-ico {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-text) 6%, transparent);
    color: var(--color-text-soft);
    --si-size: 22px;
}

.ch-fact-ico .material-symbols-outlined { font-size: 21px; }

.ch-fact-text { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.3; }
.ch-fact-l { font-size: 12.5px; color: var(--color-text-muted); }
.ch-fact-v { overflow: hidden; font-size: 15px; font-weight: 700; color: var(--color-text); text-overflow: ellipsis; white-space: nowrap; }
.ch-fact-s { overflow: hidden; font-size: 12px; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.ch-fact-go { display: grid; flex: none; color: var(--color-text-muted); }

.ch-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px 14px;
}

.ch-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ch-tl {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 6px;
}

/* the line that joins the steps */
.ch-tl:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 42px;
    bottom: -9px;
    inset-inline-start: 23px;
    width: 2px;
    background: var(--ws-line);
}

.ch-tl-ico {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-text) 6%, transparent);
    color: var(--color-text-soft);
}

/* the newest step wears its colour (the others stay calm) */
.ch-tl.is-new .ch-tl-ico,
.ch-tl.is-event .ch-tl-ico {
    background: color-mix(in srgb, var(--tone) 15%, transparent);
    color: var(--tone);
}

.ch-tl.is-new .ch-tl-ico { box-shadow: 0 0 0 2px color-mix(in srgb, var(--tone) 35%, transparent); }

.ch-tl-ico .material-symbols-outlined { font-size: 19px; }

.ch-tl-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-top: 2px;
}

.ch-tl-t {
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ch-tl.is-new .ch-tl-t { font-weight: 800; }

.ch-tl-sub {
    font-size: 12.5px;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.ch-tl-at {
    flex: none;
    padding-top: 3px;
    font-size: 12.5px;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.ch-tl-more {
    padding: 8px 6px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

/* ===== the templates dialog ===== */

.ch-tpl-list {
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
}

.ch-tpl-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 0;
    border-bottom: 1px solid var(--color-border-soft);
}

.ch-tpl-item-t {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    font-size: 14px;
}

.ch-tpl-item-l {
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.ch-tpl-item .is-sure { color: var(--ws-bad, #dc2626); }

.ch-tpl-empty {
    padding: 14px 0;
    font-size: 14px;
    color: var(--color-text-soft);
}

.ch-tpl-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ch-tpl-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 34px;
    align-items: start;
    gap: 8px;
}

.ch-tpl-row select,
.ch-tpl-row textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    font: inherit;
    font-size: 14px;
    color: var(--color-text);
}

.ch-tpl-row textarea { resize: vertical; min-height: 44px; }

.ch-tpl-row select:focus,
.ch-tpl-row textarea:focus {
    outline: none;
    border-color: var(--color-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-green) 22%, transparent);
}

.ch-tpl-addlang { align-self: flex-start; }

/* ===== narrower screens: what the visitor did goes under the conversation; phones: the list or the visitor ===== */

@media (max-width: 1240px) {
    .ch-main {
        grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        height: auto;
    }

    .ch-side { grid-row: 1 / span 2; height: max(300px, var(--ch-fit)); }
    .ch-main:not(.is-detail) .ch-detail { grid-column: 2; }
    .ch-detail { height: max(300px, var(--ch-fit)); }
    .ch-act { grid-column: 2; max-height: 420px; }
}

@media (max-width: 860px) {
    .ch-start { margin-inline-start: 0; }

    .ch-main {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
    }

    .ch-side { grid-row: auto; height: auto; min-height: 360px; }
    .ch-main .ch-detail,
    .ch-main:not(.is-detail) .ch-detail { grid-column: auto; }
    .ch-act { grid-column: auto; max-height: none; }

    .ch-main.is-detail .ch-side { display: none; }
    .ch-main:not(.is-detail) .ch-detail,
    .ch-main:not(.is-detail) .ch-act { display: none; }

    .ch-detail { height: auto; min-height: calc(100dvh - 140px); }

    .ch-back { display: grid; }

    .ch-msg { max-width: 92%; }
    .ch-msg-ava { width: 30px; height: 30px; font-size: 12px; }
    .ch-send span:last-child { display: none; }
    .ch-send { padding-inline: 14px; }

    .ch-tpl-row { grid-template-columns: minmax(0, 1fr) 34px; }
    .ch-tpl-row select { grid-column: 1 / 2; }
    .ch-tpl-row textarea { grid-column: 1 / 3; }
    .ch-tpl-row .ch-tpl-rm { grid-row: 1; grid-column: 2; }
}

/* the top bar's popup (a visitor wrote): on this page at the bottom of the list, so it never covers the message field */
.ch-page .chatpop {
    inset-inline-start: 20px;
    inset-inline-end: auto;
}

/* the columns end 20px above the window's edge: the page's own bottom margin would only make the whole page scroll a little */
@media (min-width: 861px) {
    .ch-page .ws { padding-bottom: 20px; }
}

/* two columns: the list is narrower, so the popup narrows too and stays over the list, not over the reply box */
@media (min-width: 861px) and (max-width: 1240px) {
    .ch-page .chatpop { width: min(290px, calc(100vw - 32px)); }
}

/* phones: while a visitor is open (the message field at the bottom of the screen) the popup waits; it is back with the list */
@media (max-width: 560px) {
    .ch-page .chatpop { inset-inline: 16px; }
    .ch-page.ch-detail-open .chatpop { display: none; }
}
