/* DM pills (avatar-only) */
.dept-section .group-pills .pill.dm {
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.dept-section .group-pills .pill.dm .avatar.xs {
  background: var(--bg);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
}

.dept-section .group-pills .pill.dm .avatar.xs .initials {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
}

/* User card popup tweaks */
dialog.user-modal .modal-card {
  padding: .75rem;
}

dialog.user-modal .section+.section {
  border-top: var(--line);
  margin-top: .5rem;
  padding-top: .5rem;
}

dialog.user-modal .user-card .avatar.xl {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--muted);
}

dialog.user-modal .user-card .u-meta .muted {
  color: var(--text-muted);
}


/* Core modal bridge for ChatPro-specific dialogs */
.u-modal.user-modal .u-card {
  padding: .75rem;
}

.u-modal.user-modal .section+.section {
  border-top: var(--line);
  margin-top: .5rem;
  padding-top: .5rem;
}

.u-modal.user-modal .user-card .avatar.xl {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--muted);
}

.u-modal.user-modal .user-card .u-meta .muted {
  color: var(--text-muted);
}

.u-modal.msg-actions .u-card {
  width: auto;
}

.u-modal.call-summary-dialog .u-card {
  width: min(820px, 96vw);
  max-height: min(80vh, 780px);
  padding: 0;
  border-radius: 12px;
  background: var(--bg);
  color: inherit;
}


.u-modal.call-summary-dialog .u-body {
  padding: 12px 14px;
  overflow: auto;
}

.u-modal.call-summary-dialog .u-foot {
  justify-content: space-between;
}

.u-modal.view-once-modal .u-card {
  max-width: min(680px, 92vw);
}

.u-modal.view-once-modal .u-body {
  display: grid;
  gap: 14px;
}

/* ----- Left list (unchanged from your build, kept minimal) ----- */
.dept-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  overflow-y: auto;
  border: 0;
  padding-right: 4px;

  margin: 0px -4px 0 0;
  height: 77vh;
}

.dept-section {
  height: 30px;
  overflow: clip;
  border-radius: 10px;
  padding: 4px;
  border: var(--line);
}

.dept-section.open {
  height: auto !important;
  border: none;
}

.dept-section .caret {
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: rotate(0deg);
  transition: transform .2s ease;
}

.dept-section.open .caret {
  transform: rotate(180deg);
}

.dept-section .group-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .35rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .25s ease, opacity .2s ease;
}

.dept-section.open .group-list {
  max-height: 600px;
  opacity: 1;
}

.group-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: .5rem;
  align-items: center;
  background: var(--surface), radial-gradient(100px 100px at 10% 10%, var(--primary-faded) -68%, var(--bg));
  padding: .6rem .3rem;
  border-radius: 20px;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.group-row .avatar.xs {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 700;
}

.group-row .dm-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dept-pill {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
}

#chatList{
  display:grid;
  overflow:auto;
  padding-right: 4px;
  height:-webkit-fill-available;
  margin: 0;
}

/* --- Info Tip (Notification Bubble) --- */
.chat-info-tip {
  position: fixed;
  z-index: 9999;
  max-width: 220px;
  background: var(--primary-dark);
  /* User requirement */
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  cursor: pointer;
  font-size: 0.8rem;
  animation: tipIn 0.2s ease-out;
}

/* Arrow pointing to right (since mini list is on right) */
.chat-info-tip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  /* Points right towards the mini list */
  margin-top: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent var(--primary-dark);
}

.chat-info-tip .info-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.chat-info-tip .info-preview {
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-info-tip .info-time {
  opacity: 0.6;
  font-size: 0.7em;
  margin-top: 4px;
  text-align: right;
}

@keyframes tipIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ----- Three-col expansion when info is open ----- */
.three-col.show-info {
  --col-right: 1fr;
  grid-template-columns: var(--col-left) var(--col-center) var(--col-right);
  gap: 0;
  /* margin-right: ; */
}

.belt-btn i {
  pointer-events: none;
}

.panel .right-panel {
  overflow: auto;

}

.dm-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: .35rem 0;
}

.dm-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: .5rem;
  align-items: center;
  padding: .6rem .3rem;
  border-radius: 20px;
  background: var(--surface), radial-gradient(100px 100px at 10% 10%, var(--primary-faded) -68%, var(--bg));
  border: 0;
  text-align: left;
  cursor: pointer;
}

.dm-row.active {
  background: var(--primary-dark);
}

.dm-row .avatar.xs {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.dm-row .dm-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dm-row .dm-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dm-row .dm-preview {
  font-size: .85em;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-preview-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.dm-preview-line .dm-preview {
  flex: 1 1 auto;
  min-width: 0;
}

.dm-inline-unread {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
  user-select: none;
}

.dm-inline-unread[hidden] {
  opacity: 0;
}

/* ----- Chat header ----- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: .45rem .7rem;
  border-radius: 15px 0 0;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  background: transparent;
  -webkit-backdrop-filter: var(--backdrop-2);
  backdrop-filter: var(--backdrop-2);
  isolation: isolate;
  z-index: 10;
  justify-content: space-between
}

.chat-header .avatar.lg {
  width: 34px;
  padding: 1px;
  height: 34px;
  border: var(--line);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  background: rgba(255, 255, 255, .08);
}

.chat-header .title h2 {
  margin: 0;
  font-size: 1rem;
  max-width: 280px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.chat-header .title .link.sm {
  font-size: 0.6rem;
  opacity: .8;
  padding: 0;
  text-align: left;
}

.chat-header .title {
  display: grid;
  margin: 0;
}

.chat-header .spacer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* Message search pill inside header spacer (replaces modal search) */
.chat-search-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 5px;
  max-width: 300px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--card) 70%, transparent);
  border: var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  isolation: isolate;
}
.chat-search-pill[hidden]{display:none}
.chat-search-pill input {
  width: clamp(140px, 22vw, 320px);
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  padding: 0;
  height: 22px;
  min-width: 0;
}

.chat-search-pill .sep {
  width: 1px;
  align-self: stretch;
  background: var(--strans);
}

.chat-search-pill .count {
  font-size: 12px;
  opacity: 0.75;
  min-width: 48px;
  text-align: center;
}

.chat-search-pill .bi {
  font-size: 14px;
  opacity: 0.85;
}

.chat-search-pill .icon-btn.sm {
  width: 25px;
  height: 22px;
  display: flex;
}

.chat-search-pill .icon-btn.sm i {
  font-size: 16px;
}

@media (max-width: 720px) {
  .chat-search-pill input { width: clamp(120px, 42vw, 220px); }
  .chat-search-pill .count { display: none; }
}


#chatInput {
  min-height: 38px;
  max-height: 40vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.chat-header .menu {
  position: absolute;
  top: 50%;
  right: 5.5rem;
  background: var(--surface);
  border: var(--line);
  border-radius: 8px;
  padding: .25rem;
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.chat-header .menu hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, .1);
  margin: .25rem 0;
}

.chat-header .menu>button {
  width: 100%;
  text-align: left;
  padding: .4rem .5rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.chat-header .menu>button.danger {
  color: #ff6b6b;
}

.call-btns {
  display: flex;
  gap: 5px;
}
.chat-header .icon-btn {
  width: 25px;
  height: 28px;
  background: var(--surface), linear-gradient(45deg, var(--strans)8%, var(--bg));
  color: var(--primary-dark);
  background: none;
  border: var(--line);
}
.poll-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
}

/* ----- Messages: avatar → bubble with time inside ----- */
.messages {
  display: flex;
  position: relative;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem;
  padding-top: 50px;
  padding-bottom: max(90px, calc(var(--chat-composer-height, 96px) + 12px));
  overflow-y: auto;
  min-height: 0;
  height: -webkit-fill-available
}

.date-chip {
  display: grid;
  place-items: center;
  margin: .5rem 0;
}

.msg.has-date-chip {
  flex-wrap: wrap;
}

.msg.has-date-chip > .date-chip-inline {
  flex: 0 0 100%;
  width: 100%;
  order: -1;
  margin: .15rem 0 .45rem;
}

.is-system .date-chip-inline {
  flex: auto !important;
}

.date-chip .pill {
  background: var(--strans);
  border-radius: 999px;
  font-size: 10px;
  font-family: 'Poppins';
  padding: .05rem .4rem;
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
}

.date-chip .pill:hover {
  color: var(--text);
  background: var(--primary-faded);
}

.date-chip .pill:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .16), 0 0 0 4px color-mix(in srgb, var(--primary) 55%, transparent);
}

.chat-date-jump-proxy {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.msg {
  display: flex;
  gap: .1rem 8px;
  align-items: center;
}

.msg.me {
  flex-direction: row-reverse;
}

.msg .avatar.sm {
  cursor: pointer;
  border: 0;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  color: var(--bg);
  place-items: center;
  font-weight: 700;
  margin: 4px 0 auto;
}

.sm.visually-hidden {
  display: none;
}

.me .avatar.sm {
  display: none;
}

.msg {
  position: relative;
}

.msg .msg-content {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  min-width: 0;
  max-width: 72%;
}

.msg .bubble,
.msg .bubble .text-shell,
.msg .bubble .text,
.msg .bubble .text-shell > *,
.msg .bubble .text > *,
.msg .bubble .email-quote-content,
.msg .bubble .code-block-container,
.msg .bubble .chat-code-grid,
.msg .bubble .m-code-grid {
  min-width: 0;
  max-width: 100%;
}

.msg .bubble .text-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  border-radius: 15px;
  margin: 2px 0;
  overflow: visible;
}

.me .msg-content {
  flex-direction: row;
}

/* System messages (calls, events, notices): centered, no avatar, no sender. */
.msg.is-system {
  flex-wrap: nowrap;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 !important;
}
.msg.is-system .msg-content {
  flex-direction: column;
  align-items: center;
  max-width: 90%;
  margin: 0 auto;
}
.msg.is-system .bubble {
  align-items: center;
  text-align: justify;
}
.msg.is-system .sender-strip,
.msg.is-system .avatar.sm {
  display: none;
}

/* Info-panel actions (relocated from the old header "⋮" dropdown). */
.chat-context-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, .08));
}
.chat-context-actions:empty {
  display: none;
}
.chat-context-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border, rgba(255, 255, 255, .12));
  border-radius: 999px;
  background: transparent;
  color: var(--text-main, inherit);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.chat-context-action:hover {
  background: var(--dots, rgba(255, 255, 255, .06));
}
.chat-context-action i {
  font-size: 14px;
}
.chat-context-action.danger {
  color: var(--danger, #ef4444);
  border-color: color-mix(in srgb, var(--danger, #ef4444) 40%, transparent);
}
.btn-chat-call-ico,
#btnChatMenu .ub-ico {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
}
#btnChatMenu .ub-ico svg {
  width: 18px;
  height: 18px;
}

/* Email-style skeleton for the conversation list (optimistic loading). */
.chat-skel-list {
  padding: 6px 0;
}
.chat-skel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.chat-skel-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.chat-skel {
  position: relative;
  overflow: hidden;
  background: var(--dots, rgba(255, 255, 255, .06));
  border-radius: 6px;
}
.chat-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
  animation: chat-skel-shimmer 1.2s ease-in-out infinite;
}
html[data-theme="light"] .chat-skel::after {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .06), transparent);
}
@keyframes chat-skel-shimmer {
  100% { transform: translateX(100%); }
}
.chat-skel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.chat-skel-line {
  height: 11px;
}
.chat-skel-name {
  width: 52%;
}
.chat-skel-preview {
  width: 82%;
  height: 9px;
}
.chat-skel-time {
  width: 26px;
  height: 9px;
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 4px;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 60px;
  border-radius: 10px;
  padding: 0 5px;
  background: var(--dots);
  cursor: pointer;
  font-size: 10px;
  margin: 5px 0;
}

.msg .bubble .text {
  position: relative;
  background: var(--dots);
  border-radius: .2rem 1rem 1rem 1rem;
  padding: 0.5rem .65rem;
  word-break: break-word;
  font-size: var(--text-size);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.me .bubble .text {
  background: var(--primary-dark);
  color: #fcfcfc;
  border-radius: 1rem 0.2rem 1rem 1rem;
}

.msg .bubble .time {
  font-size: .72em;
  opacity: .7;
  display: flex;
  justify-content: flex-end;
}

.msg .bubble .media img {
  max-width: 320px;
  height: auto;
  border-radius: 8px;
  display: block;
  contain: content;
}

.msg .bubble .media .expand-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 0;
  background: rgba(0, 0, 0, .4);
  color: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.msg .bubble .media .file-ph {
  width: 220px;
  height: 120px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: radial-gradient(var(--dots) 5px, transparent 20px),
    radial-gradient(var(--dots) 5px, transparent 20px),
    linear-gradient(0deg, var(--strans), var(--bg));
}

/* FIX: pending message treatment + three-dot overlay */
.msg .bubble.pending {
  opacity: .4;
}

.msg.error .bubble,
.msg .bubble.error {
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--danger) 36%, transparent);
}

.msg.error .bubble .text,
.msg .bubble.error .text {
  background: color-mix(in oklab, var(--danger) 10%, var(--dots));
}

/* Queued offline messages (STEP 4) */
.msg .bubble.queued-offline {
  opacity: 0.6;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 50%, transparent);
  position: relative;
}

.msg .bubble.queued-offline::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  animation: offline-pulse 2s infinite;
}

@keyframes offline-pulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 59 130 246), 0.7);
  }
  50% { 
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 59 130 246), 0);
  }
}

.msg .bubble .loading-dots {
  position: absolute;
  right: 10px;
  bottom: 18px;
  display: inline-flex;
  gap: 4px;
}

/* --- Style for Code Blocks --- */

/* The main container that holds the header and the <pre> tag */
.code-block-container {
  /* Dark gray background */
  border-radius: 8px;
  overflow: hidden;
  /* This is crucial to make border-radius work */
  margin-top: 0;
  max-width: 100%;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  display: grid;
  gap: 1px;
}

