/*
 * Shared conversation composer, markdown editor, attachment list and message
 * styles. styles.css imports this file for the Web UI, and the Portal loads it
 * directly as a shared asset so both surfaces render the same components.
 * Colors and radii come from the host page's --color-* / --radius-* variables.
 */

/* ── Conversation message meta and copy button ── */
.conversation-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 24px;
  margin-top: 5px;
}

/* A follow-up that waited in the queue (conversation-transcript.js). */
.conversation-message-queued {
  padding: 0 7px;
  border-radius: 9px;
  background: rgba(var(--color-accent-rgb, 63, 114, 255), 0.1);
  color: var(--color-primary-text, #3158c9);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
}

.conversation-message-copy {
  /* Keep the absolute live-region status inside the message scroller. Without
     a local containing block it can enlarge the entire conversation panel. */
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  opacity: 0.72;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.conversation-message-copy:hover {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  color: var(--color-accent);
  opacity: 1;
}

.conversation-message-copy:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  opacity: 1;
}

.conversation-message-copy[data-copy-state="copied"] {
  color: var(--color-success-text);
  opacity: 1;
}

.conversation-message-copy[data-copy-state="error"] {
  color: var(--color-danger);
  opacity: 1;
}

.conversation-message-copied-icon {
  display: none;
}

.conversation-message-copy[data-copy-state="copied"] .conversation-message-copy-icon {
  display: none;
}

.conversation-message-copy[data-copy-state="copied"] .conversation-message-copied-icon {
  display: inline;
}

.conversation-message-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (hover: none), (pointer: coarse) {
  .conversation-message-copy {
    width: 32px;
    height: 32px;
  }
}

/* ── Launch (submit) icon button ── */
.btn-icon-launch {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-launch:hover:not(:disabled) {
  background: rgba(63, 114, 255, 0.08);
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(63, 114, 255, 0.15);
}

.btn-icon-launch:active:not(:disabled) {
  transform: translateY(0);
  background: rgba(63, 114, 255, 0.15);
}

.btn-icon-launch:disabled {
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.4;
}

.btn-icon-launch.btn-loading {
  width: auto;
  min-width: 36px;
  padding: 0 12px;
  background: rgba(63, 114, 255, 0.08);
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 500;
}

/* ── Follow-up toolbar and editor container ── */
/* Follow-up toolbar */
.follow-up-toolbar {
  padding: 6px 8px;
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-radius: calc(var(--radius-small) - 1px) calc(var(--radius-small) - 1px) 0 0; /* Match wrapper's top corners, minus border width */
  position: relative; /* For dropdown z-index stacking */
}

.follow-up-toolbar-hidden {
  display: none !important;
}

.follow-up-toolbar > button,
.follow-up-toolbar > .markdown-toolbar-dropdown > button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.follow-up-toolbar > button:hover,
.follow-up-toolbar > .markdown-toolbar-dropdown > button:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.follow-up-toolbar > button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.follow-up-toolbar > button.active,
.follow-up-toolbar > .markdown-toolbar-dropdown > button.active,
.follow-up-toolbar > button.composer-maximize-btn[aria-pressed="true"] {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.follow-up-toolbar > button.markdown-voice-btn.voice-listening {
  background: rgba(229, 83, 104, 0.12);
  color: var(--color-danger);
  animation: markdown-voice-listening-pulse 1.25s ease-in-out infinite;
}

.follow-up-toolbar .toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 4px 4px;
}

/* Follow-up editor container - use position relative for button alignment */
.follow-up-editor-container {
  position: relative;
  flex: 1;
  min-width: 0;
}

.follow-up-editor-container .markdown-editor {
  min-height: 60px;
  max-height: 160px;
  padding: 8px 50px 8px 10px; /* Right padding reserves space for submit button */
  border: none;
  border-radius: 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-y: auto;
  background: transparent;
}

.follow-up-editor-container .markdown-editor-source-container {
  margin-right: 50px; /* Right margin reserves space for submit button, matching visual editor */
}

.follow-up-editor-container .markdown-editor:focus {
  outline: none;
}

/* Submitting temporarily makes the reply editor read-only. Keep the composer's
   padding instead of the generic read-only preview treatment, which removes it
   and makes the draft jump left and under the submit button until the send
   settles. */
.follow-up-editor-container .markdown-editor[contenteditable="false"] {
  padding: 8px 50px 8px 10px;
}

.follow-up-editor-container .markdown-editor[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  pointer-events: none;
}

/* ── Toolbar dropdown stacking ── */
/* Ensure follow-up toolbar dropdowns appear above all card content */
.follow-up-toolbar {
  overflow: visible !important;
}

.follow-up-toolbar .markdown-toolbar-dropdown-menu {
  z-index: 10000;
}

/* ── Attached files list ── */
.attached-files-list {
  margin-top: 8px;
  padding: 8px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.attached-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 0.9em;
}

.attached-file-item:last-child {
  margin-bottom: 0;
}

.attached-file-item .file-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-file-item .file-size {
  color: var(--color-text-muted);
  font-size: 0.85em;
  white-space: nowrap;
}

.attached-file-item .remove-file-btn {
  padding: 2px 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  font-size: 1.2em;
  line-height: 1;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.attached-file-item .remove-file-btn:hover {
  color: var(--color-danger);
  background: var(--color-surface-muted);
}

/* ── Compact icon buttons for attachments ── */
/* Compact icon buttons for file attachments */
.btn-icon-mini {
  padding: 5px 8px;
  font-size: 1em;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--color-text-muted);
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-mini svg {
  vertical-align: middle;
  color: inherit;
}

.btn-icon-mini:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-icon-mini:active {
  transform: scale(0.95);
}

/* ── Markdown editor surface and @mentions ── */
/* Markdown Editor Styles */
.markdown-editor {
  position: relative;
  min-height: 100px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  line-height: 1.6;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow-y: auto;
  white-space: normal;
  word-wrap: break-word;
}

.markdown-editor:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(63,114,255,0.1);
}

.markdown-editor.empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  opacity: 0.7;
  pointer-events: none;
  position: absolute;
}

.markdown-editor[contenteditable="false"] {
  cursor: default;
  border-color: transparent;
  background: transparent;
  padding: 0;
}

/* When inside instructions-container, remove duplicate border/styling */
.instructions-container .markdown-editor {
  border: none;
  border-radius: var(--radius-small) var(--radius-small) 0 0;
  padding: 12px;
  min-height: 60px;
  max-height: 300px;
  font-size: 15px;
  line-height: 1.5;
  background: transparent;
}

.instructions-container .markdown-editor:focus {
  box-shadow: none;
}

/* Markdown content styling inside editor */
.markdown-editor h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 16px 0 12px 0;
  line-height: 1.3;
}

