/* My Virtual World Online — Copyright (c) 2026 My Virtual World. All rights reserved. Proprietary and confidential: not open source, not MIT-licensed. No copying, porting, re-implementation or AI training without written permission (see LICENSE). · ref 0c8a5dff84bd */
/* The chat window (client/js/ui/chat.js; docs/features/CHAT.md §7, §12): by default a window floating at the bottom
   right over the world, moved by its header and sized from its top and left edges; full screen with one button (a phone is
   always full screen). The Sidebar (the agent's chats and the tools: Search, Projects, Library, Notifications) sits
   beside the chat when the window is wide enough and slides over it when it isn't — at every size. Colours come from the
   theme (theme.css), so the light and dark themes both hold and it is as see-through as Settings → Display →
   Transparency says, like every window; the accent is the platform's sky blue. */
.chat-back { z-index: 7; }
/* (#ui > * takes the pointer: the floating window's layer must not, or the world under it could not be clicked) */
#ui > .chat-back.floating, .chat-back.floating { position: fixed; inset: 0; pointer-events: none; background: none; }
.chatwin { --cw-acc: #38bdf8; --cw-col: 780px; --cw-bg: var(--panel-strong);
  display: grid; grid-template-columns: 0 minmax(0, 1fr); padding: 0; overflow: hidden; border-radius: 18px; position: relative;
  background: var(--cw-bg); animation: cw-in .22s cubic-bezier(.2, .9, .3, 1.1); container: cw / inline-size; }
.chat-back.modal-back .chatwin { width: min(1180px, calc(100vw - 24px)); height: min(860px, calc(100dvh - var(--topbar-height, 56px) - 20px)); margin-top: var(--topbar-height, 56px); }
.chat-back.floating .chatwin { position: fixed; pointer-events: auto; margin: 0; border-color: var(--line-3); box-shadow: 0 18px 50px var(--shadow-c4); }
/* (a side panel or the selection widget coming or going moves it — as they slide) */
.chat-back.floating .chatwin:not(.dragging) { transition: right .2s ease, bottom .2s ease, width .2s ease, height .2s ease; }
.chatwin.wide { grid-template-columns: 268px minmax(0, 1fr); }
.chatwin.wide.side-hidden { grid-template-columns: 0 minmax(0, 1fr); }
/* what is said can be selected and copied (the page turns selection off for the world: body { user-select: none }); its
   buttons and avatars can't, and nothing is while the window is moved or sized */
