/* ==========================================================================
   Irada Hub — CHANNELS (chat.js)
   Uses only the tokens app.css defines (--panel*, --line*, --paper, --mut,
   --faint, --accent*, --danger, --r*, --f-*), so dark and light both follow
   the member's theme with no mode-specific rules here.
   ========================================================================== */

.chat [hidden], .ch-pop [hidden], .ch-sheet [hidden] { display: none !important; }

.ch-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.chat-faint { color: var(--faint); }
.chat-pad { padding: 16px 18px; margin: 0; }

.ch-ico { width: 16px; height: 16px; flex: none; display: block; }

/* ------------------------------------------------------------- sidebar */

.chat-nav { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.chat-nav-group { display: flex; flex-direction: column; gap: 1px; }
.chat-nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 4px 0; min-height: 26px;
}
.chat-nav-head .nav-group-label { padding-bottom: 0; }
.chat-nav-icon {
  width: 26px; height: 26px; border-radius: 8px; border: 0; background: transparent;
  color: var(--faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-nav-icon:hover { background: var(--panel3); color: var(--paper); }
.chat-nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0;
  padding: 6px 10px 6px 11px; border-radius: 9px; border: 0; background: transparent;
  color: var(--mut); font-size: 13.5px; text-align: start; cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.chat-nav-item:hover { background: var(--panel2); color: var(--paper); }
.chat-nav-item.is-active { background: var(--accent-soft); color: var(--accent-fg); }
.chat-nav-item.is-unread { color: var(--paper); font-weight: 700; }
.chat-nav-item.is-muted { opacity: .62; }
.chat-nav-ico {
  width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  color: inherit; opacity: .85;
}
.chat-nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-nav-badge {
  flex: none; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: var(--danger-on, #2b0a12);
  font-family: var(--f-head); font-size: 10.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.chat-nav-add { color: var(--faint); font-weight: 500; }
.chat-nav-empty { padding: 4px 11px; font-size: 12.5px; color: var(--faint); }
.ch-dm-count {
  width: 20px; height: 20px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel3); color: var(--paper); font-size: 10.5px; font-weight: 800; font-family: var(--f-head);
}

/* ------------------------------------------------------------- avatars */

.ch-av { display: inline-flex; flex: none; }
.ch-av .avatar { width: 36px; height: 36px; font-size: 13px; border-radius: 10px; }
.ch-av--xs .avatar { width: 20px; height: 20px; font-size: 9px; border-radius: 6px; }
.ch-av--sm .avatar { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }

/* -------------------------------------------------------------- frame */

/* The chat fills the viewport (chat.js sizes it); the view's tall bottom
   padding would only add a page scroll under it. */
.view--module:has(> .chat) { padding-bottom: 14px; }

.chat {
  display: flex; min-height: 380px; min-width: 0; position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden;
}
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px 18px;
  border-bottom: 1px solid var(--line); min-height: 60px;
}
.chat-head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-head-ico { color: var(--mut); display: inline-flex; flex: none; }
.chat-head-ico .ch-ico { width: 18px; height: 18px; }
.chat-head-text { min-width: 0; display: flex; flex-direction: column; }
.chat-title {
  margin: 0; font-family: var(--f-head); font-size: 17px; font-weight: 800; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--paper);
}
.chat-topic {
  border: 0; background: transparent; padding: 0; margin-top: 2px; text-align: start;
  color: var(--mut); font-size: 12.5px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.chat-topic:disabled { cursor: default; }
.chat-topic:not(:disabled):hover { color: var(--paper); }
.chat-head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.chat-icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--mut); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative; flex: none;
}
.chat-icon-btn:hover { background: var(--panel3); color: var(--paper); border-color: var(--line); }
.chat-icon-btn.danger:hover { color: var(--danger); }
.chat-members-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--mut);
  font-family: var(--f-head); font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.chat-members-btn:hover { background: var(--panel3); color: var(--paper); }
.chat-mobile-only { display: none; }
.chat-mobile-badge {
  position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--danger); color: var(--danger-on, #2b0a12); font-size: 9.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-tag {
  display: inline-flex; align-items: center; vertical-align: middle;
  padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line2);
  font-family: var(--f-head); font-size: 10.5px; font-weight: 700; color: var(--mut);
  letter-spacing: .02em; white-space: nowrap;
}
.chat-tag--ext { color: var(--accent-fg); border-color: var(--accent-line); background: var(--accent-soft); }

