/* Keep assistance in the flex layout so draft growth never causes overlap. */
body .conversation > #ai-assistant-bar {
  position: relative;
  inset: auto;
  z-index: 30;
  width: auto;
  flex: 0 0 auto;
  margin: 8px 12px 0;
  padding: 14px;
  gap: 12px;
  border: 1px solid #ded8e8;
  border-radius: 18px;
  background: #faf8ff;
  box-shadow: none;
  max-height: 35dvh;
  overflow-y: auto;
}
body .conversation > #ai-assistant-bar.hidden { display: none; }
body #ai-assistant-bar .language {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  flex: 1 1 100%;
  width: 100%;
  gap: 10px;
  overflow: visible;
  align-items: end;
}
body #ai-assistant-bar .language label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #625a70;
  font-size: 12px;
}
body #ai-assistant-bar .language > span { align-self: end; padding-bottom: 12px; }
body #ai-assistant-bar .language select {
  width: 100%;
  max-width: none;
  height: 44px;
  padding: 0 10px;
  border: 1px solid #ded8e8;
  border-radius: 12px;
  background: #fff;
  color: #241d32;
  font-size: 16px;
}
body #ai-assistant-bar .ai-assistant-orb { display: none; }
body #ai-assistant-bar > b {
  flex: 1 1 140px;
  max-width: none;
  min-width: 0;
  font-size: 13px;
  white-space: normal;
}
body #ai-assistant-bar > b small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  white-space: normal;
  overflow: visible;
}
body #ai-assistant-bar .ai-toggle { flex: 0 0 44px; }
body #ai-assistant-bar #ai-suggest-reply {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
}
body #ai-assistant-bar .ai-reply-control { position: static; }
body #ai-assistant-bar .ai-reply-styles { position: static; width: 100%; margin-top: 10px; box-shadow: none; }
body #ai-assistant-bar .composer-assistance-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 100%;
  gap: 12px;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
}
body #ai-assistant-bar .composer-assistance-heading span { display: flex; align-items: center; gap: 8px; }
body #ai-assistant-bar .composer-assistance-heading .lucide { width: 16px; height: 16px; color: #8b5cf6; }
body #ai-assistant-bar #composer-tools-close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: -8px -6px -8px 0;
  background: transparent;
  color: inherit;
  border-radius: 50%;
}
body #composer {
  margin: 8px 12px 12px;
  padding: 8px;
  border: 1px solid #ded8e8;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 4px 18px #241d3208;
  transition: border-color .18s ease, box-shadow .18s ease;
}
body #composer:focus-within { border-color: #a78bfa; box-shadow: 0 0 0 3px #8b5cf614; }
body #composer > button:focus-visible,
body #ai-assistant-bar button:focus-visible,
body #ai-assistant-bar select:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
body #composer #message-input {
  min-width: 0;
  color: #241d32;
  background: transparent;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.5;
}
body #composer #composer-action {
  color: #fff;
  background: #6d28d9;
}
body #composer #composer-action[aria-label="Send message"] { color: #fff; }
body #composer #composer-tools-toggle[aria-expanded="true"] {
  color: #6d28d9;
  background: #eee6ff;
}
:root[data-theme="dark"] body .conversation > #ai-assistant-bar,
:root[data-theme="dark"] body #composer {
  background: #1c2832;
  border-color: #394651;
  color: #f1f0f7;
}
:root[data-theme="dark"] body #ai-assistant-bar .language label,
:root[data-theme="dark"] body #ai-assistant-bar > b small { color: #b5bdce; }
:root[data-theme="dark"] body #ai-assistant-bar .language select {
  color: #f1f0f7;
  background: #24333e;
  border-color: #394651;
}
:root[data-theme="dark"] body #composer #message-input { color: #f1f0f7; background: transparent; }
:root[data-theme="dark"] body #composer #message-input::placeholder { color: #b5bdce; }
:root[data-theme="dark"] body #composer #composer-tools-toggle[aria-expanded="true"] { color: #c4a7ff; background: #36264d; }
@media (max-width: 760px) {
  body #composer {
    display: grid;
    grid-template-columns: repeat(4, 44px) minmax(0, 1fr) 44px;
    align-items: center;
    gap: 4px;
    padding: 8px;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
  }
  body #composer #message-input {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    min-height: 52px;
    max-height: 25dvh;
    padding: 12px;
  }
  body #composer > button { grid-row: 2; width: 44px; height: 44px; }
  body #composer #ai-write { display: grid; }
  body #composer #composer-action { grid-column: -2; }
  body #composer .voice-recording { grid-column: 1 / -2; grid-row: 1 / 3; min-width: 0; }
  body #composer.recording > #composer-tools-toggle { display: none; }
  body #ai-assistant-bar .ai-reply-control { flex: 1 1 100%; }
  body #ai-assistant-bar #ai-suggest-reply { width: 100%; }
  :root.native-mobile.native-android body #composer {
    grid-template-columns: repeat(4, 48px) minmax(0, 1fr) 48px;
  }
  :root.native-mobile.native-android body #composer > button { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) { body #composer { transition: none; } }

/* Match the native chat authority, including camera and quoted-reply states. */
@media (max-width: 760px) {
  html:root.native-mobile body #composer {
    grid-template-columns: 44px 44px 44px minmax(0, 1fr) 44px 44px;
    grid-template-rows: auto 44px;
    gap: 4px;
    margin: 8px 12px max(10px, env(safe-area-inset-bottom));
    padding: 8px;
    border: 1px solid var(--ui-border);
    border-radius: 22px;
    background: var(--ui-surface);
  }
  html:root.native-mobile body #composer #message-input {
    min-height: 52px;
    max-height: min(132px, 25dvh);
    padding: 12px;
    color: var(--ui-text);
    font-size: 16px;
    line-height: 1.5;
  }
  html:root.native-mobile body #composer #message-input::placeholder { color: var(--ui-muted); }
  html:root.native-mobile body #composer #composer-action,
  html:root.native-mobile body #composer:not(.recording) #composer-action[aria-label="Send message"] {
    color: #fff;
    background: #6d28d9;
  }
  html:root.native-mobile body #composer #composer-tools-toggle[aria-expanded="true"] {
    color: var(--ui-accent);
    background: var(--ui-accent-soft);
  }
  html:root.native-mobile body #composer:not(:has(#composer-camera)) {
    grid-template-columns: repeat(4, 44px) minmax(0, 1fr) 44px;
  }
  html:root.native-mobile.native-android body #composer {
    grid-template-columns: 48px 48px 48px minmax(0, 1fr) 48px 48px;
    grid-template-rows: auto 48px;
  }
  html:root.native-mobile.native-android body #composer:not(:has(#composer-camera)) {
    grid-template-columns: repeat(4, 48px) minmax(0, 1fr) 48px;
  }
  html:root.native-mobile.native-android body #composer > button { width: 48px; height: 48px; }
}
