/* Eclick identity: display the original E mark using a clipped viewport.
 * The source logo stays unchanged; its wordmark sits outside this viewport. */
:root {--primary:#007c83; --rail-blue:#008991; --brand-teal:#008991;}
.brand-e-icon {position:relative; display:inline-block; width:44px; height:44px; overflow:hidden; flex-shrink:0; background:#f8f8f8; border-radius:50%;}
.brand-e-icon img {position:absolute; width:156px; height:auto; max-width:none; max-height:none; left:-55px; top:0; padding:0; border:0;}
.brand-chat-text {font-family:inherit; font-size:25px; font-weight:650; letter-spacing:-.8px; color:#000000; line-height:1;}
.topbar .header-brand,.account-logo,.startup-brand {display:inline-flex; align-items:center; gap:10px; text-decoration:none;}
.topbar .header-brand {height:48px;}
/* Branding is a home link, not a utility button; keep its hover surface clear. */
.topbar a.header-brand:hover,
html[data-theme="dark"] .topbar a.header-brand:hover {background:transparent; border-color:transparent; box-shadow:none; text-decoration:none;}
.startup-brand {justify-content:center;}
/* A compact square avatar keeps the account header aligned with its text. */
.sidebar-title {align-items:center; gap:12px;}
.sidebar-title>.avatar {width:48px; height:48px; border-radius:14px; overflow:hidden; flex-shrink:0;}
.sidebar-title>.avatar img {display:block;}
/* Member collage: one half-height column beside two smaller member tiles. */
.avatar.group-avatar-collage {display:grid; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; gap:1px; padding:0; border-radius:50%; overflow:hidden; background:#fff;}
.group-avatar-cell {display:flex; align-items:center; justify-content:center; width:100%; height:100%; min-width:0; min-height:0; font-size:10px; font-weight:500; color:#5e443d; background:#f6d9ce; overflow:hidden;}
.group-avatar-cell.cell-0 {grid-row:1 / 3;}
.group-avatar-cell.cell-1 {background:#d8eeee; color:#255f63;}
.group-avatar-cell.cell-2 {background:#e4def3; color:#5e4e7e;}
.group-avatar-cell img {display:block; width:100%; height:100%; object-fit:cover;}
.collage-2 .cell-1 {grid-row:1 / 3;}
.collage-1 .cell-0 {grid-column:1 / 3;}
.group-profile .group-avatar-collage .group-avatar-cell {font-size:14px;}
/* Message actions stay keyboard reachable and do not depend on hover. */
.message-text {white-space:pre-wrap; overflow-wrap:anywhere;}
.message-actions {display:flex; gap:8px; margin-top:5px;}
/* Reserve the toolbar row to prevent bubbles jumping when actions appear. */
@media(hover:hover) and (pointer:fine) {
  .message .message-actions {opacity:0; pointer-events:none; transition:opacity 150ms ease;}
  .message:hover .message-actions,.message:focus-within .message-actions {opacity:1; pointer-events:auto;}
}
.message-actions .delete-message-action {color:#b42318;}
html[data-theme="dark"] .message-actions .delete-message-action {color:#ffb6ad;}
.message-actions button {min-height:32px; padding:4px 8px; border-radius:6px; color:#426669; font-size:12px;}
.message-actions button:hover {background:#deeeed; color:#00646b;}
.outgoing .message-actions {justify-content:flex-end;}
.compose-context {display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; padding:10px 12px; border-left:3px solid #008991; border-radius:6px; background:#e9f4f3; color:#284f52; font-size:13px;}
.compose-context span {overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.compose-context button {width:36px; height:36px; flex-shrink:0; border-radius:6px;}
.compose-context svg {width:18px; height:18px;}
.message-feedback {color:#b42318; font-size:12px; margin:8px 0 0;}
.history-more {text-align:center; margin-bottom:20px;}
.history-more button {font-size:12px;}
.message-meta .receipt-read {color:#007c83; font-weight:600;}
.message-meta .receipt-ticks {display:inline-flex; align-items:center; color:#697879;}
.message-meta .receipt-ticks svg {width:19px; height:16px; stroke-width:2;}
.message-meta .receipt-ticks.receipt-read {color:#1687dc;}
html[data-theme="dark"] .message-meta .receipt-ticks {color:#afbec0;}
html[data-theme="dark"] .message-meta .receipt-ticks.receipt-read {color:#65baff;}
.message .bubble blockquote {white-space:pre-wrap; overflow-wrap:anywhere;}
/* Reply previews sit flush with the message text, without a second padded box. */
.message .bubble:has(>blockquote) {padding:8px 10px 12px; min-width:180px;}
.message .bubble>blockquote {margin:0 0 9px; padding:8px 10px; border-left:3px solid #008991; border-radius:5px; background:#eaf5f4; font-size:12px; line-height:1.45; max-height:96px; overflow:auto; text-align:left;}
.message .bubble>blockquote strong {display:block; margin-bottom:4px; color:#00646b; font-size:12px; font-weight:600;}
.message .bubble:has(>blockquote)>.message-text {display:block; padding:0 3px;}
.outgoing .bubble>blockquote {background:#ffffff20; border-left-color:#b6ece8; color:#eefafa;}
.outgoing .bubble>blockquote strong {color:#fff;}
html[data-theme="dark"] .incoming .bubble>blockquote {background:#284749; color:#e1eeee; border-left-color:#79d7d5;}
html[data-theme="dark"] .incoming .bubble>blockquote strong {color:#92dfdb;}
.conversation-title .unread-badge {background:#007c83; color:white; padding:2px 6px; border-radius:10px; font-size:10px;}
.compact-composer .send-button:not(:disabled) {background:#007c83; color:white; cursor:pointer;}
.compact-composer .send-button:not(:disabled):hover {background:#00646b;}
html[data-theme="dark"] .message-actions button {color:#b5dddd;}
html[data-theme="dark"] .message-actions button:hover {background:#28494b;}
html[data-theme="dark"] .compose-context {background:#294547; color:#e0f3f2;}
html[data-theme="dark"] .message-meta .receipt-read {color:#79d7d5;}
html[data-theme="dark"] .message-feedback {color:#ffb6ad;}
html[data-theme="dark"] .compact-composer .send-button:not(:disabled) {background:#007c83; color:white;}
/* Read conversations use normal black type; unread incoming messages add weight. */
.conversation .conversation-title strong,
.conversation.active .conversation-title strong {color:#000; font-weight:400;}
.conversation .conversation-preview>span:first-child {color:#333; font-weight:400;}
.conversation.is-unread .conversation-title strong,
.conversation.is-unread .conversation-preview>span:first-child {color:#000; font-weight:700;}
html[data-theme="dark"] .conversation .conversation-title strong,
html[data-theme="dark"] .conversation.active .conversation-title strong {color:#f0f5f5; font-weight:400;}
html[data-theme="dark"] .conversation .conversation-preview>span:first-child {color:#c2d1d1;}
html[data-theme="dark"] .conversation.is-unread .conversation-title strong,
html[data-theme="dark"] .conversation.is-unread .conversation-preview>span:first-child {color:#fff; font-weight:700;}
/* Presence always pairs a status dot with readable text. */
.presence-status {display:inline-flex; align-items:center; gap:5px; font-size:12px; color:#526174;}
.presence-status::before {content:''; width:7px; height:7px; border-radius:50%; background:#879397; flex-shrink:0;}
.presence-status.is-online {color:#16794c;}
.presence-status.is-online::before {background:#25985f;}
.conversation-preview .presence-status {font-size:10px; flex-shrink:0;}
html[data-theme="dark"] .presence-status {color:#b5c9ca;}
html[data-theme="dark"] .presence-status.is-online {color:#8edbb3;}
/* One focus boundary for the complete search control, including its icon. */
.sidebar .search:focus-within {border-color:#008991; box-shadow:0 0 0 2px #00899125;}
.sidebar .search #chat-search {background:transparent; border:0; outline:none; box-shadow:none; border-radius:0;}
html[data-theme="dark"] .sidebar .search #chat-search {background:transparent; color:#e7f1f1; border:0; outline:none; box-shadow:none;}
html[data-theme="dark"] .sidebar .search:focus-within {border-color:#79d7d5; box-shadow:0 0 0 2px #79d7d520;}
/* Slim composer: one bordered field, trailing tools, and a brand accent baseline. */
.workspace,.chat-panel {min-height:0;}
.chat-panel {overflow:hidden;}
.chat-panel>.chat-header {flex-shrink:0;}
.chat-panel>.message-history {flex:1 1 0; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; padding-bottom:24px;}
.chat-panel>.composer-area {flex:0 0 auto; position:relative; z-index:1;}
.composer-area.compact-composer-area {margin:0; padding:16px 24px 20px; background:transparent; border-radius:0; box-shadow:none;}
.composer.compact-composer {display:flex; align-items:center; gap:8px; padding:3px 6px 3px 12px; min-height:48px; background:#fff; border:1px solid #d3dadd; border-bottom:2px solid #008991; border-radius:6px; box-shadow:0 1px 3px #17353308;}
.composer.compact-composer:focus-within {border-color:#008991; box-shadow:0 0 0 2px #00899118;}
.composer.compact-composer textarea {flex:1; min-width:0; min-height:36px; height:36px; max-height:120px; padding:8px 0; margin:0; border:0; border-radius:0; background:transparent; box-shadow:none; font-size:14px; line-height:20px; outline:none;}
.composer-tools {display:flex; align-items:center; gap:1px; flex-shrink:0;}
/* Multiline drafts use full width, with tools below rather than beside the text. */
.composer.compact-composer textarea {resize:none; overflow-y:hidden; scrollbar-width:thin;}
.composer.compact-composer.is-multiline {flex-direction:column; align-items:stretch; gap:4px; padding-top:6px;}
.compact-composer.is-multiline textarea {width:100%; flex:none; max-height:200px;}
.compact-composer.is-multiline .composer-tools {align-self:flex-end;}
.compact-composer .composer-tools .icon-button,.compact-composer .send-button {display:inline-flex; align-items:center; justify-content:center; width:32px; height:38px; border:0; border-radius:5px; background:transparent; color:#566468; padding:6px;}
.compact-composer .composer-tools svg {width:18px; height:18px; stroke-width:1.5;}
.compact-composer .composer-tools .icon-button:hover {background:#e9f4f3; color:#007c83;}
.compact-composer .send-button:disabled {color:#657475; opacity:.65; cursor:not-allowed;}
.composer-tool-divider {width:1px; height:23px; margin:0 5px; background:#d3dadd;}
html[data-theme="dark"] .composer-area.compact-composer-area {background:transparent;}
html[data-theme="dark"] .composer.compact-composer {background:#1c2f31; border-color:#41585b; border-bottom-color:#69c6c5; box-shadow:none;}
/* Target the draft explicitly to override the shared dark form-input rule. */
html[data-theme="dark"] .compact-composer #draft {background:transparent; color:#e7f1f1; border:0; box-shadow:none; border-radius:0; caret-color:#79d7d5;}
html[data-theme="dark"] .compact-composer #draft::placeholder {color:#b5c9ca; opacity:1;}
html[data-theme="dark"] .composer.compact-composer:focus-within {border-color:#69c6c5; box-shadow:0 0 0 2px #69c6c518;}
html[data-theme="dark"] .compact-composer .composer-tool-divider {background:#4b6567;}
html[data-theme="dark"] .compact-composer .composer-tools .icon-button,html[data-theme="dark"] .compact-composer .send-button {background:transparent; color:#bdd0d0;}
html[data-theme="dark"] .compact-composer .composer-tools .icon-button:hover {background:#304a4c;}
@media(max-width:767px) {.composer-area.compact-composer-area {padding:10px 10px max(10px,env(safe-area-inset-bottom));} .composer.compact-composer {gap:2px;} .composer.compact-composer textarea {font-size:16px;} .compact-composer .composer-tools .icon-button,.compact-composer .send-button {width:30px; height:44px;} .compact-composer [data-action="sticker"] {display:none!important;} .composer-tool-divider {margin:0 2px;}}
html[data-theme="dark"] {--primary:#79d7d5; --brand-teal:#79d7d5;}
html[data-theme="dark"] .brand-chat-text {color:#ffffff;}
html[data-theme="dark"] .brand-e-icon img {background:transparent; padding:0;}
@media(max-width:767px) {.brand-e-icon {width:36px; height:36px;} .brand-e-icon img {width:128px; left:-45px;} .brand-chat-text {font-size:22px;}}

/* Reference layout: neutral sidebar, white conversation canvas, teal accents.
 * Keep these scoped to light appearance so dark preferences remain intact. */
html:not([data-theme="dark"]) .sidebar {background:#e1e3e8; border-right:1px solid #dce0e5;}
html:not([data-theme="dark"]) .sidebar-title {padding:24px 16px 16px;}
html:not([data-theme="dark"]) .sidebar-title .icon-button {background:#f0f2f5; color:#24585c;}
html:not([data-theme="dark"]) .sidebar>.search {background:#f5f7f9; border-color:#edf0f3;}
html:not([data-theme="dark"]) .sidebar .filters {border-bottom-color:#d7dde3; padding-top:8px; padding-bottom:6px;}
html:not([data-theme="dark"]) .conversation {background:transparent; border-bottom-color:#d7dde3;}
html:not([data-theme="dark"]) .conversation:hover {background:#eaf1f3;}
html:not([data-theme="dark"]) .conversation.active {background:#effbfc; border-bottom-color:#dff0f2; box-shadow:inset -3px 0 #008991;}
html:not([data-theme="dark"]) .chat-panel,
html:not([data-theme="dark"]) .chat-panel>.message-history,
html:not([data-theme="dark"]) .composer-area.compact-composer-area {background:#fff;}
html:not([data-theme="dark"]) .chat-header {background:#fff; border-bottom:1px solid #d4dcdf; box-shadow:0 1px 2px #20333808;}
html:not([data-theme="dark"]) .chat-header .icon-button {background:#f2f6f6; color:#56677a;}
html:not([data-theme="dark"]) .chat-header .icon-button:hover {background:#e4f1f1; color:#007c83;}
html:not([data-theme="dark"]) .incoming .bubble {background:#fff; color:#172b35; border:1px solid #f5f7f8; box-shadow:0 2px 10px #24454b03;}
html:not([data-theme="dark"]) .outgoing .bubble {background:#007f86; color:#fff; box-shadow:0 4px 12px #16484d14;}
.chat-panel .message-history {padding:28px 40px 28px;}
.chat-panel .message {margin-top:0; margin-bottom:32px;}
.message>.sender {font-weight:500;}
.chat-panel .bubble {border-radius:0 18px 18px 18px;}
.chat-panel .outgoing .bubble {border-radius:18px 0 18px 18px;}
.composer-area.compact-composer-area {padding:12px 24px 20px;}
.composer.compact-composer {border-radius:5px; box-shadow:none;}
.compact-composer.is-multiline .composer-tools {padding-top:4px;}
@media(max-width:767px) {
  .chat-panel .message-history {padding:20px 16px;}
  .chat-panel .message {margin-bottom:24px;}
  .composer-area.compact-composer-area {padding:10px 10px max(10px,env(safe-area-inset-bottom));}
}

/* Teams-like floating message tools: compact reply action and an overflow menu. */
.chat-find-panel {width:380px; flex:0 0 380px; min-height:0; display:flex; flex-direction:column; background:#fff; border-left:1px solid #dde5e7;}
.chat-find-heading {display:flex; align-items:center; justify-content:space-between; padding:16px 20px; min-height:76px; border-bottom:1px solid #e5ebed;}
.chat-find-heading h2 {font-size:15px; margin:0 0 4px;}
.chat-find-heading p {font-size:12px; margin:0;}
.chat-find-panel .chat-search-form {margin:0; padding:14px 16px 12px; border-bottom:1px solid #e5ebed;}
.chat-find-panel .chat-search-input {gap:0; border:1px solid #d8e1e4; border-bottom:2px solid #008991; border-radius:5px;}
.chat-find-panel .chat-search-input:focus-within {box-shadow:0 0 0 2px #00899115;}
.chat-find-panel .chat-search-input input {border:0; background:transparent; outline:none; padding:10px 12px; font-size:14px;}
.chat-search-input>button {min-width:40px; min-height:42px; color:#526174;}
.chat-search-input>button svg {width:18px; height:18px;}
.attachment-search-filter {display:inline-flex; align-items:center; gap:5px; min-height:32px; margin-top:12px; border:1px solid #c7d7d9; border-radius:18px; padding:4px 10px; font-size:12px; color:#426669;}
.attachment-search-filter svg {width:14px; height:14px;}
.attachment-search-filter[aria-pressed="true"] {background:#007c83; border-color:#007c83; color:white;}
.chat-find-status {padding:12px 20px; margin:0;}
.chat-find-panel .message-search-results {flex:1; min-height:0; max-height:none; margin:0; padding:0 16px; overflow-y:auto;}
.chat-find-panel .message-search-result {border:0; border-bottom:1px solid #dce5e7; border-radius:0; margin:0; padding:18px 4px;}
.chat-find-panel .search-result-heading {align-items:flex-start;}
.chat-find-panel .search-result-body {font-size:13px; max-height:110px;}
.search-attachment-label {display:inline-flex; align-items:center; gap:5px; margin-right:7px; color:#526174; font-size:11px;}
.search-attachment-label svg {width:13px; height:13px;}
.chat-find-footer {padding:12px 16px;}
/* Author display:flex on .secondary must not override the hidden attribute. */
#more-search-results[hidden] {display:none;}
#more-search-results:disabled {opacity:.55; cursor:wait;}
html[data-theme="dark"] .chat-find-panel {background:#1b3032; border-color:#405b5e;}
html[data-theme="dark"] .chat-find-heading,html[data-theme="dark"] .chat-find-panel .chat-search-form {border-color:#405b5e;}
html[data-theme="dark"] .chat-find-panel .chat-search-input {background:#243b3e; border-color:#476366; border-bottom-color:#79d7d5;}
html[data-theme="dark"] .chat-find-panel .chat-search-input input {color:#e7f1f1; background:transparent;}
html[data-theme="dark"] .chat-find-panel .message-search-result {background:transparent; border-bottom-color:#405b5e;}
html[data-theme="dark"] .attachment-search-filter,html[data-theme="dark"] .search-attachment-label {color:#bed4d5;}
@media(min-width:1500px) {.chat-find-panel {width:420px; flex-basis:420px;}}
@media(max-width:1199px) {.chat-find-panel {width:330px; flex-basis:330px;}}
@media(max-width:1023px) {.chat-find-panel {position:fixed; top:64px; bottom:32px; right:0; width:min(420px,100vw); z-index:12; box-shadow:-10px 0 35px #102d3026;}}
@media(max-width:767px) {.chat-find-panel {top:60px; bottom:48px; width:100%;} .chat-find-heading {min-height:64px;}}
.chat-search-form {margin-top:20px;}
.chat-search-form label {margin:0 0 8px!important; font-size:13px;}
.chat-search-input {display:flex; gap:8px;}
.chat-search-input input {flex:1; min-width:0; border:1px solid #b9cdcf; border-radius:8px; padding:11px 12px; font-size:15px; background:#fff; color:#172b35;}
.message-search-results {max-height:48dvh; overflow-y:auto; margin-bottom:12px;}
.message-search-result {display:block; width:100%; text-align:left; border:1px solid #dde7e7; border-radius:10px; padding:14px; margin-bottom:10px; background:#fff;}
.message-search-result:hover {background:#f0f8f7; border-color:#8dbdbf;}
.search-result-heading {display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; margin-bottom:8px;}
.search-result-heading time {font-size:10px; color:#526174;}
.search-result-body {display:block; font-size:14px; line-height:1.6; white-space:pre-wrap; overflow-wrap:anywhere; max-height:150px; overflow:auto;}
.search-result-body mark {background:#fff0ac; color:#172b35; border-radius:2px;}
.search-result-open {display:block; margin-top:10px; font-size:11px; color:#007c83;}
.message.search-target .bubble {outline:2px solid #008991; outline-offset:4px;}
html[data-theme="dark"] .chat-search-input input,html[data-theme="dark"] .message-search-result {background:#243b3e; color:#e7f1f1; border-color:#476366;}
html[data-theme="dark"] .message-search-result:hover {background:#2d484b;}
html[data-theme="dark"] .search-result-heading time {color:#b5c9ca;}
html[data-theme="dark"] .search-result-open {color:#79d7d5;}
.message.incoming {gap:10px;}
.sender-avatar {width:32px; height:32px; margin-top:22px; flex-shrink:0; border-radius:50%; background:#dff3f3; color:#00646b; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:600; overflow:hidden;}
.sender-avatar img {width:100%; height:100%; object-fit:cover;}
.message-content>.sender {font-size:12px; font-weight:400; color:#526174; margin:0 0 6px 2px;}
html[data-theme="dark"] .message-content>.sender {color:#b5c9ca;}
@media(max-width:767px) {.sender-avatar {width:28px; height:28px;} .message.incoming>.message-content {max-width:calc(100% - 38px);}}
.emoji-picker {display:grid; grid-template-columns:repeat(6,1fr); gap:6px; margin-top:20px;}
.emoji-picker button {min-height:48px; border-radius:9px; font-size:26px;}
.emoji-picker button:hover,.sticker-picker button:hover {background:#eaf5f4;}
.sticker-picker {display:grid; grid-template-columns:repeat(3,1fr); gap:10px; padding-top:20px;}
.sticker-picker button {border:1px solid #dbe7e7; border-radius:12px; padding:12px 6px;}
.chat-sticker {display:flex; align-items:center; justify-content:center; flex-direction:column; gap:6px; padding:10px; min-width:96px;}
.chat-sticker>span {font-size:52px; line-height:1.2;}
.chat-sticker strong {font-size:12px;}
.more-tools {display:grid; grid-template-columns:1fr 1fr; gap:12px; padding-top:20px;}
.upload-preview {display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:10px;}
.queued-file {display:flex; align-items:center; gap:8px; max-width:260px; padding:8px; background:#eaf5f4; border:1px solid #c9dddd; border-radius:10px; font-size:12px;}
.queued-file>img {width:54px; height:54px; border-radius:6px; object-fit:cover;}
.queued-file>span {overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.queued-file>button {width:32px; height:32px; flex-shrink:0;}
.queued-file .chat-sticker {flex-direction:row; min-width:0; padding:0;}
.queued-file .chat-sticker>span {font-size:30px;}
.upload-progress {font-size:12px; min-width:140px;}
.upload-progress progress {display:block; width:100%; accent-color:#007c83; margin-top:8px;}
.sent-file {display:flex; align-items:center; gap:10px; color:inherit; padding:10px 0; max-width:320px; overflow-wrap:anywhere;}
.sent-file>img {max-width:100%; max-height:240px; border-radius:8px; object-fit:contain;}
.sent-file:has(>img) {flex-direction:column; align-items:flex-start;}
.sent-file span {font-size:13px;}
.sent-file small {display:block; font-size:11px; margin-top:4px; opacity:.8;}
.shared-attachment {max-width:320px;}
.attachment-download {display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:40px; padding:8px 12px; margin:2px 0 8px; border:1px solid #b9d8d8; border-radius:8px; color:#00646b; background:#edf8f7; font-size:13px; font-weight:600;}
.attachment-download svg {width:17px; height:17px;}
.attachment-download {width:40px; height:40px; padding:10px;}
.attachment-download:hover {background:#d7eeec;}
.outgoing .attachment-download {background:#ffffff20; border-color:#ffffff60; color:#fff;}
.outgoing .attachment-download:hover {background:#ffffff35;}
html[data-theme="dark"] .incoming .attachment-download {background:#284749; color:#d4eeee; border-color:#4b6c6d;}
html[data-theme="dark"] .queued-file {background:#284749; border-color:#42686a; color:#e7f1f1;}
html[data-theme="dark"] .emoji-picker button:hover,html[data-theme="dark"] .sticker-picker button:hover {background:#284749;}
@media(max-width:480px) {.emoji-picker {grid-template-columns:repeat(5,1fr);} .sticker-picker {grid-template-columns:repeat(2,1fr);} .more-tools {grid-template-columns:1fr;}}
.message>div {position:relative;}
.message .message-actions {position:absolute; top:-18px; left:8px; right:auto; display:flex; gap:2px; margin:0; padding:3px; border:1px solid #d9e3e5; border-radius:9px; background:#fff; box-shadow:0 3px 12px #17363818; z-index:4;}
.outgoing .message-actions {right:8px; left:auto;}
/* Keep hover tools beside bubbles, including short one-word messages. */
@media(hover:hover) and (pointer:fine) {
  .message .message-content {max-width:calc(100% - 100px);}
  .incoming .message-content>.message-actions {left:100%; right:auto; top:24px; margin-left:8px;}
  .outgoing .message-content>.message-actions {right:100%; left:auto; top:8px; margin-right:8px;}
  /* Bridge the gap so moving from a bubble to its tools keeps them visible. */
  .message-actions::before {content:""; position:absolute; top:0; bottom:0; width:8px;}
  .incoming .message-actions::before {right:100%;}
  .outgoing .message-actions::before {left:100%;}
}
.message-actions .message-tool {display:flex; align-items:center; justify-content:center; width:32px; height:32px; min-height:32px; padding:7px; border:0; background:transparent; color:#4b6367; border-radius:6px; cursor:pointer; list-style:none; transition:background 150ms ease,color 150ms ease;}
.message-actions .message-tool:focus-visible {outline:2px solid #008991; outline-offset:1px;}
.message-tool::-webkit-details-marker {display:none;}
.message-tool svg {width:18px; height:18px;}
.message-actions .message-tool:hover {background:#eaf5f4; color:#007c83;}
.message-menu {position:relative;}
.message-menu-panel {position:absolute; right:-3px; top:36px; width:184px; padding:5px; border:1px solid #d9e3e5; border-radius:10px; background:white; box-shadow:0 8px 26px #17363824;}
.message-menu-panel button {display:flex; align-items:center; gap:10px; width:100%; min-height:40px; padding:10px; text-align:left; font-size:13px;}
.message-menu-panel svg {width:16px; height:16px;}
.message .message-actions:has(.message-menu[open]) {opacity:1; pointer-events:auto;}
html[data-theme="dark"] .message .message-actions,html[data-theme="dark"] .message-menu-panel {background:#243b3e; border-color:#476366; box-shadow:0 5px 18px #0003;}
html[data-theme="dark"] .message-actions .message-tool {color:#d4e4e4;}
html[data-theme="dark"] .message-actions .message-tool:hover,
html[data-theme="dark"] .message-actions .message-tool:focus-visible,
html[data-theme="dark"] .message-menu[open]>.message-tool {background:#355255; color:#e3f5f4;}
@media(hover:none),(pointer:coarse) {
  .message .message-actions {position:relative; top:auto; left:auto; right:auto; margin-top:6px; width:max-content; box-shadow:none;}
  .outgoing .message-actions {margin-left:auto;}
  .message-actions .message-tool {width:44px; height:44px;}
  .message-menu-panel {top:auto; bottom:50px;}
}

/* Group title editing and shared activity notices. */
.chat-header .header-name h2{display:flex;align-items:center;gap:8px}
.group-name-edit.icon-button{width:28px;height:28px;flex:none;color:var(--primary,#007c83);border-radius:7px}
.group-name-edit svg{width:16px;height:16px}
.group-name-edit:hover{background:rgba(0,137,145,.1)}
.group-name-label{display:block;margin-bottom:8px;font-weight:600}
.group-name-input{box-sizing:border-box;width:100%;padding:11px 12px;border:1px solid #a9bec2;border-radius:7px;background:var(--surface,#fff);color:inherit;font:inherit}
.group-name-input:focus{outline:2px solid #008991;outline-offset:2px}
.group-name-help{font-size:12px;line-height:1.5;opacity:.75}
.group-name-error{color:#c0392b;font-size:13px}
.chat-system-message{display:flex;justify-content:center;margin:18px 12px;text-align:center;font-size:12px;line-height:1.6;overflow-wrap:anywhere}
.chat-system-message>span{max-width:640px;padding:7px 14px;border-radius:9px;background:rgba(0,137,145,.08);color:inherit}

/* Keep the rename field and its focus indicator on the same alignment grid. */
#rename-group-form{margin-top:22px}
#rename-group-form .group-name-label{display:block;margin:0 0 8px;padding:0;font-size:13px;line-height:20px;font-weight:600}
#rename-group-form .group-name-input{display:block;margin:0;width:100%;height:46px;padding:11px 12px;line-height:22px;border:1px solid var(--border);border-radius:8px;box-shadow:none;color:var(--text);background:var(--surface,#fff)}
#rename-group-form .group-name-input:focus,
#rename-group-form .group-name-input:focus-visible{border-color:#008991;outline:none;outline-offset:0;box-shadow:0 0 0 1px #008991}
#rename-group-form .group-name-help{margin:10px 0 0;padding:0;font-size:12px;line-height:18px;color:var(--muted);opacity:1}
#rename-group-form .group-name-error{margin:8px 0 0;line-height:20px}
#rename-group-form .group-name-error:empty{display:none}
#rename-group-form .logout-actions{margin-top:24px;gap:12px}
#rename-group-form .logout-actions button{min-width:80px}

.group-presence{position:relative;display:inline-block}
.group-presence-trigger{display:inline-flex;align-items:center;padding:2px 0;font:inherit;cursor:pointer;border-radius:4px}
.group-presence-popover{display:none;position:absolute;top:100%;left:0;z-index:60;width:300px;max-width:calc(100vw - 40px);padding:16px;background:var(--surface,#fff);color:var(--text);border:1px solid var(--border);border-radius:12px;box-shadow:0 8px 28px #14232424;text-align:left}
.group-presence:hover .group-presence-popover,.group-presence:focus-within .group-presence-popover,.group-presence.is-open .group-presence-popover{display:block}
.chat-header .header-name p .group-presence-popover{color:var(--text)}
.group-presence-popover>strong{display:block;margin-bottom:10px;font-size:13px}
.group-presence-rows{display:block;max-height:280px;overflow-y:auto;overscroll-behavior:contain}
.group-presence-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;font-size:12px}
.chat-header .header-name p .group-presence-member{color:var(--text);overflow-wrap:anywhere}
.chat-header .header-name p .group-member-status{display:inline-flex;align-items:center;gap:6px;color:var(--muted);white-space:nowrap;flex:none}
.group-member-status i{width:7px;height:7px;border-radius:50%;background:#8a989a}
.chat-header .header-name p .group-member-status.is-online{color:#19995c}
.group-member-status.is-online i{background:#19995c}

.group-presence-person{display:flex;align-items:center;gap:10px;min-width:0;flex:1}
.chat-header .header-name p .group-presence-avatar{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;flex:none;border-radius:50%;overflow:hidden;background:#e2f6f7;color:#00646b;font-size:11px;font-weight:600}
.group-presence-avatar img{display:block;width:100%;height:100%;object-fit:cover}

/* Conversation activity stays in the text row; availability sits on the avatar. */
.conversation-avatar{position:relative;display:inline-flex;flex:none}
.conversation-avatar .avatar-availability{position:absolute;right:-1px;bottom:-1px;width:12px;height:12px;border-radius:50%;border:2px solid var(--surface,#fff);background:#8b999b;box-sizing:border-box;z-index:1}
.conversation-avatar .avatar-availability.is-online{background:#20a66a}
.avatar-availability.is-online::after{content:'';position:absolute;left:2px;top:1px;width:3px;height:4px;border:solid white;border-width:0 1px 1px 0;transform:rotate(45deg)}
.conversation-preview .conversation-time{font-size:10px;font-weight:400;color:var(--muted);white-space:nowrap;flex:none;margin-left:auto}
.conversation-title strong{min-width:0;overflow:hidden;text-overflow:ellipsis}

.chat-day-divider{margin:20px 0 28px;clear:both;font-size:11px;font-weight:600;gap:16px}
.chat-day-divider>span{padding:5px 12px;border-radius:8px;background:#edf2f3;color:#526174;white-space:nowrap}
html[data-theme="dark"] .chat-day-divider>span{background:#243f40;color:#c2d9da}

.call-history .call-record{width:300px;max-width:100%;padding:16px;border:1px solid var(--border);border-radius:12px;background:var(--surface,#fff);box-shadow:0 2px 8px #14232406}
.call-record-main{display:flex;align-items:center;gap:12px}
.call-record-icon{width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:50%;flex:none;background:#e2f6f7;color:#007c83}
.call-record-icon svg{width:20px;height:20px}
.call-record-main strong{display:block;font-size:14px;font-weight:600}
.call-record-main div>span{display:block;margin-top:5px;font-size:12px;line-height:1.5;color:var(--muted);overflow-wrap:anywhere}
.call-record.is-missed .call-record-icon{background:#fce9e9;color:#b33740}
.call-record.is-missed .call-record-main strong{color:#b33740}
.call-record-footer{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:14px;padding-top:10px;border-top:1px solid var(--border)}
.call-record-footer time{font-size:10px;color:var(--muted)}
.call-record-footer button{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:5px 8px;border-radius:6px;color:var(--primary);font-size:12px;font-weight:600}
.call-record-footer button:hover{background:#00899114}
.call-record-footer svg{width:15px;height:15px}
html[data-theme="dark"] .call-record.is-missed .call-record-icon{background:#4b2c2b;color:#ffb4ab}
html[data-theme="dark"] .call-record.is-missed .call-record-main strong{color:#ffb4ab}

.recording-history .call-record{width:320px;max-width:100%;padding:16px;border:1px solid var(--border);border-radius:12px;background:var(--surface,#fff)}
.call-recording-player{display:block;width:100%;height:40px;margin-top:16px}
.recording-download{display:inline-flex;align-items:center;gap:7px;font-size:12px;font-weight:600;margin-top:12px;padding:6px 0;color:var(--primary)}
.recording-download svg{width:16px;height:16px}
.recording-private{font-size:12px;color:var(--muted);margin:12px 0 0}

.sticker-picker{max-height:min(60dvh,480px);overflow-y:auto;overscroll-behavior:contain;padding:2px 6px 2px 2px;scrollbar-width:thin}

.header-name .group-member-total{color:var(--muted);font-size:12px;font-weight:400}.header-name .group-presence{display:inline-flex;align-items:center;gap:5px}

.composer-area{position:relative}.mention-list{position:absolute;bottom:calc(100% - 8px);left:28px;width:320px;max-width:calc(100% - 56px);max-height:min(300px,40dvh);overflow-y:auto;z-index:30;padding:6px;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:12px;box-shadow:0 8px 28px #0003}.mention-heading{padding:7px 10px;color:var(--muted);font-size:11px;font-weight:600}.mention-option{display:flex;align-items:center;gap:10px;width:100%;padding:9px 10px;text-align:left;border-radius:7px;color:var(--text);font-size:13px}.mention-option:hover,.mention-option[aria-selected="true"]{background:#00868a20}.mention-avatar{display:flex;align-items:center;justify-content:center;width:32px;height:32px;flex-shrink:0;border-radius:50%;background:#00868a22;font-size:11px;color:var(--text);overflow:hidden}.mention-avatar img{width:100%;height:100%;object-fit:cover}@media(max-width:600px){.mention-list{left:12px;max-width:calc(100% - 24px)}}

/* Sending is a normal progress state; errors keep their existing red style. */
.composer-area .message-feedback.is-sending{color:var(--muted,#526174);font-size:11px;margin:7px 0 0;line-height:1.5}

/* Conversation actions: mouse, keyboard, and touch. */
.conversation{position:relative;padding-right:42px}
.conversation-options{position:absolute;right:8px;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:7px;color:var(--muted);opacity:0}
.conversation:hover .conversation-options,.conversation:focus-within .conversation-options{opacity:1}
.conversation-options:hover{background:#00899118;color:var(--primary)}
.conversation-options svg{width:18px;height:18px}
.conversation-context-menu{position:fixed;z-index:1000;width:228px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow-y:auto;padding:6px;background:#fff;color:#243746;border:1px solid #dce4e7;border-radius:9px;box-shadow:0 8px 28px #142c4030;font-size:14px}
.conversation-context-menu button{display:flex;align-items:center;gap:12px;width:100%;min-height:40px;padding:9px 12px;border-radius:5px;text-align:left;color:inherit}
.conversation-context-menu svg{width:19px;height:19px;flex-shrink:0}
.conversation-context-menu button:hover,.conversation-context-menu button:focus-visible{background:#edf5f5;outline:2px solid transparent}
.conversation-context-menu .menu-separator{margin-top:6px;border-top:1px solid #dce4e7;border-radius:0;padding-top:14px}
.conversation-context-menu .menu-danger{color:#b42318}
.conversation-context-menu button:disabled{opacity:.5;cursor:not-allowed}
.chat-favorite{color:#ef4444;font-size:14px}.chat-muted{font-size:10px;color:var(--muted);font-weight:400}
.group-invite-link{width:100%;padding:12px;margin-bottom:16px}
html[data-theme="dark"] .conversation-context-menu{background:#243b3e;color:#e2eeee;border-color:#476366;box-shadow:0 8px 28px #0005}
html[data-theme="dark"] .conversation-context-menu button:hover,html[data-theme="dark"] .conversation-context-menu button:focus-visible{background:#355255}
html[data-theme="dark"] .conversation-context-menu .menu-danger{color:#ffb6ad}
html[data-theme="dark"] .conversation-context-menu .menu-separator{border-color:#476366}
@media(hover:none),(pointer:coarse){.conversation-options{opacity:1;width:36px;height:40px}.conversation-context-menu button{min-height:44px}}

.chat-list-section{margin:0;padding:0}
.chat-list-section>summary{display:flex;align-items:center;gap:8px;min-height:36px;padding:8px 16px;list-style:none;cursor:pointer;color:var(--muted);font-size:12px;font-weight:500;background:#f0f4f4;user-select:none}
.chat-list-section>summary::-webkit-details-marker{display:none}
.chat-section-chevron{width:6px;height:6px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);margin-right:2px}
.chat-list-section[open]>summary .chat-section-chevron{transform:rotate(45deg);margin-top:-3px}
.chat-section-count{margin-left:auto;font-size:11px;opacity:.7}
.chat-list-section>summary:hover{background:#e4eeee;color:#006b72}
.chat-section-empty{margin:0;padding:14px 26px;font-size:12px;color:var(--muted)}
html[data-theme="dark"] .chat-list-section>summary{background:#203638;color:#bad0d0}
html[data-theme="dark"] .chat-list-section>summary:hover{background:#2a4547;color:#e3f5f4}