/* The header bar at the top */
.code-header {
  
  /* Slightly lighter gray for the header */
  padding: 0.35em .81em;
  display: flex;
  justify-content: space-between;
  /* Puts language on left, copy button on right */
  align-items: center;
}

/* The language name label */
.language-name {
  color: var(--primary);
  font-size: 0.9em;
  font-family: sans-serif;
  font-weight: bold;
  text-transform: uppercase;
}

/* The <pre> tag that holds the code. We remove its default styling. */
.code-block {
  margin: 0;
  padding: 0;
  background: none;
  /* The container provides the background now */
}

/* The <code> tag itself */
.code-block code {
  display: block;
  padding: .91em .81em;
  /* Padding for the code inside the box */
  color: var(--text);
  /* Light text color for the code */
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  font-size: 10px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: visible;
  /* Wrap long lines instead of horizontal scrolling */

  user-select: auto !important;
  -webkit-user-select: text !important;
}

/* --- Add this to your CSS for the copy button --- */
.copy-button {
  background-color: var(--dots);
  color: #fff;
  border: none;
  padding: 0.3em 0.7em;
  border-radius: 5px;
  cursor: pointer;
  font-family: sans-serif;
  font-size: 0.8em;
  transition: background-color 0.2s;
}

.copy-button:hover {
  background-color: var(--bgblur);
}

.copy-button.copied {
  background-color: var(--primary);
}

.chat-code-grid,
.m-code-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  min-width: 0;
}

.m-code-gutter {
  display: grid;
  align-content: start;
  gap: 0;
  padding: .51rem .5rem 1rem .15rem;
  width: max(1rem, 2rem);
  color: #fff;
  background: var(--bgblur);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  user-select: none;
  -webkit-user-select: none;
  text-align: right;
}

.m-code-gutter > span {
  display: block;
}

.m-code-pre,
.m-code-pre.code-block,
.chat-code-grid .code-block {
  min-width: 0;
  overflow: hidden;
}

.msg .bubble .text code.inline-code,
.inline-code {
  display: inline;
  padding: .1rem .35rem;
  border-radius: 6px;
  background: var(--bgblur);
  color: #fff;
  font-size: .85em;
  white-space: break-spaces;
}

/* Code blocks use the quote-box structure but keep a tight, flush layout */
.email-quote-box.code-quote-box {
  padding: 0;
  background: transparent;
  overflow: hidden;
}

.email-quote-title {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.email-quote-box.code-quote-box .email-quote-title {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.email-quote-content {
  max-height: 260px;
  overflow: hidden;
  position: relative;
  word-break: break-word;
  padding-bottom: 38px; /* space for expand button overlay */
}

.email-quote-box.is-expanded .email-quote-content {
  max-height: none;
}

/* Gradual expand steps */
.email-quote-box[data-expand-step="1"] .email-quote-content { max-height: 520px; }
.email-quote-box[data-expand-step="2"] .email-quote-content { max-height: 1000px; }
.email-quote-box[data-expand-step="3"] .email-quote-content,
.email-quote-box.is-expanded .email-quote-content { max-height: none; }

.email-quote-box.is-collapsed .email-quote-content::after,
.email-quote-box[data-expand-step="1"] .email-quote-content::after,
.email-quote-box[data-expand-step="2"] .email-quote-content::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), var(--bg));
  pointer-events: none;
}

.email-quote-box.is-expanded .email-quote-content::after {
  display: none;
}

/* New expand content button (replaces old arrow toggle) */
.expand-content-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: var(--backdrop);
  color: var(--primary);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  place-items: anchor-center;
  gap: 1px;
  transition: background .15s, transform .15s;
  flex-direction: row-reverse;
}

.expand-content-btn:hover {
  background: color-mix(in oklab, var(--primary) 14%, var(--bg));
  transform: translateX(-50%) scale(1.04);
}

.expand-content-btn .ic {
  font-size: 13px;
}

/* Hide old email-quote-toggle arrow completely */
.email-quote-toggle {
  display: none !important;
}

/* Long text expand support */
.text-expandable { position: relative; }
.text-expandable.is-collapsed .text-inner { max-height: 260px; overflow: hidden; }
.text-expandable[data-expand-step="1"] .text-inner { max-height: 520px; overflow: hidden; }
.text-expandable[data-expand-step="2"] .text-inner { max-height: 1000px; overflow: hidden; }
.text-expandable.is-expanded .text-inner { max-height: none; overflow: visible; }
.text-expandable.is-collapsed .text-inner::after,
.text-expandable[data-expand-step="1"] .text-inner::after,
.text-expandable[data-expand-step="2"] .text-inner::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--muted));
  pointer-events: none;
  border-radius: 12px;
}
.text-expandable.is-expanded .text-inner::after { display: none; }
.me .text-inner::after{
  background: linear-gradient(to bottom, transparent, var(--primary-dark)) !important;
}
.msg .bubble pre.code-block {
  overflow: hidden;
  border-radius: 0 8px 8px 0;
  background: var(--dots);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  max-width: 100%;
}

.msg .bubble code {
  font-family: 'Poppins';
  background: transparent;
}

/* FIX: selection affordance in emoji popover */
.rect-popover {
  background: transparent;
  border: 0;
  padding: 0;
  overflow: visible;
}

.rect-popover::backdrop {
  background: transparent;
}

.rect-popover .popover-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0px 6px;
  border-radius: 12px;
  background: color-mix(in oklab, var(--bg) 100%, transparent);
  border: var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  isolation: isolate;
}

.rect-popover .popover-card::after {
  content: "";
  position: absolute;
  left: -7px;
  top: calc(var(--arrow-top, 16px) - 0px);
  width: 8px;
  height: 8px;
  background: color-mix(in oklab, var(--bg) 100%, transparent);
  border-left: var(--line);
  border-bottom: var(--line);
  transform: rotate(45deg);
}

.rect-popover .rx-btn.selected {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-radius: 20px;
  padding: 0 1px !important;
}

.msg .bubble .loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
  animation: ldb 1s infinite both;
}

.msg .bubble .loading-dots i:nth-child(2) {
  animation-delay: .15s;
}

.msg .bubble .loading-dots i:nth-child(3) {
  animation-delay: .3s;
}

@keyframes ldb {

  0%,
  80%,
  100% {
    transform: scale(.6);
    opacity: .4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.msg .bubble .filename {
  margin-top: .25rem;
  font-size: .85em;
  opacity: .85;
}

/* Reactions strip */
.msg .bubble .rx-strip {
  display: flex;
  justify-content: flex-end;
}

.msg .sender-line {
  font-size: .8rem;
  opacity: .85;
  margin: 0 0 .15rem;
  display: flex;
  align-items: baseline;
  gap: .3rem;
}

.msg .sender-line .sl-name.visually-hidden {
  display: none;
}

.msg .actions-bar .ab-left {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.msg .actions-bar .ab-right {
  display: none;
  align-items: center;
  gap: .35rem;
}

.msg .actions-bar .ab-copy {
  border: 0;
  background: transparent;
  opacity: 0;
  transition: opacity .15s ease;
  cursor: pointer;
}

.msg:hover .actions-bar .ab-copy {
  opacity: 1;
}

.msg .actions-bar .ab-plus {
  border: 0;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.msg .actions-bar .rx-strip:empty {
  display: none;
}

.msg .actions-bar .ab-seen {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .85em;
  opacity: .75;
}

.msg .bubble .attch-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, .5fr));
  gap: 0;
}

.group-row.active {
  background: var(--primary-dark);
}

#chatMessages {
  position: relative;
}

/* Chat loading overlay */
.chat-loading-overlay{
  position: absolute;
  inset: 0 -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--strans);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  isolation: isolate;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
  z-index: 55;
}
.chat-loading-overlay.is-visible{ opacity: 1; pointer-events: auto; }
.chat-loading-overlay.is-hiding{ opacity: 0; pointer-events: none; }

.chat-loading-card{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: var(--primary-faded);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.chat-loading-text{ font-size: 13px; opacity: 0.9; }
.chat-loading-dots{ display:flex; gap: 6px; align-items:center; }
.chat-loading-dots span{
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  animation: chatDot 1.05s infinite ease-in-out;
}
.chat-loading-dots span:nth-child(2){ animation-delay: 0.15s; }
.chat-loading-dots span:nth-child(3){ animation-delay: 0.30s; }

@keyframes chatDot{
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

#chatMessages.drop-hover::after {
  content: '';
  position: fixed;
  inset: 0;
  border-radius: 12px;
  z-index: 50;
  border: 5px dashed var(--primary);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  isolation: isolate;
  background: color-mix(in oklab, var(--primary) 6%, transparent);
  pointer-events: none;
}

.dm-row.drop-hover,
.group-row.drop-hover {
  outline: 3px dashed var(--primary);
  outline-offset: -4px;
}

.dm-preview.truncate {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.3;
}

.dm-name.truncate {
  font-size: 13px;
  align-items: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  text-transform: capitalize;
}

.msg .attch-card {
  border-radius: 8px;
  overflow: hidden;
  transform-origin: center center;
  transition: transform 0.3s ease, z-index 0s 0.3s;
}

.msg .attch-card:hover {
  transform-origin: 100% 0%;
  transform: scale(1.1) rotateZ(-10deg) translateY(-5px);
  z-index: 10;
  transition: transform 0.3s ease, z-index 0s;
}
.me .msg .attch-card:hover {
  transform-origin: 100% 0%;
  transform: scale(1.1) rotateZ(10deg) translateY(-5px);
  z-index: 10;
  transition: transform 0.3s ease, z-index 0s;
}

.msg .bubble .attch-grid .attch-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg .bubble .media.replied .tagged {
  border: var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 16px 15px;
  padding: .25rem .2rem 2rem;
  opacity: .9;
  background: var(--primary-dark);
}

.replied .text {
  background: transparent !important;
  margin-top: -2rem;
}

dialog.attch-viewer .ti.active {
  outline: 2px solid var(--primary);
}

.reply-chip {
  Pointer-events: all;
  position: relative;
  width: 50%;
  left: -2%;
  border: var(--line);
  border-radius: 10px;
  padding: .25rem .5rem;
  color: #fff;
  align-content: center;
  background: var(--bgblur);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  isolation: isolate;
}

.reply-chip .rc-wrap {
  display: flex;
  gap: .5rem;
  justify-content: space-between;
  align-items: center;
}

.reply-chip .rc-tease {
  opacity: .8;
  font-size: .85em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.reply-chip .rc-x {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.reply-hint {
  display: flex;
  position: absolute;
  align-items: flex-end;
  top: 50%;
}

.rx-wrap {
  display: flex;
  gap: .15rem;
}

.rx-btn {
  padding: 3px !important;
}

.rx-chip {
  background: var(--primary-dark);
  padding: 0 .3rem 0 .2rem;
  display: flex;
  border-radius: 100px;
  line-height: 15px;
  font-size: 0.8em;
  align-items: center;
  margin-top: -10px;
}

.me .rx-chip {
  background: var(--muted)
}

/* Audio bubble */
.audio-bubble {
  display: flex;
  width: 200px;
  align-items: center;
  gap: .5rem;
  padding: .35rem;
  border-radius: 20px;
  background: var(--dots);
}

.audio-bubble .ab-play {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  cursor: pointer;
}

.audio-bubble .ab-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .15);
  overflow: hidden;
  position: relative;
}

.audio-bubble .ab-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  height: 100%;
  background: var(--primary-light);
}

.audio-bubble .ab-time {
  text-align: right;
  opacity: .8;
  font-size: .75em;
}

/* Message actions modal */
dialog.msg-actions .modal-card {
  width: min(420px, 92vw);
}

.msg-actions .rx-row {
  display: flex;
  gap: .5rem;
  justify-content: space-between;
}

.msg-actions .rx-row .rx-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  font-size: 22px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-actions .menu-list {
  display: grid;
  gap: .25rem;
}

.msg-actions .menu-list>button {
  text-align: left;
  padding: .4rem .6rem;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.msg-actions .menu-list>button.danger {
  color: #ff6b6b;
}

/* Attach popover */
dialog.menu-popover::backdrop {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  isolation: isolate;
}

.popover-card {
  display: flex;
  flex-direction: row;
  color: var(--text);
  background: transparent;
  border: var(--line);
  border-radius: 10px;
}

.attach-menu .popover-card {
  flex-direction: column !important;
}

.popover-card>button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: .4rem .5rem;
  cursor: pointer;
}

.popover-card hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, .1);
  margin: .25rem 0;
}

/* Voice recorder */
/* Hide sine wave canvas and show only bar-fill */
.audio-bubble canvas.ab-wave {
  display: none !important;
}

.tagged-msg {
  overflow: hidden;
  background: var(--dots);
  border-radius: 8px 8px 0 0;
  padding: 1px 4px;
}

/* Generic disabled visual */
.disabled,
[aria-disabled="true"],
button:disabled,
.icon-btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.voice-modal .vr-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 10px;
  align-items: center;
}

.voice-modal .btn.round {
  display: flex;
  box-shadow: none;
  justify-content: center;
  align-items: center;
  width: 20px;
  font: -webkit-small-control;
  height: 20px !important;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  font-size: 20px;
  color: var(--text);
  margin: 5px;
}

.voice-modal .vr-live {
  display: flex;
  align-items: center;
  padding: 0 3px 0 0;
  gap: 8rem;
  background: var(--primary-faded);
  border: var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.voice-modal .vr-preview {
  display: flex;
  align-items: center;
  padding: 0 3px 0 0;
  gap: 0.3rem;
  background: var(--primary-faded);
  border: var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 100%;
}

/* Generic audio progress styles (also used in recorder preview) */
.ab-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .15);
  overflow: hidden;
  position: relative;
}

.ab-bar .ab-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}

.ab-bar:hover .ab-thumb,
.ab-bar .ab-thumb[data-hover] {
  opacity: 1;
}

