/* Daily Life Doc, round 13 (zone F1): a client's Chat (js/chat/chat-view.js, chat-msg.js, chat-field.js,
   chat-files.js), drawn as the page "Expert Plans" draws the expert's Chat: the client's grey bubbles on the left,
   the AI's white outlined bubbles and the expert's deep green ones (--mine) on the right, each with its small label
   ("Text", "AI · Text", "You · Telegram"), the day and time dividers in the middle, the plan line's chip under an AI
   message in the line kind's colour, "Not delivered · <why>" in red, and the field at the foot. */

.cm-chat { position: relative; }
.cm-scroll { padding: 14px 18px 10px; }
.cm-list { display: flex; flex-direction: column; min-height: 100%; }
.cm-list > .emp { flex: 1; }
.cm-k { display: flex; flex-direction: column; }
.cm-k:first-child { margin-top: auto; }

/* ---------- A message ---------- */
.cm { display: flex; flex-direction: column; max-width: min(72%, 560px); margin-top: 10px; animation: cm-in var(--m-add) var(--ease-out); }
.cm-in { align-self: flex-start; align-items: flex-start; }
.cm-ai, .cm-me { align-self: flex-end; align-items: flex-end; }
.cm-l { padding: 0 6px 3px; font-size: var(--t-2xs); font-weight: 500; color: var(--ink3); white-space: nowrap; }
/* The time and a routine text's plan line join the label on hover, on focus, or after a tap (.open). */
.cm-more { display: none; }
.cm-more i { font-style: normal; opacity: .75; }
.cm:hover .cm-more, .cm.open .cm-more, .cm:focus-within .cm-more { display: inline; }
/* Round 28 (zone P): the next message of a run (same side, same channel, no time row between) sits closer and keeps
   its label hidden until hover or a tap; the row keeps its height, so nothing jumps when the label shows. */
.cm.cont { margin-top: 2px; }
.cm.cont .cm-l { visibility: hidden; }
.cm.cont:hover .cm-l, .cm.cont.open .cm-l, .cm.cont:focus-within .cm-l { visibility: visible; }
.cm-body { position: relative; display: flex; flex-direction: column; align-items: inherit; max-width: 100%; }
.cm-b { padding: 8px 14px; border-radius: 16px; font-size: var(--t-s); line-height: 1.42; overflow-wrap: anywhere; }
.cm-in .cm-b { background: var(--bubble); color: var(--ink); border-bottom-left-radius: 6px; }
.cm-ai .cm-b { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--cardline); border-bottom-right-radius: 6px; }
.cm-me .cm-b { background: var(--mine); color: var(--on-mine); border-bottom-right-radius: 6px; }
.cm-me .cm-b a { color: inherit; }
.cm-t { white-space: pre-wrap; }
.cm-tr { display: block; font-size: var(--t-2xs); font-weight: 600; color: var(--ink3); }
.cm-files + .cm-b { margin-top: 4px; }
.cm-k[data-local] .cm-b { opacity: .7; }
@keyframes cm-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* A link the message carries: its title and its address, as a card inside the bubble. */
.cm-link { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; text-decoration: none; color: inherit; }
.cm-t + .cm-link { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--cardline); }
.cm-link b { font-size: var(--t-s); font-weight: 600; }
.cm-link span { font-size: var(--t-xs); color: var(--ink3); overflow-wrap: anywhere; }
.cm-me .cm-link span { color: color-mix(in srgb, var(--on-mine) 75%, transparent); }

/* Under a message: Reading…, the buttons it carried, its delivery. */
.cm-u { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 4px 0; }
.cm-u .qw { font-size: var(--t-xs); }
/* Round 25 (R5): the AI's reaction under the client's bubble, a small pill that tucks under the bubble's edge. */
.cm-react { position: relative; z-index: 1; margin: -10px 0 0 8px; padding: 1px 7px; border-radius: 999px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-size: 15px; line-height: 22px; }
/* Round 27 (RX): the client's reaction on the AI's or the expert's message tucks under the bubble's right edge; a
   reaction whose message is not in the chat stands alone on the client's side. */