.chat-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.chat-tabs:empty { display: none; }
.chat-tab {
  border: 0; background: transparent; padding: 9px 10px 8px; margin-bottom: -1px;
  color: var(--mut); font-family: var(--f-head); font-weight: 700; font-size: 13px;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.chat-tab:hover { color: var(--paper); }
.chat-tab.is-on { color: var(--accent-fg); border-bottom-color: var(--accent-line); }

.chat-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative;
  padding: 6px 0 14px; overscroll-behavior: contain; outline: none;
}
.chat-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 20px; }
.chat-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.chat-pane-head h2 { margin: 0; font-size: 15px; font-family: var(--f-head); }
.chat-older { display: flex; justify-content: center; padding: 8px 0 4px; }
.chat-empty { margin: 24px 18px; }
.chat-empty .empty-ico .ch-ico { width: 30px; height: 30px; margin: 0 auto; }

.chat-loading { display: flex; gap: 6px; justify-content: center; padding: 30px 0; }
.chat-loading span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--faint);
  animation: chatDot 1s infinite ease-in-out;
}
.chat-loading span:nth-child(2) { animation-delay: .15s; }
.chat-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: none; } }

.chat-intro { padding: 30px 22px 14px; }
.chat-intro-ico {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.chat-intro-ico .ch-ico { width: 22px; height: 22px; }
.chat-intro h2 { margin: 0 0 4px; font-size: 20px; font-family: var(--f-head); }
.chat-intro p { margin: 0; color: var(--mut); }

/* separators */
.chat-day, .chat-divider, .chat-thread-count {
  display: flex; align-items: center; gap: 10px; margin: 14px 18px 6px;
  font-family: var(--f-head); font-size: 11.5px; font-weight: 700; color: var(--mut);
}
.chat-day::before, .chat-day::after, .chat-divider::before, .chat-divider::after,
.chat-thread-count::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.chat-thread-count::before { display: none; }
.chat-day span {
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
}
.chat-divider { color: var(--danger); margin: 8px 18px 4px; }
.chat-divider::before, .chat-divider::after { background: color-mix(in srgb, var(--danger) 55%, transparent); }
.chat-divider span { text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; }

/* --------------------------------------------------------------- messages */

.msg {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px;
  padding: 6px 18px 4px; margin-top: 6px; outline: none;
  transition: background .12s var(--ease);
}
.msg.is-grouped { margin-top: 0; padding-top: 2px; }
.msg:hover, .msg.is-active, .msg:focus-within { background: var(--panel2); }
.msg.is-hit { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-line); }
.msg.is-editing { background: var(--panel2); }
.msg.is-leaving { opacity: .4; }
.msg-gutter { display: flex; justify-content: center; padding-top: 2px; }
.msg-gtime {
  font-size: 10.5px; color: var(--faint); opacity: 0; padding-top: 3px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.msg:hover .msg-gtime, .msg.is-active .msg-gtime, .msg:focus-within .msg-gtime { opacity: 1; }
.msg-main { min-width: 0; }
.msg-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; line-height: 1.3; }
.msg-author { font-family: var(--f-head); font-weight: 800; font-size: 14px; color: var(--paper); }
.msg-meta time { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.msg-meta .chat-tag { align-self: center; }
.msg-body {
  font-size: 14.5px; line-height: 1.55; color: var(--paper);
  overflow-wrap: anywhere; word-break: break-word; unicode-bidi: plaintext;
}
.msg-body p { margin: 0 0 4px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body pre { max-width: 100%; overflow-x: auto; }
.msg-body .md-table-wrap { max-width: 100%; overflow-x: auto; }
.msg-body img { max-width: 100%; }
.msg-edited { font-size: 11px; color: var(--faint); }
.msg-del .msg-body { font-style: italic; font-size: 13.5px; }

.msg-sys {
  display: flex; align-items: flex-start; gap: 8px; padding: 3px 18px 3px 30px; margin-top: 2px;
  color: var(--mut); font-size: 13px;
}
.msg-sys:hover { background: transparent; }
.msg-sys-ico { color: var(--faint); padding-top: 2px; display: inline-flex; }
.msg-sys-ico .ch-ico { width: 13px; height: 13px; }
.msg-sys-text { min-width: 0; overflow-wrap: anywhere; }
.msg-sys-text p { display: inline; margin: 0; }
.msg-sys-text b { color: var(--paper); font-weight: 700; }
.msg-sys-text time { font-size: 11px; color: var(--faint); margin-inline-start: 4px; }

/* hover toolbar */
.msg-actions {
  position: absolute; top: -14px; right: 14px; z-index: 3;
  display: none; gap: 1px; padding: 2px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--sh-sm, 0 4px 14px rgba(0,0,0,.25));
}
.msg:hover .msg-actions, .msg.is-active .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg.is-editing .msg-actions { display: none; }
.msg-act {
  width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--mut);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.msg-act:hover { background: var(--panel3); color: var(--paper); }
.chat-thread-root .msg-actions [data-act="thread"] { display: none; }

/* files */
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.msg-img {
  padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--well, var(--panel2));
  cursor: zoom-in; display: block; max-width: min(360px, 100%);
}
.msg-thumb { display: block; max-width: 100%; max-height: 260px; width: auto; height: auto; object-fit: contain; }
.msg-file {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(360px, 100%);
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
  color: var(--paper); text-decoration: none; font-size: 13px;
}
.msg-file:hover { border-color: var(--line2); background: var(--panel3); }
.msg-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.msg-file-size { color: var(--faint); font-size: 11.5px; flex: none; }