.ab-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  height: 100%;
  background: var(--primary);
}

/* Poll bubble */
.poll-bubble {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: var(--primary-dark);
  padding: 10px 5px;
  border-radius: 10px;
}

.poll-bubble .poll-q {
  font-weight: 900;
}

.poll-bubble .poll-opts {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.poll-bubble .poll-row {
  position: relative;
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: .3rem .35rem;
  border-radius: 15px;
  background: rgba(255, 255, 255, .06);
}

.poll-bubble .poll-row .po-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: color-mix(in oklab, var(--primary) 25%, transparent);
  border-radius: 15px;
  pointer-events: none;
}

.poll-bubble .poll-row .po-name {
  position: relative;
}

.poll-bubble .poll-row .po-pct {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

#chatAttach.icon-btn {
  border: var(--line)
}

/* user card layout */
#chatInfo .user-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: .75rem;
  align-items: center;
}

#chatInfo .btn-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.other .actions-bar {
  flex-direction: row-reverse
}

/* ----- Right panel details ----- */
#chatContext {
  padding: 0;
}

#chatInfo .section {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .75rem;
}
#chatInfo .d.section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#chatInfo .avatar.xl {
  width: 65px;
  height: 65px;
  padding: 2px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--strans);
}

#chatInfo .group-name {
  font-weight: 700;
  align-content: center;
  font-size: 1.5vw;
  outline: none;
}

.avatar-wrap {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-direction: column;
}

#chatInfo textarea {
  width: 100%;
  min-height: 40px;
  border-radius: 8px !important;
  border: var(--line);
  background: var(--muted);
  color: var(--text);
  padding: .5rem;
}

#chatInfo .section-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#chatInfo .files-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(auto, 1fr));
  grid-template-rows: max-content;
  gap: .5rem;
  max-height: 40vh;
  overflow: auto;
  align-items: start;
  padding-right: 3px;
  margin-right: -3px;
}
#donnaSessions {margin-right: -5px;top: 5px;display: grid;min-height: 0;height: 50vh;overflow: auto;}
#donnaSessions .item{display: flex;flex-direction: column;gap: 4px;min-width: 0;}
#donnaSessions .truncate{
    font-size: 13px;
    width: 90%;
    text-wrap-mode: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#donnaSessions .sub{
    font-size: 9px;
    font-weight: 300;
    color: var(--text-muted);
}
#donnaSessions .icon-btn{position:absolute; right:5px; top: 5px;}
#chatInfo .file-card {
  text-align: center !important;
  display: flex;
  flex-wrap: wrap;
  gap: .15rem;
  background: var(--bg);
  border: var(--line);
  min-height: 0;
  border-radius: 8px;
  padding: .4rem;
  justify-content: center;
  height: max-content;
}

#chatInfo .file-card .meta {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  max-width: -webkit-fill-available;
}

#chatInfo .file-card .thumb {
  aspect-ratio: 4/3;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, .04);
}

#chatInfo .file-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#chatInfo .file-card .thumb .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(var(--dots) 5px, transparent 20px),
    radial-gradient(var(--dots) 5px, transparent 20px),
    linear-gradient(0deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .04));
}

#chatInfo .file-card .thumb .placeholder span {
  font-size: .5rem;
  opacity: .8;
}

#chatInfo .file-card .meta .name {
  font-weight: 600;
}

#chatInfo .file-card .meta .sub {
  color: var(--text-muted);
  font-size: .5rem;
}

#chatInfo .file-card .actions {
  display: flex;
  gap: .25rem;
  justify-content: flex-end;
}

#chatInfo .user-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: .3rem .25rem;
  border-bottom: var(--line);
  overflow: hidden;
}
#chatInfo .user-row .info {
  display: grid;
  overflow: hidden;
  text-overflow: ellipsis;
  text-wrap-mode: nowrap;
  min-width: 0;
}
#chatInfo .user-row .info .pill{
  font-size:10px
}
#chatInfo .user-row .info .email {
  color: var(--text-muted);
  font-size: .68rem;
  text-overflow: ellipsis;
  text-wrap-mode: nowrap;
  overflow: hidden;
  min-width: 0;
  width: -webkit-fill-available;
}
#chatInfo .user-row .info .name {
  display: flex;
  color: var(--text);
  font-size: .7rem;
  font-weight: 600;
  text-overflow: ellipsis;
  text-wrap-mode: nowrap;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
}

#chatInfo .user-row .actions button {
  display: none;
}

#chatInfo[data-can-manage="true"] .user-row .actions button {
  display: inline-flex;
}

/* file preview dialog */
dialog.file-preview {
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  max-width: min(92vw, 720px);
  box-shadow: inset 1px 1px 18px 2px var(--primary-faded);
}

dialog.file-preview .content {
  padding: .75rem;
  max-height: 85vh;
  overflow: auto;

}

dialog.file-preview .content img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  contain: content;
}

dialog.file-preview .content .placeholder.big {
  width: 100%;
  height: 50vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(var(--dots) 5px, transparent 20px),
    radial-gradient(var(--dots) 5px, transparent 20px),
    linear-gradient(0deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .04));
  border-radius: 10px;
}

dialog.file-preview footer.actions {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  border-top: var(--line);
}

dialog.file-preview footer.actions .right {
  display: flex;
  gap: .5rem;
}

.msg.streak-mid {
  margin-bottom: -0.5px !important;
}

.msg.streak-mid,
.msg.streak-last {
  margin-top: -2px !important;
}

.msg.streak-first {
  margin-bottom: -1px
}

.msg.streak-mid,
.msg.streak-last {
  padding-left: 36px;
}

/* Header strip inside bubble */
.msg .bubble .sender-strip {
  opacity: .9;
  margin: 0 0 .2rem;
  display: none;
  /* default hidden; shown by streak rules */
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}

.msg .bubble .sender-strip .sender-name {
  font-weight: 700;
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg .bubble .sender-strip .sender-time {
  opacity: .9;
  font-size: 8px;
  font-family: unset;
}

/* Show header only for first/single messages */
.msg.streak-first .bubble .sender-strip,
.msg.streak-single .bubble .sender-strip {
  display: flex;
}

/* Remove/ignore old inline time area */
.msg .bubble .time {
  display: none !important;
}

/* Transparent media bubbles */
.msg .bubble.is-media {
  /*background: transparent; padding-top: 0.2rem;*/
  background: transparent;
  display: flex;
  flex-direction: column;
}
.bubble.is-media .media{
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 15px;
  background: var(--dots);
  flex-direction: column;
}
.me .bubble.is-media .media{background:var(--primary-faded)}

.single-attch,
.attch-card,
.msg .bubble .media {
  position: relative;
}

img {
  contain: size;
}

/* In-bubble footer */
.msg .bubble .actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  z-index: 5
}

.actions-bar {
  flex-direction: row-reverse;
}

.msg .bubble .actions-bar .ab-left {
  display: flex;
  align-items: center;
  gap: .25rem;
  z-index: 2;
  /* padding-bottom: 5px; */
}

.msg .bubble .actions-bar .rx-strip:empty {
  display: none;
}

.msg .bubble .actions-bar .ab-plus {
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 999px;
  width: 15px;
  height: 15px;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity .5s ease;
  display: grid;
  place-items: center;
}

.msg:hover .bubble .actions-bar .ab-plus {
  opacity: 1;
}

.msg .bubble .actions-bar .view-count {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  opacity: .5;
  font-size: .5rem;
}

.msg .actions-bar .view-count.seen i {
  color: var(--primary);
}

.msg .actions-bar .view-count .count {
  display: none !important;
}

/* moreactions flexbox outside bubble (hover-only) */
.msg .more-actions {
  position: absolute;
  display: flex;
  bottom: 40%;
  gap: 0px;
  left: 101%;
  flex-direction: column;
  opacity: 0;
  font-size: 9px;
  height: 0;
  justify-content: center;
}
.msg.streak-mid .more-actions, .msg.streak-last .more-actions {
  bottom:50%;
}
.msg.me .more-actions {
  left: -20px;
}

.msg .more-actions .ab-plus {
  opacity: 1;
}

.msg .more-actions .copy-btn {
  cursor: pointer;
}

.msg:hover .more-actions {
  opacity: 1;
  transition: opacity 1s ease;
}

.streak-last .more-actions {
  bottom: 60%
}

.is-media .more-actions {
  bottom: 50%
}

.is-event .more-actions {
  bottom: 75px
}

/* Underline links in every bubble */
.msg .bubble .text a,
.msg .bubble .text-shell a {
  text-decoration: underline;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg .bubble .text ul,
.msg .bubble .text ol,
.msg .bubble .text li,
.msg .bubble .text p,
.msg .bubble .text blockquote,
.msg .bubble .text pre {
  max-width: 100%;
  min-width: 0;
}

/* Search row below header */
.chat-search-row {
  padding: .35rem 0;
  margin: 0 -3px;
}

.chat-search-row .input {
  width: 100%;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  padding: .05rem .6rem;
  height: 20px;
}

/* Pinned section styles */
.dept-pill .label {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.dept-pill .label i {
  font-size: .82rem;
  color: var(--primary);
}

/* Entrance animations for bubbles */
.msg.animate-in {
  animation: bubbleInOther .26s ease-out forwards;
}

.msg.me.animate-in {
  animation: bubbleInMe .26s ease-out forwards;
}

@keyframes bubbleInOther {
  from {
    opacity: 0;
    transform: translate(-12px, 8px) scale(.985);
  }

  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes bubbleInMe {
  from {
    opacity: 0;
    transform: translate(12px, 8px) scale(.985);
  }

  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

/* Attachments preview tray above composer */
#attchPreviewTray.attachments {
  max-height: fit-content;
  flex-basis: 100%;
  position: relative;
  min-width: 0;
  width: -webkit-fill-available;
  border-radius: 10px;
  margin: 0;
}

#attchGrid.attch-grid {
  display: grid;
  flex-basis: 100%;
  gap: 4px;
  overflow-x: auto;

  position: relative;
  pointer-events: all;
  grid-auto-flow: column;
  justify-self: center;
  width: fit-content;
  max-width: -webkit-fill-available;
}

.attch-card {
  position: relative;
  background: var(--muted);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 2px;
  display: grid;
  grid-template-rows: 1fr auto;
  height: 120px;
  width: 120px;
}

.messages>.thread[hidden] {
  display: none;
}

/* Wrapper to keep the pill positioned relative to the record button */
.voice-recorder-wrapper {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

/* Container for the pills - NOW handles the arrow */
.vr-pill-container {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-63%);
  margin-bottom: 50px;
  width: 220px;
  height: 40px;
  perspective: 1000px;
}

/* The arrow is now on the container so it doesn't flip */
.vr-pill-container::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 8px;
  border-style: solid;
  border-color: var(--bg) transparent transparent transparent;
}


/* --- The Flip Transition Logic --- */
.vr-pill-container.flipped .vr-pill.live {
  transform: rotateY(-180deg);
}

.vr-pill-container.flipped .vr-pill.preview {
  transform: rotateY(0deg);
}

/* Base style for BOTH pills */
.vr-pill {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  background-color: var(--bg);
  border-radius: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  backface-visibility: hidden;
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}

/* Initial state for the live recording pill (facing forward) */
.vr-pill.live {
  transform: rotateY(0deg);
}

.vr-pill.preview {
  transform: rotateY(180deg);
}

/* --- Rest of your styles (mostly unchanged) --- */

.vr-pill .vr-wave {
  flex-grow: 1;
  height: 100%;
  width: 50%;
}

.vr-pill .vr-time,
.vr-pill .vr-preview-time {
  font-size: 12px;
  color: #a7a7ad;
  padding: 0 3px;
  flex-shrink: 0;
}

.vr-pill .vr-control {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 18px;
  padding: 0 8px;
  cursor: pointer;
  display: flex;
  position: absolute;
  bottom: 100%;
  align-items: center;
  justify-content: center;
}

.vr-control.pause {
  position: relative;
  bottom: 0;
}

/* Preview Player Styles */
.vr-pill .vr-preview-controls {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.vr-pill.preview audio {
  display: none;
}

.vr-pill .vr-play-pause {
  background: #48484a;
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.vr-pill .vr-progress-bar {
  flex-grow: 1;
  height: 4px;
  background-color: #545458;
  border-radius: 2px;
  overflow: hidden;
}

.vr-pill .vr-progress {
  width: 0%;
  height: 100%;
  background-color: var(--primary);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* 'X' Close Button */
.vr-pill .vr-close {
  position: absolute;
  top: -10px;
  right: -4px;
  padding: 0;
  background: var(--primary-dark);
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 18px;
  font-weight: bold;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  z-index: 10;
}

.vr-pill .vr-close:hover {
  background: #6e6e72;
}

.attach-menu {
  -webkit-backdrop-filter: var(--backdrop);
  backdrop-filter: var(--backdrop);
  isolation: isolate;
  border-radius: 10px;
  left: 2%;
  bottom: 110%;
  max-width: 160px;
  pointer-events: all;
}

.attch-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.attch-card .file-icon {
  font-size: 11px;
  opacity: .7;
}

.attch-card .attch-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  width: 112px;
  font-size: .6rem;
  opacity: .85;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  isolation: isolate;
  border-radius: 5px;
  padding: 5px;
  margin: 1px;
  margin-bottom: -2px;
}

.msg .bubble .attch-grid,
.msg .bubble .attch-grid * {
  pointer-events: auto !important;
}

.group-pills .pill.drop-hover {
  outline: 4px dashed var(--primary);
  outline-offset: -2px;
}

/* ——— Event bubble (background image card) ——— */
.bubble.is-event .event-card {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  min-width: 20vw;
  max-width: 20vw;
  height: 20vh;
  display: flex;
}

.bubble.is-event .event-card .bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.05);
}

.bubble.is-event .event-card .shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95), var(--primary-dark));
}