.markdown-editor h1:first-child {
  margin-top: 0;
}

.markdown-editor h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 14px 0 10px 0;
  line-height: 1.3;
}

.markdown-editor h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 12px 0 8px 0;
  line-height: 1.3;
}

.markdown-editor p {
  margin: 8px 0;
}

.markdown-editor p:first-child {
  margin-top: 0;
}

.markdown-editor p:last-child {
  margin-bottom: 0;
}

.markdown-editor ul,
.markdown-editor ol {
  margin: 8px 0;
  padding-left: 24px;
}

.markdown-editor li {
  margin: 4px 0;
}

.markdown-editor code {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
}

.markdown-editor pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: var(--radius-small);
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-editor pre code {
  background: none;
  padding: 0;
}

/* Dark mode code blocks for markdown editor */
[data-theme="dark"] .markdown-editor code {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

[data-theme="dark"] .markdown-editor pre {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .markdown-editor pre code {
  background: none;
  color: #e2e8f0;
}

.markdown-editor a {
  color: var(--color-accent);
  text-decoration: underline;
}

.markdown-editor a:hover {
  text-decoration: none;
}

/* Ctrl+click hint for links in edit mode */
.markdown-editor[contenteditable="true"] a {
  cursor: text;
}

.markdown-editor[contenteditable="true"] a:hover {
  cursor: pointer;
}

/* Link hint tooltip - rendered via JavaScript to avoid overflow clipping */
.markdown-editor-link-tooltip {
  position: fixed;
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10000;
}

.markdown-editor-link-tooltip.visible {
  opacity: 1;
}

.markdown-editor strong,
.markdown-editor b {
  font-weight: 600;
}

.markdown-editor em,
.markdown-editor i {
  font-style: italic;
}

.markdown-editor blockquote {
  border-left: 3px solid var(--color-border);
  margin: 12px 0;
  padding-left: 16px;
  color: var(--color-text-muted);
}

.markdown-editor hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}

.markdown-editor img {
  max-width: 100%;
  height: auto;
}

/* @Mention Styles */
.mention {
  display: inline;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--color-primary, #3b82f6);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.mention:hover {
  background-color: rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .mention {
  background-color: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
}

[data-theme="dark"] .mention:hover {
  background-color: rgba(96, 165, 250, 0.3);
}

/* Mention Dropdown Autocomplete */
.mention-dropdown {
  position: absolute;
  z-index: 10000;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  min-width: 220px;
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  padding: 4px 0;
}

.mention-dropdown::-webkit-scrollbar {
  width: 6px;
}

.mention-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.mention-dropdown::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.mention-dropdown::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.mention-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.mention-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--avatar-color, #60A5FA);
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.mention-option:hover,
.mention-option-selected {
  background-color: #3b82f6;
}

.mention-option:hover .mention-option-name,
.mention-option-selected .mention-option-name {
  color: #ffffff;
}

.mention-option:hover .mention-option-username,
.mention-option-selected .mention-option-username {
  color: rgba(255, 255, 255, 0.8);
}

.mention-option-name {
  font-weight: 500;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.3;
}

.mention-option-username {
  font-size: 13px;
  color: #6b7280;
  text-align: right;
  flex-shrink: 0;
  margin-left: auto;
}

[data-theme="dark"] .mention-dropdown {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .mention-dropdown::-webkit-scrollbar-thumb {
  background: #475569;
}

[data-theme="dark"] .mention-dropdown::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

[data-theme="dark"] .mention-option:hover,
[data-theme="dark"] .mention-option-selected {
  background-color: #3b82f6;
}

[data-theme="dark"] .mention-option-name {
  color: #f1f5f9;
}

[data-theme="dark"] .mention-option-username {
  color: #64748b;
}

[data-theme="dark"] .mention-option:hover .mention-option-username,
[data-theme="dark"] .mention-option-selected .mention-option-username {
  color: rgba(255, 255, 255, 0.7);
}

/* ── Optional feature status and attachment edit button ── */
.optional-feature-status {
  min-height: 240px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--color-text-muted);
  text-align: center;
}

.optional-feature-status[data-state="error"] {
  color: var(--color-danger);
}

.optional-feature-status-compact {
  min-height: 120px;
}

.optional-feature-inline-status {
  min-height: 0;
  height: auto;
  margin: 12px 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
}

/* File attachment edit button */
.attached-file-edit {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  transition: opacity 0.2s ease;
}

.attached-file-edit:hover {
  opacity: 0.7;
}

/* ── Markdown editor toolbar and dropdowns ── */
/* Markdown Editor Toolbar Styles */
.markdown-editor-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.markdown-editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  border-radius: var(--radius-small) var(--radius-small) 0 0;
}

.markdown-editor-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.markdown-editor-toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text);
}

