/* ===== Composer (contenteditable + tools) ===============================
   Compact: [+] [chips] [text…] [send] on one row.
   Expanded (the text needs the room): text on its own full-width row, and
   [+] [chips] … [send] underneath.
   ====================================================================== */
.composer-wrapper {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 24px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--background) 85%, transparent) 20%, var(--background) 55%);
}
.composer-heading {
  margin: 0 0 20px;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  text-align: center;
  color: var(--foreground);
}
.composer-shell { width: 100%; max-width: 780px; }

.cx {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 26px;
  background: var(--composer-background);
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.04), 0 8px 30px hsl(0 0% 0% / 0.06);
  transition: border-color 120ms ease, border-radius 160ms ease;
}
.cx[data-layout='expanded'] { border-radius: 22px; }

.cx-body {
  display: grid;
  align-items: end;
  gap: 4px 6px;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'lead chips editor trail';
}
.cx[data-layout='expanded'] .cx-body {
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'editor editor editor'
    'lead chips trail';
}
.cx-lead { grid-area: lead; display: flex; align-items: center; }
.cx-chips { grid-area: chips; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; align-self: center; }
.cx-chips[hidden] { display: none; }
.cx-editor { grid-area: editor; min-width: 0; display: flex; align-items: center; min-height: 36px; }
.cx-trail { grid-area: trail; display: flex; align-items: center; gap: 6px; }
.cx[data-layout='expanded'] .cx-editor { padding: 4px 6px 2px; }
.cx[data-layout='expanded'] .cx-lead,
.cx[data-layout='expanded'] .cx-chips,
.cx[data-layout='expanded'] .cx-trail { align-self: center; }

.cx-input:focus,
.cx-input:focus-visible { outline: 0; box-shadow: none; }

.cx-input {
  width: 100%;
  min-height: 24px;
  max-height: calc(1.6em * var(--cx-rows, 8));
  padding: 6px 4px;
  overflow-y: auto;
  outline: 0;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: var(--accent);
}
.cx-input:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-foreground);
  pointer-events: none;
}

/* Attachment button (next to send) */
.cx-attach {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.cx-attach:hover { background: var(--composer-hover); color: var(--foreground); }

/* "+" button */
.cx-plus {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.cx-plus:hover, .cx-plus[aria-expanded='true'] { background: var(--composer-hover); color: var(--foreground); }
.cx-plus .icon-asset { transition: transform 140ms ease; }
.cx-plus[aria-expanded='true'] .icon-asset { transform: rotate(45deg); }

/* Selected-tool chips */
.cx-chip {
  --chip-primary: #4d6bfe;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--input-border, var(--border));
  border-radius: 999px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
/* Hover: outline -> primary blue (blue border, text and icons, soft blue tint). */
.cx-chip:hover, .cx-chip:focus-visible {
  border-color: var(--chip-primary);
  background: color-mix(in srgb, var(--chip-primary) 14%, transparent);
  color: var(--chip-primary);
}
.cx-chip-logo, .cx-chip-x { display: inline-flex; align-items: center; flex: 0 0 auto; }
/* Tool icon and close mark are always visible; hover only restyles the chip (outline -> primary). */
.cx-chip-x { width: 12px; justify-content: center; opacity: 0.7; }
.cx-chip:hover .cx-chip-x, .cx-chip:focus-visible .cx-chip-x { opacity: 1; }
.cx-chip-x svg { width: 10px; height: 10px; }

/* Menu + mention popups */
.cx-menu, .cx-mentions {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: min(340px, 100%);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--dropdown-background, var(--input-background));
  box-shadow: 0 18px 55px hsl(0 0% 0% / 0.22);
  animation: cx-pop 120ms ease;
}
.cx-menu[hidden], .cx-mentions[hidden] { display: none; }
.cx-menu[data-placement='bottom'], .cx-mentions[data-placement='bottom'] { bottom: auto; top: calc(100% + 8px); }
@keyframes cx-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cx-menu, .cx-mentions { animation: none; } }

.cx-menu-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 2px 6px;
  padding: 0 10px;
  height: 36px;
  border-radius: 12px;
  background: var(--composer-background);
  color: var(--muted);
}
.cx-menu-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
}
.cx-menu-search input::-webkit-search-cancel-button { display: none; }
.cx-menu-list { display: flex; flex-direction: column; max-height: min(460px, calc(var(--cx-avail, 460px) - 64px)); overflow-y: auto; }
.cx-mentions { max-height: var(--cx-avail, 260px); overflow-y: auto; }
.cx-menu-empty { margin: 0; padding: 14px; color: var(--muted-foreground); font-size: 13px; text-align: center; }
.cx-menu-empty[hidden] { display: none; }

.cx-menu-item, .cx-mention {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.cx-menu-item[hidden], .cx-mention[hidden] { display: none; }
.cx-menu-item:hover, .cx-menu-item:focus-visible, .cx-mention:hover, .cx-mention[aria-selected='true'] {
  background: var(--button-hover);
  outline: 0;
}
.cx-menu-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 1px; }
.cx-menu-copy strong { font-size: 14px; font-weight: 600; }
.cx-menu-copy > span { color: var(--muted-foreground); font-size: 12px; line-height: 1.35; }
.cx-tick { display: grid; place-items: center; width: 20px; color: var(--accent); opacity: 0; }
.cx-menu-item[aria-checked='true'] .cx-tick { opacity: 1; }

.cx-mention { padding: 7px 10px; }
.cx-mention strong { font-size: 14px; font-weight: 600; }
.cx-mention > span:last-child { color: var(--muted-foreground); font-size: 12px; margin-inline-start: auto; }

/* Send button (kept from the previous composer) */
.chat-send-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #2c67c5;
  color: #fff;
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}
.chat-send-button:hover { opacity: 0.88; }
.chat-send-button:active { transform: scale(0.94); }
.chat-send-button:disabled { cursor: not-allowed; }

@media (max-width: 768px) {
  .composer-wrapper { padding: 14px 10px 10px; }
  .cx { border-radius: 22px; }
  .cx-chip { padding: 0 8px; }
}