.bubble.is-event .event-card .meta {
  position: relative;
  padding: .75rem;
  gap: 10px;
  color: white;
}

.bubble.is-event .event-card .title {
  font-weight: 600;
}

.bubble.is-event .event-card .sub {
  opacity: .85;
  font-size: .65rem;
  margin-top: .15rem;
}

/* ——— DM list header (name + time on one line) ——— */
#chatList .dm-list .dm-row .dm-meta .dm-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}

#chatList .dm-list .dm-row .dm-meta .dm-time {
  opacity: .66;
  font-size: .6rem;
  white-space: nowrap;
}

/* --- Split chat list layout (DMs & groups) --- */
#chatList.chat-split-root {
  height: 100%;
  margin-right: -8px;
}

#chatList .chat-split-grid {
  display: grid;
  grid-template-columns: 1fr 40px;
  /* big list + 100px mini strip on the right */
  gap: 0;
  height: 82vh;
  margin-left: -3px;
  border-radius: 15px;
}

#chatList .chat-split-main {
  min-width: 0;
  overflow: hidden;
  /* background: linear-gradient(90deg, var(--primary-faded), transparent 30%); */
  border-radius: 10px;
}

/* Right mini column (avatar-only list) */
#chatList .chat-split-mini {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: 12px;

  position: relative;
}

.chat-mini-caret:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.avatar.visually-hidden {
  display: none !important;
}

.chat-mini-list {
  flex: 1 1 auto;
  overflow-y: auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2rem 0 2px;
}

.chat-mini-list .mini-convo {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  position: relative;
  place-items: center;
  opacity: 0.4;
  transition: opacity .2s ease, transform .2s ease;
}

.chat-mini-list .mini-convo .avatar.xs {
  width: 30px;
  height: 30px;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-mini-list .mini-convo.active {
  outline: 1px solid var(--primary);
  outline-offset: 1px;
}

.chat-mini-list .mini-empty {
  font-size: 0.8rem;
  text-align: center;
  padding: 0.25rem 0.5rem;
}

/* Swap animation: big column fades down, mini fades up */
.chat-split-main.fade-down {
  animation: chatMainFadeDown 180ms ease-out;
}

.chat-mini-list.fade-up {
  animation: chatMiniFadeUp 180ms ease-out;
}

@keyframes chatMainFadeDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chatMiniFadeUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Global info tip (for new messages in mini column) */
.chat-info-tip {
  position: fixed;
  z-index: 9999;
  max-width: 260px;
  background: var(--primary-dark);
  color: var(--on-primary, #fff);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.chat-info-tip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  margin-top: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent var(--primary-dark);
}

.chat-info-tip .info-title {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.chat-info-tip .info-preview {
  opacity: 0.9;
}

.chat-info-tip .info-time {
  opacity: 0.65;
  margin-top: 0.15rem;
  font-size: 0.7rem;
}

.chat-info-tip.hide {
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

/* -------------------------------------------------------------------------
   Call system messages (ended / missed) + call summary modal
   ---------------------------------------------------------------------- */
.bubble.is-call {
  max-width: 100%;
}

/* System-style call messages (no avatar / sender strip) */
.msg.sys-call .msg-content {
  max-width: 100%;
  justify-content: center;
}

.msg.sys-call .bubble .actions-bar{
  display: none !important;
}

/* Keep missed call bubbles compact */
.call-card.call-missed {
  max-width: 360px;
}

.call-card {
  padding: 10px;
  border-radius: 12px;
  background: var(--dots);
}

.call-row {
  line-height: 1.2;
}

.call-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: var(--text-size);
}

.call-duration {
  opacity: 0.85;
  font-size: 0.92em;
  margin-bottom: 8px;
}

.call-missed {
  font-weight: 600;
}

.call-takeouts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.call-takeouts .label {
  opacity: 0.85;
  font-weight: 600;
}

.call-takeouts-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.call-takeout-card {
  position: absolute;
  right: 0;
  bottom: 34px;
  display: flex;
  gap: 8px;
  padding: 3px;
  border-radius: 10px;
  background: var(--strans);
  border: var(--line);
  color: var(--text);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  isolation: isolate;
}

.call-takeout-card[hidden]{display:none}
.call-takeout-card button{font-size: 11px;}

.call-summary-dialog {
  background: transparent;
  color: inherit;
}

.call-summary-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(80vh, 780px);
}

.call-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: var(--line);
}

.call-summary-title {
  font-weight: 700;
}

.call-summary-body {
  padding: 12px 14px;
  overflow: auto;
}

.call-summary-ai {
  white-space: pre-wrap;
  padding: 10px 12px;
  border-radius: 10px;
  border: var(--line);
  background: var(--strans);
  margin-bottom: 12px;
}

.call-summary-transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.call-summary-line {
  padding: 10px 12px;
  border-radius: 10px;
  border: var(--line);
  background: var(--strams);
}

.call-summary-line .who {
  font-weight: 700;
  margin-bottom: 4px;
}

.call-summary-line .what {
  opacity: 0.92;
  white-space: pre-wrap;
  word-break: break-word;
}

.call-summary-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: var(--line);
}

/* ----- Chat Search (icon + flyout) ----- */
.chat-search-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.chat-search-wrap .chat-search-btn {
  border-radius: 999px;
  width: 26px;
  height: 26px;
}

.chat-search-wrap .chat-search-flyout {
  position: absolute;
  top: 50%;
  right: 0;
  /* flyout opens to the LEFT of the icon */
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.05rem 0.35rem;
  border: var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 30;
  min-width: 170px;
}

.chat-search-wrap .chat-search-flyout input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.75rem;
}

.chat-search-wrap .chat-search-flyout[hidden] {
  display: none
}

.chat-search-wrap .chat-search-close {
  border-radius: 999px;
  width: 20px;
  height: 20px;
  font-size: 10px;
}

/* ----- Unread conversation badge (sidebar bubbles) ----- */
.group-row,
.dm-row,
.mini-convo {
  position: relative;
}

.unread-badge {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  user-select: none;
}

.mini-convo .unread-badge {
  top: 6px;
  right: 6px;
  transform: none;
  height: 16px;
  min-width: 16px;
  line-height: 16px;
  padding: 0 5px;
  font-size: 0.7rem;
}

/* ----- Voice note playback speed pill ----- */
.audio-bubble,
.audio-row {
  position: relative;
}

.ab-speed {
  position: absolute;
  top: -12px;
  right: 1px;
  border: var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.ab-speed:hover {
  background: rgba(0, 0, 0, 0.35);
}


/* Composer (two-row) helpers */
.composer-two-row .composer-bottom .composer-left .icon-btn,
.composer-two-row .composer-bottom .composer-right .icon-btn {
  border: var(--line); 
  background: color-mix(in oklab, var(--muted) 30%, transparent);
}

.composer-two-row .composer-bottom .composer-left .icon-btn:hover,
.composer-two-row .composer-bottom .composer-right .icon-btn:hover {
  filter: brightness(1.05);
}

/* Popover bubbles for composer buttons (format / magic / more) */
.composer-bubble {
  position: fixed;
  z-index: 2000;
  pointer-events: auto;
}

.composer-bubble .bubble-card {
  background: var(--bg);
  border: var(--line);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  isolation: isolate;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 130px;
}

.composer-bubble .bubble-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.composer-bubble .bubble-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.composer-bubble .composer-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.composer-bubble .composer-toggle-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.composer-bubble .composer-toggle-row span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.composer-bubble button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: var(--strans);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.composer-bubble button:hover {
  background: rgba(255, 255, 255, 0.10);
}

.composer-bubble .bubble-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg);
  border-right: var(--line);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  isolation: isolate;
  border-bottom: var(--line);
  transform: rotate(45deg);
  bottom: -6px;
  left: var(--arrow-left, 20px);
}

.chat-mentions-shell {
  position: relative;
  width: 100%;
  display: block;
  background: var(--muted);
  border: var(--line);
  border-radius: 20px;
}

.chat-mentions-shell .chat-mentions-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: auto;

  border-radius: inherit;
}

.chat-mentions-shell .chat-mentions-overlay::-webkit-scrollbar {
  display: none;
}

.chat-mentions-shell .chat-mentions-mirror {
  min-height: 30px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-mentions-shell textarea#chatInput.chat-mentions-textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  resize: none;
}

.chat-mentions-shell.has-value textarea#chatInput.chat-mentions-textarea {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
}

.chat-mentions-shell textarea#chatInput.chat-mentions-textarea::placeholder {
  color: var(--text-muted);
  -webkit-text-fill-color: initial;
}

.chat-mention-token {
  color: var(--primary);
  font-weight: 650;
}

.composer.code-mode .chat-mentions-shell {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

/* Mention suggestions */
.mention-suggest {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: min(380px, 92vw);
  max-height: 220px;
  overflow: auto;
  border-radius: 12px;
  border: var(--line);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  isolation: isolate;
  box-shadow: var(--shadow);
  padding: 6px;
}

.mention-suggest .ms-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.mention-suggest .ms-item:hover,
.mention-suggest .ms-item.active {
  background: rgba(255, 255, 255, 0.10);
}

.mention-suggest .ms-item .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mention-suggest .ms-item .name {
  font-weight: 650;
  font-size: 13px;
}

.mention-suggest .ms-item .sub {
  font-size: 11px;
  opacity: 0.75;
}

.mention-suggest .avatar.xs {
  width: 24px;
  height: 24px;
}

/* Smooth-jump highlight for reply/tag scroll */
.msg.jump-target .text {
  outline: 2px solid var(--primary);
  box-shadow: 0 0 0 6px color-mix(in oklab, var(--primary) 18%, transparent), var(--shadow);
}

.msg.search-hit .text {
  box-shadow: 0 0 0 px var(--primary);
}

.msg.search-hit .text::after {
  content: ' ';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  pointer-events: none;
}

.msg.search-current .text {
  outline: inset 2px var(--primary);
  box-shadow: 0 0 0 -4px color-mix(in oklab, var(--primary) 18%, transparent), var(--shadow);
  margin:2px 0
}

/* Search overlay */
dialog.chat-search-overlay .modal-card {
  width: min(520px, 94vw);
}

.chat-search-overlay .search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-search-overlay input {
  width: 100%;
}

.chat-search-overlay .hint {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 6px;
}

.chat-search-overlay .pill {
  font-variant-numeric: tabular-nums;
}

/* Reply quote area clickable hint */
.tagged{ display:flex; flex-direction:column; gap:4px}

.tagged-msg {
  cursor: pointer;
}

.tagged-msg:active {
  transform: translateY(1px);
}

/* Missed call styling */
.call-card.call-missed {
  border: 1px solid color-mix(in oklab, #ff6b6b 35%, rgba(255, 255, 255, 0.08));
  background: color-mix(in oklab, rgba(255, 255, 255, 0.03) 70%, rgba(255, 107, 107, 0.10));
}

.call-card .call-missed-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.call-card .call-missed-ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, #ff6b6b 18%, rgba(255, 255, 255, 0.06));
}

.call-card .call-missed-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-card .call-missed-meta .line1 {
  font-weight: 750;
}

.call-card .call-missed-meta .line2 {
  font-size: 12px;
  opacity: 0.8;
}

.call-card .call-missed-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.call-card .call-missed-actions .btn {
  padding: 7px 10px;
}

/* --- New Unified Popover --- */
.chat-popover {
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: transparent;
  gap: 4px;
}

.chat-popover .pop-section {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-popover hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0.25rem 0;
}

.chat-popover button {
  text-align: left;
  border: 0;
  background: var(--strans);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.chat-popover button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-popover button.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Magic Settings specific */
.magic-settings {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 0.25rem;
}

.magic-settings label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.magic-settings select {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.magic-settings select:hover {
  border-color: var(--primary-faded);
}

.magic-settings select:focus {
  border-color: var(--primary);
}

/* Composer "code editor" mode when cursor is inside a ``` fence */
.composer.code-mode .composer-top {
  position: relative;
}

.composer.code-mode .composer-top::after {
  content: "CODE";
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0.55;
  pointer-events: none;
}

.composer.code-mode textarea#chatInput {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

/* Magic settings inside each Donna modal */
.magic-settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 10px;
  border-radius: 12px;
  border: var(--line);
  background: rgba(0, 0, 0, 0.12);
  margin-bottom: 10px;
}

.magic-settings-row .magic-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1;
}

.magic-settings-row .magic-field span {
  font-size: 12px;
  opacity: 0.8;
}

.magic-settings-row select {
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.14);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.magic-settings-row select:focus {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}


/* Chat code blocks (line numbers + no wrapping) */
.email-quote-box.code-quote-box .email-quote-content{
  word-break: normal;
  border-radius: 0;
}
.email-quote-box.code-quote-box .chat-code-grid{
  margin-top: 0;
}
.email-quote-box.code-quote-box pre.code-block{
  margin: 0;
}


/* === Batch 3: chat UX polish ============================================ */

.chat-menu-anchor {
  pointer-events: none;
}

.chat-delete-banner-host {
  display: grid;
  gap: 8px;
  margin: 0 0 2px;
}

.chat-delete-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 12px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 15px;
  border: 1px solid color-mix(in oklab, var(--primary) 20%, transparent);
  -webkit-backdrop-filter: var(--backdrop);
  backdrop-filter: var(--backdrop);
  isolation: isolate;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .08);
  pointer-events: all;
}

.chat-delete-banner .label {
  font-weight: 700;
  color: var(--text);
}

.chat-delete-banner .meta {
  grid-column: 1;
  color: var(--text-muted);
  font-size: 10px;
}

.chat-delete-banner .undo {
  grid-column: 2;
  grid-row: 1 / span 2;
  border-radius: 999px;
  padding: 0 8px;
}

.msg.pending-delete,
.msg.is-queued {
  opacity: .7;
}

.msg.is-queued .bubble .text::after {
  content: 'Queued';
  position: absolute;
  right: 10px;
  bottom: -18px;
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: pulse-queued 1.5s infinite;
}