.chatwin .cw-thread { user-select: text; -webkit-user-select: text; cursor: auto; }
.chatwin .cw-thread :is(button, .cw-mav, .cw-mact, .cw-meta, .cw-modeline) { user-select: none; -webkit-user-select: none; }
.chatwin .cw-thread ::selection { background: color-mix(in srgb, var(--cw-acc) 35%, transparent); }
.chatwin.dragging, .chatwin.dragging .cw-thread { user-select: none; -webkit-user-select: none; }
@keyframes cw-in { from { opacity: 0; transform: translateY(12px) scale(.988); } to { opacity: 1; transform: none; } }
.chatwin button { font: inherit; }
/* its edges, to size it (floating only) */
.cw-grip { position: absolute; z-index: 10; touch-action: none; }
.cw-grip.nw { left: 0; top: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.cw-grip.n { left: 14px; right: 0; top: 0; height: 5px; cursor: ns-resize; }
.cw-grip.w { left: 0; top: 14px; bottom: 0; width: 5px; cursor: ew-resize; }
.chat-back:not(.floating) .cw-grip { display: none; }
.chat-back.floating .cw-head { cursor: grab; touch-action: none; }
.chatwin.dragging .cw-head { cursor: grabbing; }
.chat-back.floating .cw-head button { cursor: pointer; }

/* ---- the Sidebar */
.cw-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg2) 70%, transparent); }
.chatwin.wide.side-hidden .cw-side { visibility: hidden; }
.cw-side-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 4px 14px; }
.cw-side-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); }
.cw-side-x { width: 28px; height: 28px; border-color: transparent; background: transparent; color: var(--dim); }
.cw-new { margin: 4px 10px 6px; display: flex; align-items: center; gap: 8px; justify-content: flex-start; font-weight: 600; padding: 8px 10px; }
.cw-navs { display: flex; flex-direction: column; gap: 1px; padding: 0 6px 8px; border-bottom: 1px solid var(--line); }
.cw-nav { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer; font-size: 13.5px; text-align: left; }
.cw-nav:hover { background: var(--btn-hover); }
.cw-nav.on { background: color-mix(in srgb, var(--cw-acc) 16%, transparent); }
.cw-nav-ic { width: 18px; flex: none; display: grid; place-items: center; color: var(--dim); }
.cw-nav.on .cw-nav-ic { color: var(--cw-acc); }
.cw-nav-n { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.cw-view-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px; min-width: 0; }
.cw-view-title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-back { border-color: transparent; background: transparent; }
.cw-search { display: flex; align-items: center; gap: 6px; margin: 4px 10px 6px; padding: 6px 10px; border-radius: 10px; background: var(--btn); border: 1px solid var(--line); }
.cw-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; }
.cw-search span { color: var(--dim); }
.cw-list { flex: 1; overflow-y: auto; padding: 2px 6px 12px; overscroll-behavior: contain; }
.cw-group { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--dim); padding: 12px 8px 4px; }
.cw-item { display: flex; align-items: center; border-radius: 9px; }
.cw-item:hover, .cw-item.on { background: var(--btn-hover); }
.cw-item.on { box-shadow: inset 2px 0 0 var(--cw-acc); }
.cw-item-open, .cw-item.hit, .cw-proj-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; border-radius: 9px; }
.cw-item.hit { flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
.cw-proj-item { width: 100%; }
.cw-item.hit:hover, .cw-proj-item:hover { background: var(--btn-hover); }
.cw-item-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.cw-item.hit .cw-item-t { flex: none; max-width: 100%; }
.cw-item-p { flex: none; max-width: 42%; font-size: 11px; color: var(--dim); border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-item-n { flex: none; font-size: 11.5px; color: var(--dim); }
.cw-proj-ic { flex: none; color: var(--dim); }
.cw-snip { font-size: 12px; color: var(--dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cw-snip mark { background: color-mix(in srgb, var(--cw-acc) 35%, transparent); color: var(--text); border-radius: 3px; }
.cw-item-more { flex: none; opacity: 0; border: 0; background: transparent; color: var(--dim); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.cw-item:hover .cw-item-more, .cw-item.on .cw-item-more, .cw-item-more:focus-visible { opacity: 1; }
@media (pointer: coarse) { .cw-item-more { opacity: .7; } }
.cw-empty { color: var(--dim); font-size: 13px; padding: 16px 10px; line-height: 1.5; }
.cw-empty .btn { margin-top: 10px; }
/* a project: its instructions, a new chat in it, its chats */
.cw-proj { display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 10px; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
.cw-proj-l { font-size: 12px; color: var(--dim); padding: 0 2px; }
.cw-proj-in { width: 100%; min-height: 84px; max-height: 40vh; resize: vertical; font: inherit; font-size: 13px; line-height: 1.45; border-radius: 10px; padding: 8px 10px; box-sizing: border-box; }
.cw-proj-row { display: flex; align-items: center; gap: 6px; }
.cw-proj-st { font-size: 12px; }
.cw-proj-new { display: flex; align-items: center; gap: 8px; justify-content: flex-start; }
/* the Library */
.cw-lib { display: flex; flex-direction: column; gap: 2px; }
.cw-lib-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 9px; }
.cw-lib-item:hover { background: var(--btn-hover); }
.cw-lib-open { flex: none; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--btn); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 18px; }
.cw-lib-open img { width: 100%; height: 100%; object-fit: cover; }
.cw-lib-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cw-lib-n { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-lib-s { font-size: 11.5px; color: var(--dim); }
.cw-lib-b { flex: none; display: flex; align-items: center; gap: 2px; }
.cw-lib-b .btn.icon { width: 26px; height: 26px; border-color: transparent; background: transparent; color: var(--dim); }
/* not wide enough to sit beside the chat: the Sidebar slides over it */
.chatwin:not(.wide) { grid-template-columns: minmax(0, 1fr); }
.chatwin:not(.wide) .cw-side { position: absolute; z-index: 8; inset: 0 auto 0 0; width: min(300px, 86%); visibility: hidden; transform: translateX(-102%); transition: transform .22s ease, visibility 0s .22s;
  background: var(--cw-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 8px 0 30px var(--shadow-c4); }
:root.see-through .chatwin:not(.wide) .cw-side { backdrop-filter: none; -webkit-backdrop-filter: none; }
.chatwin.drawer .cw-side { visibility: visible; transform: none; transition: transform .22s ease; }
.chatwin.drawer .cw-main::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .35); z-index: 7; }

/* ---- the open chat */
/* (one column, never wider than the window: an implicit 'auto' column grew to the widest thing in a message — a table, a
   line of code — and pushed the header's buttons, the send button and the text past the window's edge) */
.cw-main { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); min-width: 0; min-height: 0; }
.cw-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.chatwin.wide:not(.side-hidden) .cw-burger { display: none; }
.cw-agent { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 8px 4px 4px; border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer; }
.cw-agent:hover { background: var(--btn-hover); }
.cw-av { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--cw-acc) 28%, var(--bg2)), color-mix(in srgb, var(--cw-acc) 6%, var(--bg2))); }
.cw-id { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.15; }
.cw-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-status { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-status.live { color: var(--good); }
.cw-caret { color: var(--dim); font-size: 11px; }
.cw-title { flex: 1; min-width: 0; text-align: center; color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-acts { display: flex; gap: 2px; flex: none; margin-left: auto; }
.cw-acts .btn.icon { border-color: transparent; background: transparent; }
.cw-acts .btn.icon:hover:not(:disabled) { background: var(--btn-hover); }
.cw-acts .btn.icon:disabled { opacity: .35; cursor: default; }

.cw-scroll { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-behavior: auto; min-width: 0; }
.cw-thread { max-width: var(--cw-col); margin: 0 auto; padding: 18px 18px 26px; display: flex; flex-direction: column; gap: 18px; }
.cw-main:has(.cw-rail:not([hidden])) .cw-thread { padding-right: 32px; }
.cw-msg { position: relative; min-width: 0; }
.cw-msg.user { align-self: flex-end; max-width: min(78%, 620px); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cw-bubble { background: color-mix(in srgb, var(--text) 9%, transparent); border-radius: 18px 18px 6px 18px; padding: 9px 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.cw-msg.assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.cw-mav { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--btn); }
.cw-mbody { min-width: 0; }
.cw-msg.sys { align-self: center; max-width: 90%; font-size: 13px; color: var(--dim); text-align: center; padding: 6px 12px; border-radius: 10px; background: var(--btn); }
.cw-msg.sys.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.cw-msg.flash .cw-bubble, .cw-msg.flash .cw-md { animation: cw-flash 1.6s ease; }
@keyframes cw-flash { 0%, 40% { background: color-mix(in srgb, var(--cw-acc) 25%, transparent); } 100% { background: transparent; } }
.cw-msg.user.flash .cw-bubble { animation-name: cw-flash-me; }
@keyframes cw-flash-me { 0%, 40% { background: color-mix(in srgb, var(--cw-acc) 32%, transparent); } 100% { background: color-mix(in srgb, var(--text) 9%, transparent); } }
.cw-stopped { font-size: 12px; color: var(--dim); margin-top: 4px; }
.cw-mact { display: flex; align-items: center; gap: 2px; margin-top: 4px; min-height: 26px; opacity: 0; transition: opacity .15s; }
.cw-msg:hover .cw-mact, .cw-msg:focus-within .cw-mact, .cw-msg.assistant:last-child .cw-mact { opacity: 1; }
@media (pointer: coarse) { .cw-mact { opacity: 1; } }
.cw-ic { border: 0; background: transparent; color: var(--dim); cursor: pointer; width: 28px; height: 26px; border-radius: 7px; font-size: 14px; }
.cw-ic:hover { background: var(--btn-hover); color: var(--text); }
.cw-meta { font-size: 11.5px; color: var(--muted-2); margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-msg.user.editing { width: min(100%, 620px); max-width: none; }
.cw-edit-in { width: 100%; min-height: 70px; resize: vertical; border-radius: 14px; padding: 10px 12px; font: inherit; line-height: 1.5; }
.cw-edit-acts { display: flex; gap: 6px; justify-content: flex-end; }

/* the message rail: a tick for each message the person sent; hover (or tap) lists them; a click goes back to one
   (client/js/ui/chat-rail.js; after 9085's chat-prompt-navigation) */
.cw-rail { position: absolute; right: 5px; top: 50%; z-index: 3; transform: translateY(-50%); max-height: 56%; display: flex; flex-direction: column; justify-content: center; }
.cw-rail[hidden] { display: none; }
.cw-rail-ticks { display: flex; flex-direction: column; align-items: flex-end; padding: 4px 0; min-height: 0; overflow: hidden; }
.cw-rail-tick { display: flex; width: 26px; height: 10px; flex: 0 1 10px; min-height: 3px; align-items: center; justify-content: flex-end; padding: 0 1px 0 0; border: 0; outline: 0; background: transparent; cursor: pointer; }
.cw-rail-tick > span { display: block; width: 9px; height: 2px; border-radius: 999px; background: color-mix(in srgb, var(--text) 42%, transparent); transition: width .1s ease-out, background-color .1s ease-out; }
.cw-rail-tick.on > span, .cw-rail-tick.hov > span, .cw-rail-tick:hover > span, .cw-rail-tick:focus-visible > span { width: 14px; background: var(--gold); }
.cw-rail-tick:focus-visible { border-radius: 4px; box-shadow: 0 0 0 1px var(--gold); }
.cw-rail-pop { position: absolute; top: 50%; right: calc(100% + 4px); width: 300px; max-height: 340px; overflow-x: hidden; overflow-y: auto; padding: 5px;
  border: 1px solid var(--line-3); border-radius: 10px; background: var(--panel-strong); box-shadow: 0 14px 34px var(--shadow-c4);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translate(4px, -50%); transition: opacity .12s ease-out, transform .12s ease-out, visibility 0s .12s; }
.cw-rail.open .cw-rail-pop { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(0, -50%); transition: opacity .12s ease-out, transform .12s ease-out; }
.cw-rail-row { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--dim); padding: 6px 8px; border-radius: 7px; font-size: 12.5px; line-height: 1.35; cursor: pointer; }
.cw-rail-row > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.cw-rail-row:hover, .cw-rail-row.hov { background: var(--btn-hover); color: var(--text); }
.cw-rail-row.on { color: var(--text); background: color-mix(in srgb, var(--gold) 14%, transparent); }
@media (prefers-reduced-motion: reduce) { .cw-rail-pop, .cw-rail.open .cw-rail-pop, .cw-rail-tick > span { transition: none; } }

/* attachments in a message */
.cw-mfiles { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.cw-thumb img { display: block; max-width: 220px; max-height: 220px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; }
.cw-fchip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 12px; background: var(--btn); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px; max-width: 260px; }
.cw-fchip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the answer being written, thinking, steps */
.cw-wait { color: var(--dim); font-size: 14px; display: flex; align-items: center; gap: 8px; padding-top: 5px; }
.cw-dots { display: inline-flex; gap: 4px; }
.cw-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cw-acc); animation: cw-dot 1.2s infinite ease-in-out; }
.cw-dots i:nth-child(2) { animation-delay: .15s; } .cw-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cw-dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.cw-caret { display: inline-block; width: 8px; height: 1.05em; vertical-align: text-bottom; margin-left: 2px; border-radius: 2px; background: var(--cw-acc); animation: cw-blink 1s steps(2) infinite; }
.cw-agent .cw-caret { width: auto; height: auto; background: none; animation: none; }
@keyframes cw-blink { 50% { opacity: 0; } }
.cw-think { margin: 0 0 8px; border-left: 2px solid var(--line-3); padding-left: 10px; }
.cw-think summary { cursor: pointer; color: var(--dim); font-size: 13px; list-style: none; }
.cw-think summary::before { content: '▸ '; } .cw-think[open] summary::before { content: '▾ '; }
.cw-think.live summary { background: linear-gradient(90deg, var(--dim), var(--text), var(--dim)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: cw-shine 2s linear infinite; }
@keyframes cw-shine { to { background-position: -200% 0; } }
.cw-think-t { white-space: pre-wrap; color: var(--dim); font-size: 13px; line-height: 1.5; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.cw-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cw-step { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--btn); color: var(--dim); }
.cw-step.ok { color: var(--good); } .cw-step.bad { color: var(--bad); }

/* Markdown (client/js/ui/chat-md.js) */
.cw-md { line-height: 1.62; overflow-wrap: anywhere; font-size: 15px; }
.cw-md > :first-child { margin-top: 0; } .cw-md > :last-child { margin-bottom: 0; }
.cw-md p, .cw-md ul, .cw-md ol, .cw-md blockquote, .cw-md .md-table, .cw-md .md-code { margin: 0 0 12px; }
.cw-md h1, .cw-md h2, .cw-md h3, .cw-md h4, .cw-md h5, .cw-md h6 { margin: 18px 0 8px; line-height: 1.3; }
.cw-md h1 { font-size: 1.45em; } .cw-md h2 { font-size: 1.28em; } .cw-md h3 { font-size: 1.12em; } .cw-md h4, .cw-md h5, .cw-md h6 { font-size: 1em; }
.cw-md ul, .cw-md ol { padding-left: 1.5em; } .cw-md li { margin: 3px 0; } .cw-md li > ul, .cw-md li > ol { margin: 4px 0; }
.cw-md li.task { list-style: none; margin-left: -1.3em; }
.cw-md a { color: var(--cw-acc); text-decoration: underline; text-underline-offset: 2px; }
.cw-md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: color-mix(in srgb, var(--text) 10%, transparent); padding: .12em .38em; border-radius: 5px; }
.cw-md blockquote { border-left: 3px solid var(--line-3); padding: 2px 0 2px 12px; color: var(--dim); }
.cw-md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md-code { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: color-mix(in srgb, #000 35%, var(--bg2)); }
.md-code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; font-size: 12px; color: var(--dim); background: color-mix(in srgb, var(--text) 6%, transparent); }
.md-copy { border: 0; background: transparent; color: var(--dim); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.md-copy:hover { color: var(--text); background: var(--btn-hover); }
.md-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.md-code pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; white-space: pre; color: var(--text); }
.md-table { overflow-x: auto; }
.md-table table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md-table th, .md-table td { border: 1px solid var(--line-2); padding: 6px 10px; vertical-align: top; }
.md-table th { background: color-mix(in srgb, var(--text) 6%, transparent); font-weight: 600; }

/* the first look of a chat */
.cw-hello { text-align: center; padding: min(12vh, 90px) 10px 20px; }
.cw-hello-av { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; font-size: 36px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--cw-acc) 30%, var(--bg2)), color-mix(in srgb, var(--cw-acc) 6%, var(--bg2))); box-shadow: 0 8px 28px color-mix(in srgb, var(--cw-acc) 25%, transparent); }
.cw-hello h2 { margin: 0 0 6px; font-size: 24px; }
.cw-hello p { margin: 0 auto 18px; max-width: 460px; font-size: 14px; }
.cw-sugg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 560px; margin: 0 auto; }
.cw-sug { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; font-size: 13.5px; }
.cw-sug:hover { background: var(--btn-hover); }