/* reactions */
.msg-rx { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.rx {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px;
  border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2);
  color: var(--mut); font-size: 12px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums;
}
.rx:hover:not(:disabled) { border-color: var(--accent-line); }
.rx.is-mine { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-fg); }
.rx:disabled { cursor: default; }
.rx-e { font-size: 14px; line-height: 1; }
.rx-add { padding: 0 7px; color: var(--faint); }

/* thread summary */
.msg-thread {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; padding: 4px 8px 4px 6px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer;
  color: var(--accent-fg); font-size: 12.5px;
}
.msg-thread b { font-family: var(--f-head); }
.msg-thread span { color: var(--faint); }
.msg-thread:hover { background: var(--panel); border-color: var(--line2); }

/* inline edit */
.msg-editbox { margin: 4px 0 2px; }
.msg-edit-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.msg-edit-foot .chat-faint { margin-inline-end: auto; font-size: 11.5px; }

.chat-jump {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  font-family: var(--f-head); font-weight: 800; font-size: 12.5px; box-shadow: var(--sh-lg, 0 10px 30px rgba(0,0,0,.35));
}

.chat-drop {
  position: absolute; inset: 8px; z-index: 6; border-radius: var(--r);
  border: 2px dashed var(--accent-line); background: color-mix(in srgb, var(--panel) 86%, transparent);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.chat-drop > div { display: flex; align-items: center; gap: 10px; color: var(--accent-fg); font-family: var(--f-head); font-weight: 800; }
.chat-drop .ch-ico { width: 22px; height: 22px; }

/* --------------------------------------------------------------- composer */

.chat-foot { padding: 0 16px 14px; }
.chat-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel2);
  color: var(--mut); font-size: 13.5px;
}
.chat-bar b { color: var(--paper); }
.cmp { position: relative; }
.cmp-box {
  position: relative; display: flex; align-items: flex-end; gap: 6px;
  border: 1px solid var(--line2); border-radius: var(--r); background: var(--panel2);
  padding: 6px 6px 6px 12px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.cmp-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.cmp-input {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
  color: var(--paper); font: inherit; font-size: 14.5px; line-height: 1.5;
  padding: 6px 0; max-height: 220px; min-height: 24px; overflow-y: auto;
}
.msg-editbox .cmp-input {
  width: 100%; border: 1px solid var(--accent-line); border-radius: 10px; background: var(--panel);
  padding: 8px 10px; max-height: 260px;
}
.cmp-input::placeholder { color: var(--faint); }
.cmp-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.cmp-btn, .cmp-send {
  width: 34px; height: 34px; border-radius: 9px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cmp-btn { background: transparent; color: var(--mut); }
.cmp-btn:hover { background: var(--panel3); color: var(--paper); }
.cmp-send { background: var(--accent); color: var(--accent-ink); }
.cmp-send:hover { filter: brightness(1.06); }
.cmp-send:disabled { opacity: .5; cursor: progress; }
.cmp-count { font-size: 11px; color: var(--faint); padding: 0 4px; font-variant-numeric: tabular-nums; }
.cmp-count.is-over { color: var(--danger); font-weight: 700; }
.cmp-hint { margin-top: 5px; font-size: 11px; color: var(--faint); padding-inline-start: 4px; }
.cmp-hint b { font-weight: 700; color: var(--mut); }
.cmp-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.cmp-file {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  padding: 4px 4px 4px 6px; border: 1px solid var(--line2); border-radius: 10px; background: var(--panel2);
  font-size: 12.5px; color: var(--paper);
}
.cmp-file img { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; flex: none; }
.cmp-file-name { min-width: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-file-size { color: var(--faint); font-size: 11px; flex: none; }
.cmp-file-x {
  width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--mut);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.cmp-file-x:hover { background: var(--panel3); color: var(--danger); }
.cmp-mention { left: 6px; right: auto; bottom: calc(100% + 6px); }
.cmp-at {
  width: 20px; height: 20px; border-radius: 6px; background: var(--panel3); color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none;
}

/* ------------------------------------------------------------ side panel */

.chat-panel {
  width: min(400px, 42%); flex: none; display: flex; flex-direction: column; min-height: 0;
  border-inline-start: 1px solid var(--line); background: var(--panel);
}
.chat-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); min-height: 60px;
}
.chat-panel-head h2 { margin: 0; font-size: 15px; font-family: var(--f-head); }
.chat-panel-sub { font-size: 12px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-panel-head > div { min-width: 0; }
.chat-panel-tools { padding: 10px 16px 0; }
.chat-panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0 16px; }
.chat-thread-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0 12px; }
.chat-thread-root .msg { margin-top: 10px; }
.chat-thread-count { margin: 6px 16px 2px; }
.chat-thread-foot { padding: 0 12px 12px; }
.chat-thread-foot .cmp-hint { display: none; }