.cm-ai .cm-react, .cm-me .cm-react { margin: -10px 8px 0 0; }
.cm-ai .cm-u, .cm-me .cm-u { justify-content: flex-end; }
.cm-rx .cm-react { margin: 0; }
.cm-btns { display: inline-flex; gap: 4px; }
.cm-btns span { padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--ink2); font-size: var(--t-xs); font-weight: 600; }
.cm-dl { font-size: var(--t-xs); font-weight: 500; color: var(--ink3); }
.cm-dl.bad { color: var(--bad-d); }
.cm-dl button { font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* The plan line's chip under an AI message, in the middle, in the kind's colour. */
.cm-mid { display: flex; justify-content: center; margin-top: 8px; }
.cm-chip { padding: 4px 12px; border-radius: 14px; font-size: var(--t-xs); font-weight: 500; text-align: center; }
.cm-chip.k-sch { background: var(--atlas-bg); color: var(--atlas-d); }
.cm-chip.k-when { background: var(--try-bg); color: var(--try-d); }
.cm-chip.k-ask { background: var(--good-bg); color: var(--good-d); }
.cm-chip.k-rep { background: var(--soft); color: var(--ink2); }
.cm-chip.k-apr { background: var(--care); color: var(--care-d); }

/* A line by the system, and the dividers. A long line wraps in a box with round corners (fixer FX-W of round 38:
   the pill's 999px radius drew a line of several lines as an ellipse and cut its first and last lines). */
.cm-sys { align-self: center; max-width: 90%; margin-top: 10px; }
.cm-sys span { display: inline-block; padding: 4px 12px; border-radius: 14px; overflow-wrap: anywhere; background: var(--care); color: var(--care-d); font-size: var(--t-xs); font-weight: 500; text-align: center; }
.cm-sys.grey span { background: var(--soft); color: var(--ink2); }
.cm-day { align-self: center; margin: 16px 0 2px; font-size: var(--t-xs); font-weight: 500; color: var(--ink3); text-align: center; }
.cm-day i, .cptime i { font-style: normal; color: var(--ink3); opacity: .75; }

/* Files in a message. */
.cm-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cm-in .cm-files { justify-content: flex-start; }
.cm-ai .cm-files, .cm-me .cm-files { justify-content: flex-end; }
.cf-ph img { display: block; width: 180px; height: 180px; object-fit: cover; border-radius: 14px; background: var(--soft); }
.cf-vid { display: block; width: 240px; max-width: 100%; border-radius: 14px; background: #000; }
.cf-voice { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 14px; background: var(--bubble); }
.cf-voice small { font-size: var(--t-2xs); font-weight: 600; color: var(--ink3); }
.cf-voice audio { width: 240px; max-width: 100%; height: 36px; }
.cf-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--soft); color: var(--ink); font-size: var(--t-sm); text-decoration: none; }
.cf-file svg { width: 16px; height: 16px; flex: none; }
.cf-file small { color: var(--ink3); }
.cf-wait { width: 120px; height: 90px; border-radius: 14px; background: var(--soft); }

/* ---------- The quiet line while Pause AI is on, the field ---------- */
.cm-paused { flex: none; padding: 7px 16px; border-top: 1px solid var(--cardline); background: var(--try-bg); color: var(--try-d); font-size: var(--t-xs); font-weight: 500; text-align: center; }
.cm-field { align-items: flex-end; }
.cm-plus { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--field); color: var(--ink2);
  transition: transform var(--m-press) var(--ease-out); }
.cm-plus:active, .csend:active { transform: scale(.92); }
.cm-plus svg { width: 18px; height: 18px; }
.cm-box { flex: 1; min-width: 0; min-height: 40px; max-height: 150px; padding: 9px 14px; border: 0; border-radius: 20px; background: var(--field); color: var(--ink);
  font: inherit; font-size: var(--t-s); line-height: 1.4; resize: none; outline: none; }
.cm-box:focus { box-shadow: inset 0 0 0 1.5px var(--sage); }
.cm-up { align-self: center; font-size: var(--t-xs); }
/* The knowledge base item picked with "@" (fixer FX-AT): one pill on its own row above the words, with ✕. */
.cm-field { flex-wrap: wrap; }
.cm-pick { flex: 1 0 100%; display: flex; align-items: center; gap: 2px; padding-left: 48px; animation: cm-pick-in var(--m-step) var(--ease-out); }
.cm-pick[hidden] { display: none; }
.cm-pick .kref { max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.cm-unpick { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--ink3); }
.cm-unpick svg { width: 12px; height: 12px; }
@keyframes cm-pick-in { from { opacity: 0; transform: translateY(4px); } }
.csend { transition: opacity var(--m-step) ease, transform var(--m-press) var(--ease-out); }

@media (max-width: 880px) {
  .cm-scroll { padding: 10px 12px 8px; }
  .cm { max-width: 86%; }
  .cf-ph img { width: 150px; height: 150px; }
}