/* can't chat */
.cw-blocked { position: absolute; inset: 56px 0 0; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.cw-blk-card { max-width: 420px; text-align: center; }
.cw-blk-av { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; background: var(--btn); }
.cw-blk-card p { font-size: 15px; line-height: 1.5; margin: 0 0 14px; }

.cw-down { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-3);
  background: var(--panel-strong); color: var(--text); cursor: pointer; box-shadow: var(--shadow); z-index: 2; }

/* ---- the composer */
.cw-foot { padding: 0 14px 10px; }
.cw-box { max-width: var(--cw-col); margin: 0 auto; border: 1px solid var(--line-3); border-radius: 22px; background: var(--bg2); padding: 8px 8px 6px 12px;
  box-shadow: 0 6px 24px var(--shadow-c5); transition: border-color .15s; }
.cw-box:focus-within { border-color: color-mix(in srgb, var(--cw-acc) 55%, var(--line-3)); }
.cw-in { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; padding: 6px 2px; max-height: 38vh; }
/* (a small window: the tools wrap onto a second row, never cut off — the left ones stay left; the microphone, voice and
   send are one group, at the right edge, moving to the next row together) */
.cw-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; row-gap: 4px; }
.cw-tools-r { display: flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; max-width: 100%; }
.cw-grow { flex: 1; }
.cw-tool { border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 999px; padding: 5px 10px; cursor: pointer; font-size: 13px; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.cw-tool:hover { background: var(--btn-hover); color: var(--text); }
.cw-tool.on { color: var(--cw-acc); }
.cw-attach { font-size: 18px; line-height: 1; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-3); }
.cw-send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); font-size: 18px; font-weight: 700; cursor: pointer; flex: none; }
.cw-send:disabled { opacity: .35; cursor: default; }
.cw-send.stop { background: var(--text); font-size: 13px; }
.cw-note { text-align: center; font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.cw-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 6px; }
.cw-files.hidden { display: none; }
.cw-file-chip { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: 12px; background: var(--btn); border: 1px solid var(--line); max-width: 230px; font-size: 12.5px; }
.cw-file-chip.bad { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.cw-file-chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; }
.cw-file-ic { width: 34px; height: 34px; display: grid; place-items: center; font-size: 18px; border-radius: 8px; background: var(--btn); }
.cw-file-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-file-p { color: var(--dim); font-size: 11.5px; }
.cw-file-x { border: 0; background: transparent; color: var(--dim); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.cw-drop { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--cw-acc) 14%, var(--panel-strong)); border: 2px dashed var(--cw-acc); border-radius: 18px; z-index: 5; font-size: 18px; font-weight: 600; pointer-events: none; }

