:root { --bg: #f4f6f5; --panel: #fff; --ink: #17201d; --muted: #5d6b66; --line: #dde3e0; --brand: #0f5c4d; --brand-bg: #0f5c4d; --brand-ink: #fff; --mine: #d9efe8; --theirs: #fff; --admin: #fff3d6; --warn: #8a5300; --warn-bg: #fff4e0; --bad: #a42020; --tag-ink: #fff; --danger-ink: #a42020; --skel: #e3e8e6; }
/* dark (UI QA #6, WCAG AA 4.5:1): --brand is the ACCENT for text on dark surfaces (#4fc2a6: 7.6:1 on the panel, 5.9:1 on an Admin bubble, 5.4:1 on
   your own bubble); --brand-bg is the background under white text (#17695a: 6.6:1; the 85 % subtitle 5.2:1). The ADMIN tag is dark on amber
   (11:1); "Switch chat off" is dark red on white (7.5:1) */
@media (prefers-color-scheme: dark) { :root { --bg: #0f1412; --panel: #18201d; --ink: #e6ece9; --muted: #a9b6b0; --line: #2a3531; --brand: #4fc2a6; --brand-bg: #17695a; --mine: #1f3d35; --theirs: #1d2623; --admin: #3a3120; --warn: #f0c060; --warn-bg: #2f2716; --bad: #ff8a8a; --tag-ink: #1a1205; --danger-ink: #a42020; --skel: #222c28; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--bg); overflow: hidden; }
#bar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--brand-bg); color: var(--brand-ink); min-height: 52px; }
#heading { flex: 1; min-width: 0; }
#title { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#subtitle { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--brand-bg); color: var(--brand-ink); min-height: 44px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.icon { background: transparent; color: inherit; font-size: 26px; line-height: 1; padding: 4px 10px; min-width: 44px; }
button.small { min-height: 44px; min-width: 44px; padding: 6px 10px; font-size: 13px; }
button.danger { background: #fff; color: var(--danger-ink); }
button.link { background: transparent; color: var(--brand); min-height: 44px; margin: 6px auto; display: block; }
.badge { background: #fff; color: var(--brand-bg); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c9d2cf; flex: none; }
.dot.on { background: #7dffb0; }
#banner { padding: 10px 14px; background: var(--warn-bg); color: var(--warn); font-size: 14px; border-bottom: 1px solid var(--line); }
#banner button { margin-left: 8px; min-height: 44px; padding: 6px 12px; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#thread { position: relative; }
section[hidden], [hidden] { display: none !important; }
#login { padding: 24px 16px; gap: 12px; }
#login input { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 10px; width: 8em; margin: 0 8px; background: var(--panel); color: var(--ink); }
#tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
#tabs button { flex: 1; background: transparent; color: var(--muted); border-radius: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
#tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
#search { margin: 10px 12px 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
#list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; }
#list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); cursor: pointer; min-height: 60px; }
#list li:active { background: var(--mine); }
#list .who { flex: 1; min-width: 0; }
#list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .count { background: var(--brand-bg); color: var(--brand-ink); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); text-align: center; padding: 24px; }
#msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.m { max-width: 85%; padding: 8px 10px; border-radius: 12px; background: var(--theirs); border: 1px solid var(--line); align-self: flex-start; overflow-wrap: anywhere; white-space: pre-wrap; }
.m.me { align-self: flex-end; background: var(--mine); }
.m.admin { background: var(--admin); }
.m.sys { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; }
.m.pending { opacity: .6; }
.m .from { font-size: 12px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.m .q { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 6px; margin-bottom: 4px; white-space: normal; }
.m .t { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.tag { font-size: 10px; font-weight: 700; background: var(--warn); color: var(--tag-ink); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.note { padding: 10px 14px; background: var(--warn-bg); color: var(--warn); font-size: 14px; border-top: 1px solid var(--line); }
.hint { padding: 6px 14px; color: var(--bad); font-size: 13px; background: var(--panel); }
#replybar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
#replytext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#composer { display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
#input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 18px; resize: none; max-height: 30vh; background: var(--bg); color: var(--ink); }
/* mobile text-chat polish (Agent 3): reconnect indicator, "new messages" button, tap targets */
#conn { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); color: var(--muted); font-size: 14px; border-bottom: 1px solid var(--line); }
#conn::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; animation: nkpulse 1.2s ease-in-out infinite; }
#conn.down::before { background: var(--bad); animation: none; }
#conntext { flex: 1; min-width: 0; }
#conn button { min-height: 44px; padding: 6px 12px; flex: none; }
@keyframes nkpulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { #conn::before { animation: none; } }
#jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 2; border-radius: 999px; padding: 10px 18px; min-height: 44px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#send { min-width: 64px; }
#input { min-height: 44px; font-size: 16px; }
#replyx { min-height: 44px; }
/* combined fix round (UI QA): loading skeleton (#7), Back to CRM (#4), Hold note on the home screen (#1), screen-reader-only text (#9) */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#boot { padding: 20px 16px; gap: 12px; }
.boottext { margin: 0; color: var(--muted); }
.skel { height: 56px; border-radius: 10px; background: var(--skel); animation: nkpulse 1.4s ease-in-out infinite; }
.skel.short { width: 60%; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; text-decoration: none; font-weight: 600; align-self: flex-start; padding: 12px 20px; }
.small { font-size: 14px; padding: 0; text-align: left; }
#homenote { border-top: 0; border-bottom: 1px solid var(--line); }
#list li:focus-visible, .m:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