.markdown-editor-toolbar-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.markdown-editor-toolbar-btn:active {
  background: rgba(0, 0, 0, 0.1);
  transform: translateY(1px);
}

/* Active state when formatting is enabled at cursor position */
.markdown-editor-toolbar-btn.active {
  background: var(--color-primary-muted, rgba(59, 130, 246, 0.15));
  color: var(--color-primary, #3b82f6);
  border-color: var(--color-primary, #3b82f6);
}

.markdown-editor-toolbar-btn.active:hover {
  background: var(--color-primary-muted, rgba(59, 130, 246, 0.25));
}

.markdown-editor-toolbar-btn.markdown-voice-btn.voice-listening {
  background: rgba(229, 83, 104, 0.18);
  color: var(--color-danger);
  border-color: var(--color-danger);
  animation: markdown-voice-listening-pulse 1.25s ease-in-out infinite;
}

@keyframes markdown-voice-listening-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(229, 83, 104, 0.3), 0 0 8px rgba(229, 83, 104, 0.18);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(229, 83, 104, 0.14), 0 0 14px rgba(229, 83, 104, 0.28);
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .markdown-editor-toolbar-btn.markdown-voice-btn.voice-listening,
  .follow-up-toolbar > button.markdown-voice-btn.voice-listening {
    animation: none;
  }
}

.markdown-toolbar-separator {
  width: 1px;
  height: 16px;
  background: var(--color-border);
  margin: 0 4px;
  align-self: center;
}

[data-theme="dark"] .markdown-editor-toolbar {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .markdown-editor-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .markdown-editor-toolbar-btn.active {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border-color: #60a5fa;
}

[data-theme="dark"] .markdown-editor-toolbar-btn.active:hover {
  background: rgba(59, 130, 246, 0.35);
}

/* Ensure proper border radius when toolbar is present */
.instructions-container .markdown-editor-toolbar {
  border-radius: var(--radius-small) var(--radius-small) 0 0;
}

/* Adjust editor styling when preceded by toolbar */
.markdown-editor-wrapper .markdown-editor {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Markdown Toolbar Dropdown Styles */
.markdown-toolbar-dropdown {
  position: relative;
  display: inline-flex;
}

.markdown-toolbar-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 2px;
}

.markdown-toolbar-dropdown-btn .dropdown-arrow {
  opacity: 0.6;
  margin-left: 2px;
}

.markdown-toolbar-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 140px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  margin-top: 4px;
}

.markdown-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--color-text);
  font-size: 13px;
}