@keyframes pulse-queued {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.bubble.pending-delete .text {
  position: relative;
  border-style: dashed !important;
  opacity: .78;
  filter: saturate(.9);
}

.bubble.pending-delete .text::after {
  content: attr(data-delete-scope);
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: capitalize;
}

.text-shell.is-disappearing {
  position: relative;
  isolation: isolate;
}

.text-shell.is-disappearing::before,
.text-shell.is-disappearing::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
}

.text-shell.is-disappearing::before {
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.9) 0 1px, transparent 1.5px),
    radial-gradient(circle at 22% 82%, rgba(255,255,255,.55) 0 1px, transparent 1.4px),
    radial-gradient(circle at 74% 16%, rgba(255,255,255,.7) 0 1px, transparent 1.4px),
    radial-gradient(circle at 86% 64%, rgba(255,255,255,.6) 0 1px, transparent 1.6px),
    radial-gradient(circle at 62% 82%, rgba(255,255,255,.5) 0 1px, transparent 1.6px);
  opacity: .7;
  mix-blend-mode: screen;
  animation: bubbleStardust 3.2s linear infinite;
}

.text-shell.is-disappearing::after {
  border: 1px solid color-mix(in oklab, var(--primary) 38%, white 18%);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 16%, transparent), 0 0 18px rgba(255,255,255,.08) inset;
}

@keyframes bubbleStardust {
  0% { transform: translate3d(0, 0, 0); opacity: .55; }
  50% { transform: translate3d(0, -1px, 0); opacity: .92; }
  100% { transform: translate3d(0, 0, 0); opacity: .55; }
}

.text-shell.is-view-once {
  position: relative;
  overflow: clip;
}

.text-shell.is-view-once .view-once-mask {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 76%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  isolation: isolate;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.text-shell.is-scheduled {
  position: relative;
  isolation: isolate;
  animation: chatScheduledPulse 1.9s ease-in-out infinite;
}

.text-shell.is-scheduled::after {
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--primary, #7c5cff) 18%, transparent),
    0 0 16px color-mix(in oklab, var(--primary, #7c5cff) 10%, transparent);
}

@keyframes chatScheduledPulse {
  0%, 100% { opacity: .72; }
  50% { opacity: 1; }
}

.message-mode-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
  user-select: none;
}

.message-mode-tip[hidden] {
    display:none
}

.message-mode-tip[data-mode="scheduled"] {
  color: color-mix(in oklab, var(--primary, #7c5cff) 70%, var(--text) 30%);
}

.message-mode-tip[data-mode="disappearing"] {
  color: color-mix(in oklab, #ffe28a 70%, var(--text) 30%);
}

.text-shell.is-view-once[data-locked="1"] > :not(.view-once-mask):not(.message-mode-tip) {
  opacity: 0 !important;
  max-height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.text-shell.is-view-once[data-locked="1"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.08));
  pointer-events: none;
}

.text-shell.is-view-once[data-consumed="1"] {
  cursor: default;
}

.text-shell.is-view-once[data-consumed="1"] .view-once-mask {
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  color: var(--text-muted);
}

.msg .text-shell.is-view-once {
  cursor: pointer;
}

body.view-once-guard-active {
  -webkit-user-select: none;
  user-select: none;
}

.chat-empty-state {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(430px, calc(100% - 32px));
  margin: clamp(20px, 8vh, 64px) auto;
  padding: 26px 20px 22px;
  border-radius: 26px;
  border: 1px solid color-mix(in oklab, var(--line-color, rgba(255,255,255,.08)) 82%, transparent);
  background:
    radial-gradient(circle at top, color-mix(in oklab, var(--primary, #7c5cff) 9%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in oklab, var(--surface) 92%, transparent), color-mix(in oklab, var(--surface-2, var(--surface)) 88%, transparent));
  box-shadow: 0 20px 40px rgba(0,0,0,.08);
  text-align: center;
  overflow: hidden;
}

.chat-empty-state::after {
  content: '';
  position: absolute;
  inset: auto 12px 10px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--primary, #7c5cff) 22%, transparent), transparent);
  opacity: .72;
  pointer-events: none;
}

.chat-empty-state.compact {
  width: 100%;
  margin: 8px auto 0;
  padding: 16px 14px 14px;
  border-radius: 18px;
  gap: 10px;
}

.chat-empty-visual {
  --empty-card-scale: 1;
  position: relative;
  width: 152px;
  height: 122px;
  display: grid;
  place-items: center;
}

.chat-empty-state.compact .chat-empty-visual {
  --empty-card-scale: .84;
  width: 120px;
  height: 96px;
}

.chat-empty-aurora {
  position: absolute;
  inset: 20px 28px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 32% 34%, color-mix(in oklab, var(--primary, #7c5cff) 24%, white 12%), transparent 54%),
    radial-gradient(circle at 68% 70%, color-mix(in oklab, var(--primary, #7c5cff) 16%, transparent), transparent 62%);
  filter: blur(18px);
  opacity: .88;
  animation: chatEmptyAurora 5.8s ease-in-out infinite;
}

.chat-empty-ring {
  position: absolute;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary, #7c5cff) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary, #7c5cff) 10%, transparent);
}

.chat-empty-ring.ring-a {
  inset: 10px 16px;
  animation: chatEmptyRing 10s linear infinite;
}

.chat-empty-ring.ring-b {
  inset: 0 32px 28px;
  opacity: .72;
  animation: chatEmptyRing 12.5s linear infinite reverse;
}

.chat-empty-card {
  --chat-empty-card-transform: translateY(0) scale(var(--empty-card-scale));
  position: absolute;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
  width: 96px;
  min-height: 68px;
  padding: 12px 10px;
  border-radius: 18px;
  border: 1px solid color-mix(in oklab, var(--line-color, rgba(255,255,255,.08)) 75%, transparent);
  background: linear-gradient(180deg, color-mix(in oklab, var(--surface) 88%, transparent), color-mix(in oklab, var(--surface-2, var(--surface)) 84%, transparent));
  box-shadow: 0 16px 30px rgba(0,0,0,.10);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transform-origin: center;
  transform: var(--chat-empty-card-transform);
  animation: chatEmptyFloat 4.8s ease-in-out infinite;
}

.chat-empty-card.card-main {
  z-index: 3;
  --chat-empty-card-transform: translateY(0) scale(var(--empty-card-scale));
}

.chat-empty-card.card-back {
  z-index: 1;
  opacity: .76;
  --chat-empty-card-transform: translate(-22px, 8px) rotate(-8deg) scale(calc(.92 * var(--empty-card-scale)));
  animation-delay: -.9s;
}

.chat-empty-card.card-side {
  z-index: 2;
  width: 72px;
  min-height: 48px;
  padding: 8px 8px;
  opacity: .94;
  --chat-empty-card-transform: translate(38px, 22px) rotate(9deg) scale(var(--empty-card-scale));
  animation-delay: -1.8s;
}

.chat-empty-avatar {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--primary, #7c5cff) 55%, white 12%), color-mix(in oklab, var(--primary, #7c5cff) 28%, transparent));
  box-shadow: 0 0 0 5px color-mix(in oklab, var(--primary, #7c5cff) 8%, transparent);
}

.chat-empty-avatar.small {
  width: 16px;
  height: 16px;
}

.chat-empty-card-line {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in oklab, var(--surface) 68%, transparent), color-mix(in oklab, var(--text) 18%, transparent), color-mix(in oklab, var(--surface) 68%, transparent));
  background-size: 180% 100%;
  animation: chatEmptyLine 3.4s ease-in-out infinite;
}

.chat-empty-card-line.line-1 {
  width: 44px;
}

.chat-empty-card-line.line-2 {
  width: 56px;
  opacity: .74;
  animation-delay: .18s;
}

.chat-empty-card-line.line-3 {
  width: 34px;
  opacity: .78;
}

.chat-empty-chip {
  grid-column: 2;
  width: 30px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary, #7c5cff) 18%, transparent);
  opacity: .78;
}

.chat-empty-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary, #7c5cff) 70%, white 30%);
  box-shadow: 0 0 0 7px color-mix(in oklab, var(--primary, #7c5cff) 8%, transparent);
  animation: chatEmptySpark 3.2s ease-in-out infinite;
}

.chat-empty-spark.spark-a {
  top: 18px;
  left: 22px;
}

.chat-empty-spark.spark-b {
  top: 26px;
  right: 18px;
  animation-delay: .72s;
}

.chat-empty-spark.spark-c {
  bottom: 18px;
  left: 30px;
  animation-delay: 1.24s;
}

.chat-empty-lines {
  display: grid;
  gap: 8px;
  width: min(260px, 100%);
}

.chat-empty-line {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in oklab, var(--surface) 70%, transparent), color-mix(in oklab, var(--text) 10%, transparent), color-mix(in oklab, var(--surface) 70%, transparent));
  background-size: 180% 100%;
  animation: chatEmptyLine 3.4s ease-in-out infinite;
}

.chat-empty-line.line-1 { width: 100%; }
.chat-empty-line.line-2 { width: 82%; justify-self: center; animation-delay: .18s; }
.chat-empty-line.line-3 { width: 62%; justify-self: center; animation-delay: .28s; }
.chat-empty-line.line-4 { width: 44%; justify-self: center; animation-delay: .36s; }

.chat-empty-copy {
  display: grid;
  gap: 6px;
}

.chat-empty-copy strong {
  font-size: 15px;
}

.chat-empty-state.compact .chat-empty-copy strong {
  font-size: 14px;
}

.chat-empty-copy p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.chat-list-guide {
  padding: 10px 12px 18px;
}

.group-empty-wrap {
  padding: 2px 0;
}

@keyframes chatEmptyAurora {
  0%, 100% { transform: scale(.92); opacity: .62; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes chatEmptyRing {
  0% { transform: rotate(0deg) scale(.98); opacity: .55; }
  50% { opacity: .95; }
  100% { transform: rotate(360deg) scale(1.02); opacity: .55; }
}

@keyframes chatEmptyFloat {
  0%, 100% { transform: var(--chat-empty-card-transform) translateY(0); }
  50% { transform: var(--chat-empty-card-transform) translateY(-4px); }
}

@keyframes chatEmptySpark {
  0%, 100% { transform: scale(.7); opacity: .4; }
  50% { transform: scale(1.18); opacity: 1; }
}

@keyframes chatEmptyLine {
  0%, 100% { background-position: 0% 50%; opacity: .68; }
  50% { background-position: 100% 50%; opacity: 1; }
}

#chatSend {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  white-space: nowrap;
  padding: 0 4px 0 6px;
}

#chatSend .chat-send-btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#chatSend .chat-send-btn-mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  font-size: 10px;
  line-height: 1;
  opacity: .96;
  margin-left: 2px;
  padding-left: 6px;
  border-left: 1px solid color-mix(in oklab, var(--text) 14%, transparent);
  cursor: pointer;
  touch-action: manipulation;
}

#chatSend .chat-send-btn-mode .bi {
  display: block;
  line-height: 1;
}

#chatSend.has-send-mode {
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 24%, transparent), 0 10px 20px rgba(0, 0, 0, .08);
}

#chatSend[data-send-mode="active"]::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid color-mix(in oklab, var(--primary) 36%, transparent);
  pointer-events: none;
}

.send-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
}

.send-mode-grid button {
  border: var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease;
}

.send-mode-grid button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 18px rgba(0, 0, 0, .08);
}

.send-mode-grid button[data-active="1"] {
  border-color: color-mix(in oklab, var(--primary) 32%, transparent);
  background: color-mix(in oklab, var(--surface) 88%, var(--primary-faded) 12%);
}

.view-once-modal .modal-card {
  max-width: min(680px, 92vw);
}

.view-once-modal .modal-body {
  display: grid;
  gap: 14px;
}

.view-once-modal .content-box {
  display: grid;
  gap: 12px;
}

.view-once-modal .content-box img,
.view-once-modal .content-box video {
  max-width: 100%;
  border-radius: 16px;
  display: block;
}

.view-once-modal .content-box audio {
  width: 100%;
}

.view-once-modal .content-box .text-content {
  white-space: pre-wrap;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .send-mode-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Phase 4: unified chat left panel --- */
.chat-route-filters {
  margin-top: 5px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
  position: relative
}

.chat-route-filter-group {
  position: relative;
  display: inline-flex
}

.chat-route-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  cursor: pointer;
  transition: transform .14s ease,border-color .14s ease,background .14s ease,color .14s ease
}

.chat-route-filter-chip:hover {
  transform: translateY(-1px);
}

.chat-route-filter-chip.active {
  background: color-mix(in srgb, var(--primary-dark) 75%, var(--primary));
  color: #fff;
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
}

.chat-route-filter-count {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
}

.chat-route-filter-chip.active .chat-route-filter-count {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
}

.chat-route-tag-trigger {
  justify-content: center;
}

.chat-route-filter-chevron {
  font-size: .76rem;
  opacity: .78;
  transition: transform 140ms ease;
}

.chat-route-filter-group.is-open .chat-route-filter-chevron {
  transform: rotate(180deg);
}

.chat-route-tag-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 240px;
  max-height: min(46vh, 340px);
  overflow: auto;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, rgba(8, 12, 18, 0.96));
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.34);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.chat-route-tag-menu[hidden] {
  display: none !important;
}

.chat-route-tag-menu-body {
  display: grid;
  gap: 6px;
}

.chat-route-tag-empty {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: .84rem;
}

.chat-route-tag-option {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.chat-route-tag-option:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 26%, var(--line));
  background: color-mix(in srgb, var(--surface) 90%, var(--primary-faded));
}

.chat-route-tag-option.active {
  border-color: color-mix(in srgb, var(--primary) 42%, transparent);
  background: color-mix(in srgb, var(--primary-dark) 20%, var(--surface));
}

.chat-route-tag-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-route-tag-count {
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 800;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
}

.chat-conversation-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-conversation-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-conversation-section + .chat-conversation-section {
  margin-top: 5px;
}

.chat-conversation-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 0;
}

.chat-conversation-section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: capitalize;
  color: color-mix(in srgb, var(--text-muted) 90%, white 10%);
}