.chat-people { list-style: none; margin: 0; padding: 4px 8px; }
.chat-person { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.chat-person:hover { background: var(--panel2); }
.chat-person-text { flex: 1; min-width: 0; }
.chat-person-name { font-weight: 700; font-size: 13.5px; color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-person-sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-person-acts { display: flex; gap: 2px; flex: none; }
.chat-person-acts .chat-icon-btn { width: 30px; height: 30px; }

.chat-search { padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 8px; }
.chat-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); align-self: flex-start; max-width: 100%; }
.chat-seg label {
  position: relative; cursor: pointer; min-width: 0; margin: 0;
  text-transform: none; letter-spacing: 0; font-size: 12px; color: inherit; display: block;
}
.chat-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chat-seg span {
  display: block; padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--mut);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px;
}
.chat-seg input:checked + span { background: var(--lift, var(--panel3)); color: var(--paper); }
.chat-seg input:focus-visible + span { outline: 2px solid var(--accent-fg); outline-offset: 1px; }
.chat-hits { list-style: none; margin: 0; padding: 0 8px; }
.chat-hit {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: start;
  padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--paper);
}
.chat-hit:hover { background: var(--panel2); }
.chat-hit-meta { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 12.5px; }
.chat-hit-meta time { margin-inline-start: auto; font-size: 11px; color: var(--faint); }
.chat-hit-body { font-size: 13px; color: var(--mut); overflow-wrap: anywhere; }
.chat-hit-body mark { background: var(--accent-soft); color: var(--accent-fg); border-radius: 3px; padding: 0 1px; }

/* tasks + files tabs */
.chat-tasks, .chat-doclist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-task {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "st title" "st meta";
  column-gap: 12px; row-gap: 2px; align-items: center; width: 100%; text-align: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel2);
  color: var(--paper); cursor: pointer;
}
.chat-task:hover { border-color: var(--line2); background: var(--panel3); }
.chat-task-status {
  grid-area: st; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line2);
  font-family: var(--f-head); font-size: 11px; font-weight: 700; color: var(--mut); white-space: nowrap;
}
.chat-task-status[data-status="done"] { color: var(--accent-fg); border-color: var(--accent-line); }
.chat-task-title { grid-area: title; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-task-meta { grid-area: meta; font-size: 12px; color: var(--faint); }
.chat-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 14px; }
.chat-gal {
  padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; aspect-ratio: 1;
  background: var(--panel2); cursor: zoom-in;
}
.chat-gal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-doclist li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }

/* --------------------------------------------------------- popovers/menus */

