/* PRE Web GUI — Chat messages, streaming, tool cards */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 56px;
}

.topbar-title {
  font-family: 'Calendas Plus', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.context-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}

.context-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.context-bar {
  width: 100px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.context-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.context-fill.warning { background: var(--warning); }
.context-fill.danger { background: var(--danger); }

.context-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Messages container */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

/* Welcome screen — kinetic typography */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  text-align: center;
  padding: 20px 0;
}
.welcome-logo {
  font-family: 'Calendas Plus', Georgia, serif;
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 6px;
  margin-bottom: 12px;
  animation: logoReveal 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-text {
  font-family: 'Calendas Plus', Georgia, serif;
  font-size: 1.3rem;
  color: var(--text-secondary);
  font-style: italic;
  animation: subtitleFadeUp 0.8s 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.welcome-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
  max-width: 420px;
  line-height: 1.5;
  animation: taglineFadeUp 0.8s 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Welcome tutorial cards */
.welcome-tutorial {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  max-width: 720px;
  width: 100%;
  margin-top: 24px;
  padding: 0 16px;
  animation: taglineFadeUp 0.8s 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tutorial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tutorial-card:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.tutorial-card-icon {
  font-size: 1.2rem;
  margin-bottom: 6px;
  display: block;
}
.tutorial-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.tutorial-card-prompt {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Home screen dashboard ── */
.welcome-dashboard {
  max-width: 720px;
  width: 100%;
  padding: 0 16px;
  margin-top: 20px;
  animation: taglineFadeUp 0.8s 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.welcome-dashboard:empty { display: none; }
.resume-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--accent, #4a6fa5);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.resume-banner:hover {
  background: var(--hover);
  border-color: var(--text-primary);
}
.resume-banner-icon {
  font-size: 1.2em;
  opacity: 0.7;
}
.resume-banner-text {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.resume-banner-text strong {
  color: var(--text-primary);
}
.resume-banner-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.dashboard-card-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.dashboard-event {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.78rem;
  line-height: 1.4;
}
.dashboard-event-time {
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.72rem;
}
.dashboard-event-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dashboard-session {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.78rem;
  cursor: pointer;
  border-radius: 4px;
}
.dashboard-session:hover {
  color: var(--primary);
}
.dashboard-session-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  flex: 1;
}
.dashboard-session:hover .dashboard-session-name {
  color: var(--primary);
}
.dashboard-session-time {
  color: var(--text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}
.dashboard-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 6px;
}
.dashboard-stat {
  text-align: center;
}
.dashboard-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.dashboard-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.dashboard-telegram-active {
  font-size: 1.3rem;
}
.dashboard-empty {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
  padding: 4px 0;
}
.suggestions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.suggestion-chip:hover {
  background: var(--hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}
.suggestion-icon {
  font-size: 1em;
}
@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .suggestions-row {
    justify-content: center;
  }
}

/* ── First-run workflow templates ── */
.workflow-header {
  text-align: center;
  max-width: 720px;
  width: 100%;
  margin-bottom: 4px;
  padding: 0 16px;
  animation: taglineFadeUp 0.8s 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.workflow-header-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.workflow-header-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  max-width: 720px;
  width: 100%;
  padding: 0 16px;
  animation: taglineFadeUp 0.8s 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.workflow-card {
  border-left: 3px solid var(--primary);
}
.workflow-card:hover {
  border-left-color: var(--primary);
}

.welcome-explore-btn {
  margin-top: 16px;
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  animation: taglineFadeUp 0.8s 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.welcome-explore-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Tutorial panel (right-panel) */
.tutorial-category {
  margin-bottom: 20px;
}
.tutorial-category-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tutorial-prompt-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.tutorial-prompt-item:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--surface-hover);
}
.tutorial-prompt-item::before {
  content: '→ ';
  color: var(--primary);
  font-weight: 600;
}
.tutorial-tip {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
  padding: 0 4px;
  line-height: 1.4;
}

/* Message bubbles */
.message {
  max-width: 800px;
  margin: 0 auto 16px;
  padding: 16px 20px;
  border-radius: 16px;
  animation: messageSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.message.user {
  background: var(--msg-user-bg);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.message.assistant {
  background: var(--msg-assistant-bg);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-header {
  justify-content: flex-start;
}

.message-role {
  color: var(--primary);
}

.copy-btn {
  margin-left: auto;
  padding: 4px 6px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
}
.message:hover .copy-btn {
  opacity: 1;
}
.copy-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.copy-btn.copied {
  opacity: 1;
  color: var(--success);
}
.message.user .message-role {
  color: var(--text-secondary);
}

.message-content {
  color: var(--text);
  line-height: 1.7;
}

/* Markdown rendering inside messages */
.message-content h1,
.message-content h2,
.message-content h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  color: var(--text);
  letter-spacing: -0.01em;
}
.message-content h1 { font-size: 1.5rem; font-weight: 750; }
.message-content h2 { font-size: 1.25rem; font-weight: 700; }
.message-content h3 { font-size: 1.1rem; font-weight: 650; }

.message-content p {
  margin-bottom: 0.8em;
}
.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul, .message-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}
.message-content li {
  margin-bottom: 0.3em;
}

.message-content code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Code block wrapper with header */
.code-block-wrapper {
  border: 1px solid var(--code-border);
  border-radius: 12px;
  overflow: hidden;
  margin: 0.8em 0;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--code-border);
  font-size: 0.75rem;
}

.code-block-lang {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.3px;
}

.code-block-copy {
  padding: 3px 5px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s ease, background 0.15s ease;
}
.code-block-copy:hover {
  color: var(--text);
  background: var(--surface-active);
}
.code-block-copy.copied {
  color: var(--success);
}

.message-content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0.8em 0;
}

/* Reset pre styles when inside code block wrapper */
.message-content .code-block-wrapper pre {
  border: none;
  border-radius: 0;
  margin: 0;
}

.message-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.message-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 0.8em 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Tables */
.message-content .table-wrapper {
  overflow-x: auto;
  margin: 0.8em 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.message-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.message-content thead {
  background: var(--surface-hover);
}
.message-content th {
  padding: 10px 14px;
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--border);
  color: var(--primary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.message-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.message-content tbody tr:last-child td {
  border-bottom: none;
}
.message-content tbody tr:hover {
  background: var(--surface-hover);
}

.message-content strong {
  color: var(--text);
  font-weight: 700;
}

.message-content a {
  color: var(--primary);
}

/* Thinking indicator (shown during TTFT wait) */
.thinking-indicator-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.thinking-indicator-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  animation: pulse 1.5s ease-in-out infinite;
}
.thinking-indicator-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.thinking-indicator-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: breathe 1.4s ease-in-out infinite;
}
.thinking-indicator-dots span:nth-child(2) {
  animation-delay: 0.16s;
}
.thinking-indicator-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

/* Thinking block */
.thinking-block {
  background: var(--thinking-bg);
  border: 1px solid var(--thinking-border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
}
.thinking-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tool call card */
.tool-card {
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 8px 0;
  animation: toolCardEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tool-card-name {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
}
.tool-card-status {
  margin-left: auto;
  font-size: 0.75rem;
}
.tool-card-body {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.tool-card-body pre {
  margin-top: 6px;
  max-height: 200px;
  overflow: auto;
}

/* ── Compact agent card (replaces verbose tool cards for spawn_agent) ── */
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  margin: 8px 0;
  overflow: hidden;
  animation: toolCardEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.agent-card.agent-done {
  border-left-color: var(--success);
}
.agent-card.agent-failed {
  border-left-color: var(--danger);
}
.agent-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.agent-card-header:hover {
  background: var(--surface-hover);
}
.agent-card-icon {
  font-size: 1rem;
  flex-shrink: 0;
  color: var(--primary);
}
.agent-card.agent-done .agent-card-icon { color: var(--success); }
.agent-card.agent-failed .agent-card-icon { color: var(--danger); }
.agent-card-icon.spinning {
  animation: agent-pulse 1s ease-in-out infinite;
}
.agent-card-task {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.agent-card-tools-count {
  font-family: 'SF Mono', monospace;
}
.agent-card-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.agent-card.expanded .agent-card-chevron {
  transform: rotate(90deg);
}
.agent-card-details {
  display: none;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 0.8rem;
  max-height: 300px;
  overflow-y: auto;
}
.agent-card.expanded .agent-card-details {
  display: block;
}
.agent-card-tool-log {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
}
.agent-card-tool-log li {
  padding: 3px 0;
  color: var(--text-secondary);
  font-family: 'SF Mono', monospace;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-card-tool-log li::before {
  content: '→';
  color: var(--text-muted);
}
.agent-card-result {
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-card-result pre {
  margin: 4px 0;
  max-height: 200px;
  overflow: auto;
}
.agent-card-feed-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--primary);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
.agent-card-feed-link:hover {
  text-decoration: underline;
}

/* Legacy agent status bar (kept for non-agent status events) */
.agent-status-bar {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-status-icon {
  color: var(--primary);
  font-size: 0.9rem;
}
.agent-status-icon.spinning {
  animation: agent-pulse 1s ease-in-out infinite;
}
.agent-status-icon.done {
  color: var(--success, #4ade80);
}
.agent-status-icon.error {
  color: var(--danger, #f87171);
}
/* agent-pulse keyframe defined in animations.css */

/* Streaming cursor */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--primary);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}

/* Attachments in user messages */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.msg-attachment-image {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 300px;
}
.msg-attachment-image img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
}
.msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.msg-attachment-file svg {
  flex-shrink: 0;
  color: var(--primary);
}

/* Input area */
.input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.input-area.drag-over {
  border-top-color: var(--primary);
  background: var(--primary-bg);
}

/* Quick Actions bar (above input) */
.quick-actions-bar {
  max-width: 800px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.quick-actions-bar:empty {
  display: none;
}
.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.3;
}
.quick-action-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}
.quick-action-btn .qa-icon {
  font-size: 0.85rem;
}
.quick-action-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s ease;
  margin-left: 2px;
}
.quick-action-edit-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* Attachment preview bar (above input) */
.attachment-preview {
  max-width: 800px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attachment-preview.hidden {
  display: none;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 220px;
}
.attachment-chip.image-chip {
  padding: 3px;
}
.attachment-chip.image-chip img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
}
.attachment-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.attachment-chip-size {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}
.attachment-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.attachment-remove:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

/* Attach button */
.btn-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-attach:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.chat-form {
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 16px;
  padding: 10px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.input-wrapper:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(108, 180, 238, 0.12), 0 2px 12px rgba(0, 0, 0, 0.06);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 200px;
}
.chat-input::placeholder {
  color: var(--text-muted);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 4px;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.typing-indicator {
  font-size: 0.75rem;
  color: var(--primary);
}
.typing-indicator.hidden {
  display: none;
}

/* Stats line after response */
.stats-line {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: 'SF Mono', monospace;
}

/* ── Delegate selector ── */
.delegate-selector {
  position: relative;
}
.btn-delegate {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 44px;
  text-align: center;
}
.btn-delegate:hover {
  border-color: var(--primary);
}
.btn-delegate.delegate-active {
  border-color: var(--delegate-color, var(--primary));
  color: var(--delegate-color, var(--primary));
  background: color-mix(in srgb, var(--delegate-color, var(--primary)) 10%, var(--surface));
}
.delegate-label {
  pointer-events: none;
}
.delegate-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}
.delegate-dropdown.hidden {
  display: none;
}
.delegate-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.delegate-option:hover {
  background: var(--hover);
}
.delegate-option.active {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
}
.delegate-option small {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.delegate-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.delegate-status {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.delegate-status.unavailable {
  color: var(--warning);
}

/* Delegate badge on messages */
.delegate-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.delegate-badge-claude { background: rgba(204,120,92,0.15); color: #cc785c; }
.delegate-badge-codex { background: rgba(16,163,127,0.15); color: #10a37f; }
.delegate-badge-gemini { background: rgba(66,133,244,0.15); color: #4285f4; }
.delegate-tag {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 6px;
}

/* ── Research mode toggle ── */
.research-selector {
  position: relative;
}
.btn-research {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-research:hover {
  border-color: #8b5cf6;
  color: #8b5cf6;
}
.btn-research.research-active {
  border-color: #8b5cf6;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
}
.research-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  min-width: 240px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}
.research-dropdown.hidden {
  display: none;
}
.research-dropdown-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: #8b5cf6;
  letter-spacing: 0.5px;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.research-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.research-option:hover {
  background: var(--hover);
}
.research-option input[type="radio"] {
  margin-top: 3px;
  accent-color: #8b5cf6;
}
.research-option-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.82rem;
  color: var(--text);
}
.research-option-text small {
  color: var(--text-muted);
  font-size: 0.72rem;
}
.research-option.unavailable {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Research progress tracker ── */
.research-progress {
  padding: 16px 20px;
  margin: 8px 0;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.06);
}
.research-progress-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 600;
  color: #8b5cf6;
  font-size: 0.85rem;
}
.research-progress-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(139, 92, 246, 0.2);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.research-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.research-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.research-progress-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.research-progress-sections {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  font-size: 0.8rem;
}
.research-progress-sections li {
  padding: 3px 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.research-progress-sections li.done {
  color: var(--text);
}
.research-progress-sections li.active {
  color: #8b5cf6;
  font-weight: 500;
}
.research-section-check {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