.chat-conversation-section-title i {
  color: var(--primary);
  font-size: .84rem;
}

.chat-conversation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 12px;
}

.chat-conversation-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 2px;
  align-items: center;
  width: 100%;
  padding: 10px 10px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg), transparent);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.chat-conversation-row:hover {
  transform: translateY(-1px);
}

.chat-conversation-row.active {
  background: color-mix(in srgb, var(--primary-dark) 40%, transparent);
}

.chat-conversation-row .avatar.xs {
  width: 34px;
  height: 34px;
  min-width: 33px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.chat-conversation-row .dm-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 5px;
}

.chat-conversation-row .dm-name {
  display: block;
  font-weight: 650;
  line-height: 1.2;
}

.chat-conversation-row .dm-preview {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  width: fit-content;
  gap: 4px;
}

.chat-row-side .dm-time {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.chat-row-side .dm-inline-unread {
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
}

.chat-conversation-row[data-muted="1"] .dm-name::after {
  content: 'Muted';
  margin-left: 8px;
  font-size: .66rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chat-conversation-row.is-donna .dm-name::before {
  content: '✦';
  margin-right: 7px;
  color: var(--primary);
}

/* === Phase 6: lightweight chat media previews ================================= */
.chat-media-thumb {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.chat-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-media-thumb.is-tile {
  aspect-ratio: 4 / 3;
}

.chat-media-thumb.is-audio img {
  object-fit: cover;
}

.chat-video-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.chat-video-play i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: rgba(10, 10, 14, 0.58);
  color: #fff;
  font-size: 30px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  isolation: isolate;
}

.chat-video-bubble,
.chat-file-bubble {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
}

.chat-video-bubble {
  display: block;
  width: min(320px, 100%);
  border-radius: 14px;
  overflow: hidden;
}

.chat-video-bubble .chat-media-thumb {
  aspect-ratio: 16 / 10;
  min-height: 180px;
}

.chat-video-bubble:focus-visible,
.chat-file-bubble:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chat-inline-media {
  display: inline-block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 240px;
}

.chat-inline-media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 240px;
}

.reply-chip-asset {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: 0.5rem;
}

.reply-chip-thumb {
  width: clamp(58px, 16vw, 112px);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}

.reply-chip .chat-file-bubble,
.media.replied .chat-file-bubble {
  width: auto;
  min-width: 0;
}

.chat-file-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: min(320px, 100%);
  padding: 10px;
  border-radius: 12px;
  text-align: left;
  border: var(--line);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.chat-file-bubble:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-file-bubble.is-compact {
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
}

.chat-file-bubble-preview-wrap {
  flex: 0 0 72px;
  width: 72px;
}

.chat-file-bubble.is-compact .chat-file-bubble-preview-wrap {
  flex-basis: 56px;
  width: 56px;
}

.chat-file-bubble-thumb {
  aspect-ratio: 4 / 3;
}

.chat-file-bubble-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-file-bubble-meta strong,
.chat-file-bubble-meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-file-bubble-meta strong {
  font-size: 13px;
  font-weight: 700;
}

.chat-file-bubble-meta small {
  color: var(--text-muted);
  font-size: 11px;
}

.msg .bubble .attch-grid .attch-card .chat-media-thumb,
.attch-card .chat-media-thumb,
#chatInfo .file-card .thumb .chat-media-thumb {
  width: 100%;
  height: 100%;
}

.msg .bubble .attch-grid .attch-card .chat-media-thumb img,
.attch-card .chat-media-thumb img,
#chatInfo .file-card .thumb .chat-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#chatInfo .file-card .thumb .chat-video-play i {
  width: 42px;
  height: 42px;
  font-size: 22px;
}

.vr-pill-container::after {
  border-color: color-mix(in oklab, var(--primary) 18%, var(--bg)) transparent transparent transparent;
}

.vr-pill {
  border: 1px solid color-mix(in oklab, var(--primary-dark) 20%, rgba(255, 255, 255, 0.10));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.30), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.vr-pill.live {
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary-faded) 18%, transparent), 0 12px 32px rgba(0, 0, 0, 0.32);
  padding: 8px 0;
}

.vr-pill .vr-wave {
  border-radius: 8px;
  /* background: var(--primary-faded); */
}

.vr-pill .vr-play-pause {
  background: color-mix(in oklab, var(--primary) 34%, #2b2b31);
}

/* --- Phase 7 chat engagement / details --- */
.msg .bubble .keep-badge {
  position: absolute;
  top: .5rem;
  right: .65rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .1rem .3rem;
  border-radius: 999px;
  backdrop-filter: var(--backdrop);
  border: var(--line);
  font-size: .62rem;
  z-index: 2;
  pointer-events: none;
}

.msg .bubble .keep-badge i {
  color: var(--primary);
}

.rx-chip {
  border: 0;
  cursor: pointer;
}

.msg-actions .rx-section {
  display: grid;
  gap: .55rem;
}

.msg-actions .rx-section-label,
.reaction-popover-label {
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .7;
}

.msg-actions .rx-row.popular,
.reaction-popover-row.popular {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}

.msg-actions .rx-grid,
.reaction-popover-row.all {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .45rem;
}

.msg-actions .rx-btn.selected,
.reaction-popover-card .rx-btn.selected {
  border-color: rgba(255, 255, 255, .35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}

.reaction-popover-card {
  flex-direction: column;
  gap: .5rem;
  padding: .55rem;
  min-width: 280px;
  background: rgba(12, 12, 16, .96);
  border-radius: 16px;
}

.chat-tags-section .section-h,
.message-details-shell .section-h {
  align-items: center;
}

.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 30px;
  padding: .2rem .65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .06);
  font-size: .85rem;
}

.tag-chip.reaction {
  background: rgba(255, 255, 255, .04);
}

.tag-editor-row {
  display: flex;
  gap: .55rem;
  align-items: center;
}

.tag-editor-row .input {
  flex: 1;
}

.tag-manager-list {
  display: grid;
  gap: .5rem;
}

.tag-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .55rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .06);
}

.tag-manager-main {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

.user-modal.user-details-modal .user-card.detail {
  grid-template-columns: 84px 1fr;
  align-items: center;
}

.user-modal.user-details-modal .u-meta .name {
  font-weight: 700;
  font-size: 1.15rem;
}

.user-detail-grid,
.message-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}

.detail-card {
  display: grid;
  padding: .25rem .5rem;
  border-radius: 14px;
  background: var(--bg);
  border: var(--line);
}

.detail-card.wide {
  grid-column: 1 / -1;
}

.detail-card .label {
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .66;
}

.message-preview-card {
  margin-top: .5rem;
  padding: .5rem;
  border-radius: 14px;
  background: var(--bg);
  border: var(--line);
  white-space: pre-wrap;
}

.detail-people-list {
  display: grid;
  gap: .5rem;
}

.detail-person {
  display: grid;
  align-items: center;
  gap: .65rem;
  padding: .55rem .25rem;
  grid-template-columns: 40px 1fr;
}
.detail-person .xs{height: 40px}
.detail-person img{contain:content}
.detail-person-copy {
  min-width: 0;
}

.detail-person-copy .name {
  font-weight: 600;
}

.detail-person-copy .meta {
  opacity: .72;
  font-size: .64rem;
}

@media (max-width: 720px) {
  .msg-actions .rx-grid,
  .reaction-popover-row.all,
  .user-detail-grid,
  .message-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Phase 3 — emoji library, reaction picker, and send mode refinement */
.chat-emoji-float {
  min-width: 320px;
  max-width: min(92vw, 360px);
  position: absolute;
}

.chat-emoji-panel,
.chat-reaction-panel {
  display: grid;
  backdrop-filter: var(--backdrop);
  border: var(--line);
  padding: 8px;
  gap: 8px;
  border-radius: 18px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, .18);
  backdrop-filter: var(--backdrop-2);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  max-width: 222px;
  max-height: 70vh;
}

.chat-emoji-top-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-emoji-top-tab {
  border: 0;
  background: color-mix(in oklab, var(--text) 8%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 8px;
  font: inherit;
  cursor: pointer;
}

.chat-emoji-top-tab.is-active {
  background: color-mix(in oklab, var(--primary) 18%, transparent);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 26%, transparent);
}

.chat-emoji-top-tab.is-disabled {
  opacity: .5;
  cursor: not-allowed;
}

.chat-emoji-search-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 5px;
  border-radius: 12px;
  background: var(--strans) !important;
  border: var(--line);
}

.chat-emoji-search-row i {
  opacity: .65;
}

.chat-emoji-search {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
  font: inherit;
}

.chat-emoji-cats {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
  overflow-x: auto;
}

.chat-emoji-cat {
  border: 0;
  background: var(--strans);
  color: var(--text);
  font: inherit;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  padding: 5px;
  line-height: 1;
}

.chat-emoji-cat.is-active {
  background: color-mix(in oklab, var(--primary) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 24%, transparent);
}

.chat-emoji-grid {
  display: grid;
  gap: 5px;
  align-content: start;
  max-height: min(50vh, 450px);
  width: -webkit-fill-available;
  overflow: auto;
  grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
  padding: 10px 0 0;
  border-top: var(--line);
}

.chat-emoji-btn {
  color: var(--text);
  padding: 3px 0;
  display: flex;
  border-radius: 15px;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease;
}

.chat-emoji-btn:hover,
.chat-reaction-btn:hover,
.chat-send-mode-card:hover,
.chat-send-mode-tile:hover,
.chat-send-quick-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, .10);
  background: var(--strans);
}

.chat-emoji-btn .char {
  font-size: 22px;
  line-height: 1;
}

.chat-emoji-btn .label {
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 72%, transparent);
}

.chat-emoji-empty {
  grid-column: 1 / -1;
  padding: 16px;
  text-align: center;
  color: color-mix(in oklab, var(--text) 65%, transparent);
}

.chat-emoji-footer {
  padding: 0;
  font-size: 11px;
  color: color-mix(in oklab, var(--text) 64%, transparent);
}

.chat-reaction-panel {
  max-width: 210px;
  min-width: min(16vw, 180px);
  max-height: 50vh;
  padding: 12px;
}

.chat-reaction-head {
  display: block;
  align-items: flex-start;
}

.chat-reaction-title {
  font-weight: 700;
}

.chat-reaction-subtitle,
.chat-reaction-label {
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 66%, transparent);
}

.chat-reaction-section + .chat-reaction-section {
  display: grid;
  gap: 8px;
}

.chat-reaction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
  gap: 4px;
  overflow: auto;
  max-height: min(100px, 17vh);
}

.chat-reaction-btn {
  border-radius: 14px;
  padding: 0;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.chat-reaction-btn .emoji {
  font-size: 16px;
}

.chat-reaction-btn .label {
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 78%, transparent);
}

.chat-reaction-btn.is-selected {
  background: color-mix(in oklab, var(--primary) 16%, transparent);
  border-color: color-mix(in oklab, var(--primary) 30%, transparent);
}

.chat-send-mode-banner {
  /* display: flex; */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in oklab, var(--primary) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--primary) 24%, transparent);
}

.chat-send-mode-banner-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-send-mode-banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--primary) 16%, transparent);
  color: var(--primary);
  flex: 0 0 auto;
}

.chat-send-mode-banner-copy {
  min-width: 0;
}

.chat-send-mode-banner-title {
  font-size: 13px;
  font-weight: 700;
}

.chat-send-mode-banner-summary {
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 72%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-send-mode-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-send-mode-banner-btn,
.chat-send-mode-clear-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.chat-send-mode-sheet {
  min-width: min(92vw, 360px);
  display: grid;
  gap: 12px;
}

.chat-send-mode-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat-send-mode-sheet-title {
  font-size: 14px;
  font-weight: 700;
}

.chat-send-mode-sheet-summary {
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 70%, transparent);
}

.chat-send-mode-card-list,
.chat-send-mode-tile-grid,
.chat-send-quick-grid {
  display: grid;
  gap: 8px;
}

.chat-send-mode-card-list {
  grid-template-columns: 1fr;
}

.chat-send-mode-card,
.chat-send-mode-tile,
.chat-send-quick-card {
  border: var(--line);
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease;
}

.chat-send-mode-card-body,
.chat-send-quick-card {
  flex: 1;
}

.chat-send-mode-card-body span,
.chat-send-quick-card span {
  display: block;
  font-size: 12px;
  color: color-mix(in oklab, var(--text) 72%, transparent);
}

.chat-send-mode-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  color: var(--primary);
  flex: 0 0 auto;
}

.chat-send-mode-card-badge {
  font-size: 11px;
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  border-radius: 999px;
  padding: 5px 8px;
  flex: 0 0 auto;
}

.chat-send-mode-card.is-active,
.chat-send-mode-tile.is-active,
.chat-send-quick-card:focus-visible {
  border-color: color-mix(in oklab, var(--primary) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 24%, transparent);
}

.chat-send-mode-tile-grid,
.chat-send-quick-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chat-send-mode-tile {
  justify-content: center;
  font-weight: 600;
}

.chat-send-mode-tile.is-custom {
  justify-content: flex-start;
}

.chat-send-mode-tile-copy {
  display: grid;
  gap: 2px;
  justify-items: start;
}

.chat-send-mode-tile-copy .muted {
  font-size: 11px;
  font-weight: 500;
  color: color-mix(in oklab, var(--text) 68%, transparent);
}

.chat-send-quick-card {
  display: grid;
  gap: 4px;
}

.chat-send-quick-card strong {
  font-size: 13px;
}