/* ---- menus */
.cw-pop { position: absolute; z-index: 9; min-width: 220px; max-width: min(420px, calc(100% - 16px)); overflow-y: auto; padding: 5px; border-radius: 14px;
  background: var(--panel-strong); border: 1px solid var(--line-3); box-shadow: 0 16px 40px var(--shadow-c4); }
.cw-pi { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.cw-pi:hover:not(:disabled) { background: var(--btn-hover); }
.cw-pi:disabled { color: var(--dim); cursor: default; }
.cw-pi.danger .cw-pi-l { color: var(--bad); }
.cw-pi-l { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-pi-l em { font-style: normal; font-size: 11px; color: var(--dim); margin-left: 4px; }
.cw-pi-s { grid-column: 1; font-size: 11.5px; color: var(--dim); margin-top: 1px; }
.cw-pi-ok { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--cw-acc); }
.cw-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.cw-pop-models { width: min(400px, calc(100% - 16px)); }
.cw-msearch { width: 100%; margin-bottom: 4px; }
.cw-pop-note { font-size: 11.5px; color: var(--dim); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ---- a small window (floating, or a phone): tighter, the chat's name in the header gives way */
@container cw (max-width: 699px) {
  .cw-thread { padding: 14px 12px 20px; gap: 16px; }
  .cw-main:has(.cw-rail:not([hidden])) .cw-thread { padding-right: 28px; }
  .cw-msg.user { max-width: 88%; }
  .cw-title { display: none; }
  .cw-foot { padding: 0 8px 8px; }
  .cw-note { display: none; }
  .cw-sugg { grid-template-columns: minmax(0, 1fr); }
  .cw-hello { padding-top: 5%; }
  .cw-hello h2 { font-size: 21px; }
  .cw-tool { padding: 5px 8px; max-width: 130px; }
  .cw-down { bottom: 120px; }
  .cw-thumb img { max-width: 180px; max-height: 180px; }
}
@container cw (max-width: 430px) {
  .cw-name { font-size: 14px; }
  .cw-agent { padding-right: 4px; }
  .cw-tool { max-width: 104px; }
  .cw-rail-pop { width: 220px !important; }
}
/* ---- a phone: the window is the whole screen below the top bar */
@media (max-width: 699px) {
  .chat-back.modal-back .chatwin { width: 100vw; height: calc(100dvh - var(--topbar-height, 56px)); border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .cw-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .cw-md { font-size: 15.5px; }
  .cw-in { font-size: 16px; }   /* (16 px: a phone does not zoom in on it) */
  .cw-hello { padding-top: 6vh; }
}

/* ---- an agent's payment waiting for its owner's OK, in the chat */
.cw-appr { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; padding: 10px 12px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); background: color-mix(in srgb, var(--gold) 9%, transparent); }
.cw-appr.approved { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: color-mix(in srgb, var(--good) 8%, transparent); }
.cw-appr.declined, .cw-appr.expired { opacity: .75; background: transparent; }
.cw-appr.failed { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.cw-appr-ic { font-size: 20px; }
.cw-appr-t { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.cw-appr-s { font-size: 12.5px; color: var(--dim); }
.cw-appr-b { display: flex; gap: 6px; }

/* ---- the bell (client/js/ui/notify.js) */
.bellb { position: relative; }
.bell-n { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; pointer-events: none; }
.bell-n.hidden { display: none; }
.bell-panel { position: fixed; z-index: 9; top: calc(var(--topbar-height, 56px) + 6px); right: 10px; width: min(400px, calc(100vw - 20px));
  max-height: min(620px, calc(100dvh - var(--topbar-height, 56px) - 20px)); display: flex; flex-direction: column; padding: 0; overflow: hidden; border-radius: 16px; }
.bell-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.bell-head .grow { flex: 1; }
.bell-list { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.bell-empty { padding: 26px 18px; color: var(--dim); font-size: 13.5px; line-height: 1.5; text-align: center; }
.bell-item { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: default; }
.bell-item[data-chat] { cursor: pointer; }
.bell-item:hover { background: var(--btn); }
.bell-item.unread { background: color-mix(in srgb, #38bdf8 8%, transparent); }
.bell-item.unread .bell-t::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #38bdf8; margin-left: 6px; vertical-align: middle; }
.bell-ic { font-size: 18px; flex: none; padding-top: 1px; }
.bell-txt { min-width: 0; flex: 1; }
.bell-t { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.bell-b { font-size: 13px; color: var(--dim); margin-top: 2px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bell-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bell-st { font-size: 12.5px; margin-top: 6px; color: var(--dim); }
.bell-st.approved { color: var(--good); } .bell-st.failed { color: var(--bad); }
.bell-when { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.bell-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bell-push { display: flex; align-items: center; gap: 8px; font-size: 13.5px; flex: 1; cursor: pointer; }
.bell-hint { width: 100%; font-size: 12px; color: var(--dim); line-height: 1.45; }
@media (max-width: 699px) { .bell-panel { right: 0; left: 0; width: 100vw; border-radius: 0 0 16px 16px; } }

/* ---- voice (client/js/ui/chat-voice.js; docs/features/CHAT.md §9.4): dictation, read aloud, voice mode */
.cw-mic, .cw-vm { width: 34px; height: 34px; padding: 0; font-size: 16px; line-height: 1; flex: none; display: grid; place-items: center; }
.cw-mic.on { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.cw-tools .cw-model { min-width: 0; flex: 0 1 auto; }
.cw-box.dictating .cw-tools { display: none; }
.cw-rec { display: flex; align-items: center; gap: 8px; padding: 2px 0 0; }
.cw-rec.hidden { display: none; }
.cw-rec-x, .cw-rec-ok { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-3); background: transparent; color: var(--text); cursor: pointer; flex: none; font-size: 15px; }
.cw-rec-ok { background: var(--primary); color: var(--on-primary); border: 0; font-weight: 700; font-size: 17px; }
.cw-rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); animation: cw-blink 1.2s step-end infinite; flex: none; }
.cw-rec-wave { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.cw-rec-wave i { flex: 1 1 0; max-width: 5px; min-width: 2px; height: 100%; border-radius: 2px; background: var(--cw-acc); transform: scaleY(.08); transition: transform .07s linear; }
.cw-rec-t { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--dim); }
.cw-rec-s { font-size: 12px; color: var(--dim); white-space: nowrap; }
.cw-rec-s:empty { display: none; }
.cw-rec.busy .cw-rec-dot { animation: none; background: var(--cw-acc); }
.cw-rec.busy .cw-rec-wave i { animation: vm-wave 1s ease-in-out infinite; }
.cw-rec.busy .cw-rec-wave i:nth-child(3n) { animation-delay: -.33s; }
.cw-rec.busy .cw-rec-wave i:nth-child(3n+1) { animation-delay: -.66s; }
.cw-rec.busy .cw-rec-ok { opacity: .45; pointer-events: none; }
@keyframes vm-wave { 50% { transform: scaleY(.6); } }
.cw-ic.on { color: var(--cw-acc); background: color-mix(in srgb, var(--cw-acc) 14%, transparent); }

/* voice mode, in the chat (2026-10-08: no window of its own): its status beside the buttons, and a blue glow that
   pulses with the sound — --lv, how loud now (0–1), set every frame by chat-voice.js — on the 🎧 button and the top edge of
   the message box; reading aloud, on the answer's blue stop square. (Its name in the world glows too: app.css .voicing.) */
.chatwin { --vm-blue: 56, 189, 248; }
.cw-vm.vm-on { color: rgb(var(--vm-blue)); border-color: rgba(var(--vm-blue), .7); background: rgba(var(--vm-blue), .14);
  box-shadow: 0 0 calc(5px + var(--lv, 0) * 18px) calc(var(--lv, 0) * 4px) rgba(var(--vm-blue), calc(.35 + var(--lv, 0) * .5)); }
.cw-box { position: relative; }
.cw-box.vm-on { border-top-color: rgba(var(--vm-blue), .75); }
.cw-box.vm-on::before { content: ''; position: absolute; left: 16px; right: 16px; top: -1px; height: 2px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(var(--vm-blue)) 12%, rgb(var(--vm-blue)) 88%, transparent);
  box-shadow: 0 0 calc(4px + var(--lv, 0) * 18px) calc(var(--lv, 0) * 4px) rgba(var(--vm-blue), calc(.45 + var(--lv, 0) * .5)); opacity: calc(.6 + var(--lv, 0) * .4); }
.cw-ic.on[data-a="speak"] { color: rgb(var(--vm-blue)); background: rgba(var(--vm-blue), .16);
  box-shadow: 0 0 calc(3px + var(--lv, 0) * 14px) calc(var(--lv, 0) * 3px) rgba(var(--vm-blue), calc(.35 + var(--lv, 0) * .55)); }
.cw-mic.muted { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.cw-vm-state { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; min-width: 0; color: rgb(var(--vm-blue)); border-color: rgba(var(--vm-blue), .35);
  background: rgba(var(--vm-blue), .08); overflow: hidden; }
.cw-vm-state.hidden { display: none; }
.cw-vm-state b { font-weight: 650; white-space: nowrap; }
.cw-vm-state small { color: var(--dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-vm-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--vm-blue)); transform: scale(calc(1 + var(--lv, 0) * .8)); }
.cw-vm-state[data-state="thinking"] .cw-vm-dot, .cw-vm-state[data-state="hearing"] .cw-vm-dot { animation: cw-dot 1.2s infinite ease-in-out; }
.cw-vm-state:is([data-state="paused"], [data-state="muted"], [data-state="starting"]) { color: var(--dim); border-color: var(--line-3); background: transparent; }
.cw-vm-state:is([data-state="paused"], [data-state="muted"], [data-state="starting"]) .cw-vm-dot { background: var(--dim); }
/* (the box's own buttons give way to the status in a small window) */
.chatwin.voice-mode .cw-effort .cw-tool-lb { display: none; }
@container cw (max-width: 520px) { .chatwin.voice-mode .cw-model { display: none; } .cw-vm-state { max-width: 190px; } }
/* (a phone in voice mode: attaching and the thinking effort wait, Work · Life keeps its icons — the status needs the room) */
@container cw (max-width: 520px) {
  .chatwin.voice-mode :is(.cw-attach, .cw-effort) { display: none; }
  .chatwin.voice-mode .cw-cmode .cw-tool-lb { display: none; }
}
@media (max-width: 699px) {
  .cw-effort .cw-tool-lb { display: none; }
  .cw-tools .cw-model { max-width: 112px; }
}
@media (prefers-reduced-motion: reduce) { .cw-vm-state .cw-vm-dot { animation: none !important; } }

/* ---- Work · Life (CHAT.md §13): the switch beside the model and effort, and the line where a chat switched */
.cw-cmode { display: inline-flex; flex: none; padding: 2px; gap: 2px; border-radius: 999px; background: var(--btn); border: 1px solid var(--line); }
.cw-cmode.hidden { display: none; }
.cw-cmode .cw-tool { padding: 3px 9px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.cw-cmode .cw-tool.on { background: color-mix(in srgb, var(--cm, var(--cw-acc)) 22%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--cm, var(--cw-acc)) 50%, transparent); font-weight: 600; }
.cw-cmode [data-cm="work"] { --cm: #818cf8; }
.cw-cmode [data-cm="life"] { --cm: #f59e0b; }
.cw-msg.sys.cw-modeline { align-self: stretch; max-width: none; background: none; padding: 0; display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.cw-modeline::before, .cw-modeline::after { content: ''; flex: 1; height: 1px; background: color-mix(in srgb, var(--cm) 45%, var(--line)); }
.cw-modeline > span { color: color-mix(in srgb, var(--cm) 70%, var(--text)); white-space: nowrap; }
.cw-modeline.work { --cm: #818cf8; } .cw-modeline.life { --cm: #f59e0b; }
/* (a narrow window: the mode it is in by name, the other by its icon) */
@container cw (max-width: 520px) { .cw-cmode .cw-tool:not(.on) .cw-tool-lb { display: none; } .cw-cmode .cw-tool { padding: 3px 7px; } }
/* (the window as it opens, 460 px: one row — the effort by its 💡 alone, the model's name shorter; smaller still, the row wraps) */
@container cw (max-width: 520px) { .cw-effort .cw-tool-lb { display: none; } .cw-tools .cw-model { max-width: 90px; } .cw-tools-r { gap: 2px; } }

/* ---- talking with someone else's agent (ui/talk-bar.js, CHAT.md §14): a short bar, its answers in the agent's bubble */
.tb { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(580px, calc(100vw - 24px));
  z-index: 6; padding: 8px 10px 8px 12px; border-radius: 18px; display: grid; gap: 6px; pointer-events: auto; box-shadow: var(--shadow); }
#ui > .tb { pointer-events: auto; }
body:has(> #ui > .tb) #phud .prompt { display: none; }   /* (the bar is the talk: no "E Talk to…" over it) */
.tb-top { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.tb-av { font-size: 18px; line-height: 1; flex: none; }
.tb-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-left { margin-left: auto; display: flex; gap: 10px; color: var(--dim); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-time.on { color: var(--text); font-weight: 600; }
.tb-msgs.low { color: var(--warn, #f59e0b); font-weight: 600; }
.tb-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--dim); font-size: 15px; cursor: pointer; }
.tb-x:hover { background: var(--btn-hover); color: var(--text); }
.tb-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-in { flex: 1; min-width: 0; height: 40px; border-radius: 12px; border: 1px solid var(--line-3); background: var(--bg2); color: var(--text); padding: 0 12px; font: inherit; font-size: 15px; outline: 0; }
.tb-in:focus { border-color: color-mix(in srgb, var(--primary) 55%, var(--line-3)); }
.tb-in:disabled { opacity: .55; }
.tb-count { flex: none; min-width: 50px; text-align: right; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.tb-count.low { color: var(--warn, #f59e0b); }
.tb-mic, .tb-send { flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 17px; display: grid; place-items: center; }
.tb-mic { border: 1px solid var(--line-3); background: var(--btn); color: var(--text); }
.tb-mic.on { color: #38bdf8; border-color: rgba(56, 189, 248, .8); box-shadow: 0 0 0 3px rgba(56, 189, 248, .35); }
.tb-send { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; }
.tb-mic:disabled, .tb-send:disabled { opacity: .35; cursor: default; }
.tb-note { font-size: 12.5px; color: var(--dim); } .tb-note:empty { display: none; } .tb-note.bad { color: var(--bad); }
/* a phone: the stick and the buttons are at the foot, and the keyboard rises from there — the bar goes under the top bar */
@media (pointer: coarse) { .tb { top: calc(64px + env(safe-area-inset-top)); bottom: auto; } .tb-count { display: none; } }
@media (max-width: 420px) { .tb-left { gap: 6px; font-size: 12px; } }