.ch-pop {
  position: fixed; z-index: 140; padding: 5px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: var(--sh-lg, 0 14px 40px rgba(0,0,0,.4)); animation: popIn .13s var(--ease) both;
  max-width: calc(100vw - 16px);
}
.ch-picker { display: grid; grid-template-columns: repeat(6, 36px); gap: 2px; }
.ch-emoji {
  width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font-size: 19px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.ch-emoji:hover, .ch-emoji:focus-visible { background: var(--panel3); }
.ch-menu { display: flex; flex-direction: column; min-width: 220px; }
.ch-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--paper);
  font-size: 13.5px; cursor: pointer;
}
.ch-menu-item .ch-ico { color: var(--mut); }
.ch-menu-item small { margin-inline-start: auto; color: var(--faint); font-size: 11px; padding-inline-start: 8px; }
.ch-menu-item:hover, .ch-menu-item:focus-visible { background: var(--panel3); }
.ch-menu-item.is-danger, .ch-menu-item.is-danger .ch-ico { color: var(--danger); }
.ch-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ---------------------------------------------------------------- modals */

.ch-modal .modal-head .btn-icon { width: 32px; height: 32px; }
.chat-confirm { margin: 0; color: var(--mut); line-height: 1.55; }
.ch-browse-top { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.ch-browse-top .inp { flex: 1; min-width: 0; }
.ch-browse-list { max-height: min(56vh, 460px); overflow-y: auto; margin: 0 -6px; }
.ch-browse { list-style: none; margin: 0; padding: 0; }
.ch-browse-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; }
.ch-browse-row:hover { background: var(--panel2); }
.ch-browse-row.is-archived { opacity: .7; }
.ch-browse-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.ch-browse-text b { font-size: 14px; }
.ch-browse-text .chat-faint { flex-basis: 100%; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ch-picked { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ch-picked:empty { display: none; }
.ch-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 3px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-fg);
  font-size: 12.5px; font-weight: 700; cursor: pointer; max-width: 100%;
}
.ch-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-chip .ch-av .avatar { border-radius: 999px; }
.ch-people-pick { max-height: min(48vh, 400px); overflow-y: auto; margin: 10px -6px 0; display: flex; flex-direction: column; gap: 1px; }
.ch-pick {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--paper); cursor: pointer;
}
.ch-pick:hover { background: var(--panel2); }
.ch-pick.is-on { background: var(--accent-soft); }
.ch-pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-pick-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-pick-text .chat-faint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-check {
  width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line2); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.ch-pick.is-on .ch-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* mobile conversation sheet */
.ch-sheet-ov { align-items: stretch; justify-content: flex-start; }
.ch-sheet {
  width: min(320px, 88vw); height: 100%; overflow-y: auto; padding: 12px 10px 24px;
  background: var(--panel); border-inline-end: 1px solid var(--line); animation: chatSheetIn .2s var(--ease) both;
}
.ch-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 12px 8px; }
.ch-sheet-head h2 { margin: 0; font-size: 16px; font-family: var(--f-head); }
@keyframes chatSheetIn { from { transform: translateX(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* focus rings everywhere the buttons are bare */
.chat button:focus-visible, .ch-pop button:focus-visible, .chat-nav button:focus-visible,
.ch-sheet button:focus-visible, .ch-modal button:focus-visible, .chat a:focus-visible {
  outline: 2px solid var(--accent-fg); outline-offset: 2px;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .chat.has-panel .chat-panel {
    position: absolute; inset: 0 0 0 auto; width: min(420px, 100%); z-index: 8;
    box-shadow: -18px 0 40px rgba(0, 0, 0, .28);
  }
}
@media (max-width: 720px) {
  .chat { border-radius: var(--r); border-left: 0; border-right: 0; }
  .chat-mobile-only { display: inline-flex; }
  .chat-head { padding: 8px 8px 8px 6px; gap: 6px; min-height: 54px; }
  .chat-head-ico { display: none; }
  .chat-title { font-size: 16px; }
  .chat-members-btn span { display: none; }
  .chat-members-btn { width: 34px; padding: 0; justify-content: center; }
  .msg { padding-left: 12px; padding-right: 12px; grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; }
  .ch-av--md .avatar { width: 32px; height: 32px; }
  .msg-actions { right: 8px; }
  .chat-foot { padding: 0 8px 8px; }
  .cmp-hint { display: none; }
  .chat-day, .chat-divider { margin-left: 12px; margin-right: 12px; }
  .chat-pane { padding: 12px; }
  .chat.has-panel .chat-panel {
    position: fixed; inset: 0; width: 100%; z-index: 95; border: 0; box-shadow: none;
  }
}
@media (hover: none) {
  .msg:hover:not(.is-active) { background: transparent; }
  .msg:hover:not(.is-active) .msg-actions { display: none; }
  .msg-gtime { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-pop, .ch-sheet, .chat-loading span { animation: none; }
}