@media (max-width: 640px) {
  .chat-emoji-grid,
  .chat-reaction-grid,
  .chat-send-mode-tile-grid,
  .chat-send-quick-grid {
    grid-template-columns: 1fr;
  }

  .chat-send-mode-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

#chatMessages {
  scroll-behavior: auto;
}

/* ── Links in chat bubbles: always use --primary ── */
.msg .bubble .text a,
.msg .bubble a,
.msg .bubble .md-link,
.msg .bubble .text a:visited,
.msg .bubble a:visited {
  color: var(--primary-light);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity .12s;
}
.msg .bubble .text a:hover,
.msg .bubble a:hover {
  opacity: .85;
}
.me .bubble .text a,
.me .bubble a {
  color: color-mix(in oklab, var(--primary) 65%, #fff);
}

/* ── Markdown list styling ── */
.msg .bubble .text .md-list,
.msg .bubble .text .md-olist {
  margin: 4px 0;
  padding-left: 1.4em;
  font-size: inherit;
  line-height: 1.55;
}
.msg .bubble .text .md-list li,
.msg .bubble .text .md-olist li {
  margin-bottom: 2px;
}
.msg .bubble .text .md-list { list-style-type: disc; }
.msg .bubble .text .md-olist { list-style-type: decimal; }

.msg .bubble .text .md-h1 { font-size: 1.2em; font-weight: 800; margin: 4px 0; }
.msg .bubble .text .md-h2 { font-size: 1.1em; font-weight: 700; margin: 4px 0; }
.msg .bubble .text .md-h3 { font-size: 1.05em; font-weight: 650; margin: 3px 0; }

.msg .bubble .text strong { font-weight: 700; }
.msg .bubble .text em { font-style: italic; }
.msg .bubble .text s { text-decoration: line-through; }
.msg .bubble .text u { text-decoration: underline; }
.msg .bubble .text .quote {
  border-left: 3px solid var(--primary-faded);
  padding: 2px 8px;
  margin: 4px 0;
  opacity: .85;
  font-style: italic;
}

/* ── Reaction detail pills (message details modal) ── */
.reaction-detail-section {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
  height: fit-content;
}

.reaction-detail-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: var(--line);
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font-size: 13px;
  cursor: default;
  transition: background .12s;
}
.reaction-detail-pill:hover {
  background: color-mix(in oklab, var(--primary) 8%, var(--bg));
}

.reaction-avatar-stack {
  display: flex;
  flex-direction: row;
}
.reaction-avatar-stack .rx-av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  background: var(--primary-dark);
  color: #fff;
  flex-shrink: 0;
}
.reaction-avatar-stack .rx-av + .rx-av {
  margin-left: -8px;
}
.reaction-avatar-stack .rx-av-more {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 700;
  background: var(--muted);
  color: var(--text);
  margin-left: -8px;
  flex-shrink: 0;
}
.reaction-detail-pill .rx-emoji {
  font-size: 16px;
  line-height: 1;
}

/* ✨ Donna typing effect (Glassy Pulse for Assistance Mode) */
.msg.typing .loading-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.msg.typing .loading-dots i {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: dot-bounce 1.4s infinite ease-in-out both;
}

.msg.typing .loading-dots i:nth-child(1) { animation-delay: -0.32s; }
.msg.typing .loading-dots i:nth-child(2) { animation-delay: -0.16s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

@keyframes blink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0; }
}

/* 🧠 Action cards */
.donna-action {
  background: #f4f6f8;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 6px;
  font-size: 13px;
  border-left: 3px solid #4f46e5;
}

.donna-action-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.donna-action-meta {
  opacity: 0.7;
  font-size: 12px;
}

/* Donna Modes Row */
.donna-modes-row {
  display: flex;
  gap: 8px;
  padding: 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.donna-modes-row::-webkit-scrollbar {
  display: none;
}

.mode-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  animation: mode-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mode-pop-in {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.mode-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.mode-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.mode-pill.fixed {
  cursor: default;
}

/* Donna usage meter — sits at the right end of the modes row. */
.donna-token-pill {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--strans);
  border: var(--line);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.donna-token-pill:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.donna-token-pill .bi-coin { font-size: 12px; opacity: 0.85; }
.donna-token-pill .dtp-bar {
  width: 46px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.donna-token-pill .dtp-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
}
.donna-token-pill.is-warn .dtp-fill { background: #ffbd2e; }
.donna-token-pill.is-over .dtp-fill { background: #ff5f56; }
.donna-token-pill.is-over { color: #ff8a80; border-color: rgba(255, 95, 86, 0.4); }

/* Hover detail card: percentage → actual token conversion + headroom. */
.donna-token-pill { position: relative; }
.donna-token-pill .dtp-tip {
  position: fixed;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 3px;
  min-width: 180px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--bg);
  border: var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  pointer-events: none;
}
.donna-token-pill .dtp-tip b {color: var(--text);font-size: 13px;font-weight: 700;}
.donna-token-pill .dtp-tip .dtp-tip-warn { color: #ffbd2e; }
.donna-token-pill.is-over .dtp-tip .dtp-tip-warn { color: #ff8a80; }
.donna-token-pill .dtp-tip .dtp-tip-foot { opacity: 0.55; font-size: 10px; margin-top: 2px; }
.donna-token-pill:hover .dtp-tip { display: flex; }

/* Donna Prompt Bubble */
.donna-prompt {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}

/* Thinking & Streaming Animations */
.bubble.typing .text {
  background: color-mix(in oklab, var(--bg) 40%, transparent) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  animation: pulse-glass 2.5s infinite ease-in-out;
}

@keyframes pulse-glass {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.995); }
}

/* Word pouring effect */
.streaming-token {
  opacity: 0;
  display: inline-block;
  white-space: pre-wrap;
  transform: translateY(2px);
  animation: word-pour-in 0.15s cubic-bezier(0.2, 0, 0.4, 1) forwards;
}

@keyframes word-pour-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Blinking block cursor */
.donna-block-cursor {
  display: inline-block;
  width: 8px;
  height: 1.2em;
  background: var(--primary);
  vertical-align: middle;
  margin-left: 4px;
  box-shadow: 0 0 10px var(--primary);
  animation: blink-block-cursor 0.6s step-end infinite;
}

@keyframes blink-block-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Error/Warning bubbles */
.text[data-error="true"] {
  border: 1px solid rgba(255, 59, 48, 0.3);
  background: rgba(255, 59, 48, 0.05);
}

.text[data-warning="true"] {
  border: 1px solid rgba(255, 149, 0, 0.3);
  background: rgba(255, 149, 0, 0.05);
}

/* Stop button state with fade morph */
.icon-btn.is-stop {
  color: #ff3b30 !important;
}

#chatSend i {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#chatSend.morphing i {
  opacity: 0;
  transform: scale(0.8);
}

/* Donna Terminal UI */
.is-terminal-state .text {
  background: #000 !important;
  border: 1px solid #1a1a1a !important;
  padding: 0 !important;
  overflow: hidden;
  max-width: 90% !important;
}

.donna-terminal {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  color: #00ff41;
  background: #000;
  padding: 0;
  font-size: 11px;
  line-height: 1.5;
}

.donna-terminal .terminal-header {
  background: #1a1a1a;
  color: #888;
  padding: 6px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  gap: 6px;
}

.donna-terminal .terminal-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.donna-terminal .terminal-header .dot.red { background: #ff5f56; }
.donna-terminal .terminal-header .dot.yellow { background: #ffbd2e; }
.donna-terminal .terminal-header .dot.green { background: #27c93f; }
.donna-terminal .terminal-header .terminal-title { margin-left: 4px; flex: 1; }

.donna-terminal .terminal-body {
  padding: 12px;
  max-height: 240px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  color: #00ff41;
  font-size: 11px;
  line-height: 1.6;
  text-shadow: 0 0 5px rgba(0, 255, 65, 0.4);
}

.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: #00ff41;
  vertical-align: middle;
  margin-left: 4px;
  animation: terminal-blink 0.8s infinite;
  box-shadow: 0 0 8px #00ff41;
}

@keyframes terminal-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Streaming Token Fade In */
.streaming-token {
  animation: token-fade-in 0.15s ease-out forwards;
}

/* Donna Intro */
.is-donna-intro {
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
}

.donna-intro-wrapper {
  width: 100%;
  display: flex;
}

.donna-intro-card {
  background: color-mix(in oklab, var(--bg) 40%, transparent);
  border: var(--line);
  border-radius: 24px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.donna-intro-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 20px 0 10px;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.donna-intro-header p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 30px;
}

.donna-logo-large {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.donna-logo-large img {
  width: 100%;
  height: 100%;
  z-index: 2;
  position: relative;
}

.donna-glow {
  position: absolute;
  inset: -10px;
  background: var(--primary);
  filter: blur(20px);
  opacity: 0.4;
  border-radius: 50%;
  animation: logo-pulse 4s infinite ease-in-out;
}

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.2); opacity: 0.5; }
}

.donna-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.donna-suggestion-btn {
  background: var(--strans);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.donna-suggestion-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-faded);
  transform: translateY(-2px);
}

.donna-suggestion-btn i {
  font-size: 18px;
  color: var(--primary);
}

.donna-suggestion-btn span {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .donna-quick-actions { grid-template-columns: 1fr; }
}

/* Donna Context Panel Tabs */
.donna-tabs {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
  margin: 2px 0 12px;
}

.donna-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.donna-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.donna-tab-content {
  padding: 0;
}

.donna-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  padding: 8px 0;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  transition: transform 0.2s;
}

.file-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.06);
}

.file-icon {
  font-size: 24px;
  color: var(--primary);
}

.file-name {
  font-size: 10px;
  width: 100%;
  text-align: center;
  opacity: 0.8;
}

/* Donna Settings Panel */
.donna-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.donna-tab-content .setting-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.donna-tab-content .setting-row .bits-slider-wrap {display:none}

.setting-row span {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.8;
}

.setting-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-toggle-row span {
  font-size: 13px;
}
#btnPruneMemory{background:var(--primary); color:#fff}

/* Notch Slider (Custom Component Styles) */
.bits-notch-slider-wrap {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.bits-notch-track {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 4px;
  background: var(--strans);
  border-radius: 2px;
}

.bits-notches {
  position: absolute;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  z-index: 1;
}

.bits-notch {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.bits-notch.active {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.bits-notch-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  z-index: 2;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: left 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Security Focus for Composer */
.security-focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 12px var(--primary) !important;
  animation: security-pulse 1.5s infinite;
}

@keyframes security-pulse {
  0%, 100% { box-shadow: 0 0 12px var(--primary); }
  50% { box-shadow: 0 0 20px var(--primary); }
}

.vr-donna-limit-notify {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 59, 48, 0.9);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Enhanced Donna Files Grid */
.donna-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  padding: 12px;
}

.donna-files-grid .file-item {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s ease;
}

.donna-files-grid .file-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  background: var(--primary-light);
}

.donna-files-grid .file-icon {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--primary);
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.donna-files-grid .file-name {
  font-size: 11px;
  font-weight: 600;
  max-width: 100%;
}

.donna-files-grid .file-meta {
  font-size: 9px;
  opacity: 0.6;
  margin-top: 2px;
}

/* AI Info Section in Right Panel */
.ai-info-section {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px !important;
}

.ai-meta-grid {
  display: grid;
  /* grid-template-columns: 1fr 1fr; */
  gap: 12px;
}

.ai-meta-item {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: space-between;
}

.ai-meta-item label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
  font-weight: 700;
}

.ai-meta-item .ss-dd {
  /* width: 100%; */
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg);
  border: var(--line);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
}

.ai-byok-link {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.ai-byok-link .u-btn {
  font-size: 10px;
  opacity: 0.7;
  border: var(--line);
}

.ai-byok-link .u-btn:hover {
  opacity: 1;
  color: var(--primary);
}

/* --- Donna Cinematic Rebuild --- */

.donna-thinking-msg .bubble {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.donna-thinking-glass {
  position: relative;
  padding: 6px 12px;
  background: var(--btrans);
  border-radius: 18px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: var(--line);
  display: inline-flex;
  overflow: hidden;
  width: fit-content;
  animation: donna-glass-pulse 2.5s infinite ease-in-out;
}

.donna-pulse-shell {
  position: absolute;
  inset: 0;
  animation: donna-glass-pulse 2.4s ease-in-out infinite;
  pointer-events: none;
  background: var(--bg);
}

@keyframes donna-glass-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.02); }
}

.donna-thinking-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.donna-thinking-dots i {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary-faded);
  animation: donna-dot-bounce 1.5s infinite ease-in-out both;
}

.donna-thinking-dots i:nth-child(1) {animation-delay: -0.52s;}
.donna-thinking-dots i:nth-child(2) { animation-delay: -0.16s; }

@keyframes donna-dot-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Terminal Mode */
.terminal-mode .bubble {
  background: #121212 !important;
  border: 1px solid #333;
  color: #00ff41;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  padding: 12px !important;
  border-radius: 8px;
  max-width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.terminal-header {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid #333;
  padding-bottom: 6px;
}

.terminal-header .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }

.terminal-title {
  font-size: 10px;
  color: #888;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.terminal-body {
  font-size: 13px;
  line-height: 1.5;
}

.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: #00ff41;
  margin-left: 4px;
  vertical-align: middle;
  animation: terminal-blink 1s step-end infinite;
}

@keyframes terminal-blink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}

/* Word Pouring */
.pour-token {
  display: inline-block;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: pre-wrap;
}

.pour-token.visible {
  opacity: 1;
  transform: translateY(0);
}

.donna-block-cursor {
  display: inline-block;
  width: 10px;
  height: 1.2em;
  background: rgb(var(--primary-rgb));
  vertical-align: middle;
  margin-left: 2px;
  animation: donna-cursor-blink 1s step-end infinite;
}

@keyframes donna-cursor-blink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}

#chatSend.is-streaming i::before {
  content: "\F584"; /* bi-stop-circle */
  color: #ff4d4d;
}