.markdown-dropdown-item:hover {
  background: var(--color-surface-muted);
}

.markdown-dropdown-item:first-child {
  border-radius: var(--radius-small) var(--radius-small) 0 0;
}

.markdown-dropdown-item:last-child {
  border-radius: 0 0 var(--radius-small) var(--radius-small);
}

.markdown-color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
}

.markdown-color-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.markdown-color-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .markdown-toolbar-dropdown-menu {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .markdown-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ── Markdown editor mode toggle and source container ── */
/* ============================================================
   MARKDOWN EDITOR MODE TOGGLE
   Toggle buttons for switching between Visual and Source modes
   ============================================================ */

.markdown-editor-mode-toggle {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  gap: 4px;
  background: var(--color-surface-secondary, var(--color-surface-muted));
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.markdown-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.markdown-mode-btn svg {
  flex-shrink: 0;
}

.markdown-mode-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text);
}

.markdown-mode-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.markdown-mode-btn.active:hover {
  background: var(--color-surface);
}

/* Source editor container (Monaco Editor) */
.markdown-source-container,
.markdown-editor-source-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.markdown-source-container .monaco-editor,
.markdown-editor-source-container .monaco-editor {
  height: 100% !important;
}

/* Dark mode for mode toggle */
[data-theme="dark"] .markdown-editor-mode-toggle {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .markdown-mode-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .markdown-mode-btn.active {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── Conversation message list ── */
.task-conversation-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Conversation message bubbles ──
   One look for every conversation transcript (task Conversation panel,
   Dashboard drawer): 14px text with timestamps, and lines capped at 680px so a
   maximized panel stays readable. Hosts may still override the custom
   properties, but none do today. */
.task-conversation-messages[hidden] {
  display: none;
}

.task-conversation-message {
  width: fit-content;
  max-width: var(--conversation-message-max-width, min(92%, 680px));
  min-width: 0;
  padding: var(--conversation-message-padding, 10px 12px);
  border: 1px solid var(--color-border);
}

.task-conversation-message.is-user {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--color-accent) 22%, var(--color-border));
  border-radius: 14px 14px 4px 14px;
  background: color-mix(in srgb, var(--color-accent) 7%, var(--color-surface));
}

.task-conversation-message.is-assistant {
  align-self: flex-start;
  border-radius: 14px 14px 14px 4px;
  background: var(--color-surface-muted);
}

.task-conversation-message-body {
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: var(--conversation-message-font-size, 14px);
  line-height: var(--conversation-message-line-height, 1.6);
}

.task-conversation-message-body > :first-child {
  margin-top: 0;
}

.task-conversation-message-body > :last-child {
  margin-bottom: 0;
}

/* Long code lines scroll inside their block (or wrap with its toggle). An
   unstyled <pre> lets them run past the bubble, and the transcript's scroll
   area then scrolls sideways. highlight.js already does this for fences with
   a language on the task page; the Dashboard drawer does not load it. */
.task-conversation-message-body pre {
  overflow-x: auto;
}

.task-conversation-message-time {
  display: inline-block;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 10px;
  text-align: right;
}

/* ── Conversation composer ── */
.task-conversation-composer {
  padding: 11px 12px 12px;
}

.task-conversation-input-row {
  position: relative;
  display: flex;
  align-items: stretch;
}

.task-conversation-editor-wrapper {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  overflow: visible;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface);
}

.task-conversation-editor-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(63, 114, 255, 0.1);
}

.task-conversation-editor-wrapper .follow-up-editor-container .markdown-editor {
  min-height: 68px;
  max-height: 180px;
  border: 0;
}

.task-conversation-input-row > .task-conversation-submit {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
}

/* Override the default hover/active transforms so the absolutely positioned
   button stays vertically centered instead of jumping when hovered. */
.task-conversation-input-row > .task-conversation-submit:hover:not(:disabled),
.task-conversation-input-row > .task-conversation-submit:active:not(:disabled) {
  transform: translateY(-50%);
}

.task-conversation-editor-wrapper:has(.follow-up-toolbar:not(.follow-up-toolbar-hidden)) ~ .task-conversation-submit {
  top: calc(50% + 20px);
}

.task-conversation-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}