.donna-thinking-msg {
  margin-bottom: 16px;
  animation: donna-fade-in 0.4s ease-out;
}

@keyframes donna-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.donna-thinking-msg .bubble {
  min-width: 120px;
}

.terminal-mode .text-shell {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* Ensure tokens don't wrap in weird places */
.pour-token {
  white-space: pre-wrap;
}

/* Responsive grid for blocks in Donna chats */
.is-donna .msg .text {
  max-width: 100%;
}

/* --- Donna Reactive Bubble Architecture (v2) --- */

/* 1. Base Bubble & Container Stability */
.msg.is-donna-assist {
  margin: 12px 0;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.msg.is-donna-assist .bubble {
  width: 100%;
  max-width: 92%;
  overflow: visible;
  transition: min-height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.msg.is-donna-assist .text {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* 2. Unified State Container (The "Stable Shell") */
.donna-unified-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  will-change: height;
  transition: height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 3. Terminal Bubble (Expanded Top Row) */
.donna-terminal-row {
  background: #0c0c0c;
  border: 1px solid #333;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.donna-terminal-header {
  background: #1a1a1a;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #222;
}

.donna-terminal-body {
  padding: 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 11px;
  color: #0f0;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  text-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
}

.term-line {
  margin-bottom: 4px;
  opacity: 0;
  transform: translateX(-4px);
  animation: term-line-in 0.3s forwards;
}

@keyframes term-line-in {
  to { opacity: 1; transform: translateX(0); }
}

.term-prompt { color: #888; margin-right: 8px; }

/* 4. Output Bubble (Bottom Row) */
.donna-output-row {
  padding: 12px 16px;
  background: var(--dots);
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  transition: background 0.3s ease;
}

.is-streaming .donna-output-row {
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 5. Intent / Confirmation Bubble */
.donna-intent-bubble {
  background: linear-gradient(135deg, color-mix(in oklab, var(--primary) 8%, var(--bg)), var(--bg));
  border: 1px solid color-mix(in oklab, var(--primary) 20%, transparent);
  border-radius: 18px;
  padding: 10px;
  display: flex;
  font-size: var(--text-size);
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: intent-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes intent-pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.intent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-light);
}

.intent-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* 6. Details / Form Bubble */
.donna-details-bubble {
  background: var(--surface);
  border: var(--line);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.6;
}

/* 7. Summary Bubble */
.donna-summary-bubble {
  background: color-mix(in oklab, var(--primary) 4%, var(--bg));
  border-left: 4px solid var(--primary);
  border-radius: 4px 16px 16px 4px;
  padding: 14px;
}

.summary-step {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.summary-step i { color: var(--primary); }

/* ✨ Smoother Streaming Cursor */
.donna-block-cursor {
  display: inline-block;
  width: 7px;
  height: 1.1em;
  background: var(--primary);
  vertical-align: middle;
  margin-left: 3px;
  border-radius: 1px;
  animation: donna-cursor-blink 0.8s step-end infinite;
}

@keyframes donna-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Thoughts Toggle Styling */
/* ── Unified "Thoughts" pill ─────────────────────────────────────────────
   One collapsible surface for Donna's reasoning — live breadcrumbs while she
   works, or recorded thoughts afterwards. The pill is the label; the box opens
   beneath it with a smooth grid-rows height transition (no measuring / no jank). */
.donna-thoughts { margin: 8px 0 4px; }

.donna-thoughts-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  background: color-mix(in oklab, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--primary) 22%, transparent);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.donna-thoughts-pill:hover { color: var(--primary); background: color-mix(in oklab, var(--primary) 16%, transparent); }
.donna-thoughts-pill .dt-ico { font-size: 13px; opacity: 0.9; }
.donna-thoughts-pill .dt-caret { font-size: 11px; transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); }
.donna-thoughts.open .donna-thoughts-pill .dt-caret { transform: rotate(180deg); }

/* Live "thinking" indicator — soft breathing dot while breadcrumbs stream in. */
.donna-thoughts-pill .dt-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 60%, transparent);
  animation: dt-pulse 1.4s ease-out infinite;
}
@keyframes dt-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* The smooth-height trick: animate grid-template-rows 0fr → 1fr. */
.donna-thoughts-reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: all .3s ease-in;
}
.donna-thoughts.open .donna-thoughts-reveal {grid-template-rows: 1fr;height: fit-content;opacity: 1;transition: all .6s linear(0 0%, 0 2.27%, 0.02 4.53%, 0.04 6.8%, 0.06 9.07%, 0.1 11.33%, 0.14 13.6%, 0.25 18.15%, 0.39 22.7%, 0.56 27.25%, 0.77 31.8%, 1 36.35%, 0.89 40.9%, 0.85 43.18%, 0.81 45.45%, 0.79 47.72%, 0.77 50%, 0.75 52.27%, 0.75 54.55%, 0.75 56.82%, 0.77 59.1%, 0.79 61.38%, 0.81 63.65%, 0.85 65.93%, 0.89 68.2%, 1 72.7%, 0.97 74.98%, 0.95 77.25%, 0.94 79.53%, 0.94 81.8%, 0.94 84.08%, 0.95 86.35%, 0.97 88.63%, 1 90.9%, 0.99 93.18%, 0.98 95.45%, 0.99 97.73%, 1 100%);}
.donna-thoughts-inner { overflow: hidden; min-height: 0; }
.donna-thoughts.open .donna-thoughts-inner {margin-top: 6px;padding: 8px 12px !important;}

/* Recorded thoughts (plain text) styling. */
.donna-thoughts-inner:not(.donna-terminal-body):not(.donna-steps-term) {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  padding: 0px;
  white-space: pre-wrap;
  background: var(--strans);
  border-radius: 8px;
  border-left: var(--line);
}

/* ── Donna live turn surface + step breadcrumbs (the "terminal") ──────────
   DonnaLiveBubble owns the live row's interior: the bubble text sits on TOP
   (.donna-output-row > .donna-live-body), the step terminal sits BELOW it
   (.donna-steps). Each breadcrumb is one step group with its real action lines;
   the live (active) group shows a breathing dot + spinning icon. */
.donna-unified-shell.is-live { gap: 6px; }
.donna-live-body { min-height: 1.15em; }
.donna-steps { margin-top: 2px; }
.donna-steps[hidden] { display: none; }

.donna-steps-term,
.donna-thoughts-inner.donna-steps-term {
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: #0c0c0d;
  border: 1px solid color-mix(in oklab, var(--primary) 14%, #2b2b30);
  border-radius: 12px;
  padding: 11px 13px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11.5px;
  font-style: normal;
  line-height: 1.5;
  color: #c8c8d0;
  max-height: 300px;
  overflow-y: auto;
}
.donna-thoughts.open .donna-thoughts-inner.donna-steps-term { margin-top: 6px; }

.donna-step-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0;
  animation: dsg-in 0.3s ease forwards;
}
@keyframes dsg-in { to { opacity: 1; } }

.dsg-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #e8e8ef;
}
.dsg-ico { font-size: 13px; flex: none; }
.donna-step-group.is-active .dsg-ico { color: var(--primary); animation: dsg-spin 0.9s linear infinite; }
.donna-step-group.is-done   .dsg-ico { color: #27c93f; }
.donna-step-group.is-error  .dsg-ico { color: #ff6b6b; }
.donna-step-group.is-error  .dsg-label { color: #ff9b9b; }
@keyframes dsg-spin { to { transform: rotate(360deg); } }

.dsg-live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  margin-left: 2px; flex: none;
  animation: dt-pulse 1.4s ease-out infinite;
}

.dsg-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 20px;
}
.donna-step-line {
  display: flex;
  gap: 6px;
  color: #9aa0aa;
  opacity: 0;
  transform: translateX(-4px);
  animation: term-line-in 0.3s forwards;
}
.dsl-mark { color: var(--primary); opacity: 0.85; flex: none; }
.dsl-text { flex: 1; word-break: break-word; }
.donna-step-group.is-done .dsl-text { color: #b0b6c0; }

/* ── Donna live turn (v3): ONE normal-looking bubble, two internal rows ──────
   .donna-turn holds an optional terminal row (the "mode brain"), a reasoning
   pill (real model thoughts), and the answer. It carries NO background of its
   own — the surrounding chat bubble skin shows through, so a Donna turn is
   visually identical to every other message (no nested shell). */
.donna-turn {display: flex;flex-direction: column;gap: 2px;width: 100%;}
.donna-turn .donna-answer {
  font-size: 13px;
  line-height: 1.6;
  min-height: 1.15em;
  word-break: break-word;
}
.donna-turn .donna-thoughts { margin: 0; }

/* Terminal row — a collapsible CRT panel. Open (live typing) while Donna works;
   collapses to just its header afterwards (the header stays clickable to re-open). */
.donna-terminal {
  border: 1px solid color-mix(in oklab, var(--primary) 16%, #2b2b30);
  border-radius: 12px;
  padding: 6px;
  overflow: hidden;
  background: #0b0b0c;
}
.donna-terminal[hidden] { display: none; }
.donna-terminal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  background: #131316;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: #d6d6de;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: left;
}
.donna-terminal-head .dtt-ico { font-size: 13px; color: var(--primary); flex: none; }
.donna-terminal-head .dtt-label { flex: 1; }
.donna-terminal-head .dtt-caret { font-size: 11px; transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); }
.donna-terminal.open .donna-terminal-head .dtt-caret { transform: rotate(180deg); }
.donna-terminal-head .dtt-live {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--primary);
  animation: dt-pulse 1.4s ease-out infinite;
}
/* The "breathing" live dots appear ONLY while actively working; once a turn finalizes
   (or on a reloaded/recorded turn) the .is-live class is gone and the dot disappears,
   so a finished pill never keeps pulsing. */
.donna-terminal-head .dtt-live,
.donna-thoughts .donna-thoughts-pill .dt-live { display: none; }
.donna-terminal.is-live .donna-terminal-head .dtt-live,
.donna-thoughts.is-live .donna-thoughts-pill .dt-live { display: inline-block; }

.donna-terminal-reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.donna-terminal.open .donna-terminal-reveal { grid-template-rows: 1fr; }
.donna-terminal-scroll {
  overflow: hidden;
  min-height: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 0 13px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #c8c8d0;
}
.donna-terminal.open .donna-terminal-scroll {padding: 10px 10px 0;}

/* Each terminal line types in (char by char from JS) with a trailing block cursor. */
.donna-terminal .term-line {
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateX(-4px);
  animation: term-line-in 0.25s forwards;
}
.donna-terminal .tl-mark { color: var(--primary); opacity: 0.85; flex: none; }
.donna-terminal .tl-text { flex: 1; word-break: break-word; white-space: pre-wrap; }
.donna-terminal .term-line.tl-head { font-weight: 700; color: #e8e8ef; margin-top: 4px; }
.donna-terminal .term-line.tl-head:first-child { margin-top: 0; }
.donna-terminal .term-line.tl-done .tl-mark { color: #27c93f; }
.donna-terminal .term-line.tl-error .tl-mark,
.donna-terminal .term-line.tl-error .tl-text { color: #ff9b9b; }
.donna-terminal .tl-cursor {
  display: inline-block;
  width: 6px; height: 1em;
  background: var(--primary);
  vertical-align: -2px;
  border-radius: 1px;
  animation: donna-cursor-blink 0.8s step-end infinite;
}

/* Reasoning pill body holds rendered markdown (not the italic plain-text look). */
.donna-thoughts-inner.donna-reasoning {
  font-style: normal;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  border-left: 2px solid var(--line-color);
}

/* ===================== Chat Settings page (/chat/settings) ===================== */
#chat-root.cs-open { position: relative; }
.chat-settings-view {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg, #15171c);
}
.chat-settings-view[hidden] { display: none; }
.chat-settings-view .cs-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  flex: 0 0 auto;
}
.chat-settings-view .cs-back { font-size: 18px; }
.chat-settings-view .cs-head-title h2 { margin: 0; font-size: 18px; }
.chat-settings-view .cs-head-title p { margin: 2px 0 0; font-size: 12px; }
.chat-settings-view .cs-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px 60px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.chat-settings-view .cs-group {
  margin-bottom: 26px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.02);
}
.chat-settings-view .cs-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.7;
  margin: 14px 2px 8px;
}
.chat-settings-view .cs-group-title .bi { opacity: 0.8; }
.chat-settings-view .cs-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 2px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.06));
}
.chat-settings-view .cs-group > .cs-row:first-of-type { border-top: none; }
.chat-settings-view .cs-row-main { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.chat-settings-view .cs-row-title { font-size: 14px; font-weight: 600; }
.chat-settings-view .cs-row-desc { font-size: 12px; opacity: 0.6; line-height: 1.35; }
.chat-settings-view .cs-row-btns { display: inline-flex; gap: 8px; flex: 0 0 auto; }
.chat-settings-view .cs-row-slider input[type="range"] { width: 150px; flex: 0 0 auto; }
.chat-settings-view .cs-select {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  color: inherit;
  font-size: 13px;
}
/* Toggle switch */
.chat-settings-view .cs-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: background 0.2s;
}
.chat-settings-view .cs-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.chat-settings-view .cs-switch:checked { background: var(--primary, #07cfc1); }
.chat-settings-view .cs-switch:checked::after { transform: translateX(18px); }
.chat-settings-view .cs-group-donna { border-color: rgba(7, 207, 193, 0.25); }

/* Appearance preferences applied live to conversations. */
html[data-chat-font="small"] .messages { font-size: 13px; }
html[data-chat-font="large"] .messages { font-size: 16px; }
html[data-chat-bubbles="square"] .msg .bubble .text-shell { border-radius: 6px; }
html[data-chat-avatars="hidden"] .msg .avatar.sm { display: none; }
html[data-chat-motion="reduced"] .messages *,
html[data-chat-motion="reduced"] .chat-settings-view * {
  transition: none !important;
  animation: none !important;
}
